Skip to content

Commit

Permalink
Add an interface for common status mutations.
Browse files Browse the repository at this point in the history
  • Loading branch information
markusthoemmes committed May 6, 2020
1 parent 31dd807 commit a276bd9
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 8 deletions.
29 changes: 29 additions & 0 deletions pkg/apis/operator/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,35 @@ const (
DeploymentsAvailable apis.ConditionType = "DeploymentsAvailable"
)

// KComponentStatus is a common interface for status mutations of all known types.
type KComponentStatus interface {
// MarkInstallSucceeded marks the InstallationSucceeded status as true.
MarkInstallSucceeded()
// MarkInstallFailed marks the InstallationSucceeded status as false with the given
// message.
MarkInstallFailed(msg string)

// MarkDeploymentsAvailable marks the DeploymentsAvailable status as true.
MarkDeploymentsAvailable()
// MarkDeploymentsNotReady marks the DeploymentsAvailable status as false and calls out
// it's waiting for deployments.
MarkDeploymentsNotReady()

// MarkDependenciesInstalled marks the DependenciesInstalled status as true.
MarkDependenciesInstalled()
// MarkDependencyInstalling marks the DependenciesInstalled status as false with the
// given message.
MarkDependencyInstalling(msg string)
// MarkDependencyMissing marks the DependenciesInstalled status as false with the
// given message.
MarkDependencyMissing(msg string)

// GetVersion gets the currently installed version of the component.
GetVersion() string
// SetVersion sets the currently installed version of the component.
SetVersion(version string)
}

// CommonSpec unifies common fields and functions on the Spec.
type CommonSpec struct {
// A means to override the corresponding entries in the upstream configmaps
Expand Down
22 changes: 18 additions & 4 deletions pkg/apis/operator/v1alpha1/knativeeventing_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ import (
"knative.dev/pkg/apis"
)

var eventingCondSet = apis.NewLivingConditionSet(
DependenciesInstalled,
DeploymentsAvailable,
InstallSucceeded,
var (
_ KComponentStatus = (*KnativeEventingStatus)(nil)

eventingCondSet = apis.NewLivingConditionSet(
DependenciesInstalled,
DeploymentsAvailable,
InstallSucceeded,
)
)

// GroupVersionKind returns SchemeGroupVersion of an KnativeEventing
Expand Down Expand Up @@ -102,3 +106,13 @@ func (es *KnativeEventingStatus) MarkDependencyMissing(msg string) {
"Error",
"Dependency missing: %s", msg)
}

// GetVersion gets the currently installed version of the component.
func (es *KnativeEventingStatus) GetVersion() string {
return es.Version
}

// SetVersion sets the currently installed version of the component.
func (es *KnativeEventingStatus) SetVersion(version string) {
es.Version = version
}
22 changes: 18 additions & 4 deletions pkg/apis/operator/v1alpha1/knativeserving_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ import (
"knative.dev/pkg/apis"
)

var servingCondSet = apis.NewLivingConditionSet(
DependenciesInstalled,
DeploymentsAvailable,
InstallSucceeded,
var (
_ KComponentStatus = (*KnativeServingStatus)(nil)

servingCondSet = apis.NewLivingConditionSet(
DependenciesInstalled,
DeploymentsAvailable,
InstallSucceeded,
)
)

// GroupVersionKind returns SchemeGroupVersion of a KnativeServing
Expand Down Expand Up @@ -100,3 +104,13 @@ func (is *KnativeServingStatus) MarkDependencyMissing(msg string) {
"Error",
"Dependency missing: %s", msg)
}

// GetVersion gets the currently installed version of the component.
func (is *KnativeServingStatus) GetVersion() string {
return is.Version
}

// SetVersion sets the currently installed version of the component.
func (is *KnativeServingStatus) SetVersion(version string) {
is.Version = version
}

0 comments on commit a276bd9

Please sign in to comment.