From cbc813f27472f55ca3f6b5d8db18864a5b316e0a Mon Sep 17 00:00:00 2001 From: mmanthir Date: Mon, 16 Dec 2024 09:45:31 -0500 Subject: [PATCH] Deployment manager failed due to BMC secret Serializing the IncompleteSecret to generate correct configuration. Updated the test cases. Test plan: - 'make' and 'make test' ran successfully - 'deployctl tool generates the expected configuration Signed-off-by: mmanthir --- build/build.go | 17 ++++++++++------- build/build_suite_test.go | 21 +++++++-------------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/build/build.go b/build/build.go index 36654ea1..c587d8b0 100644 --- a/build/build.go +++ b/build/build.go @@ -95,9 +95,12 @@ func parseIncompleteSecret(secret *v1.Secret) *IncompleteSecret { warningMsg := "Warning: Incomplete secret, please replace it with the secret content" if secret.Type == v1.SecretTypeTLS { return &IncompleteSecret{ - TypeMeta: secret.TypeMeta, - ObjectMeta: secret.ObjectMeta, - Type: secret.Type, + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{ + Name: secret.Name, + Namespace: secret.Namespace, + }, + Type: secret.Type, Data: map[string]string{ v1.TLSCertKey: warningMsg, v1.TLSPrivateKeyKey: warningMsg, @@ -132,10 +135,10 @@ func parseIncompleteSecret(secret *v1.Secret) *IncompleteSecret { // IncompleteSecret defines a struct that contains a warning message in the secret // data if the secret is incomplete type IncompleteSecret struct { - TypeMeta metav1.TypeMeta - ObjectMeta metav1.ObjectMeta - Type v1.SecretType - Data map[string]string + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + Type v1.SecretType `json:"type"` + Data map[string]string `json:"data"` } // Deployment defines the structure used to store all of the details of a diff --git a/build/build_suite_test.go b/build/build_suite_test.go index e57a99cf..c3e6b1ff 100644 --- a/build/build_suite_test.go +++ b/build/build_suite_test.go @@ -51,15 +51,14 @@ metadata: namespace: fakens type: kubernetes.io/basic-auth --- -Data: +apiVersion: v1 +data: Fake Data: 'Warning: Incomplete secret, please replace it with the secret content' -ObjectMeta: +kind: Secret +metadata: name: incomsec1 namespace: bar -Type: fake type -TypeMeta: - apiVersion: v1 - kind: Secret +type: fake type --- metadata: name: sys1 @@ -297,10 +296,7 @@ var _ = Describe("Test Build utilities:", func() { } got := parseIncompleteSecret(&secret) expect := IncompleteSecret{ - TypeMeta: metav1.TypeMeta{ - APIVersion: "v1", - Kind: "Secret", - }, + TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: "foo", Namespace: "bar", @@ -679,10 +675,7 @@ var _ = Describe("Test Build utilities:", func() { fakeInput := []byte("") secret := v1.Secret{ - TypeMeta: metav1.TypeMeta{ - APIVersion: "v1", - Kind: "Secret", - }, + TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: secName, Namespace: ns,