Skip to content

Commit

Permalink
extracting some of the common functions of the parser
Browse files Browse the repository at this point in the history
Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>
  • Loading branch information
Skarlso committed Dec 13, 2023
1 parent de6a2b9 commit 1275775
Show file tree
Hide file tree
Showing 11 changed files with 305 additions and 327 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ func newExternalSecretV1Alpha1() *ExternalSecret {
Name: "test-target",
CreationPolicy: Owner,
Immutable: false,
Template: &SecretTemplate{
Template: &ExternalSecretTemplate{
Type: corev1.SecretTypeOpaque,
Metadata: TemplateMetadata{
Metadata: ExternalSecretTemplateMetadata{
Annotations: map[string]string{
"foo": "bar",
},
Expand Down
12 changes: 6 additions & 6 deletions apis/externalsecrets/v1alpha1/externalsecret_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ const (
None ExternalSecretCreationPolicy = "None"
)

// TemplateMetadata defines metadata fields for the Secret blueprint.
type TemplateMetadata struct {
// ExternalSecretTemplateMetadata defines metadata fields for the Secret blueprint.
type ExternalSecretTemplateMetadata struct {
// +optional
Annotations map[string]string `json:"annotations,omitempty"`

// +optional
Labels map[string]string `json:"labels,omitempty"`
}

// SecretTemplate defines a blueprint for the created Secret resource.
// ExternalSecretTemplate defines a blueprint for the created Secret resource.
// we can not use native corev1.Secret, it will have empty ObjectMeta values: https://github.com/kubernetes-sigs/controller-tools/issues/448
type SecretTemplate struct {
type ExternalSecretTemplate struct {
// +optional
Type corev1.SecretType `json:"type,omitempty"`

Expand All @@ -67,7 +67,7 @@ type SecretTemplate struct {
EngineVersion TemplateEngineVersion `json:"engineVersion,omitempty"`

// +optional
Metadata TemplateMetadata `json:"metadata,omitempty"`
Metadata ExternalSecretTemplateMetadata `json:"metadata,omitempty"`

// +optional
Data map[string]string `json:"data,omitempty"`
Expand Down Expand Up @@ -117,7 +117,7 @@ type ExternalSecretTarget struct {

// Template defines a blueprint for the created Secret resource.
// +optional
Template *SecretTemplate `json:"template,omitempty"`
Template *ExternalSecretTemplate `json:"template,omitempty"`

// Immutable defines if the final secret will be immutable
// +optional
Expand Down
6 changes: 4 additions & 2 deletions apis/externalsecrets/v1alpha1/pushsecret_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
corev1 "k8s.io/api/core/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

esv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1"
)

const (
Expand Down Expand Up @@ -60,9 +62,9 @@ type PushSecretSpec struct {
Selector PushSecretSelector `json:"selector"`
// Secret Data that should be pushed to providers
Data []PushSecretData `json:"data,omitempty"`
// Template defines a blueprint for the pushed secret.
// Template defines a blueprint for the created Secret resource.
// +optional
Template *SecretTemplate `json:"template,omitempty"`
Template *esv1beta1.ExternalSecretTemplate `json:"template,omitempty"`
}

type PushSecretSecret struct {
Expand Down
123 changes: 62 additions & 61 deletions apis/externalsecrets/v1alpha1/zz_generated.deepcopy.go

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

4 changes: 2 additions & 2 deletions config/crds/bases/external-secrets.io_externalsecrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ spec:
- v2
type: string
metadata:
description: TemplateMetadata defines metadata fields for
the Secret blueprint.
description: ExternalSecretTemplateMetadata defines metadata
fields for the Secret blueprint.
properties:
annotations:
additionalProperties:
Expand Down
37 changes: 31 additions & 6 deletions config/crds/bases/external-secrets.io_pushsecrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,24 +163,30 @@ spec:
- secret
type: object
template:
description: Template defines a blueprint for the pushed secret.
description: Template defines a blueprint for the created Secret resource.
properties:
data:
additionalProperties:
type: string
type: object
engineVersion:
default: v1
default: v2
description: EngineVersion specifies the template engine version
that should be used to compile/execute the template specified
in .data and .templateFrom[].
enum:
- v1
- v2
type: string
mergePolicy:
default: Replace
enum:
- Replace
- Merge
type: string
metadata:
description: TemplateMetadata defines metadata fields for the
Secret blueprint.
description: ExternalSecretTemplateMetadata defines metadata fields
for the Secret blueprint.
properties:
annotations:
additionalProperties:
Expand All @@ -193,8 +199,6 @@ spec:
type: object
templateFrom:
items:
maxProperties: 1
minProperties: 1
properties:
configMap:
properties:
Expand All @@ -203,6 +207,12 @@ spec:
properties:
key:
type: string
templateAs:
default: Values
enum:
- Values
- KeysAndValues
type: string
required:
- key
type: object
Expand All @@ -213,13 +223,21 @@ spec:
- items
- name
type: object
literal:
type: string
secret:
properties:
items:
items:
properties:
key:
type: string
templateAs:
default: Values
enum:
- Values
- KeysAndValues
type: string
required:
- key
type: object
Expand All @@ -230,6 +248,13 @@ spec:
- items
- name
type: object
target:
default: Data
enum:
- Data
- Annotations
- Labels
type: string
type: object
type: array
type:
Expand Down

0 comments on commit 1275775

Please sign in to comment.