From 32acd0c37eddb3a37293db532e00fc6e7f8c8446 Mon Sep 17 00:00:00 2001 From: mattmoor-sockpuppet Date: Mon, 29 Jul 2019 07:30:06 -0700 Subject: [PATCH] Auto-update dependencies (#60) Produced via: `dep ensure -update github.com/knative/test-infra knative.dev/pkg` /assign @mattmoor --- Gopkg.lock | 4 +-- vendor/knative.dev/pkg/Gopkg.lock | 4 +-- .../pkg/apis/metadata_validation.go | 27 +++++++++++++++++++ vendor/knative.dev/pkg/webhook/user_info.go | 16 +++-------- 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 38fccef4..61eff116 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -938,7 +938,7 @@ [[projects]] branch = "master" - digest = "1:ebc565a6cd5ee8b686a82263489b4038979293df11dfe8fbbd1f7a3b54564232" + digest = "1:552f31c039d33d163776e7ef843513f599b1ceefcee7a3e4245c910f60904387" name = "knative.dev/pkg" packages = [ "apis", @@ -957,7 +957,7 @@ "metrics/metricskey", ] pruneopts = "T" - revision = "154a0848d46b569c96b9eb18d5535bbc43bb108c" + revision = "cb7014ea6ef60a6dfe23f5506703f84dd6310e15" [solve-meta] analyzer-name = "dep" diff --git a/vendor/knative.dev/pkg/Gopkg.lock b/vendor/knative.dev/pkg/Gopkg.lock index eb5750db..c94847ba 100644 --- a/vendor/knative.dev/pkg/Gopkg.lock +++ b/vendor/knative.dev/pkg/Gopkg.lock @@ -313,14 +313,14 @@ [[projects]] branch = "master" - digest = "1:f91a467423c58e30754cb830f66a04fa3e6f28fe567e3e68e04aa61f3e51f377" + digest = "1:c5fcddf864b41dd694b4348b06406904ba8b2e403a3a1bb1a565104beb2b4092" name = "github.com/knative/test-infra" packages = [ "scripts", "tools/dep-collector", ] pruneopts = "UT" - revision = "cad8ba5b64ca151d6435a914fd29f0b8a5cdec74" + revision = "88caf452c91594b30b06b2b62c1ece171d77415c" [[projects]] digest = "1:56dbf15e091bf7926cb33a57cb6bdfc658fc6d3498d2f76f10a97ce7856f1fde" diff --git a/vendor/knative.dev/pkg/apis/metadata_validation.go b/vendor/knative.dev/pkg/apis/metadata_validation.go index d65fa7dd..047849a9 100644 --- a/vendor/knative.dev/pkg/apis/metadata_validation.go +++ b/vendor/knative.dev/pkg/apis/metadata_validation.go @@ -19,10 +19,21 @@ package apis import ( "fmt" + "k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/api/validation" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +const ( + // CreatorAnnotationSuffix is the suffix of the annotation key to describe + // the user that created the resource. + CreatorAnnotationSuffix = "/creator" + + // UpdaterAnnotationSuffix is the suffix of the annotation key to describe + // the user who last modified the resource. + UpdaterAnnotationSuffix = "/lastModifier" +) + // ValidateObjectMetadata validates that `metadata` stanza of the // resources is correct. func ValidateObjectMetadata(meta metav1.Object) *FieldError { @@ -60,3 +71,19 @@ func ValidateObjectMetadata(meta metav1.Object) *FieldError { return nil } + +// ValidateCreatorAndModifier validates `metadata.annotation` +func ValidateCreatorAndModifier(oldSpec, newSpec interface{}, oldAnnotation, newAnnotation map[string]string, groupName string) *FieldError { + var errs *FieldError + if oldAnnotation[groupName+CreatorAnnotationSuffix] != newAnnotation[groupName+CreatorAnnotationSuffix] { + errs = errs.Also(&FieldError{ + Message: "annotation value is immutable", + Paths: []string{groupName + CreatorAnnotationSuffix}, + }) + } + + if equality.Semantic.DeepEqual(oldSpec, newSpec) && oldAnnotation[groupName+UpdaterAnnotationSuffix] != newAnnotation[groupName+UpdaterAnnotationSuffix] { + errs = errs.Also(ErrInvalidValue(newAnnotation[groupName+UpdaterAnnotationSuffix], groupName+UpdaterAnnotationSuffix)) + } + return errs +} diff --git a/vendor/knative.dev/pkg/webhook/user_info.go b/vendor/knative.dev/pkg/webhook/user_info.go index 11f4e54a..405290e7 100644 --- a/vendor/knative.dev/pkg/webhook/user_info.go +++ b/vendor/knative.dev/pkg/webhook/user_info.go @@ -24,16 +24,6 @@ import ( "knative.dev/pkg/apis" ) -const ( - // CreatorAnnotationSuffix is the suffix of the annotation key to describe - // the user that created the resource. - CreatorAnnotationSuffix = "/creator" - - // UpdaterAnnotationSuffix is the suffix of the annotation key to describe - // the user who last modified the resource. - UpdaterAnnotationSuffix = "/lastModifier" -) - // SetUserInfoAnnotations sets creator and updater annotations on a resource. func SetUserInfoAnnotations(resource apis.HasSpec, ctx context.Context, groupName string) { if ui := apis.GetUserInfo(ctx); ui != nil { @@ -53,10 +43,10 @@ func SetUserInfoAnnotations(resource apis.HasSpec, ctx context.Context, groupNam if equality.Semantic.DeepEqual(old.GetUntypedSpec(), resource.GetUntypedSpec()) { return } - annotations[groupName+UpdaterAnnotationSuffix] = ui.Username + annotations[groupName+apis.UpdaterAnnotationSuffix] = ui.Username } else { - annotations[groupName+CreatorAnnotationSuffix] = ui.Username - annotations[groupName+UpdaterAnnotationSuffix] = ui.Username + annotations[groupName+apis.CreatorAnnotationSuffix] = ui.Username + annotations[groupName+apis.UpdaterAnnotationSuffix] = ui.Username } } }