Skip to content
This repository was archived by the owner on Oct 12, 2021. It is now read-only.

Commit d24ebd1

Browse files
committed
Implement all secret fields as ValueFromField type
1 parent a968f6d commit d24ebd1

File tree

19 files changed

+153
-171
lines changed

19 files changed

+153
-171
lines changed

config/300-httpsource.yaml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020 TriggerMesh Inc.
1+
# Copyright (c) 2020-2021 TriggerMesh Inc.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -53,25 +53,28 @@ spec:
5353
description: EventSource is an optional but recommended field for identifying the instance producing the events
5454
type: string
5555
basicAuthUsername:
56-
description: When informed will be used to configure Basic Authentication at the exposed endpoint
56+
description: When supplied will be used to configure Basic Authentication at the exposed endpoint
5757
type: string
5858
basicAuthPassword:
59-
description: When informed will be used to configure Basic Authentication at the exposed endpoint
59+
description: When supplied will be used to configure Basic Authentication at the exposed endpoint
60+
type: object
6061
properties:
61-
secretKeyRef:
62-
description: A reference to a Secret key containing the value.
62+
value:
63+
description: Password in plain text.
64+
type: string
65+
valueFromSecret:
66+
description: A reference to a Secret containing the password.
67+
type: object
6368
properties:
64-
key:
65-
description: Key from the Secret object.
66-
type: string
6769
name:
6870
description: Name of the Secret object.
6971
type: string
70-
required:
71-
- name
72-
- key
73-
type: object
74-
type: object
72+
key:
73+
description: Key from the Secret object.
74+
type: string
75+
oneOf:
76+
- required: ['value']
77+
- required: ['valueFromSecret']
7578
sink:
7679
description: Reference to an event sink.
7780
type: object

config/300-slacksource.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020 TriggerMesh Inc.
1+
# Copyright (c) 2020-2021 TriggerMesh Inc.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -54,8 +54,11 @@ spec:
5454
description: Signing secret to authenticate Slack callbacks.
5555
type: object
5656
properties:
57-
secretKeyRef:
58-
description: A reference to a Secret key containing the value.
57+
value:
58+
description: Signing secret in plain text.
59+
type: string
60+
valueFromSecret:
61+
description: A reference to a Secret containing the signing secret.
5962
type: object
6063
properties:
6164
name:
@@ -64,9 +67,9 @@ spec:
6467
key:
6568
description: Key from the Secret object.
6669
type: string
67-
required:
68-
- name
69-
- key
70+
oneOf:
71+
- required: ['value']
72+
- required: ['valueFromSecret']
7073
appID:
7174
description: ID which identifies the Slack application generating this
7275
event. It helps identifying the App that sources events when multiple

config/300-zendesksource.yaml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020 TriggerMesh Inc.
1+
# Copyright (c) 2020-2021 TriggerMesh Inc.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -61,8 +61,11 @@ spec:
6161
description: Zendesk API token.
6262
type: object
6363
properties:
64-
secretKeyRef:
65-
description: A reference to a Secret key containing the value.
64+
value:
65+
description: API token in plain text.
66+
type: string
67+
valueFromSecret:
68+
description: A reference to a Secret containing the API token.
6669
type: object
6770
properties:
6871
name:
@@ -71,18 +74,21 @@ spec:
7174
key:
7275
description: Key from the Secret object.
7376
type: string
74-
required:
75-
- name
76-
- key
77+
oneOf:
78+
- required: ['value']
79+
- required: ['valueFromSecret']
7780
webhookUsername:
7881
description: User name for the webhook's Basic Authentication.
7982
type: string
8083
webhookPassword:
8184
description: Password for the webhook's Basic Authentication.
8285
type: object
8386
properties:
84-
secretKeyRef:
85-
description: A reference to a Secret key containing the value.
87+
value:
88+
description: Webhook password in plain text.
89+
type: string
90+
valueFromSecret:
91+
description: A reference to a Secret containing the webhook password.
8692
type: object
8793
properties:
8894
name:
@@ -91,9 +97,9 @@ spec:
9197
key:
9298
description: Key from the Secret object.
9399
type: string
94-
required:
95-
- name
96-
- key
100+
oneOf:
101+
- required: ['value']
102+
- required: ['valueFromSecret']
97103
sink:
98104
description: Reference to an event sink.
99105
type: object

config/samples/httpsource.yaml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020 TriggerMesh Inc.
1+
# Copyright (c) 2020-2021 TriggerMesh Inc.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# Sample HTTPSource object.
16+
1517
apiVersion: sources.triggermesh.io/v1alpha1
1618
kind: HTTPSource
1719
metadata:
@@ -21,9 +23,7 @@ spec:
2123
eventSource: instance-abc123
2224
basicAuthUsername: customuser
2325
basicAuthPassword:
24-
secretKeyRef:
25-
name: httpsource
26-
key: password
26+
value: abc123secret
2727
sink:
2828
ref:
2929
apiVersion: serving.knative.dev/v1
@@ -32,16 +32,6 @@ spec:
3232

3333
---
3434

35-
apiVersion: v1
36-
kind: Secret
37-
metadata:
38-
name: httpsource
39-
type: Opaque
40-
stringData:
41-
password: abc123secret
42-
43-
---
44-
4535
apiVersion: serving.knative.dev/v1
4636
kind: Service
4737
metadata:
@@ -50,5 +40,4 @@ spec:
5040
template:
5141
spec:
5242
containers:
53-
- image: gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display
54-
43+
- image: gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display

