Skip to content

Commit 9f28255

Browse files
committed
feat: adding custom label support
1 parent 49f079b commit 9f28255

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

internal/k8s/kubernetes.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func CreateK8sConfigMap(s *secret.Secret, clusterName string) error {
3131
ObjectMeta: metav1.ObjectMeta{
3232
Name: s.Name,
3333
Namespace: s.Namespace,
34+
Labels: s.Labels,
3435
Annotations: map[string]string{
3536
"gitops.mxcd.de/secret-id": s.ID,
3637
},
@@ -57,6 +58,7 @@ func CreateK8sSecret(s *secret.Secret, clusterName string) error {
5758
ObjectMeta: metav1.ObjectMeta{
5859
Name: s.Name,
5960
Namespace: s.Namespace,
61+
Labels: s.Labels,
6062
Annotations: map[string]string{
6163
"gitops.mxcd.de/secret-id": s.ID,
6264
},
@@ -92,6 +94,7 @@ func UpdateK8sSecret(s *secret.Secret, clusterName string) error {
9294
ObjectMeta: metav1.ObjectMeta{
9395
Name: s.Name,
9496
Namespace: s.Namespace,
97+
Labels: s.Labels,
9598
Annotations: map[string]string{
9699
"gitops.mxcd.de/secret-id": s.ID,
97100
},
@@ -119,6 +122,7 @@ func UpdateK8sConfigMap(s *secret.Secret, clusterName string) error {
119122
ObjectMeta: metav1.ObjectMeta{
120123
Name: s.Name,
121124
Namespace: s.Namespace,
125+
Labels: s.Labels,
122126
Annotations: map[string]string{
123127
"gitops.mxcd.de/secret-id": s.ID,
124128
},

internal/secret/secret.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ type Secret struct {
4444

4545
// Data is the decrypted data from the secret file
4646
Data map[string]string
47+
48+
// Labels are custom labels to apply to the k8s resource
49+
Labels map[string]string
4750
}
4851

4952
type SecretTargetType string
@@ -59,6 +62,7 @@ type SecretFile struct {
5962
Type string `yaml:"type" default:"Opaque"`
6063
Data map[string]string `yaml:"data"`
6164
ID string `yaml:"id,omitempty"`
65+
Labels map[string]string `yaml:"labels,omitempty"`
6266
}
6367

6468
type TemplateData struct {
@@ -130,6 +134,7 @@ func (s *Secret) Load() error {
130134
}
131135

132136
s.Data = secretFile.Data
137+
s.Labels = secretFile.Labels
133138

134139
if util.GetCliContext().Bool("print") {
135140
s.PrettyPrint()

0 commit comments

Comments
 (0)