mirror of https://github.com/knative/caching.git
Auto-update dependencies (#118)
Produced via: `dep ensure -update knative.dev/test-infra knative.dev/pkg` /assign mattmoor
This commit is contained in:
parent
81fce3922e
commit
ad32baf448
|
@ -927,7 +927,7 @@
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:81b8fd15ad0e4a40172068f2e207d21c66fdce6f0d5fb37f340def04a5069382"
|
digest = "1:60eb83b6db703546cbddab378c2e8675237726dba71f883feeaec6ad45ba0659"
|
||||||
name = "knative.dev/pkg"
|
name = "knative.dev/pkg"
|
||||||
packages = [
|
packages = [
|
||||||
"apis",
|
"apis",
|
||||||
|
@ -946,18 +946,18 @@
|
||||||
"metrics/metricskey",
|
"metrics/metricskey",
|
||||||
]
|
]
|
||||||
pruneopts = "T"
|
pruneopts = "T"
|
||||||
revision = "4befa47ec54be729c2ffd610513155892581b088"
|
revision = "2a3fc371d3266d59a0ae7e29a724ccc9a0550793"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:988757b6c3d2df3248703c76ae0c63654319672fe368321a191cbbee88b12e69"
|
digest = "1:15b833e870afd578a79069324b74c9cc2ac07b5547f34d54516d90f781c37461"
|
||||||
name = "knative.dev/test-infra"
|
name = "knative.dev/test-infra"
|
||||||
packages = [
|
packages = [
|
||||||
"scripts",
|
"scripts",
|
||||||
"tools/dep-collector",
|
"tools/dep-collector",
|
||||||
]
|
]
|
||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "11b4f85e9c2714c45dda40abc5279b63f706f039"
|
revision = "385c6ecc17489d72a2e0927d4552bcdc1f0d08e0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c"
|
digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c"
|
||||||
|
|
|
@ -1260,14 +1260,14 @@
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:0041ff0e6be31ac2cd85ffd4cf0b6ccb576b408d4f3c1c7e48c79cbf32a1319c"
|
digest = "1:988757b6c3d2df3248703c76ae0c63654319672fe368321a191cbbee88b12e69"
|
||||||
name = "knative.dev/test-infra"
|
name = "knative.dev/test-infra"
|
||||||
packages = [
|
packages = [
|
||||||
"scripts",
|
"scripts",
|
||||||
"tools/dep-collector",
|
"tools/dep-collector",
|
||||||
]
|
]
|
||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "8923e6806b082ebc75b5464ad23d9826f8eaa97b"
|
revision = "11b4f85e9c2714c45dda40abc5279b63f706f039"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c"
|
digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c"
|
||||||
|
|
|
@ -29,32 +29,116 @@ type Destination struct {
|
||||||
// +optional
|
// +optional
|
||||||
Ref *corev1.ObjectReference `json:"ref,omitempty"`
|
Ref *corev1.ObjectReference `json:"ref,omitempty"`
|
||||||
|
|
||||||
|
// +optional
|
||||||
|
DeprecatedAPIVersion string `json:"apiVersion,omitempty"`
|
||||||
|
|
||||||
|
// +optional
|
||||||
|
DeprecatedKind string `json:"kind,omitempty"`
|
||||||
|
|
||||||
|
// +optional
|
||||||
|
DeprecatedName string `json:"name,omitempty"`
|
||||||
|
|
||||||
|
// +optional
|
||||||
|
DeprecatedNamespace string `json:"namespace,omitempty"`
|
||||||
|
|
||||||
// URI can be an absolute URL(non-empty scheme and non-empty host) pointing to the target or a relative URI. Relative URIs will be resolved using the base URI retrieved from Ref.
|
// URI can be an absolute URL(non-empty scheme and non-empty host) pointing to the target or a relative URI. Relative URIs will be resolved using the base URI retrieved from Ref.
|
||||||
// +optional
|
// +optional
|
||||||
URI *apis.URL `json:"uri,omitempty"`
|
URI *apis.URL `json:"uri,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (current *Destination) Validate(ctx context.Context) *apis.FieldError {
|
func (dest *Destination) Validate(ctx context.Context) *apis.FieldError {
|
||||||
if current != nil {
|
if dest == nil {
|
||||||
return ValidateDestination(*current).ViaField(apis.CurrentField)
|
|
||||||
} else {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
return ValidateDestination(*dest, true).ViaField(apis.CurrentField)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dest *Destination) ValidateDisallowDeprecated(ctx context.Context) *apis.FieldError {
|
||||||
|
if dest == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return ValidateDestination(*dest, false).ViaField(apis.CurrentField)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidateDestination validates Destination and either allows or disallows
|
||||||
|
// Deprecated* fields depending on the flag.
|
||||||
|
func ValidateDestination(dest Destination, allowDeprecatedFields bool) *apis.FieldError {
|
||||||
|
if !allowDeprecatedFields {
|
||||||
|
var errs *apis.FieldError
|
||||||
|
if dest.DeprecatedAPIVersion != "" {
|
||||||
|
errs = errs.Also(apis.ErrInvalidValue("apiVersion is not allowed here, it's a deprecated value", "apiVersion"))
|
||||||
|
}
|
||||||
|
if dest.DeprecatedKind != "" {
|
||||||
|
errs = errs.Also(apis.ErrInvalidValue("kind is not allowed here, it's a deprecated value", "kind"))
|
||||||
|
}
|
||||||
|
if dest.DeprecatedName != "" {
|
||||||
|
errs = errs.Also(apis.ErrInvalidValue("name is not allowed here, it's a deprecated value", "name"))
|
||||||
|
}
|
||||||
|
if dest.DeprecatedNamespace != "" {
|
||||||
|
errs = errs.Also(apis.ErrInvalidValue("namespace is not allowed here, it's a deprecated value", "namespace"))
|
||||||
|
}
|
||||||
|
if errs != nil {
|
||||||
|
return errs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
deprecatedObjectReference := dest.deprecatedObjectReference()
|
||||||
|
if dest.Ref != nil && deprecatedObjectReference != nil {
|
||||||
|
return apis.ErrGeneric("Ref and [apiVersion, kind, name] can't be both present", "[apiVersion, kind, name]", "ref")
|
||||||
|
}
|
||||||
|
|
||||||
|
var ref *corev1.ObjectReference
|
||||||
|
if dest.Ref != nil {
|
||||||
|
ref = dest.Ref
|
||||||
|
} else {
|
||||||
|
ref = deprecatedObjectReference
|
||||||
|
}
|
||||||
|
if ref == nil && dest.URI == nil {
|
||||||
|
return apis.ErrGeneric("expected at least one, got none", "[apiVersion, kind, name]", "ref", "uri")
|
||||||
|
}
|
||||||
|
|
||||||
|
if ref != nil && dest.URI != nil && dest.URI.URL().IsAbs() {
|
||||||
|
return apis.ErrGeneric("Absolute URI is not allowed when Ref or [apiVersion, kind, name] is present", "[apiVersion, kind, name]", "ref", "uri")
|
||||||
|
}
|
||||||
|
// IsAbs() check whether the URL has a non-empty scheme. Besides the non-empty scheme, we also require dest.URI has a non-empty host
|
||||||
|
if ref == nil && dest.URI != nil && (!dest.URI.URL().IsAbs() || dest.URI.Host == "") {
|
||||||
|
return apis.ErrInvalidValue("Relative URI is not allowed when Ref and [apiVersion, kind, name] is absent", "uri")
|
||||||
|
}
|
||||||
|
if ref != nil && dest.URI == nil {
|
||||||
|
if dest.Ref != nil {
|
||||||
|
return validateDestinationRef(*ref).ViaField("ref")
|
||||||
|
} else {
|
||||||
|
return validateDestinationRef(*ref)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dest Destination) deprecatedObjectReference() *corev1.ObjectReference {
|
||||||
|
if dest.DeprecatedAPIVersion == "" && dest.DeprecatedKind == "" && dest.DeprecatedName == "" && dest.DeprecatedNamespace == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &corev1.ObjectReference{
|
||||||
|
Kind: dest.DeprecatedKind,
|
||||||
|
APIVersion: dest.DeprecatedAPIVersion,
|
||||||
|
Name: dest.DeprecatedName,
|
||||||
|
Namespace: dest.DeprecatedNamespace,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ValidateDestination(dest Destination) *apis.FieldError {
|
// GetRef gets the ObjectReference from this Destination, if one is present. If no ref is present,
|
||||||
if dest.Ref == nil && dest.URI == nil {
|
// then nil is returned.
|
||||||
return apis.ErrGeneric("expected at least one, got neither", "ref", "uri")
|
// Note: this mostly exists to abstract away the deprecated ObjectReference fields. Once they are
|
||||||
|
// removed, then this method should probably be removed too.
|
||||||
|
func (dest *Destination) GetRef() *corev1.ObjectReference {
|
||||||
|
if dest == nil {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
if dest.Ref != nil && dest.URI != nil && dest.URI.URL().IsAbs() {
|
if dest.Ref != nil {
|
||||||
return apis.ErrGeneric("Absolute URI is not allowed when Ref is present", "ref", "uri")
|
return dest.Ref
|
||||||
}
|
}
|
||||||
// IsAbs() check whether the URL has a non-empty scheme. Besides the non-empty scheme, we also require dest.URI has a non-empty host
|
if ref := dest.deprecatedObjectReference(); ref != nil {
|
||||||
if dest.Ref == nil && dest.URI != nil && (!dest.URI.URL().IsAbs() || dest.URI.Host == "") {
|
return ref
|
||||||
return apis.ErrInvalidValue("Relative URI is not allowed when Ref is absent", "uri")
|
|
||||||
}
|
|
||||||
if dest.Ref != nil && dest.URI == nil {
|
|
||||||
return validateDestinationRef(*dest.Ref).ViaField("ref")
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ func CheckStatsNotReported(t *testing.T, names ...string) {
|
||||||
// reported are tagged with the tags in wantTags and that wantValue matches reported count.
|
// reported are tagged with the tags in wantTags and that wantValue matches reported count.
|
||||||
func CheckCountData(t *testing.T, name string, wantTags map[string]string, wantValue int64) {
|
func CheckCountData(t *testing.T, name string, wantTags map[string]string, wantValue int64) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
if row := checkExactlyOneRow(t, name, wantTags); row != nil {
|
if row := checkExactlyOneRow(t, name); row != nil {
|
||||||
checkRowTags(t, row, name, wantTags)
|
checkRowTags(t, row, name, wantTags)
|
||||||
|
|
||||||
if s, ok := row.Data.(*view.CountData); !ok {
|
if s, ok := row.Data.(*view.CountData); !ok {
|
||||||
|
@ -70,7 +70,7 @@ func CheckCountData(t *testing.T, name string, wantTags map[string]string, wantV
|
||||||
// It also checks that expectedMin and expectedMax match the minimum and maximum reported values, respectively.
|
// It also checks that expectedMin and expectedMax match the minimum and maximum reported values, respectively.
|
||||||
func CheckDistributionData(t *testing.T, name string, wantTags map[string]string, expectedCount int64, expectedMin float64, expectedMax float64) {
|
func CheckDistributionData(t *testing.T, name string, wantTags map[string]string, expectedCount int64, expectedMin float64, expectedMax float64) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
if row := checkExactlyOneRow(t, name, wantTags); row != nil {
|
if row := checkExactlyOneRow(t, name); row != nil {
|
||||||
checkRowTags(t, row, name, wantTags)
|
checkRowTags(t, row, name, wantTags)
|
||||||
|
|
||||||
if s, ok := row.Data.(*view.DistributionData); !ok {
|
if s, ok := row.Data.(*view.DistributionData); !ok {
|
||||||
|
@ -93,7 +93,7 @@ func CheckDistributionData(t *testing.T, name string, wantTags map[string]string
|
||||||
// reported are tagged with the tags in wantTags and that wantValue matches reported last value.
|
// reported are tagged with the tags in wantTags and that wantValue matches reported last value.
|
||||||
func CheckLastValueData(t *testing.T, name string, wantTags map[string]string, wantValue float64) {
|
func CheckLastValueData(t *testing.T, name string, wantTags map[string]string, wantValue float64) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
if row := checkExactlyOneRow(t, name, wantTags); row != nil {
|
if row := checkExactlyOneRow(t, name); row != nil {
|
||||||
checkRowTags(t, row, name, wantTags)
|
checkRowTags(t, row, name, wantTags)
|
||||||
|
|
||||||
if s, ok := row.Data.(*view.LastValueData); !ok {
|
if s, ok := row.Data.(*view.LastValueData); !ok {
|
||||||
|
@ -108,7 +108,7 @@ func CheckLastValueData(t *testing.T, name string, wantTags map[string]string, w
|
||||||
// reported are tagged with the tags in wantTags and that wantValue matches the reported sum.
|
// reported are tagged with the tags in wantTags and that wantValue matches the reported sum.
|
||||||
func CheckSumData(t *testing.T, name string, wantTags map[string]string, wantValue float64) {
|
func CheckSumData(t *testing.T, name string, wantTags map[string]string, wantValue float64) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
if row := checkExactlyOneRow(t, name, wantTags); row != nil {
|
if row := checkExactlyOneRow(t, name); row != nil {
|
||||||
checkRowTags(t, row, name, wantTags)
|
checkRowTags(t, row, name, wantTags)
|
||||||
|
|
||||||
if s, ok := row.Data.(*view.SumData); !ok {
|
if s, ok := row.Data.(*view.SumData); !ok {
|
||||||
|
@ -134,7 +134,7 @@ func Unregister(names ...string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkExactlyOneRow(t *testing.T, name string, wantTags map[string]string) *view.Row {
|
func checkExactlyOneRow(t *testing.T, name string) *view.Row {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
d, err := view.RetrieveData(name)
|
d, err := view.RetrieveData(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -150,6 +150,9 @@ func checkExactlyOneRow(t *testing.T, name string, wantTags map[string]string) *
|
||||||
|
|
||||||
func checkRowTags(t *testing.T, row *view.Row, name string, wantTags map[string]string) {
|
func checkRowTags(t *testing.T, row *view.Row, name string, wantTags map[string]string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
if wantlen, gotlen := len(wantTags), len(row.Tags); gotlen != wantlen {
|
||||||
|
t.Errorf("For metric %s: Reporter got %v tags while want %v", name, gotlen, wantlen)
|
||||||
|
}
|
||||||
for _, got := range row.Tags {
|
for _, got := range row.Tags {
|
||||||
n := got.Key.Name()
|
n := got.Key.Name()
|
||||||
if want, ok := wantTags[n]; !ok {
|
if want, ok := wantTags[n]; !ok {
|
||||||
|
|
|
@ -64,14 +64,34 @@ func NewURIResolver(ctx context.Context, callback func(types.NamespacedName)) *U
|
||||||
|
|
||||||
// URIFromDestination resolves a Destination into a URI string.
|
// URIFromDestination resolves a Destination into a URI string.
|
||||||
func (r *URIResolver) URIFromDestination(dest apisv1alpha1.Destination, parent interface{}) (string, error) {
|
func (r *URIResolver) URIFromDestination(dest apisv1alpha1.Destination, parent interface{}) (string, error) {
|
||||||
|
var deprecatedObjectReference *corev1.ObjectReference
|
||||||
|
if dest.DeprecatedAPIVersion == "" && dest.DeprecatedKind == "" && dest.DeprecatedName == "" && dest.DeprecatedNamespace == ""{
|
||||||
|
deprecatedObjectReference = nil
|
||||||
|
} else {
|
||||||
|
deprecatedObjectReference = &corev1.ObjectReference{
|
||||||
|
Kind: dest.DeprecatedKind,
|
||||||
|
APIVersion: dest.DeprecatedAPIVersion,
|
||||||
|
Name: dest.DeprecatedName,
|
||||||
|
Namespace: dest.DeprecatedNamespace,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if dest.Ref != nil && deprecatedObjectReference != nil {
|
||||||
|
return "", fmt.Errorf("ref and [apiVersion, kind, name] can't be both present")
|
||||||
|
}
|
||||||
|
var ref *corev1.ObjectReference
|
||||||
if dest.Ref != nil {
|
if dest.Ref != nil {
|
||||||
url, err := r.URIFromObjectReference(dest.Ref, parent)
|
ref = dest.Ref
|
||||||
|
} else {
|
||||||
|
ref = deprecatedObjectReference
|
||||||
|
}
|
||||||
|
if ref != nil {
|
||||||
|
url, err := r.URIFromObjectReference(ref, parent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
if dest.URI != nil {
|
if dest.URI != nil {
|
||||||
if dest.URI.URL().IsAbs() {
|
if dest.URI.URL().IsAbs() {
|
||||||
return "", fmt.Errorf("absolute URI is not allowed when Ref exists")
|
return "", fmt.Errorf("absolute URI is not allowed when Ref or [apiVersion, kind, name] exists")
|
||||||
}
|
}
|
||||||
return url.URL().ResolveReference(dest.URI.URL()).String(), nil
|
return url.URL().ResolveReference(dest.URI.URL()).String(), nil
|
||||||
}
|
}
|
||||||
|
@ -86,7 +106,7 @@ func (r *URIResolver) URIFromDestination(dest apisv1alpha1.Destination, parent i
|
||||||
return dest.URI.String(), nil
|
return dest.URI.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", fmt.Errorf("destination missing Ref and URI, expected at least one")
|
return "", fmt.Errorf("destination missing Ref, [apiVersion, kind, name] and URI, expected at least one")
|
||||||
}
|
}
|
||||||
|
|
||||||
// URIFromObjectReference resolves an ObjectReference to a URI string.
|
// URIFromObjectReference resolves an ObjectReference to a URI string.
|
||||||
|
|
|
@ -26,7 +26,8 @@ readonly PROJECT_NAME=${PROJECT_NAME:-knative-performance}
|
||||||
readonly SERVICE_ACCOUNT_NAME=${SERVICE_ACCOUNT_NAME:-mako-job}
|
readonly SERVICE_ACCOUNT_NAME=${SERVICE_ACCOUNT_NAME:-mako-job}
|
||||||
|
|
||||||
# Setup env vars.
|
# Setup env vars.
|
||||||
readonly KO_DOCKER_REPO="gcr.io/${PROJECT_NAME}"
|
export KO_DOCKER_REPO="gcr.io/${PROJECT_NAME}"
|
||||||
|
# Constants
|
||||||
readonly GOOGLE_APPLICATION_CREDENTIALS="/etc/performance-test/service-account.json"
|
readonly GOOGLE_APPLICATION_CREDENTIALS="/etc/performance-test/service-account.json"
|
||||||
readonly GITHUB_TOKEN="/etc/performance-test/github-token"
|
readonly GITHUB_TOKEN="/etc/performance-test/github-token"
|
||||||
readonly SLACK_READ_TOKEN="/etc/performance-test/slack-read-token"
|
readonly SLACK_READ_TOKEN="/etc/performance-test/slack-read-token"
|
||||||
|
@ -35,11 +36,11 @@ readonly SLACK_WRITE_TOKEN="/etc/performance-test/slack-write-token"
|
||||||
# Set up the user for cluster operations.
|
# Set up the user for cluster operations.
|
||||||
function setup_user() {
|
function setup_user() {
|
||||||
echo ">> Setting up user"
|
echo ">> Setting up user"
|
||||||
echo "Using gcloud project ${PROJECT_NAME}"
|
|
||||||
gcloud config set core/project ${PROJECT_NAME}
|
|
||||||
local user_name="${SERVICE_ACCOUNT_NAME}@${PROJECT_NAME}.iam.gserviceaccount.com"
|
local user_name="${SERVICE_ACCOUNT_NAME}@${PROJECT_NAME}.iam.gserviceaccount.com"
|
||||||
echo "Using gcloud user ${user_name}"
|
echo "Using gcloud user ${user_name}"
|
||||||
gcloud config set core/account ${user_name}
|
gcloud config set core/account ${user_name}
|
||||||
|
echo "Using gcloud project ${PROJECT_NAME}"
|
||||||
|
gcloud config set core/project ${PROJECT_NAME}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update resources installed on the cluster.
|
# Update resources installed on the cluster.
|
||||||
|
|
Loading…
Reference in New Issue