Skip to content

Commit

Permalink
fix: set status field hostReady in the conversion
Browse files Browse the repository at this point in the history
This field is required and therefore should be set as the Kube API server would – i.e. not as nil, but with an empty array when it has no elements.
  • Loading branch information
guicassolato committed Sep 4, 2023
1 parent 0599684 commit af96b5b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
14 changes: 4 additions & 10 deletions api/v1beta2/auth_config_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -1010,11 +1010,8 @@ func convertStatusFrom(src v1beta1.AuthConfigStatus) AuthConfigStatus {
}

func convertStatusSummaryTo(src AuthConfigStatusSummary) v1beta1.Summary {
var hostsReady []string
if len(src.HostsReady) > 0 {
hostsReady = make([]string, len(src.HostsReady))
copy(hostsReady, src.HostsReady)
}
hostsReady := make([]string, len(src.HostsReady))
copy(hostsReady, src.HostsReady)

return v1beta1.Summary{
Ready: src.Ready,
Expand All @@ -1029,11 +1026,8 @@ func convertStatusSummaryTo(src AuthConfigStatusSummary) v1beta1.Summary {
}

func convertStatusSummaryFrom(src v1beta1.Summary) AuthConfigStatusSummary {
var hostsReady []string
if len(src.HostsReady) > 0 {
hostsReady = make([]string, len(src.HostsReady))
copy(hostsReady, src.HostsReady)
}
hostsReady := make([]string, len(src.HostsReady))
copy(hostsReady, src.HostsReady)

return AuthConfigStatusSummary{
Ready: src.Ready,
Expand Down
34 changes: 32 additions & 2 deletions api/v1beta2/auth_config_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestConvertFrom(t *testing.T) {

func authConfig() *AuthConfig {
authConfig := &AuthConfig{}
_ = json.Unmarshal([]byte(`
err := json.Unmarshal([]byte(`
{
"metadata": {
"name": "auth-config"
Expand Down Expand Up @@ -441,14 +441,29 @@ func authConfig() *AuthConfig {
"value": "true"
}
]
},
"status": {
"summary": {
"ready": false,
"hostsReady": [],
"numHostsReady": "",
"numIdentitySources": 0,
"numMetadataSources": 0,
"numAuthorizationPolicies": 0,
"numResponseItems": 0,
"festivalWristbandEnabled": false
}
}
}`), &authConfig)
if err != nil {
panic(err)
}
return authConfig
}

func hubAuthConfig() *v1beta1.AuthConfig {
authConfig := &v1beta1.AuthConfig{}
_ = json.Unmarshal([]byte(`
err := json.Unmarshal([]byte(`
{
"metadata": {
"name": "auth-config"
Expand Down Expand Up @@ -963,7 +978,22 @@ func hubAuthConfig() *v1beta1.AuthConfig {
"value": "true"
}
]
},
"status": {
"summary": {
"ready": false,
"hostsReady": [],
"numHostsReady": "",
"numIdentitySources": 0,
"numMetadataSources": 0,
"numAuthorizationPolicies": 0,
"numResponseItems": 0,
"festivalWristbandEnabled": false
}
}
}`), &authConfig)
if err != nil {
panic(err)
}
return authConfig
}

0 comments on commit af96b5b

Please sign in to comment.