Skip to content

Commit 94a9593

Browse files
committed
feat: add Annotations to template data
Signed-off-by: Kai Fink <[email protected]>
1 parent 339c3f5 commit 94a9593

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

pkg/argo_connector.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ type TemplateData struct {
214214
KubeConfig restclient.Config
215215
Project KKPProject
216216
Labels map[string]string
217+
Annotations map[string]string
217218
}
218219

219220
/**
@@ -226,6 +227,7 @@ func (contector *ArgoConnector) ParseTemplate(userCluster UserCluster, project K
226227
return nil, err
227228
}
228229
labels := map[string]string{}
230+
annotations := map[string]string{}
229231

230232
if project.RawData["metadata"].(map[string]interface{})["labels"] != nil {
231233
projectLabels, err := FlattenToStringStringMap(project.RawData["metadata"].(map[string]interface{})["labels"])
@@ -249,12 +251,35 @@ func (contector *ArgoConnector) ParseTemplate(userCluster UserCluster, project K
249251
}
250252
}
251253

254+
if project.RawData["metadata"].(map[string]interface{})["annotations"] != nil {
255+
projectLabels, err := FlattenToStringStringMap(project.RawData["metadata"].(map[string]interface{})["annotations"])
256+
if err != nil {
257+
return nil, err
258+
}
259+
260+
for k, v := range projectLabels {
261+
labels[k] = v
262+
}
263+
}
264+
265+
if userCluster.RawData["metadata"].(map[string]interface{})["annotations"] != nil {
266+
clusterLabels, err := FlattenToStringStringMap(userCluster.RawData["metadata"].(map[string]interface{})["annotations"])
267+
if err != nil {
268+
return nil, err
269+
}
270+
271+
for k, v := range clusterLabels {
272+
labels[k] = v
273+
}
274+
}
275+
252276
data := &TemplateData{
253277
UserCluster: userCluster,
254278
BaseLabel: BASE_LABEL,
255279
KubeConfig: *kubeconfig,
256280
Project: project,
257281
Labels: labels,
282+
Annotations: annotations,
258283
}
259284

260285
buf := &bytes.Buffer{}

0 commit comments

Comments
 (0)