Skip to content

Commit

Permalink
fix tektonConfig, chain tutorial and hub e2e test issues in OpenShift…
Browse files Browse the repository at this point in the history
… environment

Signed-off-by: Jeeva Kandasamy <jkandasa@gmail.com>
  • Loading branch information
jkandasa authored and tekton-robot committed May 12, 2023
1 parent 0843725 commit a9aac2d
Show file tree
Hide file tree
Showing 42 changed files with 6,098 additions and 960 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,6 @@ tags
.idea/*

.bin/

# ignore chain certificate
test/e2e/common/cosign.pub
2 changes: 1 addition & 1 deletion pkg/apis/operator/v1alpha1/tektonhub_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
func (th *TektonHub) SetDefaults(ctx context.Context) {

if th.Spec.Api.ApiSecretName == "" {
th.Spec.Api.ApiSecretName = "tekton-hub-api"
th.Spec.Api.ApiSecretName = HubApiSecretName
}

if th.Spec.CommonSpec.TargetNamespace == "" {
Expand Down
13 changes: 7 additions & 6 deletions pkg/apis/operator/v1alpha1/tektonhub_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const (
DbDependenciesInstalled apis.ConditionType = "DbDependenciesInstalled"
DbInstallerSetAvailable apis.ConditionType = "DbInstallSetAvailable"
// DB-migration
DatabasebMigrationDone apis.ConditionType = "DatabasebMigrationDone"
// TODO: fix the typo on the value: "DatabasebMigrationDone"
DatabaseMigrationDone apis.ConditionType = "DatabasebMigrationDone"
// API
ApiDependenciesInstalled apis.ConditionType = "ApiDependenciesInstalled"
ApiInstallerSetAvailable apis.ConditionType = "ApiInstallSetAvailable"
Expand All @@ -43,7 +44,7 @@ var (
hubCondSet = apis.NewLivingConditionSet(
DbDependenciesInstalled,
DbInstallerSetAvailable,
DatabasebMigrationDone,
DatabaseMigrationDone,
PreReconciler,
ApiDependenciesInstalled,
ApiInstallerSetAvailable,
Expand Down Expand Up @@ -119,16 +120,16 @@ func (ths *TektonHubStatus) MarkDbInstallerSetAvailable() {
}

// Lifecycle for the DB migration component of Tekton Hub
func (ths *TektonHubStatus) MarkDatabasebMigrationFailed(msg string) {
func (ths *TektonHubStatus) MarkDatabaseMigrationFailed(msg string) {
ths.MarkNotReady("Database migration job not ready")
hubCondSet.Manage(ths).MarkFalse(
DatabasebMigrationDone,
DatabaseMigrationDone,
"Error",
"Database migration job not ready: %s", msg)
}

func (ths *TektonHubStatus) MarkDatabasebMigrationDone() {
hubCondSet.Manage(ths).MarkTrue(DatabasebMigrationDone)
func (ths *TektonHubStatus) MarkDatabaseMigrationDone() {
hubCondSet.Manage(ths).MarkTrue(DatabaseMigrationDone)
}

// Lifecycle for the API component of Tekton Hub
Expand Down
20 changes: 10 additions & 10 deletions pkg/apis/operator/v1alpha1/tektonhub_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestTektonHubHappyPath(t *testing.T) {

apistest.CheckConditionOngoing(th, DbDependenciesInstalled, t)
apistest.CheckConditionOngoing(th, DbInstallerSetAvailable, t)
apistest.CheckConditionOngoing(th, DatabasebMigrationDone, t)
apistest.CheckConditionOngoing(th, DatabaseMigrationDone, t)
apistest.CheckConditionOngoing(th, ApiDependenciesInstalled, t)
apistest.CheckConditionOngoing(th, PreReconciler, t)
apistest.CheckConditionOngoing(th, ApiInstallerSetAvailable, t)
Expand All @@ -62,12 +62,12 @@ func TestTektonHubHappyPath(t *testing.T) {

// Db-migration
// InstallerSet is not ready when Job pods are not up
th.MarkDatabasebMigrationFailed("waiting for Job to complete")
apistest.CheckConditionFailed(th, DatabasebMigrationDone, t)
th.MarkDatabaseMigrationFailed("waiting for Job to complete")
apistest.CheckConditionFailed(th, DatabaseMigrationDone, t)

// Installer set created for DB migration
th.MarkDatabasebMigrationDone()
apistest.CheckConditionSucceeded(th, DatabasebMigrationDone, t)
th.MarkDatabaseMigrationDone()
apistest.CheckConditionSucceeded(th, DatabaseMigrationDone, t)

//API

Expand Down Expand Up @@ -107,7 +107,7 @@ func TestTektonHubErrorPath(t *testing.T) {

apistest.CheckConditionOngoing(th, DbDependenciesInstalled, t)
apistest.CheckConditionOngoing(th, DbInstallerSetAvailable, t)
apistest.CheckConditionOngoing(th, DatabasebMigrationDone, t)
apistest.CheckConditionOngoing(th, DatabaseMigrationDone, t)
apistest.CheckConditionOngoing(th, ApiDependenciesInstalled, t)
apistest.CheckConditionOngoing(th, PreReconciler, t)
apistest.CheckConditionOngoing(th, ApiInstallerSetAvailable, t)
Expand All @@ -126,12 +126,12 @@ func TestTektonHubErrorPath(t *testing.T) {
apistest.CheckConditionSucceeded(th, DbInstallerSetAvailable, t)

// InstallerSet is not ready when Job pods are not up
th.MarkDatabasebMigrationFailed("waiting for Job to complete")
apistest.CheckConditionFailed(th, DatabasebMigrationDone, t)
th.MarkDatabaseMigrationFailed("waiting for Job to complete")
apistest.CheckConditionFailed(th, DatabaseMigrationDone, t)

// Installer set created for DB migration
th.MarkDatabasebMigrationDone()
apistest.CheckConditionSucceeded(th, DatabasebMigrationDone, t)
th.MarkDatabaseMigrationDone()
apistest.CheckConditionSucceeded(th, DatabaseMigrationDone, t)

th.MarkApiDependenciesInstalled()
apistest.CheckConditionSucceeded(th, ApiDependenciesInstalled, t)
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/operator/v1alpha1/tektonhub_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ import (
duckv1 "knative.dev/pkg/apis/duck/v1"
)

const (
HubDbSecretName = "tekton-hub-db"
HubApiSecretName = "tekton-hub-api"
)

var (
_ TektonComponent = (*TektonHub)(nil)
_ TektonComponentSpec = (*TektonHubSpec)(nil)
Expand Down
21 changes: 6 additions & 15 deletions pkg/apis/operator/v1alpha1/tektonhub_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,18 @@ func validateHubParams(params []Param, pathToParams string) *apis.FieldError {
}

func (th *TektonHub) Validate(ctx context.Context) (errs *apis.FieldError) {

if apis.IsInDelete(ctx) {
return nil
}

errs = errs.Also(th.Spec.Db.validate("spec.db"))

return errs.Also(th.Spec.Api.validate("spec.api"))

}

func (db *DbSpec) validate(path string) (errs *apis.FieldError) {
if db.DbSecretName != "" && db.DbSecretName != "tekton-hub-db" {
return errs.Also(apis.ErrInvalidValue(db.DbSecretName, path+".DbSecretName"))
// validate database secret name
if th.Spec.Db.DbSecretName != "" && th.Spec.Db.DbSecretName != HubDbSecretName {
errs = errs.Also(apis.ErrInvalidValue(th.Spec.Db.DbSecretName, "spec.db.secret"))
}
return errs
}

func (api *ApiSpec) validate(path string) (errs *apis.FieldError) {
if api.ApiSecretName != "" && api.ApiSecretName != "tekton-hub-api" {
return errs.Also(apis.ErrInvalidValue(api.ApiSecretName, path+".ApiSecretName"))
// validate api secret name
if th.Spec.Api.ApiSecretName != "" && th.Spec.Api.ApiSecretName != HubApiSecretName {
errs = errs.Also(apis.ErrInvalidValue(th.Spec.Api.ApiSecretName, "spec.api.secret"))
}

return errs
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/operator/v1alpha1/tektonhub_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func Test_ValidateTektonHub_InvalidDbSecretName(t *testing.T) {
}

err := th.Validate(context.TODO())
assert.Equal(t, "invalid value: invalid-value: spec.db.DbSecretName", err.Error())
assert.Equal(t, "invalid value: invalid-value: spec.db.secret", err.Error())
}

func Test_ValidateTektonHub_InvalidApiSecretName(t *testing.T) {
Expand All @@ -119,5 +119,5 @@ func Test_ValidateTektonHub_InvalidApiSecretName(t *testing.T) {
}

err := th.Validate(context.TODO())
assert.Equal(t, "invalid value: invalid-value: spec.api.ApiSecretName", err.Error())
assert.Equal(t, "invalid value: invalid-value: spec.api.secret", err.Error())
}
Loading

0 comments on commit a9aac2d

Please sign in to comment.