Skip to content

Commit

Permalink
fix(lifecycle-operator): renamed namespace
Browse files Browse the repository at this point in the history
Signed-off-by: realanna <[email protected]>
  • Loading branch information
RealAnna committed Sep 21, 2023
1 parent 980562c commit a6741b7
Show file tree
Hide file tree
Showing 16 changed files with 61 additions and 61 deletions.
6 changes: 3 additions & 3 deletions klt-cert-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func init() {
}

type envConfig struct {
KLTNamespace string `envconfig:"NAMESPACE" default:"keptn-lifecycle-toolkit-system"`
KeptnNamespace string `envconfig:"NAMESPACE" default:"keptn-lifecycle-toolkit-system"`
KLTLabelSelectorKey string `envconfig:"LABEL_SELECTOR_KEY" default:"keptn.sh/inject-cert"`
KLTLabelSelectorValue string `envconfig:"LABEL_SELECTOR_VALUE" default:"true"`
}
Expand Down Expand Up @@ -66,7 +66,7 @@ func main() {
Scheme: scheme,
Cache: cache.Options{
DefaultNamespaces: map[string]cache.Config{
env.KLTNamespace: {},
env.KeptnNamespace: {},
},
},
Metrics: metricsserver.Options{
Expand Down Expand Up @@ -99,7 +99,7 @@ func main() {
Scheme: mgr.GetScheme(),
CancelMgrFunc: nil,
Log: ctrl.Log.WithName("KeptnWebhookCert Controller"),
Namespace: env.KLTNamespace,
Namespace: env.KeptnNamespace,
MatchLabels: map[string]string{
env.KLTLabelSelectorKey: env.KLTLabelSelectorValue,
},
Expand Down
14 changes: 7 additions & 7 deletions lifecycle-operator/controllers/common/helperfunctions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)

const KLTNamespace = "keptn"
const KeptnNamespace = "keptn"

func Test_GetItemStatus(t *testing.T) {
tests := []struct {
Expand Down Expand Up @@ -404,15 +404,15 @@ func Test_GetTaskDefinition(t *testing.T) {
taskDef: &klcv1alpha3.KeptnTaskDefinition{
ObjectMeta: v1.ObjectMeta{
Name: "taskDef",
Namespace: KLTNamespace,
Namespace: KeptnNamespace,
},
},
taskDefName: "taskDef",
taskDefNamespace: "some-namespace",
out: &klcv1alpha3.KeptnTaskDefinition{
ObjectMeta: v1.ObjectMeta{
Name: "taskDef",
Namespace: KLTNamespace,
Namespace: KeptnNamespace,
},
},
wantError: false,
Expand All @@ -425,7 +425,7 @@ func Test_GetTaskDefinition(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
client := fake.NewClientBuilder().WithObjects(tt.taskDef).Build()
d, err := GetTaskDefinition(client, ctrl.Log.WithName("testytest"), context.TODO(), tt.taskDefName, tt.taskDefNamespace, KLTNamespace)
d, err := GetTaskDefinition(client, ctrl.Log.WithName("testytest"), context.TODO(), tt.taskDefName, tt.taskDefNamespace, KeptnNamespace)
if tt.out != nil && d != nil {
require.Equal(t, tt.out.Name, d.Name)
require.Equal(t, tt.out.Namespace, d.Namespace)
Expand Down Expand Up @@ -486,15 +486,15 @@ func Test_GetEvaluationDefinition(t *testing.T) {
evalDef: &klcv1alpha3.KeptnEvaluationDefinition{
ObjectMeta: v1.ObjectMeta{
Name: "evalDef",
Namespace: KLTNamespace,
Namespace: KeptnNamespace,
},
},
evalDefName: "evalDef",
evalDefNamespace: "some-namespace",
out: &klcv1alpha3.KeptnEvaluationDefinition{
ObjectMeta: v1.ObjectMeta{
Name: "evalDef",
Namespace: KLTNamespace,
Namespace: KeptnNamespace,
},
},
wantError: false,
Expand All @@ -507,7 +507,7 @@ func Test_GetEvaluationDefinition(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
client := fake.NewClientBuilder().WithObjects(tt.evalDef).Build()
d, err := GetEvaluationDefinition(client, ctrl.Log.WithName("testytest"), context.TODO(), tt.evalDefName, tt.evalDefNamespace, KLTNamespace)
d, err := GetEvaluationDefinition(client, ctrl.Log.WithName("testytest"), context.TODO(), tt.evalDefName, tt.evalDefNamespace, KeptnNamespace)
if tt.out != nil && d != nil {
require.Equal(t, tt.out.Name, d.Name)
require.Equal(t, tt.out.Namespace, d.Namespace)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)

const KLTNamespace = "test"
const KeptnNamespace = "test"

func Test_keptnmetric(t *testing.T) {
tests := []struct {
Expand Down Expand Up @@ -85,7 +85,7 @@ func Test_keptnmetric(t *testing.T) {
kmp := KeptnMetricProvider{
Log: ctrl.Log.WithName("testytest"),
K8sClient: client,
DefaultNamespace: KLTNamespace,
DefaultNamespace: KeptnNamespace,
}

obj := klcv1alpha3.Objective{
Expand Down Expand Up @@ -189,14 +189,14 @@ func Test_Getkeptnmetric(t *testing.T) {
metric: &metricsapi.KeptnMetric{
ObjectMeta: metav1.ObjectMeta{
Name: "metric",
Namespace: KLTNamespace,
Namespace: KeptnNamespace,
},
},
namespace: "my-other-namespace",
out: &metricsapi.KeptnMetric{
ObjectMeta: metav1.ObjectMeta{
Name: "metric",
Namespace: KLTNamespace,
Namespace: KeptnNamespace,
},
},
wantError: false,
Expand All @@ -212,7 +212,7 @@ func Test_Getkeptnmetric(t *testing.T) {
kmp := KeptnMetricProvider{
Log: ctrl.Log.WithName("testytest"),
K8sClient: client,
DefaultNamespace: KLTNamespace,
DefaultNamespace: KeptnNamespace,
}

m, err := kmp.GetKeptnMetric(context.TODO(), tt.objective, tt.namespace)
Expand Down
6 changes: 3 additions & 3 deletions lifecycle-operator/controllers/common/taskhandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestTaskHandler(t *testing.T) {
},
taskDef: &v1alpha3.KeptnTaskDefinition{
ObjectMeta: v1.ObjectMeta{
Namespace: KLTNamespace,
Namespace: KeptnNamespace,
Name: "task-def",
},
},
Expand Down Expand Up @@ -141,7 +141,7 @@ func TestTaskHandler(t *testing.T) {
},
taskDef: &v1alpha3.KeptnTaskDefinition{
ObjectMeta: v1.ObjectMeta{
Namespace: KLTNamespace,
Namespace: KeptnNamespace,
Name: "task-def",
},
},
Expand Down Expand Up @@ -377,7 +377,7 @@ func TestTaskHandler(t *testing.T) {
Client: fake.NewClientBuilder().WithObjects(initObjs...).Build(),
Tracer: trace.NewNoopTracerProvider().Tracer("tracer"),
Scheme: scheme.Scheme,
DefaultNamespace: KLTNamespace,
DefaultNamespace: KeptnNamespace,
}
status, summary, err := handler.ReconcileTasks(context.TODO(), context.TODO(), tt.object, tt.createAttr)
if len(tt.wantStatus) == len(status) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
k8sfake "sigs.k8s.io/controller-runtime/pkg/client/fake"
)

const KltNamespace = "klt-namespace"
const KeptnNamespace = "klt-namespace"

func TestKeptnEvaluationReconciler_Reconcile_FailEvaluation(t *testing.T) {

Expand Down Expand Up @@ -164,7 +164,7 @@ func TestKeptnEvaluationReconciler_Reconcile_SucceedEvaluation(t *testing.T) {
require.Equal(t, "value '10' met objective '<11'", updatedEvaluation.Status.EvaluationStatus[metric.Name].Message)
}

func TestKeptnEvaluationReconciler_Reconcile_SucceedEvaluation_withDefinitionInDefaultKLTNamespace(t *testing.T) {
func TestKeptnEvaluationReconciler_Reconcile_SucceedEvaluation_withDefinitionInDefaultKeptnNamespace(t *testing.T) {

const namespace = "my-namespace"
metric := &metricsapi.KeptnMetric{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)

const KLTNamespace = "mynamespace"
const KeptnNamespace = "mynamespace"

func TestKeptnTaskReconciler_createJob(t *testing.T) {
namespace := "default"
Expand Down Expand Up @@ -91,7 +91,7 @@ func TestKeptnTaskReconciler_createJob_withTaskDefInDefaultNamespace(t *testing.
taskDefinitionName := "my-task-definition"

cm := makeConfigMap(cmName, namespace)
taskDefinition := makeTaskDefinitionWithConfigmapRef(taskDefinitionName, KLTNamespace, cmName)
taskDefinition := makeTaskDefinitionWithConfigmapRef(taskDefinitionName, KeptnNamespace, cmName)

fakeClient := fakeclient.NewClient(cm, taskDefinition)

Expand All @@ -104,7 +104,7 @@ func TestKeptnTaskReconciler_createJob_withTaskDefInDefaultNamespace(t *testing.
EventSender: controllercommon.NewK8sSender(record.NewFakeRecorder(100)),
Log: ctrl.Log.WithName("task-controller"),
Scheme: fakeClient.Scheme(),
Namespace: KLTNamespace,
Namespace: KeptnNamespace,
}

task := makeTask("my-task", namespace, taskDefinitionName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var (
spanRecorder *sdktest.SpanRecorder
)

const KLTnamespace = "keptnlifecycle"
const KeptnNamespace = "keptnlifecycle"

var _ = BeforeSuite(func() {
var readyToStart chan struct{}
Expand All @@ -48,7 +48,7 @@ var _ = BeforeSuite(func() {
Meters: common.InitKeptnMeters(),
SpanHandler: &telemetry.SpanHandler{},
TracerFactory: &common.TracerFactory{Tracer: tracer},
Namespace: KLTnamespace,
Namespace: KeptnNamespace,
}
Eventually(controller.SetupWithManager(k8sManager)).WithTimeout(30 * time.Second).WithPolling(time.Second).Should(Succeed())
close(readyToStart)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var (
ns *v1.Namespace
)

const KLTnamespace = "keptnlifecycle"
const KeptnNamespace = "keptnlifecycle"

var _ = BeforeSuite(func() {
var readyToStart chan struct{}
Expand All @@ -48,11 +48,11 @@ var _ = BeforeSuite(func() {
Log: GinkgoLogr,
Meters: common.InitKeptnMeters(),
TracerFactory: &common.TracerFactory{Tracer: tracer},
Namespace: KLTnamespace,
Namespace: KeptnNamespace,
}
Eventually(controller.SetupWithManager(k8sManager)).WithTimeout(30 * time.Second).WithPolling(time.Second).Should(Succeed())

ns = common.MakeKLTDefaultNamespace(k8sClient, KLTnamespace)
ns = common.MakeKLTDefaultNamespace(k8sClient, KeptnNamespace)
close(readyToStart)
})

Expand Down
10 changes: 5 additions & 5 deletions lifecycle-operator/test/component/evaluation/evaluation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,17 @@ var _ = Describe("Evaluation", Ordered, func() {
It("KeptnEvaluationController Should succeed, as it finds KeptnEvaluationDefinition in default KLT namespace", func() {
By("Create EvaluationDefiniton")

evaluationDefinition = makeEvaluationDefinition(evaluationDefinitionName, KLTnamespace, metricName)
evaluationDefinition = makeEvaluationDefinition(evaluationDefinitionName, KeptnNamespace, metricName)

By("Create KeptnMetric")

metric := makeKeptnMetric(metricName, KLTnamespace)
metric := makeKeptnMetric(metricName, KeptnNamespace)

By("Update KeptnMetric to have status")

metric2 := &metricsapi.KeptnMetric{}
err := k8sClient.Get(context.TODO(), types.NamespacedName{
Namespace: KLTnamespace,
Namespace: KeptnNamespace,
Name: metric.Name,
}, metric2)
Expect(err).To(BeNil())
Expand All @@ -138,14 +138,14 @@ var _ = Describe("Evaluation", Ordered, func() {
evaluationdef := &klcv1alpha3.KeptnEvaluationDefinition{}
Eventually(func(g Gomega) {
err := k8sClient.Get(context.TODO(), types.NamespacedName{
Namespace: KLTnamespace,
Namespace: KeptnNamespace,
Name: evaluationDefinitionName,
}, evaluationdef)
g.Expect(err).To(BeNil())
g.Expect(evaluationdef.Spec.Objectives[0]).To(Equal(klcv1alpha3.Objective{
KeptnMetricRef: klcv1alpha3.KeptnMetricReference{
Name: metricName,
Namespace: KLTnamespace,
Namespace: KeptnNamespace,
},
EvaluationTarget: "<10",
}))
Expand Down
4 changes: 2 additions & 2 deletions lifecycle-operator/test/component/task/task_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
ctx context.Context
)

const KLTnamespace = "keptnlifecycle"
const KeptnNamespace = "keptnlifecycle"

var _ = BeforeSuite(func() {
var readyToStart chan struct{}
Expand All @@ -47,7 +47,7 @@ var _ = BeforeSuite(func() {
Log: GinkgoLogr,
Meters: common.InitKeptnMeters(),
TracerFactory: &common.TracerFactory{Tracer: tracer},
Namespace: KLTnamespace,
Namespace: KeptnNamespace,
}
Eventually(controller.SetupWithManager(k8sManager)).WithTimeout(30 * time.Second).WithPolling(time.Second).Should(Succeed())
close(readyToStart)
Expand Down
8 changes: 4 additions & 4 deletions lifecycle-operator/test/component/task/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ var _ = Describe("Task", Ordered, func() {

ns := &v1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: KLTnamespace,
Name: KeptnNamespace,
},
}
err := k8sClient.Create(context.TODO(), ns)
Expect(err).To(BeNil())

taskDefinition = makeTaskDefinition(taskDefinitionName, KLTnamespace)
taskDefinition = makeTaskDefinition(taskDefinitionName, KeptnNamespace)
task = makeTask(name, namespace, taskDefinition.Name)

By("Verifying that a job has been created")
Expand Down Expand Up @@ -135,13 +135,13 @@ var _ = Describe("Task", Ordered, func() {

ns := &v1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: KLTnamespace,
Name: KeptnNamespace,
},
}
err := k8sClient.Create(context.TODO(), ns)
Expect(common.IgnoreAlreadyExists(err)).To(BeNil())

taskDefinition = makeContainerTaskDefinition(taskDefinitionName, KLTnamespace)
taskDefinition = makeContainerTaskDefinition(taskDefinitionName, KeptnNamespace)
task = makeTask(name, namespace, taskDefinition.Name)

By("Verifying that a job has been created")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var (
spanRecorder *sdktest.SpanRecorder
)

const KLTnamespace = "keptnlifecycle"
const KeptnNamespace = "keptnlifecycle"

var _ = BeforeSuite(func() {
var readyToStart chan struct{}
Expand All @@ -48,7 +48,7 @@ var _ = BeforeSuite(func() {
Meters: common.InitKeptnMeters(),
SpanHandler: &telemetry.SpanHandler{},
TracerFactory: &common.TracerFactory{Tracer: tracer},
Namespace: KLTnamespace,
Namespace: KeptnNamespace,
}
Eventually(controller.SetupWithManager(k8sManager)).WithTimeout(30 * time.Second).WithPolling(time.Second).Should(Succeed())
close(readyToStart)
Expand Down
4 changes: 2 additions & 2 deletions metrics-operator/cmd/metrics/adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var (

type MetricsAdapter struct {
basecmd.AdapterBase
KltNamespace string
KeptnNamespace string
}

// RunAdapter starts the Keptn Metrics adapter to provide KeptnMetrics via the Kubernetes Custom Metrics API.
Expand Down Expand Up @@ -70,7 +70,7 @@ func (a *MetricsAdapter) makeProviderOrDie(ctx context.Context) provider.CustomM
klog.Fatalf("unable to construct dynamic client: %v", err)
}

return kmprovider.NewProvider(ctx, client, a.KltNamespace)
return kmprovider.NewProvider(ctx, client, a.KeptnNamespace)
}

func addFlags() {
Expand Down
12 changes: 6 additions & 6 deletions metrics-operator/cmd/metrics/adapter/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ var providerInstance *keptnMetricsProvider
var providerOnce sync.Once

type keptnMetricsProvider struct {
client dynamic.Interface
scheme *runtime.Scheme
logger logr.Logger
KltNamespace string
client dynamic.Interface
scheme *runtime.Scheme
logger logr.Logger
KeptnNamespace string

// cache is being populated via the updates received by the provider's dynamic informer
// this way, we avoid sending a request to the Kubernetes API each time a custom metric value should be retrieved
Expand All @@ -54,8 +54,8 @@ func NewProvider(ctx context.Context, client dynamic.Interface, namespace string
cache: CustomMetricsCache{
metrics: map[metricKey]CustomMetricValue{},
},
logger: ctrl.Log.WithName("provider"),
KltNamespace: namespace,
logger: ctrl.Log.WithName("provider"),
KeptnNamespace: namespace,
}

if err := providerInstance.watchMetrics(ctx); err != nil {
Expand Down
Loading

0 comments on commit a6741b7

Please sign in to comment.