From d04dd33affc5f7c6225c58474b586e5f626299df Mon Sep 17 00:00:00 2001 From: Vincent Date: Mon, 1 Jun 2020 11:42:04 -0400 Subject: [PATCH] Change the structure of kodata and read the yamls with the version (#115) --- .../kodata/knative-eventing/{ => 0.14.2}/1-eventing.yaml | 0 .../knative-eventing/{ => 0.14.2}/2-upgrade-to-v0.14.2.yaml | 0 .../kodata/knative-serving/{ => 0.14.0}/1-serving-crds.yaml | 0 .../kodata/knative-serving/{ => 0.14.0}/2-serving-core.yaml | 0 .../kodata/knative-serving/{ => 0.14.0}/3-serving-hpa.yaml | 0 .../kodata/knative-serving/{ => 0.14.0}/4-net-istio.yaml | 0 pkg/reconciler/knativeeventing/controller.go | 3 ++- pkg/reconciler/knativeserving/controller.go | 3 ++- version/version_test.go | 4 ++-- 9 files changed, 6 insertions(+), 4 deletions(-) rename cmd/operator/kodata/knative-eventing/{ => 0.14.2}/1-eventing.yaml (100%) rename cmd/operator/kodata/knative-eventing/{ => 0.14.2}/2-upgrade-to-v0.14.2.yaml (100%) rename cmd/operator/kodata/knative-serving/{ => 0.14.0}/1-serving-crds.yaml (100%) rename cmd/operator/kodata/knative-serving/{ => 0.14.0}/2-serving-core.yaml (100%) rename cmd/operator/kodata/knative-serving/{ => 0.14.0}/3-serving-hpa.yaml (100%) rename cmd/operator/kodata/knative-serving/{ => 0.14.0}/4-net-istio.yaml (100%) diff --git a/cmd/operator/kodata/knative-eventing/1-eventing.yaml b/cmd/operator/kodata/knative-eventing/0.14.2/1-eventing.yaml similarity index 100% rename from cmd/operator/kodata/knative-eventing/1-eventing.yaml rename to cmd/operator/kodata/knative-eventing/0.14.2/1-eventing.yaml diff --git a/cmd/operator/kodata/knative-eventing/2-upgrade-to-v0.14.2.yaml b/cmd/operator/kodata/knative-eventing/0.14.2/2-upgrade-to-v0.14.2.yaml similarity index 100% rename from cmd/operator/kodata/knative-eventing/2-upgrade-to-v0.14.2.yaml rename to cmd/operator/kodata/knative-eventing/0.14.2/2-upgrade-to-v0.14.2.yaml diff --git a/cmd/operator/kodata/knative-serving/1-serving-crds.yaml b/cmd/operator/kodata/knative-serving/0.14.0/1-serving-crds.yaml similarity index 100% rename from cmd/operator/kodata/knative-serving/1-serving-crds.yaml rename to cmd/operator/kodata/knative-serving/0.14.0/1-serving-crds.yaml diff --git a/cmd/operator/kodata/knative-serving/2-serving-core.yaml b/cmd/operator/kodata/knative-serving/0.14.0/2-serving-core.yaml similarity index 100% rename from cmd/operator/kodata/knative-serving/2-serving-core.yaml rename to cmd/operator/kodata/knative-serving/0.14.0/2-serving-core.yaml diff --git a/cmd/operator/kodata/knative-serving/3-serving-hpa.yaml b/cmd/operator/kodata/knative-serving/0.14.0/3-serving-hpa.yaml similarity index 100% rename from cmd/operator/kodata/knative-serving/3-serving-hpa.yaml rename to cmd/operator/kodata/knative-serving/0.14.0/3-serving-hpa.yaml diff --git a/cmd/operator/kodata/knative-serving/4-net-istio.yaml b/cmd/operator/kodata/knative-serving/0.14.0/4-net-istio.yaml similarity index 100% rename from cmd/operator/kodata/knative-serving/4-net-istio.yaml rename to cmd/operator/kodata/knative-serving/0.14.0/4-net-istio.yaml diff --git a/pkg/reconciler/knativeeventing/controller.go b/pkg/reconciler/knativeeventing/controller.go index 02865cdf9d..181b3359b5 100644 --- a/pkg/reconciler/knativeeventing/controller.go +++ b/pkg/reconciler/knativeeventing/controller.go @@ -30,6 +30,7 @@ import ( knereconciler "knative.dev/operator/pkg/client/injection/reconciler/operator/v1alpha1/knativeeventing" "knative.dev/operator/pkg/reconciler" "knative.dev/operator/pkg/reconciler/common" + "knative.dev/operator/version" kubeclient "knative.dev/pkg/client/injection/kube/client" deploymentinformer "knative.dev/pkg/client/injection/kube/informers/apps/v1/deployment" "knative.dev/pkg/configmap" @@ -52,7 +53,7 @@ func NewController(ctx context.Context, cmw configmap.Watcher) *controller.Impl } koDataDir := os.Getenv("KO_DATA_PATH") - config, err := mfc.NewManifest(filepath.Join(koDataDir, "knative-eventing/"), + config, err := mfc.NewManifest(filepath.Join(koDataDir, "knative-eventing", version.EventingVersion), injection.GetConfig(ctx), mf.UseLogger(zapr.NewLogger(logger.Desugar()).WithName("manifestival"))) if err != nil { diff --git a/pkg/reconciler/knativeserving/controller.go b/pkg/reconciler/knativeserving/controller.go index e885a1ee8f..b25d9d6e4c 100644 --- a/pkg/reconciler/knativeserving/controller.go +++ b/pkg/reconciler/knativeserving/controller.go @@ -37,6 +37,7 @@ import ( "knative.dev/operator/pkg/reconciler" "knative.dev/operator/pkg/reconciler/common" servingcommon "knative.dev/operator/pkg/reconciler/knativeserving/common" + "knative.dev/operator/version" deploymentinformer "knative.dev/pkg/client/injection/kube/informers/apps/v1/deployment" "knative.dev/pkg/configmap" "knative.dev/pkg/controller" @@ -65,7 +66,7 @@ func NewController(ctx context.Context, cmw configmap.Watcher) *controller.Impl } koDataDir := os.Getenv("KO_DATA_PATH") - config, err := mfc.NewManifest(filepath.Join(koDataDir, "knative-serving/"), + config, err := mfc.NewManifest(filepath.Join(koDataDir, "knative-serving", version.ServingVersion), injection.GetConfig(ctx), mf.UseLogger(zapr.NewLogger(logger.Desugar()).WithName("manifestival"))) if err != nil { diff --git a/version/version_test.go b/version/version_test.go index 9c3afb4fcd..ea5b5cad80 100644 --- a/version/version_test.go +++ b/version/version_test.go @@ -25,7 +25,7 @@ import ( func TestManifestVersionServingSame(t *testing.T) { _, b, _, _ := runtime.Caller(0) - manifest, err := mf.NewManifest(filepath.Join(filepath.Dir(b)+"/..", "cmd/operator/kodata/knative-serving/")) + manifest, err := mf.NewManifest(filepath.Join(filepath.Dir(b)+"/..", "cmd/operator/kodata/knative-serving", ServingVersion)) if err != nil { t.Fatal("Failed to load manifest", err) } @@ -45,7 +45,7 @@ func TestManifestVersionServingSame(t *testing.T) { func TestManifestVersionEventingSame(t *testing.T) { _, b, _, _ := runtime.Caller(0) - manifest, err := mf.NewManifest(filepath.Join(filepath.Dir(b)+"/..", "cmd/operator/kodata/knative-eventing/")) + manifest, err := mf.NewManifest(filepath.Join(filepath.Dir(b)+"/..", "cmd/operator/kodata/knative-eventing", EventingVersion)) if err != nil { t.Fatal("Failed to load manifest", err) }