Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit 5e263dc

Browse files
committed
Adding support for output annotations
1 parent 0d17251 commit 5e263dc

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

api/v1alpha1/workspace_types.go

+3
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ type WorkspaceSpec struct {
144144
// Specifies the agent pool name we wish to use.
145145
// +optional
146146
AgentPoolName string `json:"agentPoolName,omitempty"`
147+
// Annotations for the output secret.
148+
// +optional
149+
OutputAnnotations map[string]string `json:"outputAnnotations,omitempty"`
147150
}
148151

149152
// WorkspaceStatus defines the observed state of Workspace

config/crd/bases/app.terraform.io_workspaces.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ spec:
114114
organization:
115115
description: Terraform Cloud organization
116116
type: string
117+
outputAnnotations:
118+
additionalProperties:
119+
type: string
120+
description: Annotations for the output secret.
121+
type: object
117122
outputs:
118123
description: Outputs denote outputs wanted
119124
items:

workspacehelper/k8s_configmap.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ func configMapForTerraform(name string, namespace string, template []byte) *core
2626
}
2727
}
2828

29-
func secretForOutputs(name string, namespace string, outputs []*v1alpha1.OutputStatus) *corev1.Secret {
29+
func secretForOutputs(name string, namespace string, outputs []*v1alpha1.OutputStatus, annotations map[string]string) *corev1.Secret {
3030
data := outputsToMap(outputs)
3131
return &corev1.Secret{
3232
ObjectMeta: metav1.ObjectMeta{
33-
Name: name,
34-
Namespace: namespace,
33+
Name: name,
34+
Namespace: namespace,
35+
Annotations: annotations,
3536
},
3637
Data: data,
3738
}
@@ -122,7 +123,7 @@ func (r *WorkspaceHelper) UpsertSecretOutputs(w *v1alpha1.Workspace, outputs []*
122123
outputName := fmt.Sprintf("%s-outputs", w.Name)
123124
err := r.client.Get(context.TODO(), types.NamespacedName{Name: outputName, Namespace: w.Namespace}, found)
124125
if err != nil && k8serrors.IsNotFound(err) {
125-
secret := secretForOutputs(outputName, w.Namespace, outputs)
126+
secret := secretForOutputs(outputName, w.Namespace, outputs, w.Spec.OutputAnnotations)
126127
err = controllerutil.SetControllerReference(w, secret, r.scheme)
127128
if err != nil {
128129
return err

0 commit comments

Comments
 (0)