Skip to content
This repository has been archived by the owner on Jun 19, 2022. It is now read-only.

Removing unused pubsubSecret from sources.spec #567

Merged
merged 54 commits into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
8b1fc6b
adding github template for bugs and features
Nov 26, 2019
d0b1721
renaming
Nov 26, 2019
906e185
Merge remote-tracking branch 'upstream/master'
nachocano Nov 27, 2019
671f7d4
Merge remote-tracking branch 'upstream/master'
nachocano Nov 28, 2019
335ff3f
Merge remote-tracking branch 'upstream/master'
Dec 4, 2019
599f281
Merge remote-tracking branch 'upstream/master'
Dec 6, 2019
5b2c1d9
Merge remote-tracking branch 'upstream/master'
Dec 9, 2019
3e60124
Merge remote-tracking branch 'upstream/master'
Dec 9, 2019
e9678ba
adding comment
Dec 14, 2019
943916d
Merge remote-tracking branch 'upstream/master'
Dec 16, 2019
06194cc
Merge remote-tracking branch 'upstream/master'
Dec 18, 2019
3b95c4c
Merge remote-tracking branch 'upstream/master'
Dec 20, 2019
e7d1793
Merge remote-tracking branch 'upstream/master'
Jan 13, 2020
8b8f3fe
Merge branch 'master' of github.com:nachocano/knative-gcp
nachocano Jan 13, 2020
27b558a
Merge remote-tracking branch 'upstream/master'
Jan 14, 2020
1dcaa69
Merge remote-tracking branch 'upstream/master'
Jan 14, 2020
ed4be63
Merge remote-tracking branch 'upstream/master'
Jan 17, 2020
ed892c4
Merge branch 'master' of github.com:nachocano/knative-gcp
nachocano Jan 17, 2020
b5ee575
nits
nachocano Jan 17, 2020
91e64fe
nits
nachocano Jan 17, 2020
bd3b21e
Merge remote-tracking branch 'upstream/master'
Jan 17, 2020
4312cfd
Merge remote-tracking branch 'upstream/master'
Jan 17, 2020
948f834
Merge remote-tracking branch 'upstream/master'
Jan 21, 2020
20cc453
updating to master
Jan 21, 2020
88cc65f
missing files
Jan 21, 2020
631e269
Merge remote-tracking branch 'upstream/master'
nachocano Jan 22, 2020
f8efe36
Merge remote-tracking branch 'upstream/master'
Jan 22, 2020
e296ee0
Merge remote-tracking branch 'upstream/master'
Jan 23, 2020
07a46b4
Merge remote-tracking branch 'upstream/master'
Jan 23, 2020
d02e685
using revision instead of master
Jan 23, 2020
e124481
Merge remote-tracking branch 'upstream/master'
Jan 24, 2020
a0be819
Merge remote-tracking branch 'upstream/master'
Jan 24, 2020
5bc0eff
Merge remote-tracking branch 'upstream/master'
Jan 27, 2020
e1c8edc
Merge remote-tracking branch 'upstream/master'
nachocano Jan 29, 2020
3524ef4
Merge remote-tracking branch 'upstream/master'
nachocano Jan 31, 2020
34fe0d1
Merge remote-tracking branch 'upstream/master'
Jan 31, 2020
eb2b6e9
Merge branch 'master' of github.com:nachocano/knative-gcp
Jan 31, 2020
e2f9369
Merge remote-tracking branch 'upstream/master'
Feb 3, 2020
678ce7c
Merge remote-tracking branch 'upstream/master'
Feb 3, 2020
2222b40
Merge branch 'master' of github.com:nachocano/knative-gcp
nachocano Feb 4, 2020
ce2f847
Merge remote-tracking branch 'upstream/master'
nachocano Feb 4, 2020
30ba366
Merge remote-tracking branch 'upstream/master'
nachocano Feb 5, 2020
e569136
Merge remote-tracking branch 'upstream/master'
nachocano Feb 6, 2020
7b8676e
Merge remote-tracking branch 'upstream/master'
Feb 6, 2020
9c82620
Merge remote-tracking branch 'upstream/master'
Feb 10, 2020
4a1f584
Merge remote-tracking branch 'upstream/master'
nachocano Feb 11, 2020
463a929
Merge remote-tracking branch 'upstream/master'
Feb 13, 2020
446f718
Merge remote-tracking branch 'upstream/master'
Feb 14, 2020
e6e7820
Merge remote-tracking branch 'upstream/master'
Feb 19, 2020
fef14e6
Merge remote-tracking branch 'upstream/master'
Feb 19, 2020
439a19e
Merge remote-tracking branch 'upstream/master'
Feb 21, 2020
fdeaeba
Merge remote-tracking branch 'upstream/master'
Feb 25, 2020
39ef6c2
Merge remote-tracking branch 'upstream/master'
Feb 26, 2020
a3830db
removing pubsubsecret. Other validation cleanup.
Feb 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions config/300-cloudauditlogssource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ spec:
properties:
secret:
type: object
description: "Credential used to pull Stackdriver audit log pubsub messages. Must be a service account key in JSON format (see https://cloud.google.com/iam/docs/creating-managing-service-account-keys). If omitted, defaults to 'google-cloud-key'"
pubSubSecret:
type: object
description: "Optional credential to use for creating a Topic and subscribing to the Topic. If omitted, uses secret. Must be a service account key in JSON format (see https://cloud.google.com/iam/docs/creating-managing-service-account-keys)."
description: "Credential used to poll the Cloud Pub/Sub Subscription. It is not used to create or delete the Subscription, only to poll it. The value of the secret entry must be a service account key in the JSON format (see https://cloud.google.com/iam/docs/creating-managing-service-account-keys). Defaults to secret.name of 'google-cloud-key' and secret.key of 'key.json'."
serviceAccountName:
type: string
description: "Service Account to run Receive Adapter as. If omitted, uses 'default'."
Expand Down
2 changes: 1 addition & 1 deletion config/300-cloudpubsubsource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ spec:
properties:
secret:
type: object
description: "Credential to use to poll the Cloud Pub/Sub Subscription. It is not used to create or delete the Subscription, only to poll it. The value of the secret entry must be a service account key in the JSON format (see https://cloud.google.com/iam/docs/creating-managing-service-account-keys). Defaults to secret.name of 'google-cloud-key' and secret.key of 'key.json'."
description: "Credential used to poll the Cloud Pub/Sub Subscription. It is not used to create or delete the Subscription, only to poll it. The value of the secret entry must be a service account key in the JSON format (see https://cloud.google.com/iam/docs/creating-managing-service-account-keys). Defaults to secret.name of 'google-cloud-key' and secret.key of 'key.json'."
project:
type: string
description: "ID of the Google Cloud Project that the Pub/Sub Topic exists in. E.g. 'my-project-1234' rather than its display name, 'My Project' or its number '1234567890'. If omitted uses the Project ID from the GKE cluster metadata service."
Expand Down
5 changes: 1 addition & 4 deletions config/300-cloudschedulersource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ spec:
properties:
secret:
type: object
description: "Credential to use for managing Scheduler Jobs. Must be a service account key in JSON format (see https://cloud.google.com/iam/docs/creating-managing-service-account-keys). If omitted, defaults to 'google-cloud-key'."
pubSubSecret:
type: object
description: "Optional credential to use for creating a Topic and subscribing to the Topic. If omitted, uses secret. Must be a service account key in JSON format (see https://cloud.google.com/iam/docs/creating-managing-service-account-keys)."
description: "Credential used to poll the Cloud Pub/Sub Subscription. It is not used to create or delete the Subscription, only to poll it. The value of the secret entry must be a service account key in the JSON format (see https://cloud.google.com/iam/docs/creating-managing-service-account-keys). Defaults to secret.name of 'google-cloud-key' and secret.key of 'key.json'."
project:
type: string
description: "Google Cloud Project ID of the project into which the Scheduler job should be created. If omitted uses the Project ID from the GKE cluster metadata service."
Expand Down
5 changes: 1 addition & 4 deletions config/300-cloudstoragesource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ spec:
properties:
secret:
type: object
description: "Credential to use for managing GCS notifications. Must be a service account key in JSON format (see https://cloud.google.com/iam/docs/creating-managing-service-account-keys). If omitted, defaults to 'google-cloud-key'."
pubSubSecret:
type: object
description: "Optional credential to use for creating a Topic and subscribing to the Topic. If omitted, uses secret. Must be a service account key in JSON format (see https://cloud.google.com/iam/docs/creating-managing-service-account-keys)."
description: "Credential used to poll the Cloud Pub/Sub Subscription. It is not used to create or delete the Subscription, only to poll it. The value of the secret entry must be a service account key in the JSON format (see https://cloud.google.com/iam/docs/creating-managing-service-account-keys). Defaults to secret.name of 'google-cloud-key' and secret.key of 'key.json'."
serviceAccountName:
type: string
description: "Service Account to run Receive Adapter as. If omitted, uses 'default'."
Expand Down
2 changes: 1 addition & 1 deletion config/300-pullsubscription.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ spec:
properties:
secret:
type: object
description: "Credential to use to poll the Cloud Pub/Sub Subscription. It is not used to create or delete the Subscription, only to poll it. The value of the secret entry must be a service account key in the JSON format (see https://cloud.google.com/iam/docs/creating-managing-service-account-keys). Defaults to secret.name of 'google-cloud-key' and secret.key of 'key.json'."
description: "Credential used to poll the Cloud Pub/Sub Subscription. It is not used to create or delete the Subscription, only to poll it. The value of the secret entry must be a service account key in the JSON format (see https://cloud.google.com/iam/docs/creating-managing-service-account-keys). Defaults to secret.name of 'google-cloud-key' and secret.key of 'key.json'."
project:
type: string
description: "ID of the Google Cloud Project that the Pub/Sub Topic exists in. E.g. 'my-project-1234' rather than its display name, 'My Project' or its number '1234567890'. If omitted uses the Project ID from the GKE cluster metadata service."
Expand Down
10 changes: 1 addition & 9 deletions pkg/apis/duck/v1alpha1/pubsub_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,13 @@ type PubSubSpec struct {
// This brings in CloudEventOverrides and Sink.
duckv1.SourceSpec `json:",inline"`

// Secret is the credential to use to create the "entity" in GCP.
// Secret is the credential to use to poll from a Cloud Pub/Sub subscription.
// If not specified, defaults to:
// Name: google-cloud-key
// Key: key.json
// +optional
Secret *corev1.SecretKeySelector `json:"secret,omitempty"`

// PubSubSecret is the credential to use to create
// Topic / PullSubscription resources. If omitted, uses Secret
PubSubSecret *corev1.SecretKeySelector `json:"pubsubSecret,omitempty"`

// Project is the ID of the Google Cloud Project that the PubSub Topic exists in.
// If omitted, defaults to same as the cluster.
// +optional
Expand Down Expand Up @@ -134,10 +130,6 @@ func (s *PubSub) Populate() {
LocalObjectReference: corev1.LocalObjectReference{Name: "secret"},
Key: "secretkey",
}
s.Spec.PubSubSecret = &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{Name: "pubsubsecret"},
Key: "pubsubkey",
}
s.Status.ObservedGeneration = 42
s.Status.Conditions = duckv1.Conditions{{
// Populate ALL fields
Expand Down
5 changes: 0 additions & 5 deletions pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions pkg/apis/events/v1alpha1/cloudauditlogssource_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ package v1alpha1

import (
"context"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/equality"
"knative.dev/pkg/apis"
duckv1 "knative.dev/pkg/apis/duck/v1"
)

func (current *CloudAuditLogsSource) Validate(ctx context.Context) *apis.FieldError {
Expand All @@ -29,6 +33,14 @@ func (current *CloudAuditLogsSource) Validate(ctx context.Context) *apis.FieldEr

func (current *CloudAuditLogsSourceSpec) Validate(ctx context.Context) *apis.FieldError {
var errs *apis.FieldError

// Sink [required]
if equality.Semantic.DeepEqual(current.Sink, duckv1.Destination{}) {
errs = errs.Also(apis.ErrMissingField("sink"))
} else if err := current.Sink.Validate(ctx); err != nil {
errs = errs.Also(err.ViaField("sink"))
}

// ServiceName [required]
if current.ServiceName == "" {
errs = errs.Also(apis.ErrMissingField("serviceName"))
Expand All @@ -38,6 +50,15 @@ func (current *CloudAuditLogsSourceSpec) Validate(ctx context.Context) *apis.Fie
errs = errs.Also(apis.ErrMissingField("methodName"))
}

if current.Secret != nil {
if !equality.Semantic.DeepEqual(current.Secret, &corev1.SecretKeySelector{}) {
err := validateSecret(current.Secret)
if err != nil {
errs = errs.Also(err.ViaField("secret"))
}
}
}

return errs
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/events/v1alpha1/cloudauditlogssource_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ func TestCloudAuditLogsSourceValidationFields(t *testing.T) {
}(),
error: true,
},
"invalid scheduler secret, missing key": {
spec: func() CloudAuditLogsSourceSpec {
obj := auditLogsSourceSpec.DeepCopy()
obj.Secret = &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{Name: "test-secret"},
}
return *obj
}(),
error: true,
},
}
for n, tc := range testCases {
t.Run(n, func(t *testing.T) {
Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/events/v1alpha1/cloudpubsubsource_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"time"

duckv1alpha1 "github.com/google/knative-gcp/pkg/apis/duck/v1alpha1"
corev1 "k8s.io/api/core/v1"
duckv1 "knative.dev/pkg/apis/duck/v1"

"github.com/google/go-cmp/cmp/cmpopts"
Expand Down Expand Up @@ -76,6 +77,15 @@ func (current *CloudPubSubSourceSpec) Validate(ctx context.Context) *apis.FieldE
}
}

if current.Secret != nil {
if !equality.Semantic.DeepEqual(current.Secret, &corev1.SecretKeySelector{}) {
err := validateSecret(current.Secret)
if err != nil {
errs = errs.Also(err.ViaField("secret"))
}
}
}

return errs
}

Expand Down
Loading