From 7520dadbdd607d29e9104edd2757166c2e3990b9 Mon Sep 17 00:00:00 2001 From: Matt Moyer Date: Wed, 18 Nov 2020 14:29:13 -0600 Subject: [PATCH] Use `omitempty` on UpstreamOIDCProvider `spec.authorizationConfig` field. This allows you to omit the field in creation requests, which was annoying. Signed-off-by: Matt Moyer --- .../idp/v1alpha1/types_upstreamoidcprovider.go.tmpl | 4 ++-- .../supervisor/idp/v1alpha1/types_upstreamoidcprovider.go | 4 ++-- .../supervisor/idp/v1alpha1/types_upstreamoidcprovider.go | 4 ++-- .../supervisor/idp/v1alpha1/types_upstreamoidcprovider.go | 4 ++-- test/integration/supervisor_login_test.go | 3 --- test/integration/supervisor_upstream_test.go | 3 --- 6 files changed, 8 insertions(+), 14 deletions(-) diff --git a/apis/supervisor/idp/v1alpha1/types_upstreamoidcprovider.go.tmpl b/apis/supervisor/idp/v1alpha1/types_upstreamoidcprovider.go.tmpl index ea12b063..9be04701 100644 --- a/apis/supervisor/idp/v1alpha1/types_upstreamoidcprovider.go.tmpl +++ b/apis/supervisor/idp/v1alpha1/types_upstreamoidcprovider.go.tmpl @@ -41,7 +41,7 @@ type OIDCAuthorizationConfig struct { // AdditionalScopes are the scopes in addition to "openid" that will be requested as part of the authorization // request flow with an OIDC identity provider. By default only the "openid" scope will be requested. // +optional - AdditionalScopes []string `json:"additionalScopes"` + AdditionalScopes []string `json:"additionalScopes,omitempty"` } // OIDCClaims provides a mapping from upstream claims into identities. @@ -82,7 +82,7 @@ type UpstreamOIDCProviderSpec struct { // AuthorizationConfig holds information about how to form the OAuth2 authorization request // parameters to be used with this OIDC identity provider. // +optional - AuthorizationConfig OIDCAuthorizationConfig `json:"authorizationConfig"` + AuthorizationConfig OIDCAuthorizationConfig `json:"authorizationConfig,omitempty"` // Claims provides the names of token claims that will be used when inspecting an identity from // this OIDC identity provider. diff --git a/generated/1.17/apis/supervisor/idp/v1alpha1/types_upstreamoidcprovider.go b/generated/1.17/apis/supervisor/idp/v1alpha1/types_upstreamoidcprovider.go index ea12b063..9be04701 100644 --- a/generated/1.17/apis/supervisor/idp/v1alpha1/types_upstreamoidcprovider.go +++ b/generated/1.17/apis/supervisor/idp/v1alpha1/types_upstreamoidcprovider.go @@ -41,7 +41,7 @@ type OIDCAuthorizationConfig struct { // AdditionalScopes are the scopes in addition to "openid" that will be requested as part of the authorization // request flow with an OIDC identity provider. By default only the "openid" scope will be requested. // +optional - AdditionalScopes []string `json:"additionalScopes"` + AdditionalScopes []string `json:"additionalScopes,omitempty"` } // OIDCClaims provides a mapping from upstream claims into identities. @@ -82,7 +82,7 @@ type UpstreamOIDCProviderSpec struct { // AuthorizationConfig holds information about how to form the OAuth2 authorization request // parameters to be used with this OIDC identity provider. // +optional - AuthorizationConfig OIDCAuthorizationConfig `json:"authorizationConfig"` + AuthorizationConfig OIDCAuthorizationConfig `json:"authorizationConfig,omitempty"` // Claims provides the names of token claims that will be used when inspecting an identity from // this OIDC identity provider. diff --git a/generated/1.18/apis/supervisor/idp/v1alpha1/types_upstreamoidcprovider.go b/generated/1.18/apis/supervisor/idp/v1alpha1/types_upstreamoidcprovider.go index ea12b063..9be04701 100644 --- a/generated/1.18/apis/supervisor/idp/v1alpha1/types_upstreamoidcprovider.go +++ b/generated/1.18/apis/supervisor/idp/v1alpha1/types_upstreamoidcprovider.go @@ -41,7 +41,7 @@ type OIDCAuthorizationConfig struct { // AdditionalScopes are the scopes in addition to "openid" that will be requested as part of the authorization // request flow with an OIDC identity provider. By default only the "openid" scope will be requested. // +optional - AdditionalScopes []string `json:"additionalScopes"` + AdditionalScopes []string `json:"additionalScopes,omitempty"` } // OIDCClaims provides a mapping from upstream claims into identities. @@ -82,7 +82,7 @@ type UpstreamOIDCProviderSpec struct { // AuthorizationConfig holds information about how to form the OAuth2 authorization request // parameters to be used with this OIDC identity provider. // +optional - AuthorizationConfig OIDCAuthorizationConfig `json:"authorizationConfig"` + AuthorizationConfig OIDCAuthorizationConfig `json:"authorizationConfig,omitempty"` // Claims provides the names of token claims that will be used when inspecting an identity from // this OIDC identity provider. diff --git a/generated/1.19/apis/supervisor/idp/v1alpha1/types_upstreamoidcprovider.go b/generated/1.19/apis/supervisor/idp/v1alpha1/types_upstreamoidcprovider.go index ea12b063..9be04701 100644 --- a/generated/1.19/apis/supervisor/idp/v1alpha1/types_upstreamoidcprovider.go +++ b/generated/1.19/apis/supervisor/idp/v1alpha1/types_upstreamoidcprovider.go @@ -41,7 +41,7 @@ type OIDCAuthorizationConfig struct { // AdditionalScopes are the scopes in addition to "openid" that will be requested as part of the authorization // request flow with an OIDC identity provider. By default only the "openid" scope will be requested. // +optional - AdditionalScopes []string `json:"additionalScopes"` + AdditionalScopes []string `json:"additionalScopes,omitempty"` } // OIDCClaims provides a mapping from upstream claims into identities. @@ -82,7 +82,7 @@ type UpstreamOIDCProviderSpec struct { // AuthorizationConfig holds information about how to form the OAuth2 authorization request // parameters to be used with this OIDC identity provider. // +optional - AuthorizationConfig OIDCAuthorizationConfig `json:"authorizationConfig"` + AuthorizationConfig OIDCAuthorizationConfig `json:"authorizationConfig,omitempty"` // Claims provides the names of token claims that will be used when inspecting an identity from // this OIDC identity provider. diff --git a/test/integration/supervisor_login_test.go b/test/integration/supervisor_login_test.go index 3ac2fab8..be403a3e 100644 --- a/test/integration/supervisor_login_test.go +++ b/test/integration/supervisor_login_test.go @@ -75,9 +75,6 @@ func TestSupervisorLogin(t *testing.T) { TLS: &idpv1alpha1.TLSSpec{ CertificateAuthorityData: base64.StdEncoding.EncodeToString([]byte(env.OIDCUpstream.CABundle)), }, - AuthorizationConfig: idpv1alpha1.OIDCAuthorizationConfig{ - AdditionalScopes: []string{}, - }, Client: idpv1alpha1.OIDCClient{ SecretName: makeTestClientCredsSecret(t, testClientID, testClientSecret).Name, }, diff --git a/test/integration/supervisor_upstream_test.go b/test/integration/supervisor_upstream_test.go index c96ae7af..ffda54b8 100644 --- a/test/integration/supervisor_upstream_test.go +++ b/test/integration/supervisor_upstream_test.go @@ -24,9 +24,6 @@ func TestSupervisorUpstreamOIDCDiscovery(t *testing.T) { t.Parallel() spec := v1alpha1.UpstreamOIDCProviderSpec{ Issuer: "https://127.0.0.1:444444/issuer", - AuthorizationConfig: v1alpha1.OIDCAuthorizationConfig{ - AdditionalScopes: []string{"email", "profile"}, - }, Client: v1alpha1.OIDCClient{ SecretName: "does-not-exist", },