From 8290bc1e6a6569f88b5027c7ef30f23373c8edf8 Mon Sep 17 00:00:00 2001 From: oren-codefresh Date: Mon, 21 Jun 2021 16:28:05 +0300 Subject: [PATCH] Fix runtime (#11) * change to Autorization * fix runtime install * bump --- Makefile | 2 +- cmd/commands/runtime.go | 24 ++++++++++++++---------- pkg/store/store.go | 8 ++++++-- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 14e4d6a4f..31f5e0099 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=v0.0.14 +VERSION=v0.0.15 OUT_DIR=dist YEAR?=$(shell date +"%Y") diff --git a/cmd/commands/runtime.go b/cmd/commands/runtime.go index 5c552b46f..bf3446be5 100644 --- a/cmd/commands/runtime.go +++ b/cmd/commands/runtime.go @@ -229,8 +229,12 @@ func updateProject(repofs fs.FS, runtimeName string) error { if appset.Spec.Template.Labels == nil { appset.Spec.Template.Labels = make(map[string]string) } + if appset.Labels == nil { + appset.Labels = make(map[string]string) + } - appset.Spec.Template.Labels[store.Get().CFComponentKey] = "{{ appName }}" + appset.Spec.Template.Labels[store.Get().CFType] = store.Get().CFComponentType + appset.Labels[store.Get().CFType] = store.Get().CFRuntimeType return repofs.WriteYamls(projPath, project, appset) } @@ -356,9 +360,9 @@ func createEventSource(repofs fs.FS, path, runtimeName string) error { AfterStart: false, Labels: []eventsourcev1alpha1.Selector{ { - Key: store.Get().CFComponentKey, - Operation: "!=", - Value: "", + Key: store.Get().CFType, + Operation: "==", + Value: store.Get().CFComponentType, }, }, }, @@ -376,12 +380,12 @@ func createEventSource(repofs fs.FS, path, runtimeName string) error { }, Namespace: runtimeName, Filter: &eventsourcev1alpha1.ResourceFilter{ - AfterStart: true, + AfterStart: false, Labels: []eventsourcev1alpha1.Selector{ { - Key: store.Get().CFComponentKey, - Operation: "!=", - Value: "", + Key: store.Get().CFType, + Operation: "==", + Value: store.Get().CFRuntimeType, }, }, }, @@ -430,7 +434,7 @@ func createSensor(repofs fs.FS, path, namespace string) error { }, SecureHeaders: []*apicommon.SecureHeader{ { - Name: "Autorization", + Name: "Authorization", ValueFrom: &apicommon.ValueFromSource{ SecretKeyRef: &v1.SecretKeySelector{ LocalObjectReference: v1.LocalObjectReference{ @@ -471,7 +475,7 @@ func createSensor(repofs fs.FS, path, namespace string) error { }, SecureHeaders: []*apicommon.SecureHeader{ { - Name: "Autorization", + Name: "Authorization", ValueFrom: &apicommon.ValueFromSource{ SecretKeyRef: &v1.SecretKeySelector{ LocalObjectReference: v1.LocalObjectReference{ diff --git a/pkg/store/store.go b/pkg/store/store.go index 75cc9cf12..b2051c031 100644 --- a/pkg/store/store.go +++ b/pkg/store/store.go @@ -51,11 +51,13 @@ type Store struct { ArgoWorkflowsManifestsURL string CFTokenSecret string CFTokenSecretKey string - CFComponentKey string + CFType string EventReportingEndpoint string EventBusName string ComponentsReporterName string ComponentsReporterSA string + CFComponentType string + CFRuntimeType string } // Get returns the global store @@ -72,11 +74,13 @@ func init() { s.ArgoWorkflowsManifestsURL = ArgoWorkflowsManifestsURL s.CFTokenSecret = "codefresh-token" s.CFTokenSecretKey = "token" - s.CFComponentKey = "codefresh.io/component" + s.CFType = "codefresh.io/type" s.EventReportingEndpoint = "/argo/api/events" s.EventBusName = "codefresh-eventbus" s.ComponentsReporterName = "components-reporter" s.ComponentsReporterSA = "components-reporter-sa" + s.CFComponentType = "component" + s.CFRuntimeType = "runtime" initVersion() }