Skip to content

Commit

Permalink
Deployment manager failed due to BMC secret
Browse files Browse the repository at this point in the history
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 <mahalakshmi.manthiram@windriver.com>
  • Loading branch information
MahalakshmiManthiram committed Dec 16, 2024
1 parent 22236ba commit cbc813f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
17 changes: 10 additions & 7 deletions build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
21 changes: 7 additions & 14 deletions build/build_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit cbc813f

Please sign in to comment.