Auto-update dependencies (#60)

Produced via:
  `dep ensure -update github.com/knative/test-infra knative.dev/pkg`
/assign @mattmoor
This commit is contained in:
mattmoor-sockpuppet 2019-07-29 07:30:06 -07:00 committed by Knative Prow Robot
parent ce106ecb61
commit 32acd0c37e
4 changed files with 34 additions and 17 deletions

4
Gopkg.lock generated
View File

@ -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"

4
vendor/knative.dev/pkg/Gopkg.lock generated vendored
View File

@ -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"

View File

@ -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
}

View File

@ -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
}
}
}