Auto-update dependencies (#71)

Produced via:
  `dep ensure -update knative.dev/test-infra knative.dev/pkg`
/assign @mattmoor
This commit is contained in:
mattmoor-sockpuppet 2019-08-12 07:31:27 -07:00 committed by Knative Prow Robot
parent 19b6c0c4b2
commit 9dd4330dc6
5 changed files with 179 additions and 4 deletions

6
Gopkg.lock generated
View File

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

View File

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

View File

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

View File

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

View File

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