Skip to content

Commit 64fafbd

Browse files
committed
Use local object ref for all secrets
1 parent befb2fd commit 64fafbd

5 files changed

+183
-67
lines changed

api/v1/atlasthirdpartyintegration_types.go

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package v1
1919
import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2121

22+
"github.com/mongodb/mongodb-atlas-kubernetes/v2/api"
2223
"github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1/status"
2324
)
2425

@@ -96,9 +97,9 @@ type AtlasThirdPartyIntegrationSpec struct {
9697
}
9798

9899
type DatadogIntegration struct {
99-
// APIKeySecret is the name of a secret containing the datadog api key
100+
// APIKeySecret holds the name of a secret containing the datadog api key
100101
// +kubebuilder:validation:Required
101-
APIKeySecret string `json:"apiKeySecret"`
102+
APIKeySecret api.LocalObjectReference `json:"apiKeySecret"`
102103

103104
// Region is the Datadog region
104105
// +kubebuilder:validation:Required
@@ -119,43 +120,43 @@ type DatadogIntegration struct {
119120
}
120121

121122
type MicrosoftTeamsIntegration struct {
122-
// URLSecret is the name of a secret containing the microsoft teams secret URL
123+
// URLSecret holds the name of a secret containing the microsoft teams secret URL
123124
// +kubebuilder:validation:Required
124-
URLSecret string `json:"urlSecret"`
125+
URLSecret api.LocalObjectReference `json:"urlSecret"`
125126
}
126127

127128
type NewRelicIntegration struct {
128-
// CredentialsSecret is the name of a secret containing new relic's credentials:
129+
// CredentialsSecret holds the name of a secret containing new relic's credentials:
129130
// account id, license key, read and write tokens
130131
// +kubebuilder:validation:Required
131-
CredentialsSecret string `json:"credentialsSecret"`
132+
CredentialsSecret api.LocalObjectReference `json:"credentialsSecret"`
132133
}
133134

134135
type OpsGenieIntegration struct {
135-
// APIKeySecret is the name of a secret containing Ops Genie's API key
136+
// APIKeySecret holds the name of a secret containing Ops Genie's API key
136137
// +kubebuilder:validation:Required
137-
APIKeySecret string `json:"apiKeySecret"`
138+
APIKeySecret api.LocalObjectReference `json:"apiKeySecret"`
138139

139140
// Region is the Ops Genie region
140141
// +kubebuilder:validation:Required
141142
Region string `json:"region"`
142143
}
143144

144145
type PagerDutyIntegration struct {
145-
// ServiceKeySecret is the name of a secret containing Pager Duty service key
146+
// ServiceKeySecret holds the name of a secret containing Pager Duty service key
146147
// +kubebuilder:validation:Required
147-
ServiceKeySecret string `json:"serviceKeySecret"`
148+
ServiceKeySecret api.LocalObjectReference `json:"serviceKeySecret"`
148149

149150
// Region is the Pager Duty region
150151
// +kubebuilder:validation:Required
151152
Region string `json:"region"`
152153
}
153154

154155
type PrometheusIntegration struct {
155-
// PrometheusCredentials is the name of a secret containing the Prometheus
156+
// PrometheusCredentials holds the name of a secret containing the Prometheus
156157
// username & password
157158
// +kubebuilder:validation:Required
158-
PrometheusCredentials string `json:"prometheusCredentials"`
159+
PrometheusCredentials api.LocalObjectReference `json:"prometheusCredentials"`
159160

160161
// ServiceDiscovery to be used by Prometheus
161162
// +kubebuilder:validation:Enum:=file;http
@@ -164,9 +165,9 @@ type PrometheusIntegration struct {
164165
}
165166

166167
type SlackIntegration struct {
167-
// APITokenSecret is the name of a secret containing the Slack API token
168+
// APITokenSecret holds the name of a secret containing the Slack API token
168169
// +kubebuilder:validation:Required
169-
APITokenSecret string `json:"apiTokenSecret"`
170+
APITokenSecret api.LocalObjectReference `json:"apiTokenSecret"`
170171

171172
// ChannelName to be used by Prometheus
172173
// +kubebuilder:validation:Required
@@ -178,19 +179,19 @@ type SlackIntegration struct {
178179
}
179180

180181
type VictorOpsIntegration struct {
181-
// RoutingKey is VictorOps routing key
182+
// RoutingKey holds VictorOps routing key
182183
// +kubebuilder:validation:Required
183-
RoutingKey string `json:"routingKey"`
184+
RoutingKey api.LocalObjectReference `json:"routingKey"`
184185

185186
// APIKeySecret is the name of a secret containing Victor Ops API key
186187
// +kubebuilder:validation:Required
187188
APIKeySecret string `json:"apiKeySecret"`
188189
}
189190

190191
type WebhookIntegration struct {
191-
// URLSecret is the name of a secret containing Webhook URL and secret
192+
// URLSecret holds the name of a secret containing Webhook URL and secret
192193
// +kubebuilder:validation:Required
193-
URLSecret string `json:"urlSecret"`
194+
URLSecret api.LocalObjectReference `json:"urlSecret"`
194195
}
195196

196197
// +kubebuilder:object:root=true

api/v1/atlasthirdpartyintegration_types_test.go

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/stretchr/testify/require"
88
"k8s.io/apimachinery/pkg/runtime"
99

10+
"github.com/mongodb/mongodb-atlas-kubernetes/v2/api"
1011
"github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1/common"
1112
"github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper/cel"
1213
)
@@ -28,8 +29,10 @@ func TestIntegrationCELChecks(t *testing.T) {
2829
Spec: AtlasThirdPartyIntegrationSpec{
2930
Type: "DATADOG",
3031
Datadog: &DatadogIntegration{
31-
APIKeySecret: "api-key-secretname",
32-
Region: "US",
32+
APIKeySecret: api.LocalObjectReference{
33+
Name: "api-key-secretname",
34+
},
35+
Region: "US",
3336
},
3437
},
3538
},
@@ -40,7 +43,9 @@ func TestIntegrationCELChecks(t *testing.T) {
4043
Spec: AtlasThirdPartyIntegrationSpec{
4144
Type: "MICROSOFT_TEAMS",
4245
MicrosoftTeams: &MicrosoftTeamsIntegration{
43-
URLSecret: "url-secretname",
46+
URLSecret: api.LocalObjectReference{
47+
Name: "url-secretname",
48+
},
4449
},
4550
},
4651
},
@@ -51,7 +56,9 @@ func TestIntegrationCELChecks(t *testing.T) {
5156
Spec: AtlasThirdPartyIntegrationSpec{
5257
Type: "NEW_RELIC",
5358
NewRelic: &NewRelicIntegration{
54-
CredentialsSecret: "credentials-secretname",
59+
CredentialsSecret: api.LocalObjectReference{
60+
Name: "credentials-secretname",
61+
},
5562
},
5663
},
5764
},
@@ -62,8 +69,10 @@ func TestIntegrationCELChecks(t *testing.T) {
6269
Spec: AtlasThirdPartyIntegrationSpec{
6370
Type: "OPS_GENIE",
6471
OpsGenie: &OpsGenieIntegration{
65-
APIKeySecret: "api-key-secretname",
66-
Region: "US",
72+
APIKeySecret: api.LocalObjectReference{
73+
Name: "api-key-secretname",
74+
},
75+
Region: "US",
6776
},
6877
},
6978
},
@@ -74,8 +83,10 @@ func TestIntegrationCELChecks(t *testing.T) {
7483
Spec: AtlasThirdPartyIntegrationSpec{
7584
Type: "PAGER_DUTY",
7685
PagerDuty: &PagerDutyIntegration{
77-
ServiceKeySecret: "service-key-secretname",
78-
Region: "US",
86+
ServiceKeySecret: api.LocalObjectReference{
87+
Name: "service-key-secretname",
88+
},
89+
Region: "US",
7990
},
8091
},
8192
},
@@ -86,8 +97,10 @@ func TestIntegrationCELChecks(t *testing.T) {
8697
Spec: AtlasThirdPartyIntegrationSpec{
8798
Type: "PROMETHEUS",
8899
Prometheus: &PrometheusIntegration{
89-
PrometheusCredentials: "prometheus-credentials",
90-
ServiceDiscovery: "http",
100+
PrometheusCredentials: api.LocalObjectReference{
101+
Name: "prometheus-credentials",
102+
},
103+
ServiceDiscovery: "http",
91104
},
92105
},
93106
},
@@ -98,9 +111,11 @@ func TestIntegrationCELChecks(t *testing.T) {
98111
Spec: AtlasThirdPartyIntegrationSpec{
99112
Type: "SLACK",
100113
Slack: &SlackIntegration{
101-
APITokenSecret: "api-tooken-secretname",
102-
ChannelName: "channel",
103-
TeamName: "team",
114+
APITokenSecret: api.LocalObjectReference{
115+
Name: "api-tooken-secretname",
116+
},
117+
ChannelName: "channel",
118+
TeamName: "team",
104119
},
105120
},
106121
},
@@ -111,7 +126,9 @@ func TestIntegrationCELChecks(t *testing.T) {
111126
Spec: AtlasThirdPartyIntegrationSpec{
112127
Type: "VICTOR_OPS",
113128
VictorOps: &VictorOpsIntegration{
114-
RoutingKey: "routing-key",
129+
RoutingKey: api.LocalObjectReference{
130+
Name: "routing-key",
131+
},
115132
APIKeySecret: "keys-secetname",
116133
},
117134
},
@@ -123,7 +140,9 @@ func TestIntegrationCELChecks(t *testing.T) {
123140
Spec: AtlasThirdPartyIntegrationSpec{
124141
Type: "WEBHOOK",
125142
Webhook: &WebhookIntegration{
126-
URLSecret: "url-secretname",
143+
URLSecret: api.LocalObjectReference{
144+
Name: "url-secretname",
145+
},
127146
},
128147
},
129148
},
@@ -135,8 +154,10 @@ func TestIntegrationCELChecks(t *testing.T) {
135154
Type: "PAGER_DUTY",
136155
PagerDuty: &PagerDutyIntegration{},
137156
Prometheus: &PrometheusIntegration{
138-
PrometheusCredentials: "prometheus-credentials",
139-
ServiceDiscovery: "http",
157+
PrometheusCredentials: api.LocalObjectReference{
158+
Name: "prometheus-credentials",
159+
},
160+
ServiceDiscovery: "http",
140161
},
141162
},
142163
},
@@ -148,11 +169,15 @@ func TestIntegrationCELChecks(t *testing.T) {
148169
Spec: AtlasThirdPartyIntegrationSpec{
149170
Type: "WEBHOOK",
150171
Datadog: &DatadogIntegration{
151-
APIKeySecret: "api-key-secretname",
152-
Region: "US",
172+
APIKeySecret: api.LocalObjectReference{
173+
Name: "api-key-secretname",
174+
},
175+
Region: "US",
153176
},
154177
Webhook: &WebhookIntegration{
155-
URLSecret: "url-secretname",
178+
URLSecret: api.LocalObjectReference{
179+
Name: "url-secretname",
180+
},
156181
},
157182
},
158183
},

api/v1/zz_generated.deepcopy.go

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)