Skip to content

Commit

Permalink
feat(dex): add optional env field (#1005)
Browse files Browse the repository at this point in the history
* feat(dex): add optional env field

Signed-off-by: Robert Deusser <[email protected]>

* fix: remove non-default configuration

Signed-off-by: Robert Deusser <[email protected]>

* fix: v1alpha1 is deprecated

Signed-off-by: Robert Deusser <[email protected]>

* fix: convert dex spec between api versions

Signed-off-by: Robert Deusser <[email protected]>

* fix: ensure there is no diff in the bundle

Signed-off-by: Robert Deusser <[email protected]>

---------

Signed-off-by: Robert Deusser <[email protected]>
  • Loading branch information
rdeusser authored Oct 30, 2023
1 parent 962f30f commit 000c4a7
Show file tree
Hide file tree
Showing 12 changed files with 719 additions and 118 deletions.
37 changes: 34 additions & 3 deletions api/v1alpha1/argocd_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (src *ArgoCD) ConvertTo(dstRaw conversion.Hub) error {
sso = &v1beta1.ArgoCDSSOSpec{}
}
sso.Provider = v1beta1.SSOProviderTypeDex
sso.Dex = (*v1beta1.ArgoCDDexSpec)(src.Spec.Dex)
sso.Dex = ConvertAlphaToBetaDex(src.Spec.Dex)
}

dst.Spec.SSO = sso
Expand Down Expand Up @@ -244,13 +244,29 @@ func ConvertAlphaToBetaSSO(src *ArgoCDSSOSpec) *v1beta1.ArgoCDSSOSpec {
if src != nil {
dst = &v1beta1.ArgoCDSSOSpec{
Provider: v1beta1.SSOProviderType(src.Provider),
Dex: (*v1beta1.ArgoCDDexSpec)(src.Dex),
Dex: ConvertAlphaToBetaDex(src.Dex),
Keycloak: (*v1beta1.ArgoCDKeycloakSpec)(src.Keycloak),
}
}
return dst
}

func ConvertAlphaToBetaDex(src *ArgoCDDexSpec) *v1beta1.ArgoCDDexSpec {
var dst *v1beta1.ArgoCDDexSpec
if src != nil {
dst = &v1beta1.ArgoCDDexSpec{
Config: src.Config,
Groups: src.Groups,
Image: src.Image,
OpenShiftOAuth: src.OpenShiftOAuth,
Resources: src.Resources,
Version: src.Version,
Env: nil,
}
}
return dst
}

