From 9dd4330dc6730eb69a34fccbfd42f53827ec8cfe Mon Sep 17 00:00:00 2001 From: mattmoor-sockpuppet Date: Mon, 12 Aug 2019 07:31:27 -0700 Subject: [PATCH] Auto-update dependencies (#71) Produced via: `dep ensure -update knative.dev/test-infra knative.dev/pkg` /assign @mattmoor --- Gopkg.lock | 6 +- .../pkg/apis/v1alpha1/destination.go | 100 ++++++++++++++++++ vendor/knative.dev/pkg/apis/v1alpha1/doc.go | 18 ++++ .../apis/v1alpha1/zz_generated.deepcopy.go | 57 ++++++++++ vendor/knative.dev/pkg/hack/update-codegen.sh | 2 +- 5 files changed, 179 insertions(+), 4 deletions(-) create mode 100644 vendor/knative.dev/pkg/apis/v1alpha1/destination.go create mode 100644 vendor/knative.dev/pkg/apis/v1alpha1/doc.go create mode 100644 vendor/knative.dev/pkg/apis/v1alpha1/zz_generated.deepcopy.go diff --git a/Gopkg.lock b/Gopkg.lock index 86cf9309..b1ea636e 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -927,7 +927,7 @@ [[projects]] branch = "master" - digest = "1:c375d4501b58273f93be7fb531b551406dc57247a865520e48e724cee9398ded" + digest = "1:668f401ec93fc68a0cee8a1ff986301c748313b243e1cbf077db688b47806f75" name = "knative.dev/pkg" packages = [ "apis", @@ -946,7 +946,7 @@ "metrics/metricskey", ] pruneopts = "T" - revision = "4707aad818fed9883f7d5255dcbf67b9382260e2" + revision = "a690d27530bdb0e8921805b7893bd4a7865bb215" [[projects]] branch = "master" @@ -957,7 +957,7 @@ "tools/dep-collector", ] pruneopts = "UT" - revision = "751583ee73a463cf6449817afda38d63b29dfff7" + revision = "debabfca4db6699ea762112d7bc439ce04a44690" [solve-meta] analyzer-name = "dep" diff --git a/vendor/knative.dev/pkg/apis/v1alpha1/destination.go b/vendor/knative.dev/pkg/apis/v1alpha1/destination.go new file mode 100644 index 00000000..76454fb5 --- /dev/null +++ b/vendor/knative.dev/pkg/apis/v1alpha1/destination.go @@ -0,0 +1,100 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + "context" + "net/url" + "strings" + + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/equality" + + "knative.dev/pkg/apis" +) + +// Destination represents a target of an invocation over HTTP. +type Destination struct { + // ObjectReference points to an Addressable. + *corev1.ObjectReference `json:",inline"` + + // URI is for direct URI Designations. + URI *apis.URL `json:"uri,omitempty"` + + // Path is used with the resulting URL from Addressable ObjectReference or + // URI. Must start with `/`. Will be appended to the path of the resulting + // URL from the Addressable, or URI. + Path *string `json:"path,omitempty"` +} + +func (current *Destination) Validate(ctx context.Context) *apis.FieldError { + if current != nil { + errs := validateDestination(*current).ViaField(apis.CurrentField) + if current.Path != nil { + errs = errs.Also(validateDestinationPath(*current.Path).ViaField("path")) + } + return errs + } else { + return nil + } +} + +func validateDestination(dest Destination) *apis.FieldError { + if dest.URI != nil { + if dest.ObjectReference != nil { + return apis.ErrMultipleOneOf("uri", "[apiVersion, kind, name]") + } + if dest.URI.Host == "" || dest.URI.Scheme == "" { + return apis.ErrInvalidValue(dest.URI.String(), "uri") + } + } else if dest.ObjectReference == nil { + return apis.ErrMissingOneOf("uri", "[apiVersion, kind, name]") + } else { + return validateDestinationRef(*dest.ObjectReference) + } + return nil +} + +func validateDestinationPath(path string) *apis.FieldError { + if strings.HasPrefix(path, "/") { + if pu, err := url.Parse(path); err != nil { + return apis.ErrInvalidValue(path, apis.CurrentField) + } else if !equality.Semantic.DeepEqual(pu, &url.URL{Path: pu.Path}) { + return apis.ErrInvalidValue(path, apis.CurrentField) + } + } else { + return apis.ErrInvalidValue(path, apis.CurrentField) + } + return nil +} + +func validateDestinationRef(ref corev1.ObjectReference) *apis.FieldError { + // Check the object. + var errs *apis.FieldError + // Required Fields + if ref.Name == "" { + errs = errs.Also(apis.ErrMissingField("name")) + } + if ref.APIVersion == "" { + errs = errs.Also(apis.ErrMissingField("apiVersion")) + } + if ref.Kind == "" { + errs = errs.Also(apis.ErrMissingField("kind")) + } + + return errs +} diff --git a/vendor/knative.dev/pkg/apis/v1alpha1/doc.go b/vendor/knative.dev/pkg/apis/v1alpha1/doc.go new file mode 100644 index 00000000..9fb4a2a8 --- /dev/null +++ b/vendor/knative.dev/pkg/apis/v1alpha1/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +k8s:deepcopy-gen=package +package v1alpha1 diff --git a/vendor/knative.dev/pkg/apis/v1alpha1/zz_generated.deepcopy.go b/vendor/knative.dev/pkg/apis/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 00000000..a54dcace --- /dev/null +++ b/vendor/knative.dev/pkg/apis/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,57 @@ +// +build !ignore_autogenerated + +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" + apis "knative.dev/pkg/apis" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Destination) DeepCopyInto(out *Destination) { + *out = *in + if in.ObjectReference != nil { + in, out := &in.ObjectReference, &out.ObjectReference + *out = new(v1.ObjectReference) + **out = **in + } + if in.URI != nil { + in, out := &in.URI, &out.URI + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } + if in.Path != nil { + in, out := &in.Path, &out.Path + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Destination. +func (in *Destination) DeepCopy() *Destination { + if in == nil { + return nil + } + out := new(Destination) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/knative.dev/pkg/hack/update-codegen.sh b/vendor/knative.dev/pkg/hack/update-codegen.sh index 75be4714..e801e484 100755 --- a/vendor/knative.dev/pkg/hack/update-codegen.sh +++ b/vendor/knative.dev/pkg/hack/update-codegen.sh @@ -47,7 +47,7 @@ ${CODEGEN_PKG}/generate-groups.sh "deepcopy" \ # Depends on generate-groups.sh to install bin/deepcopy-gen ${GOPATH}/bin/deepcopy-gen --input-dirs \ - knative.dev/pkg/apis,knative.dev/pkg/logging,knative.dev/pkg/testing \ + knative.dev/pkg/apis,knative.dev/pkg/apis/v1alpha1,knative.dev/pkg/logging,knative.dev/pkg/testing \ -O zz_generated.deepcopy \ --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt