Skip to content
This repository was archived by the owner on Jun 24, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions pkg/apis/serving/v1alpha1/knativeserving_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
)

var conditions = apis.NewLivingConditionSet(
DependenciesInstalled,
DeploymentsAvailable,
InstallSucceeded,
)
Expand Down Expand Up @@ -56,6 +57,10 @@ func (is *KnativeServingStatus) IsDeploying() bool {
return is.IsInstalled() && !is.IsAvailable()
}

func (is *KnativeServingStatus) IsFullySupported() bool {
return is.GetCondition(DependenciesInstalled).IsTrue()
}

func (is *KnativeServingStatus) GetCondition(t apis.ConditionType) *apis.Condition {
return conditions.Manage(is).GetCondition(t)
}
Expand All @@ -73,6 +78,10 @@ func (is *KnativeServingStatus) MarkInstallFailed(msg string) {

func (is *KnativeServingStatus) MarkInstallSucceeded() {
conditions.Manage(is).MarkTrue(InstallSucceeded)
if is.GetCondition(DependenciesInstalled).IsUnknown() {
// Assume deps are installed if we're not sure
is.MarkDependenciesInstalled()
}
}

func (is *KnativeServingStatus) MarkDeploymentsAvailable() {
Expand All @@ -85,3 +94,21 @@ func (is *KnativeServingStatus) MarkDeploymentsNotReady() {
"NotReady",
"Waiting on deployments")
}

func (is *KnativeServingStatus) MarkDependenciesInstalled() {
conditions.Manage(is).MarkTrue(DependenciesInstalled)
}

func (is *KnativeServingStatus) MarkDependencyInstalling(msg string) {
conditions.Manage(is).MarkFalse(
DependenciesInstalled,
"Installing",
"Dependency installing: %s", msg)
}

func (is *KnativeServingStatus) MarkDependencyMissing(msg string) {
conditions.Manage(is).MarkFalse(
DependenciesInstalled,
"Error",
"Dependency missing: %s", msg)
}
19 changes: 19 additions & 0 deletions pkg/apis/serving/v1alpha1/knativeserving_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,22 @@ func TestKnativeServingGroupVersionKind(t *testing.T) {
t.Errorf("got: %v, want: %v", got, want)
}
}

func TestAssumeDepsInstalled(t *testing.T) {
ks := &KnativeServingStatus{}
ks.InitializeConditions()
assertEqual(t, ks.GetCondition(DependenciesInstalled).IsUnknown(), true)
assertEqual(t, ks.GetCondition(DependenciesInstalled).IsTrue(), false)
ks.MarkInstallSucceeded()
assertEqual(t, ks.GetCondition(DependenciesInstalled).IsUnknown(), false)
assertEqual(t, ks.GetCondition(DependenciesInstalled).IsTrue(), true)
assertEqual(t, ks.IsInstalled(), true)
assertEqual(t, ks.IsFullySupported(), true)
}

func assertEqual(t *testing.T, actual, expected interface{}) {
if actual == expected {
return
}
t.Fatalf("Expected: %v\nActual: %v", expected, actual)
}
5 changes: 3 additions & 2 deletions pkg/apis/serving/v1alpha1/knativeserving_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ import (
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

const (
InstallSucceeded apis.ConditionType = "InstallSucceeded"
DeploymentsAvailable apis.ConditionType = "DeploymentsAvailable"
DependenciesInstalled apis.ConditionType = "DependenciesInstalled"
InstallSucceeded apis.ConditionType = "InstallSucceeded"
DeploymentsAvailable apis.ConditionType = "DeploymentsAvailable"
)

// Registry defines image overrides of knative images.
Expand Down