func ConvertAlphaToBetaHA(src *ArgoCDHASpec) *v1beta1.ArgoCDHASpec {
var dst *v1beta1.ArgoCDHASpec
if src != nil {
Expand Down Expand Up @@ -448,13 +464,28 @@ func ConvertBetaToAlphaSSO(src *v1beta1.ArgoCDSSOSpec) *ArgoCDSSOSpec {
if src != nil {
dst = &ArgoCDSSOSpec{
Provider: SSOProviderType(src.Provider),
Dex: (*ArgoCDDexSpec)(src.Dex),
Dex: ConvertBetaToAlphaDex(src.Dex),
Keycloak: (*ArgoCDKeycloakSpec)(src.Keycloak),
}
}
return dst
}

func ConvertBetaToAlphaDex(src *v1beta1.ArgoCDDexSpec) *ArgoCDDexSpec {
var dst *ArgoCDDexSpec
if src != nil {
dst = &ArgoCDDexSpec{
Config: src.Config,
Groups: src.Groups,
Image: src.Image,
OpenShiftOAuth: src.OpenShiftOAuth,
Resources: src.Resources,
Version: src.Version,
}
}
return dst
}

func ConvertBetaToAlphaHA(src *v1beta1.ArgoCDHASpec) *ArgoCDHASpec {
var dst *ArgoCDHASpec
if src != nil {
Expand Down
3 changes: 3 additions & 0 deletions api/v1beta1/argocd_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ type ArgoCDDexSpec struct {
// Version is the Dex container image tag.
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Version",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:fieldGroup:Dex","urn:alm:descriptor:com.tectonic.ui:text"}
Version string `json:"version,omitempty"`

// Env lets you specify environment variables for Dex.
Env []corev1.EnvVar `json:"env,omitempty"`
}

// ArgoCDGrafanaSpec defines the desired state for the Grafana component.
Expand Down
7 changes: 7 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

115 changes: 115 additions & 0 deletions bundle/manifests/argoproj.io_argocds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13474,6 +13474,121 @@ spec:
config:
description: Config is the dex connector configuration.
type: string
env:
description: Env lets you specify environment variables for
Dex.
items:
description: EnvVar represents an environment variable present
in a Container.
properties:
name:
description: Name of the environment variable. Must
be a C_IDENTIFIER.
type: string
value:
description: 'Variable references $(VAR_NAME) are expanded
using the previously defined environment variables
in the container and any service environment variables.
If a variable cannot be resolved, the reference in
the input string will be unchanged. Double $$ are
reduced to a single $, which allows for escaping the
$(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce
the string literal "$(VAR_NAME)". Escaped references
will never be expanded, regardless of whether the
variable exists or not. Defaults to "".'
type: string
valueFrom:
description: Source for the environment variable's value.
Cannot be used if value is not empty.
properties:
configMapKeyRef:
description: Selects a key of a ConfigMap.
properties:
key:
description: The key to select.
type: string
name:
description: 'Name of the referent. More info:
https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion,
kind, uid?'
type: string
optional:
description: Specify whether the ConfigMap or
its key must be defined
type: boolean
required:
- key
type: object
fieldRef:
description: 'Selects a field of the pod: supports
metadata.name, metadata.namespace, `metadata.labels[''<KEY>'']`,
`metadata.annotations[''<KEY>'']`, spec.nodeName,
spec.serviceAccountName, status.hostIP, status.podIP,
status.podIPs.'
properties:
apiVersion:
description: Version of the schema the FieldPath
is written in terms of, defaults to "v1".
type: string
fieldPath:
description: Path of the field to select in
the specified API version.
type: string
required:
- fieldPath
type: object
resourceFieldRef:
description: 'Selects a resource of the container:
only resources limits and requests (limits.cpu,
limits.memory, limits.ephemeral-storage, requests.cpu,
requests.memory and requests.ephemeral-storage)
are currently supported.'
properties:
containerName:
description: 'Container name: required for volumes,
optional for env vars'
type: string
divisor:
anyOf:
- type: integer
- type: string
description: Specifies the output format of
the exposed resources, defaults to "1"
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
resource:
description: 'Required: resource to select'
type: string
required:
- resource
type: object
secretKeyRef:
description: Selects a key of a secret in the pod's
namespace
properties:
key:
description: The key of the secret to select
from. Must be a valid secret key.
type: string
name:
description: 'Name of the referent. More info:
https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion,
kind, uid?'
type: string
optional:
description: Specify whether the Secret or its
key must be defined
type: boolean
required:
- key
type: object
type: object
required:
- name
type: object
type: array
groups:
description: Optional list of required groups a user must
be a member of
Expand Down
115 changes: 115 additions & 0 deletions config/crd/bases/argoproj.io_argocds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13465,6 +13465,121 @@ spec:
config:
description: Config is the dex connector configuration.
type: string
env:
description: Env lets you specify environment variables for
Dex.
items:
description: EnvVar represents an environment variable present
in a Container.
properties:
name:
description: Name of the environment variable. Must
be a C_IDENTIFIER.
type: string
value:
description: 'Variable references $(VAR_NAME) are expanded
using the previously defined environment variables
in the container and any service environment variables.
If a variable cannot be resolved, the reference in
the input string will be unchanged. Double $$ are
reduced to a single $, which allows for escaping the
$(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce
the string literal "$(VAR_NAME)". Escaped references
will never be expanded, regardless of whether the
variable exists or not. Defaults to "".'
type: string
valueFrom:
description: Source for the environment variable's value.
Cannot be used if value is not empty.
properties:
configMapKeyRef:
description: Selects a key of a ConfigMap.
properties:
key:
description: The key to select.
type: string
name:
description: 'Name of the referent. More info:
https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion,
kind, uid?'
type: string
optional:
description: Specify whether the ConfigMap or
its key must be defined
type: boolean
required:
- key
type: object
fieldRef:
description: 'Selects a field of the pod: supports
metadata.name, metadata.namespace, `metadata.labels[''<KEY>'']`,
`metadata.annotations[''<KEY>'']`, spec.nodeName,
spec.serviceAccountName, status.hostIP, status.podIP,
status.podIPs.'
properties:
apiVersion:
description: Version of the schema the FieldPath
is written in terms of, defaults to "v1".
type: string
fieldPath:
description: Path of the field to select in
the specified API version.
type: string
required:
- fieldPath
type: object
resourceFieldRef:
description: 'Selects a resource of the container:
only resources limits and requests (limits.cpu,
limits.memory, limits.ephemeral-storage, requests.cpu,
requests.memory and requests.ephemeral-storage)
are currently supported.'
properties:
containerName:
description: 'Container name: required for volumes,
optional for env vars'
type: string
divisor:
anyOf:
- type: integer
- type: string
description: Specifies the output format of
the exposed resources, defaults to "1"
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
resource:
description: 'Required: resource to select'
type: string
required:
- resource
type: object
secretKeyRef:
description: Selects a key of a secret in the pod's
namespace
properties:
key:
description: The key of the secret to select
from. Must be a valid secret key.
type: string
name:
description: 'Name of the referent. More info:
https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion,
kind, uid?'
type: string
optional:
description: Specify whether the Secret or its
key must be defined
type: boolean
required:
- key
type: object
type: object
required:
- name
type: object
type: array
groups:
description: Optional list of required groups a user must
be a member of
Expand Down
Loading

0 comments on commit 000c4a7

Please sign in to comment.