config/samples/slacksource.yaml

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020 TriggerMesh Inc.
1+
# Copyright (c) 2020-2021 TriggerMesh Inc.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -21,9 +21,7 @@ metadata:
2121
spec:
2222
# optional, making sure we are receiving events on behalf of Slack
2323
signingSecret:
24-
secretKeyRef:
25-
name: slack
26-
key: signingSecret
24+
value: XXXXXXXXXXXXXXXXXX
2725
# optional, making sure the events are being sent for this integration
2826
appID: AXXXXXXXXX
2927
sink:
@@ -34,16 +32,6 @@ spec:
3432

3533
---
3634

37-
apiVersion: v1
38-
kind: Secret
39-
metadata:
40-
name: slack
41-
type: Opaque
42-
stringData:
43-
signingSecret: XXXXXXXXXXXXXXXXXX
44-
45-
---
46-
4735
apiVersion: serving.knative.dev/v1
4836
kind: Service
4937
metadata:
@@ -52,4 +40,4 @@ spec:
5240
template:
5341
spec:
5442
containers:
55-
- image: gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display
43+
- image: gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display

config/samples/zendesksource.yaml

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020 TriggerMesh Inc.
1+
# Copyright (c) 2020-2021 TriggerMesh Inc.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -22,14 +22,10 @@ spec:
2222
email: '<ZENDESK ACCOUNT USER EMAIL>'
2323
subdomain: '<ZENDESK TENANT SUBDOMAIN>'
2424
token:
25-
secretKeyRef:
26-
name: zendesksource
27-
key: token
25+
value: : '<API TOKEN FROM ZENDESK'
2826
webhookUsername: '<SOME ARBITRARY USERNAME>'
2927
webhookPassword:
30-
secretKeyRef:
31-
name: zendesksource
32-
key: webhookPassword
28+
value: '<ARBITRARY PASSWORD FOR WEBHOOK>'
3329
sink:
3430
ref:
3531
apiVersion: serving.knative.dev/v1
@@ -38,26 +34,12 @@ spec:
3834

3935
---
4036

41-
apiVersion: v1
42-
kind: Secret
43-
metadata:
44-
name: zendesksource
45-
type: Opaque
46-
stringData:
47-
token: '<API TOKEN FROM ZENDESK>'
48-
webhookPassword: '<ARBITRARY PASSWORD FOR WEBHOOK>'
49-
50-
---
51-
5237
apiVersion: serving.knative.dev/v1
5338
kind: Service
5439
metadata:
5540
name: event-display
5641
spec:
5742
template:
58-
metadata:
59-
annotations:
60-
autoscaling.knative.dev/minScale: "1"
6143
spec:
6244
containers:
63-
- image: gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display
45+
- image: gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display

go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,7 @@ k8s.io/apiserver v0.18.12/go.mod h1:uFOeW4LlxS6KDgLWy3n3gh0DhC6m41QIFgL33ouk+4w=
12221222
k8s.io/client-go v0.18.12 h1:MDGRE2tGidz29g45dI4kfelJo+aRmDqWx0Way8mD88A=
12231223
k8s.io/client-go v0.18.12/go.mod h1:0aC8XkA09dX/goYqHQJ/kVv0zL1t+weOZt3pmz9LpxA=
12241224
k8s.io/cloud-provider v0.18.8/go.mod h1:cn9AlzMPVIXA4HHLVbgGUigaQlZyHSZ7WAwDEFNrQSs=
1225+
k8s.io/code-generator v0.18.12 h1:/cSUfqlYZ90y0WDxxWfwfTXUGkJer2Gt1L3AIaVvviQ=
12251226
k8s.io/code-generator v0.18.12/go.mod h1:TgNEVx9hCyPGpdtCWA34olQYLkh3ok9ar7XfSsr8b6c=
12261227
k8s.io/component-base v0.18.8/go.mod h1:00frPRDas29rx58pPCxNkhUfPbwajlyyvu8ruNgSErU=
12271228
k8s.io/component-base v0.18.12/go.mod h1:pRGKXsx2KWfsJqlDi4sbCc1jpaB87rXIIqupjhr5wj0=

pkg/apis/sources/v1alpha1/common_types.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2020 TriggerMesh Inc.
2+
Copyright (c) 2020-2021 TriggerMesh Inc.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -39,9 +39,3 @@ type ValueFromField struct {
3939
// +optional
4040
ValueFromSecret *corev1.SecretKeySelector `json:"valueFromSecret,omitempty"`
4141
}
42-
43-
// SecretValueFromSource represents the source of a secret value
44-
type SecretValueFromSource struct {
45-
// The Secret key to select from.
46-
SecretKeyRef *corev1.SecretKeySelector `json:"secretKeyRef,omitempty"`
47-
}

pkg/apis/sources/v1alpha1/deepcopy_generated.go

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

pkg/apis/sources/v1alpha1/httpsource_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
Copyright (c) 2020 TriggerMesh Inc.
2+
Copyright (c) 2020-2021 TriggerMesh Inc.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
1010
Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
@@ -63,7 +63,7 @@ type HTTPSourceSpec struct {
6363

6464
// BasicAuthPassword used for basic authentication.
6565
// +optional
66-
BasicAuthPassword SecretValueFromSource `json:"basicAuthPassword,omitempty"`
66+
BasicAuthPassword *ValueFromField `json:"basicAuthPassword,omitempty"`
6767
}
6868

6969
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

0 commit comments

Comments
 (0)