diff --git a/Gopkg.lock b/Gopkg.lock index 1fb42a0ee1..3393298c3b 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -267,11 +267,11 @@ revision = "6f77996f0c42f7b84e5a2b252227263f93432e9b" [[projects]] - digest = "1:c280fbe00363f7c8db868a738b94df33586ce05c10d26578c3adf544d010eb64" + digest = "1:7915c656a10819b240db94ffd6afc6a621af4687db735341d9919668750485ec" name = "github.com/google/go-containerregistry" packages = ["pkg/name"] pruneopts = "NUT" - revision = "dbc4da98389f9d0c42eb314c2b346bf1d2a27310" + revision = "abf9ef06abd9f532944e28e8942644ea4b710a40" [[projects]] digest = "1:f4f203acd8b11b8747bdcd91696a01dbc95ccb9e2ca2db6abf81c3a4f5e950ce" @@ -431,62 +431,27 @@ version = "v1.3.0" [[projects]] - digest = "1:0836bde83bdc49aae7710e22d04e2555d9bd25cd133fbb78508c492307081aea" - name = "github.com/knative/build" - packages = [ - "pkg/apis/build", - "pkg/apis/build/v1alpha1", - ] - pruneopts = "NUT" - revision = "4fc8663ff9c48a66c52684b2e4cdf06ec83117c8" - version = "v0.5.0" - -[[projects]] - digest = "1:ef581dc7bdca4f2590e5bb6566a029b391a6a98da5b24d5e08b762e51b01e04c" + digest = "1:f4d08f98ce04ca52197f2bb0cd40bfc8da83ace982df9f6c4f7f241f00009f80" name = "github.com/knative/eventing" packages = [ "pkg/apis/duck/v1alpha1", "pkg/apis/eventing", "pkg/apis/eventing/v1alpha1", + "pkg/apis/messaging", + "pkg/apis/messaging/v1alpha1", "pkg/apis/sources", "pkg/apis/sources/v1alpha1", "pkg/client/clientset/versioned", "pkg/client/clientset/versioned/scheme", "pkg/client/clientset/versioned/typed/eventing/v1alpha1", + "pkg/client/clientset/versioned/typed/messaging/v1alpha1", "pkg/client/clientset/versioned/typed/sources/v1alpha1", ] pruneopts = "NUT" - revision = "53ee52c1292bc6f6807512a9081b9e64055f2bd2" - -[[projects]] - branch = "release-0.7" - digest = "1:ce855f6a786a15c09fbdc17455154c625928ec346caafb6a8f85eaf3386207f7" - name = "github.com/knative/pkg" - packages = [ - "apis", - "apis/duck", - "apis/duck/v1alpha1", - "apis/duck/v1beta1", - "changeset", - "configmap", - "kmeta", - "kmp", - "logging", - "logging/logkey", - "signals", - "test", - "test/ingress", - "test/logging", - "test/monitoring", - "test/spoof", - "test/zipkin", - "webhook", - ] - pruneopts = "NUT" - revision = "d82505e6c5b4ce46562d6c242be0e706791f35bd" + revision = "677d3d17e84b7337f006220d6bb465af4f416f81" [[projects]] - digest = "1:877272591f1cdf21c3d9d333c6393c836f22b137b4b24a303814fdf0b706ef7b" + digest = "1:1fa8a00b12c1ad84d6ed050e328d750d16c3f3bd62dae55c449322dc7c355a28" name = "github.com/knative/serving" packages = [ "pkg/apis/autoscaling", @@ -496,15 +461,16 @@ "pkg/apis/networking/v1alpha1", "pkg/apis/serving", "pkg/apis/serving/v1alpha1", + "pkg/apis/serving/v1beta1", "pkg/client/clientset/versioned", "pkg/client/clientset/versioned/scheme", "pkg/client/clientset/versioned/typed/autoscaling/v1alpha1", "pkg/client/clientset/versioned/typed/networking/v1alpha1", "pkg/client/clientset/versioned/typed/serving/v1alpha1", + "pkg/client/clientset/versioned/typed/serving/v1beta1", ] pruneopts = "NUT" - revision = "ca4fffb4743924c58e98badcf5bd3f17a3634d43" - version = "v0.5.0" + revision = "50cdf8762deae58ed89763adef26a88e7efecac7" [[projects]] branch = "master" @@ -1344,6 +1310,34 @@ pruneopts = "NUT" revision = "e494cc58111187acad93e64529228a2fc0153e39" +[[projects]] + branch = "master" + digest = "1:f0a2d6dc85eba89aa87a0b11a2866e6e954df99e5b5907015e13fe84ad3f36b7" + name = "knative.dev/pkg" + packages = [ + "apis", + "apis/duck", + "apis/duck/v1alpha1", + "apis/duck/v1beta1", + "changeset", + "configmap", + "kmeta", + "kmp", + "logging", + "logging/logkey", + "ptr", + "signals", + "test", + "test/ingress", + "test/logging", + "test/monitoring", + "test/spoof", + "test/zipkin", + "webhook", + ] + pruneopts = "NUT" + revision = "1104d6c75533160d27c02d3eb373fc567bd6d60c" + [[projects]] digest = "1:399953e7c3ac9253dcf1fe909b0a74f6d1c4e974decefd6f5d361cab06249ccc" name = "sigs.k8s.io/controller-runtime" @@ -1436,15 +1430,6 @@ "github.com/knative/eventing/pkg/apis/eventing/v1alpha1", "github.com/knative/eventing/pkg/apis/sources/v1alpha1", "github.com/knative/eventing/pkg/client/clientset/versioned", - "github.com/knative/pkg/apis", - "github.com/knative/pkg/apis/duck", - "github.com/knative/pkg/apis/duck/v1alpha1", - "github.com/knative/pkg/kmp", - "github.com/knative/pkg/logging", - "github.com/knative/pkg/logging/logkey", - "github.com/knative/pkg/signals", - "github.com/knative/pkg/test", - "github.com/knative/pkg/test/logging", "github.com/knative/serving/pkg/apis/serving/v1alpha1", "github.com/knative/serving/pkg/client/clientset/versioned", "github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1", @@ -1491,6 +1476,15 @@ "k8s.io/client-go/tools/record", "k8s.io/client-go/util/flowcontrol", "k8s.io/code-generator/cmd/deepcopy-gen", + "knative.dev/pkg/apis", + "knative.dev/pkg/apis/duck", + "knative.dev/pkg/apis/duck/v1alpha1", + "knative.dev/pkg/kmp", + "knative.dev/pkg/logging", + "knative.dev/pkg/logging/logkey", + "knative.dev/pkg/signals", + "knative.dev/pkg/test", + "knative.dev/pkg/test/logging", "sigs.k8s.io/controller-runtime/pkg/client", "sigs.k8s.io/controller-runtime/pkg/client/config", "sigs.k8s.io/controller-runtime/pkg/client/fake", diff --git a/Gopkg.toml b/Gopkg.toml index 38124cf31c..347926143b 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -36,8 +36,8 @@ required = [ unused-packages = false [[override]] - name = "github.com/knative/pkg" - branch = "release-0.7" + name = "knative.dev/pkg" + branch = "master" [[override]] name = "k8s.io/api" @@ -65,17 +65,13 @@ required = [ [[constraint]] name = "github.com/knative/serving" - version = "v0.5.0" - -# Bring build along for serving. -[[override]] - name = "github.com/knative/build" - version = "v0.5.0" + # HEAD as of 2019-06-26. Needed to test github. + revision = "50cdf8762deae58ed89763adef26a88e7efecac7" [[constraint]] name = "github.com/knative/eventing" - # HEAD as of 2019-05-12. Needed to import EventType API object. - revision = "53ee52c1292bc6f6807512a9081b9e64055f2bd2" + # HEAD as of 2019-06-26. Needed to import EventType API object. + revision = "677d3d17e84b7337f006220d6bb465af4f416f81" [[constraint]] name="sigs.k8s.io/controller-runtime" diff --git a/camel/source/cmd/controller/main.go b/camel/source/cmd/controller/main.go index 2668e9c183..d2c804f37d 100644 --- a/camel/source/cmd/controller/main.go +++ b/camel/source/cmd/controller/main.go @@ -22,9 +22,9 @@ import ( "github.com/knative/eventing-contrib/camel/source/pkg/apis" "github.com/knative/eventing-contrib/camel/source/pkg/install" "github.com/knative/eventing-contrib/camel/source/pkg/reconciler" - "github.com/knative/pkg/logging/logkey" "go.uber.org/zap" "go.uber.org/zap/zapcore" + "knative.dev/pkg/logging/logkey" "sigs.k8s.io/controller-runtime/pkg/client/config" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/runtime/signals" diff --git a/camel/source/pkg/apis/sources/v1alpha1/camelsource_types.go b/camel/source/pkg/apis/sources/v1alpha1/camelsource_types.go index b6d8506fac..d45809293b 100644 --- a/camel/source/pkg/apis/sources/v1alpha1/camelsource_types.go +++ b/camel/source/pkg/apis/sources/v1alpha1/camelsource_types.go @@ -18,11 +18,11 @@ package v1alpha1 import ( "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" - "github.com/knative/pkg/apis/duck" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" + "knative.dev/pkg/apis/duck" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" ) // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. diff --git a/camel/source/pkg/apis/sources/v1alpha1/camelsource_types_test.go b/camel/source/pkg/apis/sources/v1alpha1/camelsource_types_test.go index 50b3d17769..fc2b68c850 100644 --- a/camel/source/pkg/apis/sources/v1alpha1/camelsource_types_test.go +++ b/camel/source/pkg/apis/sources/v1alpha1/camelsource_types_test.go @@ -21,8 +21,8 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" corev1 "k8s.io/api/core/v1" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" ) func TestCamelSourceStatusIsReady(t *testing.T) { diff --git a/camel/source/pkg/reconciler/camelsource.go b/camel/source/pkg/reconciler/camelsource.go index 16e663cbda..9847c1cfcf 100644 --- a/camel/source/pkg/reconciler/camelsource.go +++ b/camel/source/pkg/reconciler/camelsource.go @@ -25,7 +25,6 @@ import ( "github.com/knative/eventing-contrib/camel/source/pkg/reconciler/resources" "github.com/knative/eventing-contrib/pkg/controller/sdk" "github.com/knative/eventing-contrib/pkg/controller/sinks" - "github.com/knative/pkg/logging" "go.uber.org/zap" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/equality" @@ -35,6 +34,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/tools/record" + "knative.dev/pkg/logging" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/manager" diff --git a/camel/source/pkg/reconciler/camelsource_test.go b/camel/source/pkg/reconciler/camelsource_test.go index ec162c015c..91501d007f 100644 --- a/camel/source/pkg/reconciler/camelsource_test.go +++ b/camel/source/pkg/reconciler/camelsource_test.go @@ -24,7 +24,6 @@ import ( sourcesv1alpha1 "github.com/knative/eventing-contrib/camel/source/pkg/apis/sources/v1alpha1" "github.com/knative/eventing-contrib/camel/source/pkg/reconciler/resources" controllertesting "github.com/knative/eventing-contrib/pkg/controller/testing" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" "go.uber.org/zap" v1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -33,6 +32,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/tools/record" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" ) var ( @@ -55,7 +55,7 @@ const ( addressableKind = "Sink" addressableAPIVersion = "duck.knative.dev/v1alpha1" addressableDNS = "addressable.sink.svc.cluster.local" - addressableURI = "http://addressable.sink.svc.cluster.local/" + addressableURI = "http://addressable.sink.svc.cluster.local" ) func init() { diff --git a/contrib/awssqs/cmd/controller/main.go b/contrib/awssqs/cmd/controller/main.go index aa44aa379a..7cd9266c57 100644 --- a/contrib/awssqs/cmd/controller/main.go +++ b/contrib/awssqs/cmd/controller/main.go @@ -21,9 +21,9 @@ import ( "github.com/knative/eventing-contrib/contrib/awssqs/pkg/apis" "github.com/knative/eventing-contrib/contrib/awssqs/pkg/reconciler" - "github.com/knative/pkg/logging/logkey" "go.uber.org/zap" "go.uber.org/zap/zapcore" + "knative.dev/pkg/logging/logkey" "sigs.k8s.io/controller-runtime/pkg/client/config" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/runtime/signals" diff --git a/contrib/awssqs/cmd/receive_adapter/main.go b/contrib/awssqs/cmd/receive_adapter/main.go index 4ec70e8f93..8a4bc0e131 100644 --- a/contrib/awssqs/cmd/receive_adapter/main.go +++ b/contrib/awssqs/cmd/receive_adapter/main.go @@ -22,7 +22,7 @@ import ( "os" awssqs "github.com/knative/eventing-contrib/contrib/awssqs/pkg/adapter" - "github.com/knative/pkg/signals" + "knative.dev/pkg/signals" "go.uber.org/zap" "go.uber.org/zap/zapcore" diff --git a/contrib/awssqs/pkg/adapter/adapter.go b/contrib/awssqs/pkg/adapter/adapter.go index 218e97bde3..d3111d3ba6 100644 --- a/contrib/awssqs/pkg/adapter/adapter.go +++ b/contrib/awssqs/pkg/adapter/adapter.go @@ -30,9 +30,9 @@ import ( "github.com/cloudevents/sdk-go/pkg/cloudevents/types" sourcesv1alpha1 "github.com/knative/eventing-contrib/contrib/awssqs/pkg/apis/sources/v1alpha1" "github.com/knative/eventing-contrib/pkg/kncloudevents" - "github.com/knative/pkg/logging" "go.uber.org/zap" "golang.org/x/net/context" + "knative.dev/pkg/logging" ) // Adapter implements the AWS SQS adapter to deliver SQS messages from diff --git a/contrib/awssqs/pkg/apis/sources/v1alpha1/aws_sqs_types.go b/contrib/awssqs/pkg/apis/sources/v1alpha1/aws_sqs_types.go index 2180a8e2c0..8cfa718a4c 100644 --- a/contrib/awssqs/pkg/apis/sources/v1alpha1/aws_sqs_types.go +++ b/contrib/awssqs/pkg/apis/sources/v1alpha1/aws_sqs_types.go @@ -17,11 +17,11 @@ limitations under the License. package v1alpha1 import ( - "github.com/knative/pkg/apis/duck" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" + "knative.dev/pkg/apis/duck" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" ) // +genclient diff --git a/contrib/awssqs/pkg/apis/sources/v1alpha1/aws_sqs_types_test.go b/contrib/awssqs/pkg/apis/sources/v1alpha1/aws_sqs_types_test.go index 295a059e25..008469de92 100644 --- a/contrib/awssqs/pkg/apis/sources/v1alpha1/aws_sqs_types_test.go +++ b/contrib/awssqs/pkg/apis/sources/v1alpha1/aws_sqs_types_test.go @@ -21,8 +21,8 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" corev1 "k8s.io/api/core/v1" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" ) func TestAwsSqsSourceStatusIsReady(t *testing.T) { diff --git a/contrib/awssqs/pkg/reconciler/awssqssource.go b/contrib/awssqs/pkg/reconciler/awssqssource.go index 7eb516a39c..b30eec19bf 100644 --- a/contrib/awssqs/pkg/reconciler/awssqssource.go +++ b/contrib/awssqs/pkg/reconciler/awssqssource.go @@ -28,7 +28,6 @@ import ( "github.com/knative/eventing-contrib/pkg/controller/sinks" "github.com/knative/eventing-contrib/pkg/reconciler/eventtype" eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1" - "github.com/knative/pkg/logging" "go.uber.org/zap" v1 "k8s.io/api/apps/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -39,6 +38,7 @@ import ( "k8s.io/apimachinery/pkg/util/sets" "k8s.io/client-go/dynamic" "k8s.io/client-go/rest" + "knative.dev/pkg/logging" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/manager" diff --git a/contrib/gcppubsub/cmd/controller/main.go b/contrib/gcppubsub/cmd/controller/main.go index 7f0a1c4d32..46cd9e5768 100644 --- a/contrib/gcppubsub/cmd/controller/main.go +++ b/contrib/gcppubsub/cmd/controller/main.go @@ -21,10 +21,10 @@ import ( "github.com/knative/eventing-contrib/contrib/gcppubsub/pkg/apis" controller "github.com/knative/eventing-contrib/contrib/gcppubsub/pkg/reconciler" - "github.com/knative/pkg/logging/logkey" "go.uber.org/zap" "go.uber.org/zap/zapcore" _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" + "knative.dev/pkg/logging/logkey" "sigs.k8s.io/controller-runtime/pkg/client/config" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/runtime/signals" diff --git a/contrib/gcppubsub/pkg/adapter/adapter.go b/contrib/gcppubsub/pkg/adapter/adapter.go index 1a8a31d9b6..a4786842f6 100644 --- a/contrib/gcppubsub/pkg/adapter/adapter.go +++ b/contrib/gcppubsub/pkg/adapter/adapter.go @@ -21,8 +21,8 @@ import ( cloudevents "github.com/cloudevents/sdk-go" "github.com/knative/eventing-contrib/pkg/kncloudevents" - "github.com/knative/pkg/logging" "go.uber.org/zap" + "knative.dev/pkg/logging" // Imports the Google Cloud Pub/Sub client package. "cloud.google.com/go/pubsub" diff --git a/contrib/gcppubsub/pkg/apis/sources/v1alpha1/gcp_pubsub_types.go b/contrib/gcppubsub/pkg/apis/sources/v1alpha1/gcp_pubsub_types.go index 9ecdb585c2..28b4a43e37 100644 --- a/contrib/gcppubsub/pkg/apis/sources/v1alpha1/gcp_pubsub_types.go +++ b/contrib/gcppubsub/pkg/apis/sources/v1alpha1/gcp_pubsub_types.go @@ -19,12 +19,12 @@ package v1alpha1 import ( "fmt" - "github.com/knative/pkg/apis" - "github.com/knative/pkg/apis/duck" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" ) // +genclient diff --git a/contrib/gcppubsub/pkg/apis/sources/v1alpha1/gcp_pubsub_types_test.go b/contrib/gcppubsub/pkg/apis/sources/v1alpha1/gcp_pubsub_types_test.go index 1ecfad13ae..de15d85e47 100644 --- a/contrib/gcppubsub/pkg/apis/sources/v1alpha1/gcp_pubsub_types_test.go +++ b/contrib/gcppubsub/pkg/apis/sources/v1alpha1/gcp_pubsub_types_test.go @@ -21,8 +21,8 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" corev1 "k8s.io/api/core/v1" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" ) func TestGcpPubSubSourceStatusIsReady(t *testing.T) { diff --git a/contrib/gcppubsub/pkg/apis/sources/v1alpha1/gcp_pubsub_validation.go b/contrib/gcppubsub/pkg/apis/sources/v1alpha1/gcp_pubsub_validation.go index 7ca130d466..359743bf3b 100644 --- a/contrib/gcppubsub/pkg/apis/sources/v1alpha1/gcp_pubsub_validation.go +++ b/contrib/gcppubsub/pkg/apis/sources/v1alpha1/gcp_pubsub_validation.go @@ -20,7 +20,7 @@ import ( "context" "github.com/google/go-cmp/cmp" - "github.com/knative/pkg/apis" + "knative.dev/pkg/apis" ) func (current *GcpPubSubSource) CheckImmutableFields(ctx context.Context, og apis.Immutable) *apis.FieldError { diff --git a/contrib/gcppubsub/pkg/reconciler/gcppubsubsource.go b/contrib/gcppubsub/pkg/reconciler/gcppubsubsource.go index 3d784c57dc..64b8a7f596 100644 --- a/contrib/gcppubsub/pkg/reconciler/gcppubsubsource.go +++ b/contrib/gcppubsub/pkg/reconciler/gcppubsubsource.go @@ -29,7 +29,6 @@ import ( "github.com/knative/eventing-contrib/pkg/controller/sinks" "github.com/knative/eventing-contrib/pkg/reconciler/eventtype" eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1" - "github.com/knative/pkg/logging" "go.uber.org/zap" v1 "k8s.io/api/apps/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -38,6 +37,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/sets" + "knative.dev/pkg/logging" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/manager" diff --git a/contrib/gcppubsub/pkg/reconciler/gcppubsubsource_test.go b/contrib/gcppubsub/pkg/reconciler/gcppubsubsource_test.go index 8ccad95ac6..1230e158fe 100644 --- a/contrib/gcppubsub/pkg/reconciler/gcppubsubsource_test.go +++ b/contrib/gcppubsub/pkg/reconciler/gcppubsubsource_test.go @@ -28,13 +28,13 @@ import ( "github.com/knative/eventing-contrib/pkg/reconciler/eventtype" eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1" eventingsourcesv1alpha1 "github.com/knative/eventing/pkg/apis/sources/v1alpha1" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" v1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/kubernetes/scheme" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -61,7 +61,7 @@ const ( brokerKind = "Broker" addressableAPIVersion = "duck.knative.dev/v1alpha1" addressableDNS = "addressable.sink.svc.cluster.local" - addressableURI = "http://addressable.sink.svc.cluster.local/" + addressableURI = "http://addressable.sink.svc.cluster.local" transformerAddressableName = "testtransformer" ) @@ -373,8 +373,15 @@ func getNonGcpPubSubSource() *eventingsourcesv1alpha1.ContainerSource { }, ObjectMeta: om(testNS, sourceName), Spec: eventingsourcesv1alpha1.ContainerSourceSpec{ - Image: image, - Args: []string(nil), + Template: &corev1.PodTemplateSpec{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{{ + Image: image, + Args: []string(nil), + }, + }, + }, + }, Sink: &corev1.ObjectReference{ Name: addressableName, Kind: addressableKind, diff --git a/contrib/github/cmd/controller/main.go b/contrib/github/cmd/controller/main.go index 65de5ee418..a469c90d8e 100644 --- a/contrib/github/cmd/controller/main.go +++ b/contrib/github/cmd/controller/main.go @@ -21,9 +21,9 @@ import ( "github.com/knative/eventing-contrib/contrib/github/pkg/apis" controller "github.com/knative/eventing-contrib/contrib/github/pkg/reconciler" - "github.com/knative/pkg/logging/logkey" "go.uber.org/zap" "go.uber.org/zap/zapcore" + "knative.dev/pkg/logging/logkey" "sigs.k8s.io/controller-runtime/pkg/client/config" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/runtime/signals" diff --git a/contrib/github/pkg/adapter/adapter_test.go b/contrib/github/pkg/adapter/adapter_test.go index d704aaa8c1..67b6ac5715 100644 --- a/contrib/github/pkg/adapter/adapter_test.go +++ b/contrib/github/pkg/adapter/adapter_test.go @@ -572,7 +572,7 @@ func TestHandleEvent(t *testing.T) { header.Set("X-"+GHHeaderDelivery, eventID) ra.HandleEvent(payload, http.Header(header)) - // TODO(https://github.com/knative/pkg/issues/250): clean this up when there is a shared test client. + // TODO(https://knative.dev/pkg/issues/250): clean this up when there is a shared test client. canonicalizeHeaders(expectedRequest) if diff := cmp.Diff(expectedRequest.Headers, h.header); diff != "" { diff --git a/contrib/github/pkg/apis/sources/v1alpha1/githubsource_types.go b/contrib/github/pkg/apis/sources/v1alpha1/githubsource_types.go index 7d115a0cb1..150b75fb70 100644 --- a/contrib/github/pkg/apis/sources/v1alpha1/githubsource_types.go +++ b/contrib/github/pkg/apis/sources/v1alpha1/githubsource_types.go @@ -19,11 +19,11 @@ package v1alpha1 import ( "fmt" - "github.com/knative/pkg/apis/duck" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" + "knative.dev/pkg/apis/duck" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" ) // Check that GitHubSource can be validated and can be defaulted. diff --git a/contrib/github/pkg/apis/sources/v1alpha1/githubsource_types_test.go b/contrib/github/pkg/apis/sources/v1alpha1/githubsource_types_test.go index 2a64ead3b1..ecd235a98a 100644 --- a/contrib/github/pkg/apis/sources/v1alpha1/githubsource_types_test.go +++ b/contrib/github/pkg/apis/sources/v1alpha1/githubsource_types_test.go @@ -21,8 +21,8 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" corev1 "k8s.io/api/core/v1" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" ) func TestGitHubSourceStatusIsReady(t *testing.T) { diff --git a/contrib/github/pkg/reconciler/githubsource.go b/contrib/github/pkg/reconciler/githubsource.go index b1eae89cd0..0d32dbb8f9 100644 --- a/contrib/github/pkg/reconciler/githubsource.go +++ b/contrib/github/pkg/reconciler/githubsource.go @@ -29,8 +29,7 @@ import ( "github.com/knative/eventing-contrib/pkg/controller/sinks" "github.com/knative/eventing-contrib/pkg/reconciler/eventtype" eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1" - "github.com/knative/pkg/logging" - servingv1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" + servingv1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" "go.uber.org/zap" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -40,6 +39,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/client-go/tools/record" + "knative.dev/pkg/logging" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/manager" @@ -66,7 +66,7 @@ func Add(mgr manager.Manager, logger *zap.SugaredLogger) error { p := &sdk.Provider{ AgentName: controllerAgentName, Parent: &sourcesv1alpha1.GitHubSource{}, - Owns: []runtime.Object{&servingv1alpha1.Service{}, &eventingv1alpha1.EventType{}}, + Owns: []runtime.Object{&servingv1beta1.Service{}, &eventingv1alpha1.EventType{}}, Reconciler: &reconciler{ recorder: mgr.GetRecorder(controllerAgentName), scheme: mgr.GetScheme(), @@ -170,9 +170,9 @@ func (r *reconciler) reconcile(ctx context.Context, source *sourcesv1alpha1.GitH return err } - routeCondition := ksvc.Status.GetCondition(servingv1alpha1.ServiceConditionRoutesReady) - receiveAdapterDomain := ksvc.Status.Domain - if routeCondition != nil && routeCondition.Status == corev1.ConditionTrue && receiveAdapterDomain != "" { + routeCondition := ksvc.Status.GetCondition(servingv1beta1.ServiceConditionReady) + if routeCondition != nil && routeCondition.Status == corev1.ConditionTrue && ksvc.Status.URL != nil { + receiveAdapterDomain := ksvc.Status.URL.Host // TODO: Mark Deployed for the ksvc // TODO: Mark some condition for the webhook status? r.addFinalizer(source) @@ -317,8 +317,8 @@ func parseOwnerRepoFrom(ownerAndRepository string) (string, string, error) { return owner, repo, nil } -func (r *reconciler) getOwnedService(ctx context.Context, source *sourcesv1alpha1.GitHubSource) (*servingv1alpha1.Service, error) { - list := &servingv1alpha1.ServiceList{} +func (r *reconciler) getOwnedService(ctx context.Context, source *sourcesv1alpha1.GitHubSource) (*servingv1beta1.Service, error) { + list := &servingv1beta1.ServiceList{} err := r.client.List(ctx, &client.ListOptions{ Namespace: source.Namespace, LabelSelector: labels.Everything(), @@ -326,7 +326,7 @@ func (r *reconciler) getOwnedService(ctx context.Context, source *sourcesv1alpha // Remove this when it's no longer needed. Raw: &metav1.ListOptions{ TypeMeta: metav1.TypeMeta{ - APIVersion: servingv1alpha1.SchemeGroupVersion.String(), + APIVersion: servingv1beta1.SchemeGroupVersion.String(), Kind: "Service", }, }, @@ -341,7 +341,7 @@ func (r *reconciler) getOwnedService(ctx context.Context, source *sourcesv1alpha return &ksvc, nil } } - return nil, apierrors.NewNotFound(servingv1alpha1.Resource("services"), "") + return nil, apierrors.NewNotFound(servingv1beta1.Resource("services"), "") } func (r *reconciler) reconcileEventTypes(ctx context.Context, source *sourcesv1alpha1.GitHubSource) error { diff --git a/contrib/github/pkg/reconciler/githubsource_test.go b/contrib/github/pkg/reconciler/githubsource_test.go index 75ca23c1f5..8dc31a74d2 100644 --- a/contrib/github/pkg/reconciler/githubsource_test.go +++ b/contrib/github/pkg/reconciler/githubsource_test.go @@ -23,22 +23,23 @@ import ( "strings" "testing" - "github.com/knative/eventing-contrib/contrib/github/pkg/reconciler/resources" - "github.com/knative/eventing-contrib/pkg/reconciler/eventtype" - "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/google/go-cmp/cmp" sourcesv1alpha1 "github.com/knative/eventing-contrib/contrib/github/pkg/apis/sources/v1alpha1" + "github.com/knative/eventing-contrib/contrib/github/pkg/reconciler/resources" controllertesting "github.com/knative/eventing-contrib/pkg/controller/testing" + "github.com/knative/eventing-contrib/pkg/reconciler/eventtype" eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" - servingv1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" + servingv1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/tools/record" + "knative.dev/pkg/apis" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "sigs.k8s.io/controller-runtime/pkg/client" ) var ( @@ -53,7 +54,7 @@ const ( gitHubSourceUID = "2b2219e2-ce67-11e8-b3a3-42010a8a00af" addressableDNS = "addressable.sink.svc.cluster.local" - addressableURI = "http://addressable.sink.svc.cluster.local/" + addressableURI = "http://addressable.sink.svc.cluster.local" addressableName = "testsink" addressableKind = "Sink" @@ -74,11 +75,18 @@ const ( webhookData = "webhookCreatorData" ) +var ( + serviceURL = apis.URL{ + Scheme: "http", + Host: serviceDNS, + } +) + func init() { // Add types to scheme sourcesv1alpha1.SchemeBuilder.AddToScheme(scheme.Scheme) duckv1alpha1.AddToScheme(scheme.Scheme) - servingv1alpha1.AddToScheme(scheme.Scheme) + servingv1beta1.AddToScheme(scheme.Scheme) eventingv1alpha1.AddToScheme(scheme.Scheme) } @@ -186,20 +194,20 @@ var testCases = []controllertesting.TestCase{ }(), // service resource func() runtime.Object { - svc := &servingv1alpha1.Service{ + svc := &servingv1beta1.Service{ ObjectMeta: metav1.ObjectMeta{ Namespace: testNS, Name: serviceName, }, - Status: servingv1alpha1.ServiceStatus{ - Status: duckv1alpha1.Status{ - Conditions: duckv1alpha1.Conditions{{ - Type: servingv1alpha1.ServiceConditionRoutesReady, + Status: servingv1beta1.ServiceStatus{ + Status: duckv1beta1.Status{ + Conditions: duckv1beta1.Conditions{{ + Type: servingv1beta1.ServiceConditionReady, Status: corev1.ConditionTrue, }}, }, - RouteStatusFields: servingv1alpha1.RouteStatusFields{ - Domain: serviceDNS, + RouteStatusFields: servingv1beta1.RouteStatusFields{ + URL: &serviceURL, }, }, } @@ -243,20 +251,20 @@ var testCases = []controllertesting.TestCase{ }(), // service resource func() runtime.Object { - svc := &servingv1alpha1.Service{ + svc := &servingv1beta1.Service{ ObjectMeta: metav1.ObjectMeta{ Namespace: testNS, Name: serviceName, }, - Status: servingv1alpha1.ServiceStatus{ - Status: duckv1alpha1.Status{ - Conditions: duckv1alpha1.Conditions{{ - Type: servingv1alpha1.ServiceConditionRoutesReady, + Status: servingv1beta1.ServiceStatus{ + Status: duckv1beta1.Status{ + Conditions: duckv1beta1.Conditions{{ + Type: servingv1beta1.ServiceConditionReady, Status: corev1.ConditionTrue, }}, }, - RouteStatusFields: servingv1alpha1.RouteStatusFields{ - Domain: serviceDNS, + RouteStatusFields: servingv1beta1.RouteStatusFields{ + URL: &serviceURL, }, }, } @@ -302,20 +310,20 @@ var testCases = []controllertesting.TestCase{ }(), // service resource func() runtime.Object { - svc := &servingv1alpha1.Service{ + svc := &servingv1beta1.Service{ ObjectMeta: metav1.ObjectMeta{ Namespace: testNS, Name: serviceName, }, - Status: servingv1alpha1.ServiceStatus{ - Status: duckv1alpha1.Status{ - Conditions: duckv1alpha1.Conditions{{ - Type: servingv1alpha1.ServiceConditionRoutesReady, + Status: servingv1beta1.ServiceStatus{ + Status: duckv1beta1.Status{ + Conditions: duckv1beta1.Conditions{{ + Type: servingv1beta1.ServiceConditionReady, Status: corev1.ConditionTrue, }}, }, - RouteStatusFields: servingv1alpha1.RouteStatusFields{ - Domain: serviceDNS, + RouteStatusFields: servingv1beta1.RouteStatusFields{ + URL: &serviceURL, }, }, } @@ -409,20 +417,20 @@ var testCases = []controllertesting.TestCase{ }(), // service resource func() runtime.Object { - svc := &servingv1alpha1.Service{ + svc := &servingv1beta1.Service{ ObjectMeta: metav1.ObjectMeta{ Namespace: testNS, Name: serviceName, }, - Status: servingv1alpha1.ServiceStatus{ - Status: duckv1alpha1.Status{ - Conditions: duckv1alpha1.Conditions{{ - Type: servingv1alpha1.ServiceConditionRoutesReady, + Status: servingv1beta1.ServiceStatus{ + Status: duckv1beta1.Status{ + Conditions: duckv1beta1.Conditions{{ + Type: servingv1beta1.ServiceConditionReady, Status: corev1.ConditionTrue, }}, }, - RouteStatusFields: servingv1alpha1.RouteStatusFields{ - Domain: serviceDNS, + RouteStatusFields: servingv1beta1.RouteStatusFields{ + URL: &serviceURL, }, }, } @@ -534,20 +542,20 @@ var testCases = []controllertesting.TestCase{ }(), // service resource func() runtime.Object { - svc := &servingv1alpha1.Service{ + svc := &servingv1beta1.Service{ ObjectMeta: metav1.ObjectMeta{ Namespace: testNS, Name: serviceName, }, - Status: servingv1alpha1.ServiceStatus{ - Status: duckv1alpha1.Status{ - Conditions: duckv1alpha1.Conditions{{ - Type: servingv1alpha1.ServiceConditionRoutesReady, + Status: servingv1beta1.ServiceStatus{ + Status: duckv1beta1.Status{ + Conditions: duckv1beta1.Conditions{{ + Type: servingv1beta1.ServiceConditionReady, Status: corev1.ConditionTrue, }}, }, - RouteStatusFields: servingv1alpha1.RouteStatusFields{ - Domain: serviceDNS, + RouteStatusFields: servingv1beta1.RouteStatusFields{ + URL: &serviceURL, }, }, } @@ -592,20 +600,20 @@ var testCases = []controllertesting.TestCase{ }(), // service resource func() runtime.Object { - svc := &servingv1alpha1.Service{ + svc := &servingv1beta1.Service{ ObjectMeta: metav1.ObjectMeta{ Namespace: testNS, Name: serviceName, }, - Status: servingv1alpha1.ServiceStatus{ - Status: duckv1alpha1.Status{ - Conditions: duckv1alpha1.Conditions{{ - Type: servingv1alpha1.ServiceConditionRoutesReady, + Status: servingv1beta1.ServiceStatus{ + Status: duckv1beta1.Status{ + Conditions: duckv1beta1.Conditions{{ + Type: servingv1beta1.ServiceConditionReady, Status: corev1.ConditionTrue, }}, }, - RouteStatusFields: servingv1alpha1.RouteStatusFields{ - Domain: serviceDNS, + RouteStatusFields: servingv1beta1.RouteStatusFields{ + URL: &serviceURL, }, }, } @@ -647,20 +655,20 @@ var testCases = []controllertesting.TestCase{ }(), // service resource func() runtime.Object { - svc := &servingv1alpha1.Service{ + svc := &servingv1beta1.Service{ ObjectMeta: metav1.ObjectMeta{ Namespace: testNS, Name: serviceName, }, - Status: servingv1alpha1.ServiceStatus{ - Status: duckv1alpha1.Status{ - Conditions: duckv1alpha1.Conditions{{ - Type: servingv1alpha1.ServiceConditionRoutesReady, + Status: servingv1beta1.ServiceStatus{ + Status: duckv1beta1.Status{ + Conditions: duckv1beta1.Conditions{{ + Type: servingv1beta1.ServiceConditionReady, Status: corev1.ConditionTrue, }}, }, - RouteStatusFields: servingv1alpha1.RouteStatusFields{ - Domain: serviceDNS, + RouteStatusFields: servingv1beta1.RouteStatusFields{ + URL: &serviceURL, }, }, } @@ -705,20 +713,20 @@ var testCases = []controllertesting.TestCase{ }(), // service resource func() runtime.Object { - svc := &servingv1alpha1.Service{ + svc := &servingv1beta1.Service{ ObjectMeta: metav1.ObjectMeta{ Namespace: testNS, Name: serviceName, }, - Status: servingv1alpha1.ServiceStatus{ - Status: duckv1alpha1.Status{ - Conditions: duckv1alpha1.Conditions{{ - Type: servingv1alpha1.ServiceConditionRoutesReady, + Status: servingv1beta1.ServiceStatus{ + Status: duckv1beta1.Status{ + Conditions: duckv1beta1.Conditions{{ + Type: servingv1beta1.ServiceConditionReady, Status: corev1.ConditionTrue, }}, }, - RouteStatusFields: servingv1alpha1.RouteStatusFields{ - Domain: serviceDNS, + RouteStatusFields: servingv1beta1.RouteStatusFields{ + URL: &serviceURL, }, }, } @@ -766,20 +774,20 @@ var testCases = []controllertesting.TestCase{ }(), // service resource func() runtime.Object { - svc := &servingv1alpha1.Service{ + svc := &servingv1beta1.Service{ ObjectMeta: metav1.ObjectMeta{ Namespace: testNS, Name: serviceName, }, - Status: servingv1alpha1.ServiceStatus{ - Status: duckv1alpha1.Status{ - Conditions: duckv1alpha1.Conditions{{ - Type: servingv1alpha1.ServiceConditionRoutesReady, + Status: servingv1beta1.ServiceStatus{ + Status: duckv1beta1.Status{ + Conditions: duckv1beta1.Conditions{{ + Type: servingv1beta1.ServiceConditionReady, Status: corev1.ConditionTrue, }}, }, - RouteStatusFields: servingv1alpha1.RouteStatusFields{ - Domain: serviceDNS, + RouteStatusFields: servingv1beta1.RouteStatusFields{ + URL: &serviceURL, }, }, } diff --git a/contrib/github/pkg/reconciler/resources/service.go b/contrib/github/pkg/reconciler/resources/service.go index 2c9eabd62b..6d7056633f 100644 --- a/contrib/github/pkg/reconciler/resources/service.go +++ b/contrib/github/pkg/reconciler/resources/service.go @@ -23,12 +23,12 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" sourcesv1alpha1 "github.com/knative/eventing-contrib/contrib/github/pkg/apis/sources/v1alpha1" - servingv1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" + servingv1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" ) // MakeService generates, but does not create, a Service for the given // GitHubSource. -func MakeService(source *sourcesv1alpha1.GitHubSource, receiveAdapterImage string) *servingv1alpha1.Service { +func MakeService(source *sourcesv1alpha1.GitHubSource, receiveAdapterImage string) *servingv1beta1.Service { labels := map[string]string{ "receive-adapter": "github", } @@ -50,23 +50,22 @@ func MakeService(source *sourcesv1alpha1.GitHubSource, receiveAdapterImage strin }, } containerArgs := []string{fmt.Sprintf("--sink=%s", sinkURI)} - return &servingv1alpha1.Service{ + return &servingv1beta1.Service{ ObjectMeta: metav1.ObjectMeta{ GenerateName: fmt.Sprintf("%s-", source.Name), Namespace: source.Namespace, Labels: labels, }, - Spec: servingv1alpha1.ServiceSpec{ - RunLatest: &servingv1alpha1.RunLatestType{ - Configuration: servingv1alpha1.ConfigurationSpec{ - RevisionTemplate: servingv1alpha1.RevisionTemplateSpec{ - Spec: servingv1alpha1.RevisionSpec{ - ServiceAccountName: source.Spec.ServiceAccountName, - Container: corev1.Container{ + Spec: servingv1beta1.ServiceSpec{ + ConfigurationSpec: servingv1beta1.ConfigurationSpec{ + Template: servingv1beta1.RevisionTemplateSpec{ + Spec: servingv1beta1.RevisionSpec{ + PodSpec: corev1.PodSpec{ + Containers: []corev1.Container{{ Image: receiveAdapterImage, Env: env, Args: containerArgs, - }, + }}, }, }, }, diff --git a/contrib/github/pkg/reconciler/webhook_client.go b/contrib/github/pkg/reconciler/webhook_client.go index e99791e73b..a79fbb758a 100644 --- a/contrib/github/pkg/reconciler/webhook_client.go +++ b/contrib/github/pkg/reconciler/webhook_client.go @@ -23,8 +23,8 @@ import ( "strconv" ghclient "github.com/google/go-github/github" - "github.com/knative/pkg/logging" "golang.org/x/oauth2" + "knative.dev/pkg/logging" ) type webhookOptions struct { diff --git a/kafka/source/cmd/controller/main.go b/kafka/source/cmd/controller/main.go index efb6633de4..abb93845a1 100644 --- a/kafka/source/cmd/controller/main.go +++ b/kafka/source/cmd/controller/main.go @@ -21,10 +21,10 @@ import ( "github.com/knative/eventing-contrib/kafka/source/pkg/apis" controller "github.com/knative/eventing-contrib/kafka/source/pkg/reconciler" - "github.com/knative/pkg/logging/logkey" "go.uber.org/zap" "go.uber.org/zap/zapcore" _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" + "knative.dev/pkg/logging/logkey" "sigs.k8s.io/controller-runtime/pkg/client/config" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/runtime/signals" diff --git a/kafka/source/cmd/receive_adapter/main.go b/kafka/source/cmd/receive_adapter/main.go index bdba4c15a9..f5235c1a10 100644 --- a/kafka/source/cmd/receive_adapter/main.go +++ b/kafka/source/cmd/receive_adapter/main.go @@ -29,8 +29,8 @@ import ( "golang.org/x/net/context" - "github.com/knative/pkg/logging" - "github.com/knative/pkg/signals" + "knative.dev/pkg/logging" + "knative.dev/pkg/signals" ) const ( diff --git a/kafka/source/pkg/adapter/adapter.go b/kafka/source/pkg/adapter/adapter.go index 2f259625eb..21a6c9b3fc 100644 --- a/kafka/source/pkg/adapter/adapter.go +++ b/kafka/source/pkg/adapter/adapter.go @@ -30,9 +30,9 @@ import ( "github.com/cloudevents/sdk-go/pkg/cloudevents/client" sourcesv1alpha1 "github.com/knative/eventing-contrib/kafka/source/pkg/apis/sources/v1alpha1" "github.com/knative/eventing-contrib/pkg/kncloudevents" - "github.com/knative/pkg/logging" "go.uber.org/zap" "golang.org/x/net/context" + "knative.dev/pkg/logging" ) type AdapterSASL struct { diff --git a/kafka/source/pkg/apis/sources/v1alpha1/kafka_types.go b/kafka/source/pkg/apis/sources/v1alpha1/kafka_types.go index fded31725e..6d1b8bf15a 100644 --- a/kafka/source/pkg/apis/sources/v1alpha1/kafka_types.go +++ b/kafka/source/pkg/apis/sources/v1alpha1/kafka_types.go @@ -19,12 +19,12 @@ package v1alpha1 import ( "fmt" - "github.com/knative/pkg/apis" - "github.com/knative/pkg/apis/duck" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" ) // +genclient diff --git a/kafka/source/pkg/apis/sources/v1alpha1/kafka_types_test.go b/kafka/source/pkg/apis/sources/v1alpha1/kafka_types_test.go index 0e60c4308a..613e85a6bf 100644 --- a/kafka/source/pkg/apis/sources/v1alpha1/kafka_types_test.go +++ b/kafka/source/pkg/apis/sources/v1alpha1/kafka_types_test.go @@ -21,8 +21,8 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" corev1 "k8s.io/api/core/v1" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" ) func TestKafkaSourceStatusIsReady(t *testing.T) { diff --git a/kafka/source/pkg/apis/sources/v1alpha1/kafka_validation.go b/kafka/source/pkg/apis/sources/v1alpha1/kafka_validation.go index 14df6532ef..111acccad4 100644 --- a/kafka/source/pkg/apis/sources/v1alpha1/kafka_validation.go +++ b/kafka/source/pkg/apis/sources/v1alpha1/kafka_validation.go @@ -20,7 +20,7 @@ import ( "context" "github.com/google/go-cmp/cmp" - "github.com/knative/pkg/apis" + "knative.dev/pkg/apis" ) func (current *KafkaSource) CheckImmutableFields(ctx context.Context, og apis.Immutable) *apis.FieldError { diff --git a/kafka/source/pkg/reconciler/kafkasource.go b/kafka/source/pkg/reconciler/kafkasource.go index 156e1504ef..770b52769e 100644 --- a/kafka/source/pkg/reconciler/kafkasource.go +++ b/kafka/source/pkg/reconciler/kafkasource.go @@ -29,7 +29,6 @@ import ( "github.com/knative/eventing-contrib/pkg/controller/sinks" "github.com/knative/eventing-contrib/pkg/reconciler/eventtype" eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1" - "github.com/knative/pkg/logging" "go.uber.org/zap" v1 "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/api/equality" @@ -39,6 +38,7 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" + "knative.dev/pkg/logging" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" diff --git a/kafka/source/pkg/reconciler/kafkasource_test.go b/kafka/source/pkg/reconciler/kafkasource_test.go index 87d76cf07e..4192736470 100644 --- a/kafka/source/pkg/reconciler/kafkasource_test.go +++ b/kafka/source/pkg/reconciler/kafkasource_test.go @@ -23,19 +23,18 @@ import ( "strings" "testing" - "github.com/knative/eventing-contrib/pkg/reconciler/eventtype" - sourcesv1alpha1 "github.com/knative/eventing-contrib/kafka/source/pkg/apis/sources/v1alpha1" controllertesting "github.com/knative/eventing-contrib/pkg/controller/testing" + "github.com/knative/eventing-contrib/pkg/reconciler/eventtype" eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1" eventingsourcesv1alpha1 "github.com/knative/eventing/pkg/apis/sources/v1alpha1" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" v1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/kubernetes/scheme" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -62,7 +61,7 @@ const ( brokerKind = "Broker" addressableAPIVersion = "duck.knative.dev/v1alpha1" addressableDNS = "addressable.sink.svc.cluster.local" - addressableURI = "http://addressable.sink.svc.cluster.local/" + addressableURI = "http://addressable.sink.svc.cluster.local" ) func init() { @@ -296,8 +295,15 @@ func getNonKafkaSource() *eventingsourcesv1alpha1.ContainerSource { }, ObjectMeta: om(testNS, sourceName), Spec: eventingsourcesv1alpha1.ContainerSourceSpec{ - Image: image, - Args: []string(nil), + Template: &corev1.PodTemplateSpec{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{{ + Image: image, + Args: []string(nil), + }, + }, + }, + }, Sink: &corev1.ObjectReference{ Name: addressableName, Kind: addressableKind, diff --git a/kafka/source/pkg/reconciler/resources/receive_adapter_test.go b/kafka/source/pkg/reconciler/resources/receive_adapter_test.go index 31aa148040..9c8708d24c 100644 --- a/kafka/source/pkg/reconciler/resources/receive_adapter_test.go +++ b/kafka/source/pkg/reconciler/resources/receive_adapter_test.go @@ -20,11 +20,11 @@ import ( "testing" "github.com/knative/eventing-contrib/kafka/source/pkg/apis/sources/v1alpha1" - "github.com/knative/pkg/kmp" v1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/pkg/kmp" ) func TestMakeReceiveAdapter(t *testing.T) { diff --git a/pkg/controller/sdk/reconciler.go b/pkg/controller/sdk/reconciler.go index 89f9922f69..496fc194b8 100644 --- a/pkg/controller/sdk/reconciler.go +++ b/pkg/controller/sdk/reconciler.go @@ -21,12 +21,12 @@ import ( "go.uber.org/zap" - "github.com/knative/pkg/logging" "k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/rest" "k8s.io/client-go/tools/record" + "knative.dev/pkg/logging" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/runtime/inject" diff --git a/pkg/controller/sdk/status_accessor_test.go b/pkg/controller/sdk/status_accessor_test.go index 24018e975b..99c48d6612 100644 --- a/pkg/controller/sdk/status_accessor_test.go +++ b/pkg/controller/sdk/status_accessor_test.go @@ -21,7 +21,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/knative/eventing-contrib/contrib/awssqs/pkg/apis/sources/v1alpha1" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" ) func TestNewReflectedStatusAccessor(t *testing.T) { diff --git a/pkg/controller/sinks/sinks.go b/pkg/controller/sinks/sinks.go index c5eb8ffb15..cf0b9828eb 100644 --- a/pkg/controller/sinks/sinks.go +++ b/pkg/controller/sinks/sinks.go @@ -20,10 +20,10 @@ import ( "context" "fmt" - "github.com/knative/pkg/apis/duck" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "knative.dev/pkg/apis/duck" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -57,9 +57,9 @@ func GetSinkURI(ctx context.Context, c client.Client, sink *corev1.ObjectReferen return "", fmt.Errorf("sink %s does not contain address", objIdentifier) } - if t.Status.Address.Hostname == "" { + url := t.Status.Address.GetURL() + if url.Host == "" { return "", fmt.Errorf("sink %s contains an empty hostname", objIdentifier) } - - return fmt.Sprintf("http://%s/", t.Status.Address.Hostname), nil + return url.String(), nil } diff --git a/pkg/controller/sinks/sinks_test.go b/pkg/controller/sinks/sinks_test.go index 8031f7298f..0e74d210c7 100644 --- a/pkg/controller/sinks/sinks_test.go +++ b/pkg/controller/sinks/sinks_test.go @@ -22,16 +22,17 @@ import ( "testing" "github.com/google/go-cmp/cmp" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/kubernetes/scheme" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" "sigs.k8s.io/controller-runtime/pkg/client/fake" ) var ( addressableDNS = "addressable.sink.svc.cluster.local" + addressableURL = fmt.Sprintf("http://%s", addressableDNS) addressableName = "testsink" addressableKind = "Sink" @@ -52,7 +53,7 @@ var ( func init() { // Add types to scheme - duckv1alpha1.AddToScheme(scheme.Scheme) + _ = duckv1alpha1.AddToScheme(scheme.Scheme) } func TestGetSinkURI(t *testing.T) { @@ -63,13 +64,21 @@ func TestGetSinkURI(t *testing.T) { wantErr error ref *corev1.ObjectReference }{ - "happy": { + "happy - hostname": { + objects: []runtime.Object{ + getAddressableWithHostname(), + }, + namespace: testNS, + ref: getAddressableRef(), + want: addressableURL, + }, + "happy - uri": { objects: []runtime.Object{ getAddressable(), }, namespace: testNS, ref: getAddressableRef(), - want: fmt.Sprintf("http://%s/", addressableDNS), + want: addressableURL, }, "nil hostname": { objects: []runtime.Object{ @@ -165,13 +174,23 @@ func getAddressable() *unstructured.Unstructured { }, "status": map[string]interface{}{ "address": map[string]interface{}{ - "hostname": addressableDNS, + "url": addressableURL, }, }, }, } } +func getAddressableWithHostname() *unstructured.Unstructured { + a := getAddressable() + a.Object["status"] = map[string]interface{}{ + "address": map[string]interface{}{ + "hostname": addressableDNS, + }, + } + return a +} + func getAddressableNoStatus() *unstructured.Unstructured { return &unstructured.Unstructured{ Object: map[string]interface{}{ diff --git a/pkg/controller/testing/table.go b/pkg/controller/testing/table.go index 7a70746df6..fbf919f274 100644 --- a/pkg/controller/testing/table.go +++ b/pkg/controller/testing/table.go @@ -25,7 +25,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/knative/eventing-contrib/pkg/controller/sdk" - "github.com/knative/pkg/apis" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -34,6 +33,7 @@ import ( dynamicfake "k8s.io/client-go/dynamic/fake" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/tools/cache" + "knative.dev/pkg/apis" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/reconcile" diff --git a/test/cleanup.go b/test/cleanup.go index 925d43bf7a..2e710449d2 100644 --- a/test/cleanup.go +++ b/test/cleanup.go @@ -24,7 +24,7 @@ import ( "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/dynamic" - "github.com/knative/pkg/test/logging" + "knative.dev/pkg/test/logging" ) // Cleaner holds resources that will be cleaned after test diff --git a/test/clients.go b/test/clients.go index 846bffb043..c1b02ac148 100644 --- a/test/clients.go +++ b/test/clients.go @@ -19,9 +19,9 @@ package test import ( eventing "github.com/knative/eventing/pkg/client/clientset/versioned" - "github.com/knative/pkg/test" serving "github.com/knative/serving/pkg/client/clientset/versioned" "k8s.io/client-go/dynamic" + "knative.dev/pkg/test" ) // Clients holds instances of interfaces for making requests to Knative. diff --git a/test/crd.go b/test/crd.go index a4fbefa674..35177b3e0e 100644 --- a/test/crd.go +++ b/test/crd.go @@ -19,10 +19,10 @@ package test import ( "github.com/knative/eventing/pkg/apis/eventing/v1alpha1" - pkgTest "github.com/knative/pkg/test" - servingv1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" + servingv1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + pkgTest "knative.dev/pkg/test" ) const ( @@ -30,14 +30,14 @@ const ( ) // Route returns a Route object in namespace -func Route(name string, namespace string, configName string) *servingv1alpha1.Route { - return &servingv1alpha1.Route{ +func Route(name string, namespace string, configName string) *servingv1beta1.Route { + return &servingv1beta1.Route{ ObjectMeta: metav1.ObjectMeta{ Namespace: namespace, Name: name, }, - Spec: servingv1alpha1.RouteSpec{ - Traffic: []servingv1alpha1.TrafficTarget{ + Spec: servingv1beta1.RouteSpec{ + Traffic: []servingv1beta1.TrafficTarget{ { ConfigurationName: configName, Percent: 100, @@ -49,20 +49,22 @@ func Route(name string, namespace string, configName string) *servingv1alpha1.Ro // Configuration returns a Configuration object in namespace with name // that uses the image specified by imagePath. -func Configuration(name string, namespace string, imagePath string) *servingv1alpha1.Configuration { - return &servingv1alpha1.Configuration{ +func Configuration(name string, namespace string, imagePath string) *servingv1beta1.Configuration { + return &servingv1beta1.Configuration{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, }, - Spec: servingv1alpha1.ConfigurationSpec{ - RevisionTemplate: servingv1alpha1.RevisionTemplateSpec{ + Spec: servingv1beta1.ConfigurationSpec{ + Template: servingv1beta1.RevisionTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{"knative.dev/type": "container"}, }, - Spec: servingv1alpha1.RevisionSpec{ - Container: corev1.Container{ - Image: imagePath, + Spec: servingv1beta1.RevisionSpec{ + PodSpec: corev1.PodSpec{ + Containers: []corev1.Container{{ + Image: imagePath, + }}, }, }, }, diff --git a/test/crd_checks.go b/test/crd_checks.go index c2763db964..ed94e37b9d 100644 --- a/test/crd_checks.go +++ b/test/crd_checks.go @@ -23,8 +23,8 @@ import ( "fmt" "time" - servingV1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" - servingtyped "github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1" + servingv1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + servingtyped "github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1" "go.opencensus.io/trace" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" @@ -39,7 +39,7 @@ const ( // interval until inState returns `true` indicating it is done, returns an // error or timeout. desc will be used to name the metric that is emitted to // track how long it took for name to get into the state checked by inState. -func WaitForRouteState(client servingtyped.RouteInterface, name string, inState func(r *servingV1alpha1.Route) (bool, error), desc string) error { +func WaitForRouteState(client servingtyped.RouteInterface, name string, inState func(r *servingv1beta1.Route) (bool, error), desc string) error { metricName := fmt.Sprintf("WaitForRouteState/%s/%s", name, desc) _, span := trace.StartSpan(context.Background(), metricName) defer span.End() diff --git a/test/e2e/e2e.go b/test/e2e/e2e.go index 21f69d432a..3e83abff2b 100644 --- a/test/e2e/e2e.go +++ b/test/e2e/e2e.go @@ -21,12 +21,12 @@ import ( "github.com/knative/eventing-contrib/test" "github.com/knative/eventing/pkg/apis/eventing/v1alpha1" - pkgTest "github.com/knative/pkg/test" - "github.com/knative/pkg/test/logging" - servingV1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" + servingv1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" corev1 "k8s.io/api/core/v1" rbacV1beta1 "k8s.io/api/rbac/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + pkgTest "knative.dev/pkg/test" + "knative.dev/pkg/test/logging" // Mysteriously required to support GCP auth (required by k8s libs). // Apparently just importing it is enough. @_@ side effects @_@. @@ -67,21 +67,21 @@ func TearDown(clients *test.Clients, cleaner *test.Cleaner, logger logging.Forma // CreateRouteAndConfig will create Route and Config objects using clients. // The Config object will serve requests to a container started from the image at imagePath. func CreateRouteAndConfig(clients *test.Clients, logger logging.FormatLogger, cleaner *test.Cleaner, name string, imagePath string) error { - configurations := clients.Serving.ServingV1alpha1().Configurations(pkgTest.Flags.Namespace) + configurations := clients.Serving.ServingV1beta1().Configurations(pkgTest.Flags.Namespace) config, err := configurations.Create( test.Configuration(name, pkgTest.Flags.Namespace, imagePath)) if err != nil { return err } - cleaner.Add(servingV1alpha1.SchemeGroupVersion.Group, servingV1alpha1.SchemeGroupVersion.Version, "configurations", pkgTest.Flags.Namespace, config.ObjectMeta.Name) + cleaner.Add(servingv1beta1.SchemeGroupVersion.Group, servingv1beta1.SchemeGroupVersion.Version, "configurations", pkgTest.Flags.Namespace, config.ObjectMeta.Name) - routes := clients.Serving.ServingV1alpha1().Routes(pkgTest.Flags.Namespace) + routes := clients.Serving.ServingV1beta1().Routes(pkgTest.Flags.Namespace) route, err := routes.Create( test.Route(name, pkgTest.Flags.Namespace, name)) if err != nil { return err } - cleaner.Add(servingV1alpha1.SchemeGroupVersion.Group, servingV1alpha1.SchemeGroupVersion.Version, "routes", pkgTest.Flags.Namespace, route.ObjectMeta.Name) + cleaner.Add(servingv1beta1.SchemeGroupVersion.Group, servingv1beta1.SchemeGroupVersion.Version, "routes", pkgTest.Flags.Namespace, route.ObjectMeta.Name) return nil } @@ -91,7 +91,7 @@ func WithRouteReady(clients *test.Clients, logger logging.FormatLogger, cleaner if err != nil { return err } - routes := clients.Serving.ServingV1alpha1().Routes(pkgTest.Flags.Namespace) + routes := clients.Serving.ServingV1beta1().Routes(pkgTest.Flags.Namespace) if err := test.WaitForRouteState(routes, name, test.IsRouteReady, "RouteIsReady"); err != nil { return err } diff --git a/test/e2e_flags.go b/test/e2e_flags.go index 3259c925f3..fce0eefe2d 100644 --- a/test/e2e_flags.go +++ b/test/e2e_flags.go @@ -21,8 +21,8 @@ package test import ( "flag" - pkgTest "github.com/knative/pkg/test" - "github.com/knative/pkg/test/logging" + pkgTest "knative.dev/pkg/test" + "knative.dev/pkg/test/logging" ) // EventingSourcesFlags holds the command line flags specific to knative/eventing-contrib diff --git a/test/states.go b/test/states.go index 3147430eeb..5190e6e533 100644 --- a/test/states.go +++ b/test/states.go @@ -16,7 +16,7 @@ limitations under the License. package test import ( - "github.com/knative/serving/pkg/apis/serving/v1alpha1" + "github.com/knative/serving/pkg/apis/serving/v1beta1" ) // states contains functions for asserting against the state of Knative Serving @@ -26,18 +26,18 @@ import ( // IsRevisionReady will check the status conditions of the revision and return true if the revision is // ready to serve traffic. It will return false if the status indicates a state other than deploying // or being ready. It will also return false if the type of the condition is unexpected. -func IsRevisionReady(r *v1alpha1.Revision) (bool, error) { +func IsRevisionReady(r *v1beta1.Revision) (bool, error) { return r.Status.IsReady(), nil } // IsServiceReady will check the status conditions of the service and return true if the service is // ready. This means that its configurations and routes have all reported ready. -func IsServiceReady(s *v1alpha1.Service) (bool, error) { +func IsServiceReady(s *v1beta1.Service) (bool, error) { return s.Status.IsReady(), nil } // IsRouteReady will check the status conditions of the route and return true if the route is // ready. -func IsRouteReady(r *v1alpha1.Route) (bool, error) { +func IsRouteReady(r *v1beta1.Route) (bool, error) { return r.Status.IsReady(), nil } diff --git a/third_party/VENDOR-LICENSE b/third_party/VENDOR-LICENSE index a0aa3d6456..443735f06c 100644 --- a/third_party/VENDOR-LICENSE +++ b/third_party/VENDOR-LICENSE @@ -3576,422 +3576,7 @@ SOFTWARE. =========================================================== -Import: github.com/knative/eventing-contrib/vendor/github.com/knative/build - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. - - - -=========================================================== -Import: github.com/knative/eventing-contrib/vendor/github.com/knative/eventing - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. - - - -=========================================================== -Import: github.com/knative/eventing-contrib/vendor/github.com/knative/pkg +Import: github.com/knative/eventing-contrib/vendor/github.com/knative/eventing Apache License Version 2.0, January 2004 @@ -8299,6 +7884,213 @@ Import: github.com/knative/eventing-contrib/vendor/k8s.io/kube-openapi +=========================================================== +Import: github.com/knative/eventing-contrib/vendor/knative.dev/pkg + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. + + + =========================================================== Import: github.com/knative/eventing-contrib/vendor/sigs.k8s.io/controller-runtime diff --git a/vendor/github.com/google/go-containerregistry/cmd/ko/test/kodata/kenobi b/vendor/github.com/google/go-containerregistry/cmd/ko/test/kodata/kenobi deleted file mode 120000 index 5d7eddc7f3..0000000000 --- a/vendor/github.com/google/go-containerregistry/cmd/ko/test/kodata/kenobi +++ /dev/null @@ -1 +0,0 @@ -../kenobi \ No newline at end of file diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/check.go b/vendor/github.com/google/go-containerregistry/pkg/name/check.go index 01a25d554a..01b03e5626 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/name/check.go +++ b/vendor/github.com/google/go-containerregistry/pkg/name/check.go @@ -19,15 +19,6 @@ import ( "unicode/utf8" ) -// Strictness defines the level of strictness for name validation. -type Strictness int - -// Enums for CRUD operations. -const ( - StrictValidation Strictness = iota - WeakValidation -) - // stripRunesFn returns a function which returns -1 (i.e. a value which // signals deletion in strings.Map) for runes in 'runes', and the rune otherwise. func stripRunesFn(runes string) func(rune) rune { diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/digest.go b/vendor/github.com/google/go-containerregistry/pkg/name/digest.go index ea6287a847..2dc0f7f371 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/name/digest.go +++ b/vendor/github.com/google/go-containerregistry/pkg/name/digest.go @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package name defines structured types for representing image references. package name import ( @@ -63,8 +62,8 @@ func checkDigest(name string) error { return checkElement("digest", name, digestChars, 7+64, 7+64) } -// NewDigest returns a new Digest representing the given name, according to the given strictness. -func NewDigest(name string, strict Strictness) (Digest, error) { +// NewDigest returns a new Digest representing the given name. +func NewDigest(name string, opts ...Option) (Digest, error) { // Split on "@" parts := strings.Split(name, digestDelim) if len(parts) != 2 { @@ -73,17 +72,17 @@ func NewDigest(name string, strict Strictness) (Digest, error) { base := parts[0] digest := parts[1] - // We don't require a digest, but if we get one check it's valid, - // even when not being strict. - // If we are being strict, we want to validate the digest regardless in case - // it's empty. - if digest != "" || strict == StrictValidation { - if err := checkDigest(digest); err != nil { - return Digest{}, err - } + // Always check that the digest is valid. + if err := checkDigest(digest); err != nil { + return Digest{}, err + } + + tag, err := NewTag(base, opts...) + if err == nil { + base = tag.Repository.Name() } - repo, err := NewRepository(base, strict) + repo, err := NewRepository(base, opts...) if err != nil { return Digest{}, err } diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/doc.go b/vendor/github.com/google/go-containerregistry/pkg/name/doc.go new file mode 100644 index 0000000000..b294794dc1 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/name/doc.go @@ -0,0 +1,42 @@ +// Copyright 2018 Google LLC All Rights Reserved. +// +// 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 name defines structured types for representing image references. +// +// What's in a name? For image references, not nearly enough! +// +// Image references look a lot like URLs, but they differ in that they don't +// contain the scheme (http or https), they can end with a :tag or a @digest +// (the latter being validated), and they perform defaulting for missing +// components. +// +// Since image references don't contain the scheme, we do our best to infer +// if we use http or https from the given hostname. We allow http fallback for +// any host that looks like localhost (localhost, 127.0.0.1, ::1), ends in +// ".local", or is in the "private" address space per RFC 1918. For everything +// else, we assume https only. To override this heuristic, use the Insecure +// option. +// +// Image references with a digest signal to us that we should verify the content +// of the image matches the digest. E.g. when pulling a Digest reference, we'll +// calculate the sha256 of the manifest returned by the registry and error out +// if it doesn't match what we asked for. +// +// For defaulting, we interpret "ubuntu" as +// "index.docker.io/library/ubuntu:latest" because we add the missing repo +// "library", the missing registry "index.docker.io", and the missing tag +// "latest". To disable this defaulting, use the StrictValidation option. This +// is useful e.g. to only allow image references that explicitly set a tag or +// digest, so that you don't accidentally pull "latest". +package name diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/options.go b/vendor/github.com/google/go-containerregistry/pkg/name/options.go new file mode 100644 index 0000000000..98beaae110 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/name/options.go @@ -0,0 +1,49 @@ +// Copyright 2018 Google LLC All Rights Reserved. +// +// 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 name + +type options struct { + strict bool // weak by default + insecure bool // secure by default +} + +func makeOptions(opts ...Option) options { + opt := options{} + for _, o := range opts { + o(&opt) + } + return opt +} + +// Option is a functional option for name parsing. +type Option func(*options) + +// StrictValidation is an Option that requires image references to be fully +// specified; i.e. no defaulting for registry (dockerhub), repo (library), +// or tag (latest). +func StrictValidation(opts *options) { + opts.strict = true +} + +// WeakValidation is an Option that sets defaults when parsing names, see +// StrictValidation. +func WeakValidation(opts *options) { + opts.strict = false +} + +// Insecure is an Option that allows image references to be fetched without TLS. +func Insecure(opts *options) { + opts.insecure = true +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/ref.go b/vendor/github.com/google/go-containerregistry/pkg/name/ref.go index 58775daa30..cca3034053 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/name/ref.go +++ b/vendor/github.com/google/go-containerregistry/pkg/name/ref.go @@ -38,11 +38,11 @@ type Reference interface { } // ParseReference parses the string as a reference, either by tag or digest. -func ParseReference(s string, strict Strictness) (Reference, error) { - if t, err := NewTag(s, strict); err == nil { +func ParseReference(s string, opts ...Option) (Reference, error) { + if t, err := NewTag(s, opts...); err == nil { return t, nil } - if d, err := NewDigest(s, strict); err == nil { + if d, err := NewDigest(s, opts...); err == nil { return d, nil } // TODO: Combine above errors into something more useful? diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/registry.go b/vendor/github.com/google/go-containerregistry/pkg/name/registry.go index ab74193080..c12dd46c2c 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/name/registry.go +++ b/vendor/github.com/google/go-containerregistry/pkg/name/registry.go @@ -114,8 +114,9 @@ func checkRegistry(name string) error { // NewRegistry returns a Registry based on the given name. // Strict validation requires explicit, valid RFC 3986 URI authorities to be given. -func NewRegistry(name string, strict Strictness) (Registry, error) { - if strict == StrictValidation && len(name) == 0 { +func NewRegistry(name string, opts ...Option) (Registry, error) { + opt := makeOptions(opts...) + if opt.strict && len(name) == 0 { return Registry{}, NewErrBadName("strict validation requires the registry to be explicitly defined") } @@ -129,16 +130,13 @@ func NewRegistry(name string, strict Strictness) (Registry, error) { name = DefaultRegistry } - return Registry{registry: name}, nil + return Registry{registry: name, insecure: opt.insecure}, nil } // NewInsecureRegistry returns an Insecure Registry based on the given name. -// Strict validation requires explicit, valid RFC 3986 URI authorities to be given. -func NewInsecureRegistry(name string, strict Strictness) (Registry, error) { - reg, err := NewRegistry(name, strict) - if err != nil { - return Registry{}, err - } - reg.insecure = true - return reg, nil +// +// Deprecated: Use the Insecure Option with NewRegistry instead. +func NewInsecureRegistry(name string, opts ...Option) (Registry, error) { + opts = append(opts, Insecure) + return NewRegistry(name, opts...) } diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/repository.go b/vendor/github.com/google/go-containerregistry/pkg/name/repository.go index 43cc5b82b3..f333779884 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/name/repository.go +++ b/vendor/github.com/google/go-containerregistry/pkg/name/repository.go @@ -68,7 +68,8 @@ func checkRepository(repository string) error { } // NewRepository returns a new Repository representing the given name, according to the given strictness. -func NewRepository(name string, strict Strictness) (Repository, error) { +func NewRepository(name string, opts ...Option) (Repository, error) { + opt := makeOptions(opts...) if len(name) == 0 { return Repository{}, NewErrBadName("a repository name must be specified") } @@ -88,11 +89,11 @@ func NewRepository(name string, strict Strictness) (Repository, error) { return Repository{}, err } - reg, err := NewRegistry(registry, strict) + reg, err := NewRegistry(registry, opts...) if err != nil { return Repository{}, err } - if hasImplicitNamespace(repo, reg) && strict == StrictValidation { + if hasImplicitNamespace(repo, reg) && opt.strict { return Repository{}, NewErrBadName("strict validation requires the full repository path (missing 'library')") } return Repository{reg, repo}, nil diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/tag.go b/vendor/github.com/google/go-containerregistry/pkg/name/tag.go index b8375e1f9b..e6cce34dbd 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/name/tag.go +++ b/vendor/github.com/google/go-containerregistry/pkg/name/tag.go @@ -71,7 +71,8 @@ func checkTag(name string) error { } // NewTag returns a new Tag representing the given name, according to the given strictness. -func NewTag(name string, strict Strictness) (Tag, error) { +func NewTag(name string, opts ...Option) (Tag, error) { + opt := makeOptions(opts...) base := name tag := "" @@ -87,13 +88,13 @@ func NewTag(name string, strict Strictness) (Tag, error) { // even when not being strict. // If we are being strict, we want to validate the tag regardless in case // it's empty. - if tag != "" || strict == StrictValidation { + if tag != "" || opt.strict { if err := checkTag(tag); err != nil { return Tag{}, err } } - repo, err := NewRepository(base, strict) + repo, err := NewRepository(base, opts...) if err != nil { return Tag{}, err } diff --git a/vendor/github.com/knative/build/AUTHORS b/vendor/github.com/knative/build/AUTHORS deleted file mode 100644 index 9c2b57e2ca..0000000000 --- a/vendor/github.com/knative/build/AUTHORS +++ /dev/null @@ -1,8 +0,0 @@ -# This is the list of Knative authors for copyright purposes. -# -# This does not necessarily list everyone who has contributed code, since in -# some cases, their employer may be the copyright holder. To see the full list -# of contributors, see the revision history in source control. -Google LLC -Pivotal Software, Inc. -Red Hat, Inc. \ No newline at end of file diff --git a/vendor/github.com/knative/build/LICENSE b/vendor/github.com/knative/build/LICENSE deleted file mode 100644 index d645695673..0000000000 --- a/vendor/github.com/knative/build/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. diff --git a/vendor/github.com/knative/build/cmd/controller/kodata/HEAD b/vendor/github.com/knative/build/cmd/controller/kodata/HEAD deleted file mode 120000 index 8f63681d36..0000000000 --- a/vendor/github.com/knative/build/cmd/controller/kodata/HEAD +++ /dev/null @@ -1 +0,0 @@ -../../../.git/HEAD \ No newline at end of file diff --git a/vendor/github.com/knative/build/cmd/controller/kodata/LICENSE b/vendor/github.com/knative/build/cmd/controller/kodata/LICENSE deleted file mode 120000 index 5853aaea53..0000000000 --- a/vendor/github.com/knative/build/cmd/controller/kodata/LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/build/cmd/controller/kodata/VENDOR-LICENSE b/vendor/github.com/knative/build/cmd/controller/kodata/VENDOR-LICENSE deleted file mode 120000 index 3cc8976451..0000000000 --- a/vendor/github.com/knative/build/cmd/controller/kodata/VENDOR-LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/build/cmd/creds-init/kodata/HEAD b/vendor/github.com/knative/build/cmd/creds-init/kodata/HEAD deleted file mode 120000 index 8f63681d36..0000000000 --- a/vendor/github.com/knative/build/cmd/creds-init/kodata/HEAD +++ /dev/null @@ -1 +0,0 @@ -../../../.git/HEAD \ No newline at end of file diff --git a/vendor/github.com/knative/build/cmd/creds-init/kodata/LICENSE b/vendor/github.com/knative/build/cmd/creds-init/kodata/LICENSE deleted file mode 120000 index 5853aaea53..0000000000 --- a/vendor/github.com/knative/build/cmd/creds-init/kodata/LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/build/cmd/creds-init/kodata/VENDOR-LICENSE b/vendor/github.com/knative/build/cmd/creds-init/kodata/VENDOR-LICENSE deleted file mode 120000 index 3cc8976451..0000000000 --- a/vendor/github.com/knative/build/cmd/creds-init/kodata/VENDOR-LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/build/cmd/git-init/kodata/HEAD b/vendor/github.com/knative/build/cmd/git-init/kodata/HEAD deleted file mode 120000 index 8f63681d36..0000000000 --- a/vendor/github.com/knative/build/cmd/git-init/kodata/HEAD +++ /dev/null @@ -1 +0,0 @@ -../../../.git/HEAD \ No newline at end of file diff --git a/vendor/github.com/knative/build/cmd/git-init/kodata/LICENSE b/vendor/github.com/knative/build/cmd/git-init/kodata/LICENSE deleted file mode 120000 index 5853aaea53..0000000000 --- a/vendor/github.com/knative/build/cmd/git-init/kodata/LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/build/cmd/git-init/kodata/VENDOR-LICENSE b/vendor/github.com/knative/build/cmd/git-init/kodata/VENDOR-LICENSE deleted file mode 120000 index 3cc8976451..0000000000 --- a/vendor/github.com/knative/build/cmd/git-init/kodata/VENDOR-LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/build/cmd/logs/kodata/HEAD b/vendor/github.com/knative/build/cmd/logs/kodata/HEAD deleted file mode 120000 index 8f63681d36..0000000000 --- a/vendor/github.com/knative/build/cmd/logs/kodata/HEAD +++ /dev/null @@ -1 +0,0 @@ -../../../.git/HEAD \ No newline at end of file diff --git a/vendor/github.com/knative/build/cmd/logs/kodata/LICENSE b/vendor/github.com/knative/build/cmd/logs/kodata/LICENSE deleted file mode 120000 index 5853aaea53..0000000000 --- a/vendor/github.com/knative/build/cmd/logs/kodata/LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/build/cmd/logs/kodata/VENDOR-LICENSE b/vendor/github.com/knative/build/cmd/logs/kodata/VENDOR-LICENSE deleted file mode 120000 index 3cc8976451..0000000000 --- a/vendor/github.com/knative/build/cmd/logs/kodata/VENDOR-LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/build/cmd/nop/kodata/HEAD b/vendor/github.com/knative/build/cmd/nop/kodata/HEAD deleted file mode 120000 index 8f63681d36..0000000000 --- a/vendor/github.com/knative/build/cmd/nop/kodata/HEAD +++ /dev/null @@ -1 +0,0 @@ -../../../.git/HEAD \ No newline at end of file diff --git a/vendor/github.com/knative/build/cmd/nop/kodata/LICENSE b/vendor/github.com/knative/build/cmd/nop/kodata/LICENSE deleted file mode 120000 index 5853aaea53..0000000000 --- a/vendor/github.com/knative/build/cmd/nop/kodata/LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/build/cmd/nop/kodata/VENDOR-LICENSE b/vendor/github.com/knative/build/cmd/nop/kodata/VENDOR-LICENSE deleted file mode 120000 index 3cc8976451..0000000000 --- a/vendor/github.com/knative/build/cmd/nop/kodata/VENDOR-LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/build/cmd/webhook/kodata/HEAD b/vendor/github.com/knative/build/cmd/webhook/kodata/HEAD deleted file mode 120000 index 8f63681d36..0000000000 --- a/vendor/github.com/knative/build/cmd/webhook/kodata/HEAD +++ /dev/null @@ -1 +0,0 @@ -../../../.git/HEAD \ No newline at end of file diff --git a/vendor/github.com/knative/build/cmd/webhook/kodata/LICENSE b/vendor/github.com/knative/build/cmd/webhook/kodata/LICENSE deleted file mode 120000 index 5853aaea53..0000000000 --- a/vendor/github.com/knative/build/cmd/webhook/kodata/LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/build/cmd/webhook/kodata/VENDOR-LICENSE b/vendor/github.com/knative/build/cmd/webhook/kodata/VENDOR-LICENSE deleted file mode 120000 index 3cc8976451..0000000000 --- a/vendor/github.com/knative/build/cmd/webhook/kodata/VENDOR-LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/build/config/300-imagecache.yaml b/vendor/github.com/knative/build/config/300-imagecache.yaml deleted file mode 120000 index f10d6dacf6..0000000000 --- a/vendor/github.com/knative/build/config/300-imagecache.yaml +++ /dev/null @@ -1 +0,0 @@ -../vendor/github.com/knative/caching/config/image.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_template_types.go b/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_template_types.go deleted file mode 100644 index 250c4a0fa7..0000000000 --- a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_template_types.go +++ /dev/null @@ -1,117 +0,0 @@ -/* -Copyright 2018 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" - - "github.com/knative/pkg/apis" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - - "github.com/knative/pkg/kmeta" -) - -// Template is an interface for accessing the BuildTemplateSpec -// from various forms of template (namespace-/cluster-scoped). -type Template interface { - TemplateSpec() BuildTemplateSpec -} - -// +genclient -// +genclient:noStatus -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// BuildTemplate is a template that can used to easily create Builds. -type BuildTemplate struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec BuildTemplateSpec `json:"spec"` -} - -// Check that our resource implements several interfaces. -var _ kmeta.OwnerRefable = (*BuildTemplate)(nil) -var _ Template = (*BuildTemplate)(nil) -var _ BuildTemplateInterface = (*BuildTemplate)(nil) - -// Check that BuildTemplate may be validated and defaulted. -var _ apis.Validatable = (*BuildTemplate)(nil) -var _ apis.Defaultable = (*BuildTemplate)(nil) - -// BuildTemplateSpec is the spec for a BuildTemplate. -type BuildTemplateSpec struct { - // TODO(dprotaso) Metadata.Generation should increment so we - // can drop this property when conversion webhooks enable us - // to migrate - // +optional - DeprecatedGeneration int64 `json:"generation,omitempty"` - - // Parameters defines the parameters that can be populated in a template. - Parameters []ParameterSpec `json:"parameters,omitempty"` - - // Steps are the steps of the build; each step is run sequentially with the - // source mounted into /workspace. - Steps []corev1.Container `json:"steps"` - - // Volumes is a collection of volumes that are available to mount into the - // steps of the build. - Volumes []corev1.Volume `json:"volumes"` -} - -// ParameterSpec defines the possible parameters that can be populated in a -// template. -type ParameterSpec struct { - // Name is the unique name of this template parameter. - Name string `json:"name"` - - // Description is a human-readable explanation of this template parameter. - Description string `json:"description,omitempty"` - - // Default, if specified, defines the default value that should be applied if - // the build does not specify the value for this parameter. - Default *string `json:"default,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// BuildTemplateList is a list of BuildTemplate resources. -type BuildTemplateList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata"` - - Items []BuildTemplate `json:"items"` -} - -// TemplateSpec returnes the Spec used by the template -func (bt *BuildTemplate) TemplateSpec() BuildTemplateSpec { - return bt.Spec -} - -// Copy performes a deep copy -func (bt *BuildTemplate) Copy() BuildTemplateInterface { - return bt.DeepCopy() -} - -// GetGroupVersionKind gives kind -func (bt *BuildTemplate) GetGroupVersionKind() schema.GroupVersionKind { - return SchemeGroupVersion.WithKind("BuildTemplate") -} - -// SetDefaults for build template -func (bt *BuildTemplate) SetDefaults(ctx context.Context) {} diff --git a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_template_validation.go b/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_template_validation.go deleted file mode 100644 index d90b8fde50..0000000000 --- a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_template_validation.go +++ /dev/null @@ -1,89 +0,0 @@ -/* -Copyright 2018 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" - - "github.com/knative/pkg/apis" - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/util/sets" -) - -// Validate build template -func (b *BuildTemplate) Validate(ctx context.Context) *apis.FieldError { - return validateObjectMetadata(b.GetObjectMeta()).ViaField("metadata").Also(b.Spec.Validate(ctx).ViaField("spec")) -} - -// Validate Build Template -func (b *BuildTemplateSpec) Validate(ctx context.Context) *apis.FieldError { - if err := validateSteps(b.Steps); err != nil { - return err - } - if err := ValidateVolumes(b.Volumes); err != nil { - return err - } - if err := validateParameters(b.Parameters); err != nil { - return err - } - return nil -} - -//ValidateVolumes validates collection of volumes that are available to mount into the -// steps of the build ot build template. -func ValidateVolumes(volumes []corev1.Volume) *apis.FieldError { - // Build must not duplicate volume names. - vols := sets.NewString() - for _, v := range volumes { - if vols.Has(v.Name) { - return apis.ErrMultipleOneOf("name") - } - vols.Insert(v.Name) - } - return nil -} - -func validateSteps(steps []corev1.Container) *apis.FieldError { - // Build must not duplicate step names. - names := sets.NewString() - for _, s := range steps { - if s.Image == "" { - return apis.ErrMissingField("Image") - } - - if s.Name == "" { - continue - } - if names.Has(s.Name) { - return apis.ErrMultipleOneOf("name") - } - names.Insert(s.Name) - } - return nil -} - -func validateParameters(params []ParameterSpec) *apis.FieldError { - // Template must not duplicate parameter names. - seen := sets.NewString() - for _, p := range params { - if seen.Has(p.Name) { - return apis.ErrInvalidKeyName("ParamName", "b.spec.params") - } - seen.Insert(p.Name) - } - return nil -} diff --git a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_types.go b/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_types.go deleted file mode 100644 index 6f18d1786e..0000000000 --- a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_types.go +++ /dev/null @@ -1,337 +0,0 @@ -/* -Copyright 2018 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 ( - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - - "github.com/knative/pkg/apis" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" - "github.com/knative/pkg/kmeta" -) - -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// Build represents a build of a container image. A Build is made up of a -// source, and a set of steps. Steps can mount volumes to share data between -// themselves. A build may be created by instantiating a BuildTemplate. -type Build struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec BuildSpec `json:"spec"` - Status BuildStatus `json:"status"` -} - -// Check that our resource implements several interfaces. -var _ kmeta.OwnerRefable = (*Build)(nil) - -// Check that Build may be validated and defaulted. -var _ apis.Validatable = (*Build)(nil) -var _ apis.Defaultable = (*Build)(nil) - -// BuildSpec is the spec for a Build resource. -type BuildSpec struct { - // TODO(dprotaso) Metadata.Generation should increment so we - // can drop this property when conversion webhooks enable us - // to migrate - // +optional - DeprecatedGeneration int64 `json:"generation,omitempty"` - - // Source specifies the input to the build. - // +optional - Source *SourceSpec `json:"source,omitempty"` - - // Sources specifies the inputs to the build. - // +optional - Sources []SourceSpec `json:"sources,omitempty"` - - // Steps are the steps of the build; each step is run sequentially with the - // source mounted into /workspace. - // +optional - Steps []corev1.Container `json:"steps,omitempty"` - - // Volumes is a collection of volumes that are available to mount into the - // steps of the build. - // +optional - Volumes []corev1.Volume `json:"volumes,omitempty"` - - // The name of the service account as which to run this build. - // +optional - ServiceAccountName string `json:"serviceAccountName,omitempty"` - - // Template, if specified, references a BuildTemplate resource to use to - // populate fields in the build, and optional Arguments to pass to the - // template. The default Kind of template is BuildTemplate - // +optional - Template *TemplateInstantiationSpec `json:"template,omitempty"` - - // NodeSelector is a selector which must be true for the pod to fit on a node. - // Selector which must match a node's labels for the pod to be scheduled on that node. - // More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ - // +optional - NodeSelector map[string]string `json:"nodeSelector,omitempty"` - - // Time after which the build times out. Defaults to 10 minutes. - // Specified build timeout should be less than 24h. - // Refer Go's ParseDuration documentation for expected format: https://golang.org/pkg/time/#ParseDuration - // +optional - Timeout *metav1.Duration `json:"timeout,omitempty"` - - // If specified, the pod's scheduling constraints - // +optional - Affinity *corev1.Affinity `json:"affinity,omitempty"` - - // Used for cancelling a job (and maybe more later on) - // +optional - Status BuildSpecStatus -} - -// BuildSpecStatus defines the build spec status the user can provide -type BuildSpecStatus string - -const ( - // BuildSpecStatusCancelled indicates that the user wants to cancel the build, - // if not already cancelled or terminated - BuildSpecStatusCancelled = "BuildCancelled" -) - -// TemplateKind defines the type of BuildTemplate used by the build. -type TemplateKind string - -const ( - // BuildTemplateKind indicates that the template type has a namepace scope. - BuildTemplateKind TemplateKind = "BuildTemplate" - // ClusterBuildTemplateKind indicates that template type has a cluster scope. - ClusterBuildTemplateKind TemplateKind = "ClusterBuildTemplate" -) - -// TemplateInstantiationSpec specifies how a BuildTemplate is instantiated into -// a Build. -type TemplateInstantiationSpec struct { - // Name references the BuildTemplate resource to use. - // The template is assumed to exist in the Build's namespace. - Name string `json:"name"` - - // The Kind of the template to be used, possible values are BuildTemplate - // or ClusterBuildTemplate. If nothing is specified, the default if is BuildTemplate - // +optional - Kind TemplateKind `json:"kind,omitempty"` - - // Arguments, if specified, lists values that should be applied to the - // parameters specified by the template. - // +optional - Arguments []ArgumentSpec `json:"arguments,omitempty"` - - // Env, if specified will provide variables to all build template steps. - // This will override any of the template's steps environment variables. - // +optional - Env []corev1.EnvVar `json:"env,omitempty"` -} - -// ArgumentSpec defines the actual values to use to populate a template's -// parameters. -type ArgumentSpec struct { - // Name is the name of the argument. - Name string `json:"name"` - // Value is the value of the argument. - Value string `json:"value"` - // TODO(jasonhall): ValueFrom? -} - -// SourceSpec defines the input to the Build -type SourceSpec struct { - // Git represents source in a Git repository. - // +optional - Git *GitSourceSpec `json:"git,omitempty"` - - // GCS represents source in Google Cloud Storage. - // +optional - GCS *GCSSourceSpec `json:"gcs,omitempty"` - - // Custom indicates that source should be retrieved using a custom - // process defined in a container invocation. - // +optional - Custom *corev1.Container `json:"custom,omitempty"` - - // SubPath specifies a path within the fetched source which should be - // built. This option makes parent directories *inaccessible* to the - // build steps. (The specific source type may, in fact, not even fetch - // files not in the SubPath.) - // +optional - SubPath string `json:"subPath,omitempty"` - - // Name is the name of source. This field is used to uniquely identify the - // source init containers - // Restrictions on the allowed charatcers - // Must be a basename (no /) - // Must be a valid DNS name (only alphanumeric characters, no _) - // https://tools.ietf.org/html/rfc1123#section-2 - // +optional - Name string `json:"name,omitempty"` - - // TargetPath is the path in workspace directory where the source will be copied. - // TargetPath is optional and if its not set source will be copied under workspace. - // TargetPath should not be set for custom source. - TargetPath string `json:"targetPath,omitempty"` -} - -// GitSourceSpec describes a Git repo source input to the Build. -type GitSourceSpec struct { - // URL of the Git repository to clone from. - Url string `json:"url"` - - // Git revision (branch, tag, commit SHA or ref) to clone. See - // https://git-scm.com/docs/gitrevisions#_specifying_revisions for more - // information. - Revision string `json:"revision"` -} - -// GCSSourceSpec describes source input to the Build in the form of an archive, -// or a source manifest describing files to fetch. -type GCSSourceSpec struct { - // Type declares the style of source to fetch. - Type GCSSourceType `json:"type,omitempty"` - - // Location specifies the location of the source archive or manifest file. - Location string `json:"location,omitempty"` -} - -// GCSSourceType defines a type of GCS source fetch. -type GCSSourceType string - -const ( - // GCSArchive indicates that source should be fetched from a typical archive file. - GCSArchive GCSSourceType = "Archive" - - // GCSManifest indicates that source should be fetched using a - // manifest-based protocol which enables incremental source upload. - GCSManifest GCSSourceType = "Manifest" -) - -// BuildProvider defines a build execution implementation. -type BuildProvider string - -const ( - // GoogleBuildProvider indicates that this build was performed with Google Cloud Build. - GoogleBuildProvider BuildProvider = "Google" - // ClusterBuildProvider indicates that this build was performed on-cluster. - ClusterBuildProvider BuildProvider = "Cluster" -) - -// BuildStatus is the status for a Build resource -type BuildStatus struct { - duckv1alpha1.Status `json:",inline"` - - // +optional - Builder BuildProvider `json:"builder,omitempty"` - - // Cluster provides additional information if the builder is Cluster. - // +optional - Cluster *ClusterSpec `json:"cluster,omitempty"` - - // Google provides additional information if the builder is Google. - // +optional - Google *GoogleSpec `json:"google,omitempty"` - - // StartTime is the time the build is actually started. - // +optional - StartTime *metav1.Time `json:"startTime,omitempty"` - - // CompletionTime is the time the build completed. - // +optional - CompletionTime *metav1.Time `json:"completionTime,omitempty"` - - // StepStates describes the state of each build step container. - // +optional - StepStates []corev1.ContainerState `json:"stepStates,omitempty"` - - // StepsCompleted lists the name of build steps completed. - // +optional - StepsCompleted []string `json:"stepsCompleted",omitempty` -} - -// Check that BuildStatus may have its conditions managed. -var _ duckv1alpha1.ConditionsAccessor = (*BuildStatus)(nil) - -// ClusterSpec provides information about the on-cluster build, if applicable. -type ClusterSpec struct { - // Namespace is the namespace in which the pod is running. - Namespace string `json:"namespace"` - // PodName is the name of the pod responsible for executing this build's steps. - PodName string `json:"podName"` -} - -// GoogleSpec provides information about the GCB build, if applicable. -type GoogleSpec struct { - // Operation is the unique name of the GCB API Operation for the build. - Operation string `json:"operation"` -} - -// BuildSucceeded is set when the build is running, and becomes True when the -// build finishes successfully. -// -// If the build is ongoing, its status will be Unknown. If it fails, its status -// will be False. -const BuildSucceeded = duckv1alpha1.ConditionSucceeded - -const BuildCancelled duckv1alpha1.ConditionType = "Cancelled" - -var buildCondSet = duckv1alpha1.NewBatchConditionSet() - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// BuildList is a list of Build resources -type BuildList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata"` - - // Items is the list of Build items in this list. - Items []Build `json:"items"` -} - -// GetCondition returns the Condition matching the given type. -func (bs *BuildStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition { - return buildCondSet.Manage(bs).GetCondition(t) -} - -// SetCondition sets the condition, unsetting previous conditions with the same -// type as necessary. -func (bs *BuildStatus) SetCondition(newCond *duckv1alpha1.Condition) { - if newCond != nil { - buildCondSet.Manage(bs).SetCondition(*newCond) - } -} - -// GetConditions returns the Conditions array. This enables generic handling of -// conditions by implementing the duckv1alpha1.Conditions interface. -func (bs *BuildStatus) GetConditions() duckv1alpha1.Conditions { - return bs.Conditions -} - -// SetConditions sets the Conditions array. This enables generic handling of -// conditions by implementing the duckv1alpha1.Conditions interface. -func (bs *BuildStatus) SetConditions(conditions duckv1alpha1.Conditions) { - bs.Conditions = conditions -} - -func (b *Build) GetGroupVersionKind() schema.GroupVersionKind { - return SchemeGroupVersion.WithKind("Build") -} diff --git a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_validation.go b/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_validation.go deleted file mode 100644 index ee6a2c34eb..0000000000 --- a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_validation.go +++ /dev/null @@ -1,132 +0,0 @@ -/* -Copyright 2018 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" - "time" - - "github.com/knative/pkg/apis" -) - -// Validate Build -func (b *Build) Validate(ctx context.Context) *apis.FieldError { - return validateObjectMetadata(b.GetObjectMeta()).ViaField("metadata").Also(b.Spec.Validate(ctx).ViaField("spec")) -} - -// Validate for build spec -func (bs *BuildSpec) Validate(ctx context.Context) *apis.FieldError { - if bs.Template == nil && len(bs.Steps) == 0 { - return apis.ErrMissingOneOf("template", "steps") - } - if bs.Template != nil && len(bs.Steps) > 0 { - return apis.ErrMultipleOneOf("template", "steps") - } - - // If a build specifies a template, all the template's parameters without - // defaults must be satisfied by the build's parameters. - if bs.Template != nil { - return bs.Template.Validate(ctx).ViaField("template") - } - - // Below method potentially has a bug: - // It does not Validate if only a "Source" has been set, it only validates if multiple sources have been set - return bs.validateSources(). - Also(ValidateVolumes(bs.Volumes).ViaField("volumes")). - Also(bs.validateTimeout()). - Also(validateSteps(bs.Steps).ViaField("steps")) -} - -// Validate template -func (b *TemplateInstantiationSpec) Validate(ctx context.Context) *apis.FieldError { - if b == nil { - return nil - } - if b.Name == "" { - return apis.ErrMissingField("name") - } - if b.Kind != "" { - switch b.Kind { - case ClusterBuildTemplateKind, - BuildTemplateKind: - return nil - default: - return apis.ErrInvalidValue(string(b.Kind), "kind") - } - } - return nil -} - -// Validate build timeout -func (bs *BuildSpec) validateTimeout() *apis.FieldError { - if bs.Timeout == nil { - return nil - } - maxTimeout := time.Duration(24 * time.Hour) - - if bs.Timeout.Duration > maxTimeout || bs.Timeout.Duration < 0 { - return apis.ErrOutOfBoundsValue(bs.Timeout.Duration.String(), "0", "24", "timeout") - } - return nil -} - -// Validate source -func (bs BuildSpec) validateSources() *apis.FieldError { - var subPathExists bool - var emptyTargetPath bool - names := map[string]string{} - pathtree := pathTree{ - nodeMap: map[string]map[string]string{}, - } - - // Both source and sources cannot be defined in build - if len(bs.Sources) > 0 && bs.Source != nil { - return apis.ErrMultipleOneOf("source", "sources") - } - for _, source := range bs.Sources { - // Check all source have unique names - if _, ok := names[source.Name]; ok { - return apis.ErrMultipleOneOf("name").ViaField("sources") - } - // Multiple sources cannot have subpath defined - if source.SubPath != "" { - if subPathExists { - return apis.ErrMultipleOneOf("subpath").ViaField("sources") - } - subPathExists = true - } - names[source.Name] = "" - - if source.TargetPath == "" { - if source.Custom != nil { - continue - } - if emptyTargetPath { - return apis.ErrInvalidValue("Empty Target Path", "targetPath").ViaField("sources") - } - emptyTargetPath = true - } else { - if source.Custom != nil { - return apis.ErrInvalidValue(source.TargetPath, "targetPath").ViaField("sources") - } - if err := insertNode(source.TargetPath, pathtree).ViaField("sources"); err != nil { - return err - } - } - } - return nil -} diff --git a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/cluster_build_template_types.go b/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/cluster_build_template_types.go deleted file mode 100644 index dbe8fed60b..0000000000 --- a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/cluster_build_template_types.go +++ /dev/null @@ -1,76 +0,0 @@ -/* -Copyright 2018 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" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - - "github.com/knative/pkg/apis" - "github.com/knative/pkg/kmeta" -) - -// +genclient -// +genclient:noStatus -// +genclient:nonNamespaced -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// ClusterBuildTemplate is a template that can used to easily create Builds. -type ClusterBuildTemplate struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec BuildTemplateSpec `json:"spec"` -} - -// Check that our resource implements several interfaces. -var _ kmeta.OwnerRefable = (*ClusterBuildTemplate)(nil) -var _ Template = (*ClusterBuildTemplate)(nil) -var _ BuildTemplateInterface = (*ClusterBuildTemplate)(nil) - -// Check that ClusterBuildTemplate may be validated and defaulted. -var _ apis.Validatable = (*ClusterBuildTemplate)(nil) -var _ apis.Defaultable = (*ClusterBuildTemplate)(nil) - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// ClusterBuildTemplateList is a list of BuildTemplate resources. -type ClusterBuildTemplateList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata"` - - Items []ClusterBuildTemplate `json:"items"` -} - -// TemplateSpec returnes the Spec used by the template -func (bt *ClusterBuildTemplate) TemplateSpec() BuildTemplateSpec { - return bt.Spec -} - -// Copy performes a deep copy -func (bt *ClusterBuildTemplate) Copy() BuildTemplateInterface { - return bt.DeepCopy() -} - -func (bt *ClusterBuildTemplate) GetGroupVersionKind() schema.GroupVersionKind { - return SchemeGroupVersion.WithKind("ClusterBuildTemplate") -} - -// SetDefaults -func (b *ClusterBuildTemplate) SetDefaults(ctx context.Context) {} diff --git a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/metadata_validation.go b/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/metadata_validation.go deleted file mode 100644 index 8801c3fca6..0000000000 --- a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/metadata_validation.go +++ /dev/null @@ -1,47 +0,0 @@ -/* -Copyright 2018 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 ( - "strings" - - "github.com/knative/pkg/apis" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -const ( - maxLength = 63 -) - -func validateObjectMetadata(meta metav1.Object) *apis.FieldError { - name := meta.GetName() - - if strings.Contains(name, ".") { - return &apis.FieldError{ - Message: "Invalid resource name: special character . must not be present", - Paths: []string{"name"}, - } - } - - if len(name) > maxLength { - return &apis.FieldError{ - Message: "Invalid resource name: length must be no more than 63 characters", - Paths: []string{"name"}, - } - } - return nil -} diff --git a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/target_path_validation.go b/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/target_path_validation.go deleted file mode 100644 index 3439a87eba..0000000000 --- a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/target_path_validation.go +++ /dev/null @@ -1,69 +0,0 @@ -/* -Copyright 2018 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 ( - "strings" - - "github.com/knative/pkg/apis" -) - -type pathTree struct { - nodeMap map[string]map[string]string -} - -// insertNode functions checks the path does not have overlap with existing -// paths in path.nodeMap. If not it creates a key for path and adds -func insertNode(path string, pathtree pathTree) *apis.FieldError { - err := &apis.FieldError{ - Message: "Overlapping Target Paths", - Paths: []string{"targetPath"}, - } - path = strings.Trim(path, "/") - parts := strings.Split(path, "/") - - for nodePath, nodeMap := range pathtree.nodeMap { - if len(nodeMap) > len(parts) { - if strings.HasPrefix(nodePath, path) { - return err - } - } - - if len(nodeMap) == len(parts) { - if path == nodePath { - return err - } - } - if len(nodeMap) < len(parts) { - if strings.HasPrefix(path, nodePath) { - return err - } - } - } - // path is trimmed with "/" - addNode(path, pathtree) - return nil -} - -func addNode(path string, tree pathTree) { - parts := strings.Split(path, "/") - nm := map[string]string{} - - for _, part := range parts { - nm[part] = part - } - tree.nodeMap[path] = nm -} diff --git a/vendor/github.com/knative/build/test/panic/kodata/LICENSE b/vendor/github.com/knative/build/test/panic/kodata/LICENSE deleted file mode 120000 index 5853aaea53..0000000000 --- a/vendor/github.com/knative/build/test/panic/kodata/LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/build/test/panic/kodata/VENDOR-LICENSE b/vendor/github.com/knative/build/test/panic/kodata/VENDOR-LICENSE deleted file mode 120000 index 3cc8976451..0000000000 --- a/vendor/github.com/knative/build/test/panic/kodata/VENDOR-LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/build/test/workingdir/kodata/LICENSE b/vendor/github.com/knative/build/test/workingdir/kodata/LICENSE deleted file mode 120000 index 5853aaea53..0000000000 --- a/vendor/github.com/knative/build/test/workingdir/kodata/LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/build/test/workingdir/kodata/VENDOR-LICENSE b/vendor/github.com/knative/build/test/workingdir/kodata/VENDOR-LICENSE deleted file mode 120000 index 3cc8976451..0000000000 --- a/vendor/github.com/knative/build/test/workingdir/kodata/VENDOR-LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/eventing/pkg/apis/duck/v1alpha1/channelable_types.go b/vendor/github.com/knative/eventing/pkg/apis/duck/v1alpha1/channelable_types.go new file mode 100644 index 0000000000..d4063bc98d --- /dev/null +++ b/vendor/github.com/knative/eventing/pkg/apis/duck/v1alpha1/channelable_types.go @@ -0,0 +1,128 @@ +/* +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 ( + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" + "knative.dev/pkg/apis/duck/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Channelable is a skeleton type wrapping Subscribable and Addressable in the manner we expect resource writers +// defining compatible resources to embed it. We will typically use this type to deserialize +// Channelable ObjectReferences and access their subscription and address data. This is not a real resource. +type Channelable struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec is the part where the Channelable fulfills the Subscribable contract. + Spec ChannelableSpec `json:"spec,omitempty"` + + Status ChannelableStatus `json:"status,omitempty"` +} + +// ChannelableSpec contains Spec of the Channelable object +type ChannelableSpec struct { + SubscribableTypeSpec `json:",inline"` +} + +// ChannelableStatus contains the Status of a Channelable object. +type ChannelableStatus struct { + // inherits duck/v1beta1 Status, which currently provides: + // * ObservedGeneration - the 'Generation' of the Service that was last processed by the controller. + // * Conditions - the latest available observations of a resource's current state. + duckv1beta1.Status `json:",inline"` + // AddressStatus is the part where the Channelable fulfills the Addressable contract. + v1alpha1.AddressStatus `json:",inline"` + // Subscribers is populated with the statuses of each of the Channelable's subscribers. + SubscribableTypeStatus `json:",inline"` +} + +var ( + // Verify Channelable resources meet duck contracts. + _ duck.Populatable = (*Channelable)(nil) + _ apis.Listable = (*Channelable)(nil) +) + +// Populate implements duck.Populatable +func (c *Channelable) Populate() { + c.Spec.Subscribable = &Subscribable{ + // Populate ALL fields + Subscribers: []SubscriberSpec{{ + UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1", + Generation: 1, + SubscriberURI: "call1", + ReplyURI: "sink2", + }, { + UID: "34c5aec8-deb6-11e8-9f32-f2801f1b9fd1", + Generation: 2, + SubscriberURI: "call2", + ReplyURI: "sink2", + }}, + } + c.Status = ChannelableStatus{ + AddressStatus: v1alpha1.AddressStatus{ + Address: &v1alpha1.Addressable{ + // Populate ALL fields + Addressable: duckv1beta1.Addressable{ + URL: &apis.URL{ + Scheme: "http", + Host: "test-domain", + }, + }, + Hostname: "test-domain", + }, + }, + SubscribableTypeStatus: SubscribableTypeStatus{ + SubscribableStatus: &SubscribableStatus{ + Subscribers: []SubscriberStatus{{ + UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1", + ObservedGeneration: 1, + Ready: corev1.ConditionTrue, + Message: "Some message", + }, { + UID: "34c5aec8-deb6-11e8-9f32-f2801f1b9fd1", + ObservedGeneration: 2, + Ready: corev1.ConditionFalse, + Message: "Some message", + }}, + }, + }, + } +} + +// GetListType implements apis.Listable +func (c *Channelable) GetListType() runtime.Object { + return &ChannelableList{} +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ChannelableList is a list of Channelable resources. +type ChannelableList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Channelable `json:"items"` +} diff --git a/vendor/github.com/knative/eventing/pkg/apis/duck/v1alpha1/subscribable_types.go b/vendor/github.com/knative/eventing/pkg/apis/duck/v1alpha1/subscribable_types.go index 407a791240..98a9a4bbd2 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/duck/v1alpha1/subscribable_types.go +++ b/vendor/github.com/knative/eventing/pkg/apis/duck/v1alpha1/subscribable_types.go @@ -17,7 +17,8 @@ limitations under the License. package v1alpha1 import ( - "github.com/knative/pkg/apis/duck" + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -27,80 +28,144 @@ import ( // Subscribable is the schema for the subscribable portion of the spec // section of the resource. type Subscribable struct { - // TODO: What is actually required here for Channel spec. - // This is the list of subscriptions for this channel. + // This is the list of subscriptions for this subscribable. // +patchMergeKey=uid // +patchStrategy=merge - Subscribers []ChannelSubscriberSpec `json:"subscribers,omitempty" patchStrategy:"merge" patchMergeKey:"uid"` + Subscribers []SubscriberSpec `json:"subscribers,omitempty" patchStrategy:"merge" patchMergeKey:"uid"` } -// ChannelSubscriberSpec defines a single subscriber to a Channel. -// Ref is a reference to the Subscription this ChannelSubscriberSpec was created for +// Subscribable is an Implementable "duck type". +var _ duck.Implementable = (*Subscribable)(nil) + +// SubscriberSpec defines a single subscriber to a Subscribable. +// Ref is a reference to the Subscription this SubscriberSpec was created for // SubscriberURI is the endpoint for the subscriber // ReplyURI is the endpoint for the reply // At least one of SubscriberURI and ReplyURI must be present -type ChannelSubscriberSpec struct { +type SubscriberSpec struct { // Deprecated: use UID. // +optional DeprecatedRef *corev1.ObjectReference `json:"ref,omitempty" yaml:"ref,omitempty"` // UID is used to understand the origin of the subscriber. // +optional UID types.UID `json:"uid,omitempty"` + // Generation of the origin of the subscriber with uid:UID. + // +optional + Generation int64 `json:"generation,omitempty"` // +optional SubscriberURI string `json:"subscriberURI,omitempty"` // +optional ReplyURI string `json:"replyURI,omitempty"` } -// Channel is a skeleton type wrapping Subscribable in the manner we expect resource writers +// SubscribableStatus is the schema for the subscribable's status portion of the status +// section of the resource. +type SubscribableStatus struct { + // This is the list of subscription's statuses for this channel. + // +patchMergeKey=uid + // +patchStrategy=merge + Subscribers []SubscriberStatus `json:"subscribers,omitempty" patchStrategy:"merge" patchMergeKey:"uid"` +} + +// SubscriberStatus defines the status of a single subscriber to a Channel. +type SubscriberStatus struct { + // UID is used to understand the origin of the subscriber. + // +optional + UID types.UID `json:"uid,omitempty"` + // Generation of the origin of the subscriber with uid:UID. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + // Status of the subscriber. + // +optional + Ready corev1.ConditionStatus `json:"ready,omitempty"` + // A human readable message indicating details of Ready status. + // +optional + Message string `json:"message,omitempty"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// SubscribableType is a skeleton type wrapping Subscribable in the manner we expect resource writers // defining compatible resources to embed it. We will typically use this type to deserialize -// Channel ObjectReferences and access the Subscription data. This is not a real resource. -type Channel struct { +// SubscribableType ObjectReferences and access the Subscription data. This is not a real resource. +type SubscribableType struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - // ChannelSpec is the part where Subscribable object is + // SubscribableTypeSpec is the part where Subscribable object is // configured as to be compatible with Subscribable contract. - Spec ChannelSpec `json:"spec"` + Spec SubscribableTypeSpec `json:"spec"` + + // SubscribableTypeStatus is the part where SubscribableStatus object is + // configured as to be compatible with Subscribable contract. + Status SubscribableTypeStatus `json:"status"` } -// ChannelSpec shows how we expect folks to embed Subscribable in their Spec field. -type ChannelSpec struct { +// SubscribableTypeSpec shows how we expect folks to embed Subscribable in their Spec field. +type SubscribableTypeSpec struct { Subscribable *Subscribable `json:"subscribable,omitempty"` } +// SubscribableTypeStatus shows how we expect folks to embed Subscribable in their Status field. +type SubscribableTypeStatus struct { + SubscribableStatus *SubscribableStatus `json:"subscribablestatus,omitempty"` +} + +var ( + // Verify SubscribableType resources meet duck contracts. + _ duck.Populatable = (*SubscribableType)(nil) + _ apis.Listable = (*SubscribableType)(nil) +) + // GetFullType implements duck.Implementable func (s *Subscribable) GetFullType() duck.Populatable { - return &Channel{} + return &SubscribableType{} } // Populate implements duck.Populatable -func (c *Channel) Populate() { +func (c *SubscribableType) Populate() { c.Spec.Subscribable = &Subscribable{ // Populate ALL fields - Subscribers: []ChannelSubscriberSpec{{ + Subscribers: []SubscriberSpec{{ UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1", + Generation: 1, SubscriberURI: "call1", ReplyURI: "sink2", }, { UID: "34c5aec8-deb6-11e8-9f32-f2801f1b9fd1", + Generation: 2, SubscriberURI: "call2", ReplyURI: "sink2", }}, } + c.Status.SubscribableStatus = &SubscribableStatus{ + // Populate ALL fields + Subscribers: []SubscriberStatus{{ + UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1", + ObservedGeneration: 1, + Ready: corev1.ConditionTrue, + Message: "Some message", + }, { + UID: "34c5aec8-deb6-11e8-9f32-f2801f1b9fd1", + ObservedGeneration: 2, + Ready: corev1.ConditionFalse, + Message: "Some message", + }}, + } } // GetListType implements apis.Listable -func (c *Channel) GetListType() runtime.Object { - return &ChannelList{} +func (c *SubscribableType) GetListType() runtime.Object { + return &SubscribableTypeList{} } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// ChannelList is a list of Channel resources -type ChannelList struct { +// SubscribableTypeList is a list of SubscribableType resources +type SubscribableTypeList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata"` - Items []Channel `json:"items"` + Items []SubscribableType `json:"items"` } diff --git a/vendor/github.com/knative/eventing/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/knative/eventing/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go index 6c64827c71..cc04eff548 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/github.com/knative/eventing/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go @@ -26,32 +26,41 @@ import ( ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Channel) DeepCopyInto(out *Channel) { +func (in *Channelable) DeepCopyInto(out *Channelable) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Channel. -func (in *Channel) DeepCopy() *Channel { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Channelable. +func (in *Channelable) DeepCopy() *Channelable { if in == nil { return nil } - out := new(Channel) + out := new(Channelable) in.DeepCopyInto(out) return out } +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Channelable) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ChannelList) DeepCopyInto(out *ChannelList) { +func (in *ChannelableList) DeepCopyInto(out *ChannelableList) { *out = *in out.TypeMeta = in.TypeMeta out.ListMeta = in.ListMeta if in.Items != nil { in, out := &in.Items, &out.Items - *out = make([]Channel, len(*in)) + *out = make([]Channelable, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -59,18 +68,18 @@ func (in *ChannelList) DeepCopyInto(out *ChannelList) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChannelList. -func (in *ChannelList) DeepCopy() *ChannelList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChannelableList. +func (in *ChannelableList) DeepCopy() *ChannelableList { if in == nil { return nil } - out := new(ChannelList) + out := new(ChannelableList) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ChannelList) DeepCopyObject() runtime.Object { +func (in *ChannelableList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -78,43 +87,37 @@ func (in *ChannelList) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ChannelSpec) DeepCopyInto(out *ChannelSpec) { +func (in *ChannelableSpec) DeepCopyInto(out *ChannelableSpec) { *out = *in - if in.Subscribable != nil { - in, out := &in.Subscribable, &out.Subscribable - *out = new(Subscribable) - (*in).DeepCopyInto(*out) - } + in.SubscribableTypeSpec.DeepCopyInto(&out.SubscribableTypeSpec) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChannelSpec. -func (in *ChannelSpec) DeepCopy() *ChannelSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChannelableSpec. +func (in *ChannelableSpec) DeepCopy() *ChannelableSpec { if in == nil { return nil } - out := new(ChannelSpec) + out := new(ChannelableSpec) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ChannelSubscriberSpec) DeepCopyInto(out *ChannelSubscriberSpec) { +func (in *ChannelableStatus) DeepCopyInto(out *ChannelableStatus) { *out = *in - if in.DeprecatedRef != nil { - in, out := &in.DeprecatedRef, &out.DeprecatedRef - *out = new(v1.ObjectReference) - **out = **in - } + in.Status.DeepCopyInto(&out.Status) + in.AddressStatus.DeepCopyInto(&out.AddressStatus) + in.SubscribableTypeStatus.DeepCopyInto(&out.SubscribableTypeStatus) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChannelSubscriberSpec. -func (in *ChannelSubscriberSpec) DeepCopy() *ChannelSubscriberSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChannelableStatus. +func (in *ChannelableStatus) DeepCopy() *ChannelableStatus { if in == nil { return nil } - out := new(ChannelSubscriberSpec) + out := new(ChannelableStatus) in.DeepCopyInto(out) return out } @@ -124,7 +127,7 @@ func (in *Subscribable) DeepCopyInto(out *Subscribable) { *out = *in if in.Subscribers != nil { in, out := &in.Subscribers, &out.Subscribers - *out = make([]ChannelSubscriberSpec, len(*in)) + *out = make([]SubscriberSpec, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -141,3 +144,164 @@ func (in *Subscribable) DeepCopy() *Subscribable { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscribableStatus) DeepCopyInto(out *SubscribableStatus) { + *out = *in + if in.Subscribers != nil { + in, out := &in.Subscribers, &out.Subscribers + *out = make([]SubscriberStatus, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscribableStatus. +func (in *SubscribableStatus) DeepCopy() *SubscribableStatus { + if in == nil { + return nil + } + out := new(SubscribableStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscribableType) DeepCopyInto(out *SubscribableType) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscribableType. +func (in *SubscribableType) DeepCopy() *SubscribableType { + if in == nil { + return nil + } + out := new(SubscribableType) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SubscribableType) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscribableTypeList) DeepCopyInto(out *SubscribableTypeList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]SubscribableType, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscribableTypeList. +func (in *SubscribableTypeList) DeepCopy() *SubscribableTypeList { + if in == nil { + return nil + } + out := new(SubscribableTypeList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SubscribableTypeList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscribableTypeSpec) DeepCopyInto(out *SubscribableTypeSpec) { + *out = *in + if in.Subscribable != nil { + in, out := &in.Subscribable, &out.Subscribable + *out = new(Subscribable) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscribableTypeSpec. +func (in *SubscribableTypeSpec) DeepCopy() *SubscribableTypeSpec { + if in == nil { + return nil + } + out := new(SubscribableTypeSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscribableTypeStatus) DeepCopyInto(out *SubscribableTypeStatus) { + *out = *in + if in.SubscribableStatus != nil { + in, out := &in.SubscribableStatus, &out.SubscribableStatus + *out = new(SubscribableStatus) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscribableTypeStatus. +func (in *SubscribableTypeStatus) DeepCopy() *SubscribableTypeStatus { + if in == nil { + return nil + } + out := new(SubscribableTypeStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriberSpec) DeepCopyInto(out *SubscriberSpec) { + *out = *in + if in.DeprecatedRef != nil { + in, out := &in.DeprecatedRef, &out.DeprecatedRef + *out = new(v1.ObjectReference) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriberSpec. +func (in *SubscriberSpec) DeepCopy() *SubscriberSpec { + if in == nil { + return nil + } + out := new(SubscriberSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriberStatus) DeepCopyInto(out *SubscriberStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriberStatus. +func (in *SubscriberStatus) DeepCopy() *SubscriberStatus { + if in == nil { + return nil + } + out := new(SubscriberStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/register.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/register.go index 49493ed577..daa6a11d41 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/register.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/register.go @@ -18,4 +18,12 @@ package eventing const ( GroupName = "eventing.knative.dev" + + // CreatorAnnotation is the annotation key to describe the user that + // created the resource. + CreatorAnnotation = GroupName + "/creator" + + // UpdaterAnnotation is the annotation key to describe the user that + // last updated the resource. + UpdaterAnnotation = GroupName + "/lastModifier" ) diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/broker_defaults.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/broker_defaults.go index 6351fea1a2..3c6c0726e0 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/broker_defaults.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/broker_defaults.go @@ -16,10 +16,13 @@ limitations under the License. package v1alpha1 -import "context" +import ( + "context" +) func (b *Broker) SetDefaults(ctx context.Context) { b.Spec.SetDefaults(ctx) + setUserInfoAnnotations(b, ctx) } func (bs *BrokerSpec) SetDefaults(ctx context.Context) { diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/broker_lifecycle.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/broker_lifecycle.go index d6fa93499a..215bab258a 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/broker_lifecycle.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/broker_lifecycle.go @@ -17,12 +17,16 @@ limitations under the License. package v1alpha1 import ( - v1 "k8s.io/api/apps/v1" + "time" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + duckv1alpha1 "github.com/knative/eventing/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis" + appsv1 "k8s.io/api/apps/v1" + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -var brokerCondSet = duckv1alpha1.NewLivingConditionSet( +var brokerCondSet = apis.NewLivingConditionSet( BrokerConditionIngress, BrokerConditionTriggerChannel, BrokerConditionIngressChannel, @@ -32,22 +36,22 @@ var brokerCondSet = duckv1alpha1.NewLivingConditionSet( ) const ( - BrokerConditionReady = duckv1alpha1.ConditionReady - BrokerConditionIngress duckv1alpha1.ConditionType = "IngressReady" + BrokerConditionReady = apis.ConditionReady + BrokerConditionIngress apis.ConditionType = "IngressReady" - BrokerConditionTriggerChannel duckv1alpha1.ConditionType = "TriggerChannelReady" + BrokerConditionTriggerChannel apis.ConditionType = "TriggerChannelReady" - BrokerConditionIngressChannel duckv1alpha1.ConditionType = "IngressChannelReady" + BrokerConditionIngressChannel apis.ConditionType = "IngressChannelReady" - BrokerConditionIngressSubscription duckv1alpha1.ConditionType = "IngressSubscriptionReady" + BrokerConditionIngressSubscription apis.ConditionType = "IngressSubscriptionReady" - BrokerConditionFilter duckv1alpha1.ConditionType = "FilterReady" + BrokerConditionFilter apis.ConditionType = "FilterReady" - BrokerConditionAddressable duckv1alpha1.ConditionType = "Addressable" + BrokerConditionAddressable apis.ConditionType = "Addressable" ) // GetCondition returns the condition currently associated with the given type, or nil. -func (bs *BrokerStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition { +func (bs *BrokerStatus) GetCondition(t apis.ConditionType) *apis.Condition { return brokerCondSet.Manage(bs).GetCondition(t) } @@ -65,7 +69,7 @@ func (bs *BrokerStatus) MarkIngressFailed(reason, format string, args ...interfa brokerCondSet.Manage(bs).MarkFalse(BrokerConditionIngress, reason, format, args...) } -func (bs *BrokerStatus) PropagateIngressDeploymentAvailability(d *v1.Deployment) { +func (bs *BrokerStatus) PropagateIngressDeploymentAvailability(d *appsv1.Deployment) { if deploymentIsAvailable(&d.Status) { brokerCondSet.Manage(bs).MarkTrue(BrokerConditionIngress) } else { @@ -91,6 +95,16 @@ func (bs *BrokerStatus) PropagateTriggerChannelReadiness(cs *ChannelStatus) { } } +func (bs *BrokerStatus) PropagateTriggerChannelReadinessCRD(cs *duckv1alpha1.ChannelableStatus) { + // TODO: Once you can get a Ready status from Channelable in a generic way, use it here... + address := cs.AddressStatus.Address + if address != nil { + brokerCondSet.Manage(bs).MarkTrue(BrokerConditionTriggerChannel) + } else { + bs.MarkTriggerChannelFailed("ChannelNotReady", "trigger Channel is not ready: not addressalbe") + } +} + func (bs *BrokerStatus) MarkIngressChannelFailed(reason, format string, args ...interface{}) { brokerCondSet.Manage(bs).MarkFalse(BrokerConditionIngressChannel, reason, format, args...) } @@ -107,6 +121,16 @@ func (bs *BrokerStatus) PropagateIngressChannelReadiness(cs *ChannelStatus) { } } +func (bs *BrokerStatus) PropagateIngressChannelReadinessCRD(cs *duckv1alpha1.ChannelableStatus) { + // TODO: Once you can get a Ready status from Channelable in a generic way, use it here... + address := cs.AddressStatus.Address + if address != nil { + brokerCondSet.Manage(bs).MarkTrue(BrokerConditionIngressChannel) + } else { + bs.MarkIngressChannelFailed("ChannelNotReady", "ingress Channel is not ready: not addressable") + } +} + func (bs *BrokerStatus) MarkIngressSubscriptionFailed(reason, format string, args ...interface{}) { brokerCondSet.Manage(bs).MarkFalse(BrokerConditionIngressSubscription, reason, format, args...) } @@ -127,7 +151,7 @@ func (bs *BrokerStatus) MarkFilterFailed(reason, format string, args ...interfac brokerCondSet.Manage(bs).MarkFalse(BrokerConditionFilter, reason, format, args...) } -func (bs *BrokerStatus) PropagateFilterDeploymentAvailability(d *v1.Deployment) { +func (bs *BrokerStatus) PropagateFilterDeploymentAvailability(d *appsv1.Deployment) { if deploymentIsAvailable(&d.Status) { brokerCondSet.Manage(bs).MarkTrue(BrokerConditionFilter) } else { @@ -137,10 +161,10 @@ func (bs *BrokerStatus) PropagateFilterDeploymentAvailability(d *v1.Deployment) } } -func deploymentIsAvailable(d *v1.DeploymentStatus) bool { +func deploymentIsAvailable(d *appsv1.DeploymentStatus) bool { // Check if the Deployment is available. for _, cond := range d.Conditions { - if cond.Type == v1.DeploymentAvailable { + if cond.Type == appsv1.DeploymentAvailable { return cond.Status == "True" } } @@ -150,11 +174,34 @@ func deploymentIsAvailable(d *v1.DeploymentStatus) bool { // SetAddress makes this Broker addressable by setting the hostname. It also // sets the BrokerConditionAddressable to true. -func (bs *BrokerStatus) SetAddress(hostname string) { - bs.Address.Hostname = hostname - if hostname != "" { +func (bs *BrokerStatus) SetAddress(url *apis.URL) { + if url != nil { + bs.Address.Hostname = url.Host + bs.Address.URL = url brokerCondSet.Manage(bs).MarkTrue(BrokerConditionAddressable) } else { + bs.Address.Hostname = "" + bs.Address.URL = nil brokerCondSet.Manage(bs).MarkFalse(BrokerConditionAddressable, "emptyHostname", "hostname is the empty string") } } + +// MarkDeprecated adds a warning condition that using Channel Provisioners is deprecated +// and will stop working in the future. Note that this does not affect the Ready condition. +func (cs *BrokerStatus) MarkDeprecated(reason, msg string) { + dc := apis.Condition{ + Type: "Deprecated", + Reason: reason, + Status: v1.ConditionTrue, + Severity: apis.ConditionSeverityWarning, + Message: msg, + LastTransitionTime: apis.VolatileTime{Inner: metav1.NewTime(time.Now())}, + } + for i, c := range cs.Conditions { + if c.Type == dc.Type { + cs.Conditions[i] = dc + return + } + } + cs.Conditions = append(cs.Conditions, dc) +} diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/broker_types.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/broker_types.go index 27d2448bc5..6bfc59a00e 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/broker_types.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/broker_types.go @@ -17,10 +17,12 @@ package v1alpha1 import ( - "github.com/knative/pkg/apis" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" - "github.com/knative/pkg/kmeta" - "github.com/knative/pkg/webhook" + "knative.dev/pkg/apis" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/kmeta" + "knative.dev/pkg/webhook" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -29,6 +31,11 @@ import ( // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// Broker collects a pool of events that are consumable using Triggers. Brokers +// provide a well-known endpoint for event delivery that senders can use with +// minimal knowledge of the event routing strategy. Receivers use Triggers to +// request delivery of events from a Broker's pool to a specific URL or +// Addressable endpoint. type Broker struct { metav1.TypeMeta `json:",inline"` // +optional @@ -55,21 +62,51 @@ var ( _ kmeta.OwnerRefable = (*Broker)(nil) ) +// This should be duck so that Broker can also use this +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type ChannelTemplateSpec struct { + metav1.TypeMeta `json:",inline"` + + // Spec defines the Spec to use for each channel created. Passed + // in verbatim to the Channel CRD as Spec section. + // +optional + Spec runtime.RawExtension `json:"spec"` +} + +// Internal version of ChannelTemplateSpec that includes ObjectMeta so that +// we can easily create new Channels off of it. +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type ChannelTemplateSpecInternal struct { + metav1.TypeMeta `json:",inline"` + + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec defines the Spec to use for each channel created. Passed + // in verbatim to the Channel CRD as Spec section. + // +optional + Spec runtime.RawExtension `json:"spec"` +} + type BrokerSpec struct { - // ChannelTemplate, if specified will be used to create all the Channels used internally by the + // DeprecatedChannelTemplate, if specified will be used to create all the Channels used internally by the // Broker. Only Provisioner and Arguments may be specified. If left unspecified, the default // Channel for the namespace will be used. // // +optional - ChannelTemplate *ChannelSpec `json:"channelTemplate,omitempty"` + DeprecatedChannelTemplate *ChannelSpec `json:"channelTemplate,omitempty"` + + // ChannelTemplate specifies which Channel CRD to use to create all the Channels used internally by the + // Broker. + ChannelTemplate ChannelTemplateSpec `json:"channelTemplateSpec"` } // BrokerStatus represents the current state of a Broker. type BrokerStatus struct { - // inherits duck/v1alpha1 Status, which currently provides: + // inherits duck/v1beta1 Status, which currently provides: // * ObservedGeneration - the 'Generation' of the Service that was last processed by the controller. // * Conditions - the latest available observations of a resource's current state. - duckv1alpha1.Status `json:",inline"` + duckv1beta1.Status `json:",inline"` // Broker is Addressable. It currently exposes the endpoint as a // fully-qualified DNS name which will distribute traffic over the @@ -77,6 +114,12 @@ type BrokerStatus struct { // // It generally has the form {broker}-router.{namespace}.svc.{cluster domain name} Address duckv1alpha1.Addressable `json:"address,omitempty"` + + // TriggerChannel is an objectref to the object for the TriggerChannel + TriggerChannel *corev1.ObjectReference `json:"triggerChannel,omitempty"` + + // IngressChannel is an objectref to the object for the IngressChannel + IngressChannel *corev1.ObjectReference `json:"IngressChannel,omitempty"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -93,3 +136,8 @@ type BrokerList struct { func (t *Broker) GetGroupVersionKind() schema.GroupVersionKind { return SchemeGroupVersion.WithKind("Broker") } + +// GetSpec returns the spec of the Broker. +func (b *Broker) GetSpec() interface{} { + return b.Spec +} diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/broker_validation.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/broker_validation.go index 483e1ffab8..f4d949ba8e 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/broker_validation.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/broker_validation.go @@ -19,7 +19,8 @@ package v1alpha1 import ( "context" - "github.com/knative/pkg/apis" + "knative.dev/pkg/apis" + "k8s.io/apimachinery/pkg/api/equality" ) func (b *Broker) Validate(ctx context.Context) *apis.FieldError { @@ -27,8 +28,51 @@ func (b *Broker) Validate(ctx context.Context) *apis.FieldError { } func (bs *BrokerSpec) Validate(ctx context.Context) *apis.FieldError { + var errs *apis.FieldError + + if bs.DeprecatedChannelTemplate != nil && !equality.Semantic.DeepEqual(bs.ChannelTemplate, ChannelTemplateSpec{}) { + errs = errs.Also(apis.ErrMultipleOneOf("channelTemplate", "channelTemplateSpec")) + return errs + } + + if dcte := isValidDeprecatedChannelTemplate(bs.DeprecatedChannelTemplate); dcte != nil { + errs = errs.Also(dcte.ViaField("channelTemplate")) + } + + if !equality.Semantic.DeepEqual(bs.ChannelTemplate, ChannelTemplateSpec{}) { + if cte := isValidChannelTemplate(bs.ChannelTemplate); cte != nil { + errs = errs.Also(cte.ViaField("channelTemplateSpec")) + } + } + // TODO validate that the channelTemplate only specifies the provisioner and arguments. - return nil + return errs +} + +func isValidDeprecatedChannelTemplate(dct *ChannelSpec) *apis.FieldError { + if dct == nil { + return nil + } + var errs *apis.FieldError + if dct.DeprecatedGeneration != 0 { + errs = errs.Also(apis.ErrDisallowedFields("deprecatedGeneration")) + } + if dct.Subscribable != nil { + errs = errs.Also(apis.ErrDisallowedFields("subscribable")) + } + + return errs +} + +func isValidChannelTemplate(dct ChannelTemplateSpec) *apis.FieldError { + var errs *apis.FieldError + if dct.Kind == "" { + errs = errs.Also(apis.ErrMissingField("kind")) + } + if dct.APIVersion == "" { + errs = errs.Also(apis.ErrMissingField("apiVersion")) + } + return errs } func (b *Broker) CheckImmutableFields(ctx context.Context, og apis.Immutable) *apis.FieldError { diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/channel_defaults.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/channel_defaults.go index c904eb1cfb..c135ac60d3 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/channel_defaults.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/channel_defaults.go @@ -48,6 +48,7 @@ func (c *Channel) SetDefaults(ctx context.Context) { } } c.Spec.SetDefaults(ctx) + setUserInfoAnnotations(c, ctx) } func (cs *ChannelSpec) SetDefaults(ctx context.Context) {} diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/channel_lifecycle.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/channel_lifecycle.go index 117f726827..16a996b03d 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/channel_lifecycle.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/channel_lifecycle.go @@ -19,33 +19,32 @@ package v1alpha1 import ( "time" - "github.com/knative/pkg/apis" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -var chanCondSet = duckv1alpha1.NewLivingConditionSet(ChannelConditionProvisioned, ChannelConditionAddressable, ChannelConditionProvisionerInstalled) +var chanCondSet = apis.NewLivingConditionSet(ChannelConditionProvisioned, ChannelConditionAddressable, ChannelConditionProvisionerInstalled) const ( // ChannelConditionReady has status True when the Channel is ready to // accept traffic. - ChannelConditionReady = duckv1alpha1.ConditionReady + ChannelConditionReady = apis.ConditionReady // ChannelConditionProvisioned has status True when the Channel's // backing resources have been provisioned. - ChannelConditionProvisioned duckv1alpha1.ConditionType = "Provisioned" + ChannelConditionProvisioned apis.ConditionType = "Provisioned" // ChannelConditionAddressable has status true when this Channel meets // the Addressable contract and has a non-empty hostname. - ChannelConditionAddressable duckv1alpha1.ConditionType = "Addressable" + ChannelConditionAddressable apis.ConditionType = "Addressable" // ChannelConditionProvisionerInstalled has status true when the channel is being watched // by the provisioner's channel controller (in other words, the provisioner is installed) - ChannelConditionProvisionerInstalled duckv1alpha1.ConditionType = "ProvisionerInstalled" + ChannelConditionProvisionerInstalled apis.ConditionType = "ProvisionerInstalled" ) // GetCondition returns the condition currently associated with the given type, or nil. -func (cs *ChannelStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition { +func (cs *ChannelStatus) GetCondition(t apis.ConditionType) *apis.Condition { return chanCondSet.Manage(cs).GetCondition(t) } @@ -87,11 +86,11 @@ func (cs *ChannelStatus) MarkProvisionerNotInstalled(reason, messageFormat strin // MarkDeprecated adds a warning condition that this Channel is deprecated and will stop working in // the future. Note that this does not affect the Ready condition. func (cs *ChannelStatus) MarkDeprecated(reason, msg string) { - dc := duckv1alpha1.Condition{ + dc := apis.Condition{ Type: "Deprecated", Reason: reason, Status: v1.ConditionTrue, - Severity: duckv1alpha1.ConditionSeverityWarning, + Severity: apis.ConditionSeverityWarning, Message: msg, LastTransitionTime: apis.VolatileTime{Inner: metav1.NewTime(time.Now())}, } @@ -106,11 +105,14 @@ func (cs *ChannelStatus) MarkDeprecated(reason, msg string) { // SetAddress makes this Channel addressable by setting the hostname. It also // sets the ChannelConditionAddressable to true. -func (cs *ChannelStatus) SetAddress(hostname string) { - cs.Address.Hostname = hostname - if hostname != "" { +func (cs *ChannelStatus) SetAddress(url *apis.URL) { + if url != nil { + cs.Address.Hostname = url.Host + cs.Address.URL = url chanCondSet.Manage(cs).MarkTrue(ChannelConditionAddressable) } else { + cs.Address.Hostname = "" + cs.Address.URL = nil chanCondSet.Manage(cs).MarkFalse(ChannelConditionAddressable, "emptyHostname", "hostname is the empty string") } } diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/channel_types.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/channel_types.go index af0b7dcce1..7120b50953 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/channel_types.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/channel_types.go @@ -18,10 +18,11 @@ package v1alpha1 import ( eventingduck "github.com/knative/eventing/pkg/apis/duck/v1alpha1" - "github.com/knative/pkg/apis" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" - "github.com/knative/pkg/kmeta" - "github.com/knative/pkg/webhook" + "knative.dev/pkg/apis" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/kmeta" + "knative.dev/pkg/webhook" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -86,10 +87,10 @@ type ChannelSpec struct { // ChannelStatus represents the current state of a Channel. type ChannelStatus struct { - // inherits duck/v1alpha1 Status, which currently provides: + // inherits duck/v1beta1 Status, which currently provides: // * ObservedGeneration - the 'Generation' of the Service that was last processed by the controller. // * Conditions - the latest available observations of a resource's current state. - duckv1alpha1.Status `json:",inline"` + duckv1beta1.Status `json:",inline"` // Channel is Addressable. It currently exposes the endpoint as a // fully-qualified DNS name which will distribute traffic over the @@ -101,6 +102,8 @@ type ChannelStatus struct { // Internal is status unique to each ClusterChannelProvisioner. // +optional Internal *runtime.RawExtension `json:"internal,omitempty"` + + eventingduck.SubscribableTypeStatus `json:",inline"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -117,3 +120,8 @@ type ChannelList struct { func (c *Channel) GetGroupVersionKind() schema.GroupVersionKind { return SchemeGroupVersion.WithKind("Channel") } + +// GetSpec returns the spec of the Channel. +func (c *Channel) GetSpec() interface{} { + return c.Spec +} diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/channel_validation.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/channel_validation.go index d452f31ad4..76c7f3dd8d 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/channel_validation.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/channel_validation.go @@ -21,8 +21,8 @@ import ( "fmt" "github.com/google/go-cmp/cmp/cmpopts" - "github.com/knative/pkg/apis" - "github.com/knative/pkg/kmp" + "knative.dev/pkg/apis" + "knative.dev/pkg/kmp" ) func (c *Channel) Validate(ctx context.Context) *apis.FieldError { diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/cluster_channel_provisioner_types.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/cluster_channel_provisioner_types.go index e14ff5fc9a..9f7f333d63 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/cluster_channel_provisioner_types.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/cluster_channel_provisioner_types.go @@ -17,14 +17,13 @@ limitations under the License. package v1alpha1 import ( - "github.com/knative/pkg/apis" - "github.com/knative/pkg/kmeta" - "github.com/knative/pkg/webhook" + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/kmeta" + "knative.dev/pkg/webhook" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" ) // +genclient @@ -69,30 +68,24 @@ type ClusterChannelProvisionerSpec struct { DeprecatedGeneration int64 `json:"generation,omitempty"` } -var ccProvCondSet = duckv1alpha1.NewLivingConditionSet() +var ccProvCondSet = apis.NewLivingConditionSet() // ClusterChannelProvisionerStatus is the status for a ClusterChannelProvisioner resource type ClusterChannelProvisionerStatus struct { - // Conditions holds the state of a cluster provisioner at a point in time. - // +optional - // +patchMergeKey=type - // +patchStrategy=merge - Conditions duckv1alpha1.Conditions `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` - - // ObservedGeneration is the 'Generation' of the ClusterChannelProvisioner that - // was last reconciled by the controller. - // +optional - ObservedGeneration int64 `json:"observedGeneration,omitempty"` + // inherits duck/v1beta1 Status, which currently provides: + // * ObservedGeneration - the 'Generation' of the Service that was last processed by the controller. + // * Conditions - the latest available observations of a resource's current state. + duckv1beta1.Status `json:",inline"` } const ( // ClusterChannelProvisionerConditionReady has status True when the Controller reconciling objects // controlled by it is ready to control them. - ClusterChannelProvisionerConditionReady = duckv1alpha1.ConditionReady + ClusterChannelProvisionerConditionReady = apis.ConditionReady ) // GetCondition returns the condition currently associated with the given type, or nil. -func (ps *ClusterChannelProvisionerStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition { +func (ps *ClusterChannelProvisionerStatus) GetCondition(t apis.ConditionType) *apis.Condition { return ccProvCondSet.Manage(ps).GetCondition(t) } diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/cluster_channel_provisioner_validation.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/cluster_channel_provisioner_validation.go index 0aacde90ad..b1ba51c184 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/cluster_channel_provisioner_validation.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/cluster_channel_provisioner_validation.go @@ -19,7 +19,7 @@ package v1alpha1 import ( "context" - "github.com/knative/pkg/apis" + "knative.dev/pkg/apis" ) // Validate validates the ClusterChannelProvisioner resource. diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/eventtype_lifecycle.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/eventtype_lifecycle.go index 5cef6862a6..6783fb3681 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/eventtype_lifecycle.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/eventtype_lifecycle.go @@ -16,18 +16,20 @@ limitations under the License. package v1alpha1 -import duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" +import ( + "knative.dev/pkg/apis" +) -var eventTypeCondSet = duckv1alpha1.NewLivingConditionSet(EventTypeConditionBrokerExists, EventTypeConditionBrokerReady) +var eventTypeCondSet = apis.NewLivingConditionSet(EventTypeConditionBrokerExists, EventTypeConditionBrokerReady) const ( - EventTypeConditionReady = duckv1alpha1.ConditionReady - EventTypeConditionBrokerExists duckv1alpha1.ConditionType = "BrokerExists" - EventTypeConditionBrokerReady duckv1alpha1.ConditionType = "BrokerReady" + EventTypeConditionReady = apis.ConditionReady + EventTypeConditionBrokerExists apis.ConditionType = "BrokerExists" + EventTypeConditionBrokerReady apis.ConditionType = "BrokerReady" ) // GetCondition returns the condition currently associated with the given type, or nil. -func (et *EventTypeStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition { +func (et *EventTypeStatus) GetCondition(t apis.ConditionType) *apis.Condition { return eventTypeCondSet.Manage(et).GetCondition(t) } diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/eventtype_types.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/eventtype_types.go index bf6e1a2fb7..36fb4f82f1 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/eventtype_types.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/eventtype_types.go @@ -17,9 +17,9 @@ package v1alpha1 import ( - "github.com/knative/pkg/apis" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" - "github.com/knative/pkg/webhook" + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/webhook" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" ) @@ -66,10 +66,10 @@ type EventTypeSpec struct { // EventTypeStatus represents the current state of a EventType. type EventTypeStatus struct { - // inherits duck/v1alpha1 Status, which currently provides: + // inherits duck/v1beta1 Status, which currently provides: // * ObservedGeneration - the 'Generation' of the Service that was last processed by the controller. // * Conditions - the latest available observations of a resource's current state. - duckv1alpha1.Status `json:",inline"` + duckv1beta1.Status `json:",inline"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/eventtype_validation.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/eventtype_validation.go index a162f7dc92..83efc7594f 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/eventtype_validation.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/eventtype_validation.go @@ -21,8 +21,8 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" - "github.com/knative/pkg/apis" - "github.com/knative/pkg/kmp" + "knative.dev/pkg/apis" + "knative.dev/pkg/kmp" ) func (et *EventType) Validate(ctx context.Context) *apis.FieldError { diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/register.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/register.go index 977cad56aa..320b6be84b 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/register.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/register.go @@ -51,12 +51,12 @@ func addKnownTypes(scheme *runtime.Scheme) error { &ChannelList{}, &ClusterChannelProvisioner{}, &ClusterChannelProvisionerList{}, + &EventType{}, + &EventTypeList{}, &Subscription{}, &SubscriptionList{}, &Trigger{}, &TriggerList{}, - &EventType{}, - &EventTypeList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/subscribable_channelable_validation.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/subscribable_channelable_validation.go index b415b68a18..e04c668baa 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/subscribable_channelable_validation.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/subscribable_channelable_validation.go @@ -20,7 +20,7 @@ import ( "reflect" "github.com/google/go-cmp/cmp" - "github.com/knative/pkg/apis" + "knative.dev/pkg/apis" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/equality" ) @@ -29,28 +29,12 @@ func isChannelEmpty(f corev1.ObjectReference) bool { return equality.Semantic.DeepEqual(f, corev1.ObjectReference{}) } -// Valid from only contains the following fields: -// - Kind == 'Channel' -// - APIVersion == 'eventing.knative.dev/v1alpha1' -// - Name == not empty +// Valid if it is a valid object reference. func isValidChannel(f corev1.ObjectReference) *apis.FieldError { - errs := isValidObjectReference(f) - - if f.Kind != "Channel" { - fe := apis.ErrInvalidValue(f.Kind, "kind") - fe.Paths = []string{"kind"} - fe.Details = "only 'Channel' kind is allowed" - errs = errs.Also(fe) - } - if f.APIVersion != "eventing.knative.dev/v1alpha1" { - fe := apis.ErrInvalidValue(f.APIVersion, "apiVersion") - fe.Details = "only eventing.knative.dev/v1alpha1 is allowed for apiVersion" - errs = errs.Also(fe) - } - return errs + return IsValidObjectReference(f) } -func isValidObjectReference(f corev1.ObjectReference) *apis.FieldError { +func IsValidObjectReference(f corev1.ObjectReference) *apis.FieldError { return checkRequiredObjectReferenceFields(f). Also(checkDisallowedObjectReferenceFields(f)) } diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/subscription_defaults.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/subscription_defaults.go index a3d3133e6d..2e2b5b1618 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/subscription_defaults.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/subscription_defaults.go @@ -16,10 +16,13 @@ limitations under the License. package v1alpha1 -import "context" +import ( + "context" +) func (s *Subscription) SetDefaults(ctx context.Context) { s.Spec.SetDefaults(ctx) + setUserInfoAnnotations(s, ctx) } func (ss *SubscriptionSpec) SetDefaults(ctx context.Context) { diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/subscription_lifecycle.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/subscription_lifecycle.go index 193673d0ad..3e79330006 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/subscription_lifecycle.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/subscription_lifecycle.go @@ -16,22 +16,31 @@ package v1alpha1 -import duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" +import ( + "knative.dev/pkg/apis" +) + +// subCondSet is a condition set with Ready as the happy condition and +// ReferencesResolved and ChannelReady as the dependent conditions. +var subCondSet = apis.NewLivingConditionSet(SubscriptionConditionReferencesResolved, SubscriptionConditionAddedToChannel, SubscriptionConditionChannelReady) const ( // SubscriptionConditionReady has status True when all subconditions below have been set to True. - SubscriptionConditionReady = duckv1alpha1.ConditionReady + SubscriptionConditionReady = apis.ConditionReady // SubscriptionConditionReferencesResolved has status True when all the specified references have been successfully // resolved. - SubscriptionConditionReferencesResolved duckv1alpha1.ConditionType = "Resolved" + SubscriptionConditionReferencesResolved apis.ConditionType = "Resolved" - // SubscriptionConditionChannelReady has status True when controller has successfully added a + // SubscriptionConditionAddedToChannel has status True when controller has successfully added a // subscription to the spec.channel resource. - SubscriptionConditionChannelReady duckv1alpha1.ConditionType = "ChannelReady" + SubscriptionConditionAddedToChannel apis.ConditionType = "AddedToChannel" + + // SubscriptionConditionChannelReady has status True when the channel has marked the subscriber as 'ready' + SubscriptionConditionChannelReady apis.ConditionType = "ChannelReady" ) // GetCondition returns the condition currently associated with the given type, or nil. -func (ss *SubscriptionStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition { +func (ss *SubscriptionStatus) GetCondition(t apis.ConditionType) *apis.Condition { return subCondSet.Manage(ss).GetCondition(t) } @@ -40,6 +49,16 @@ func (ss *SubscriptionStatus) IsReady() bool { return subCondSet.Manage(ss).IsHappy() } +// IsAddedToChannel returns true if SubscriptionConditionAddedToChannel is true +func (ss *SubscriptionStatus) IsAddedToChannel() bool { + return ss.GetCondition(SubscriptionConditionAddedToChannel).IsTrue() +} + +// AreReferencesResolved returns true if SubscriptionConditionReferencesResolved is true +func (ss *SubscriptionStatus) AreReferencesResolved() bool { + return ss.GetCondition(SubscriptionConditionReferencesResolved).IsTrue() +} + // InitializeConditions sets relevant unset conditions to Unknown state. func (ss *SubscriptionStatus) InitializeConditions() { subCondSet.Manage(ss).InitializeConditions() @@ -54,3 +73,23 @@ func (ss *SubscriptionStatus) MarkReferencesResolved() { func (ss *SubscriptionStatus) MarkChannelReady() { subCondSet.Manage(ss).MarkTrue(SubscriptionConditionChannelReady) } + +// MarkAddedToChannel sets the AddedToChannel condition to True state. +func (ss *SubscriptionStatus) MarkAddedToChannel() { + subCondSet.Manage(ss).MarkTrue(SubscriptionConditionAddedToChannel) +} + +// MarkReferencesNotResolved sets the ReferencesResolved condition to False state. +func (ss *SubscriptionStatus) MarkReferencesNotResolved(reason, messageFormat string, messageA ...interface{}) { + subCondSet.Manage(ss).MarkFalse(SubscriptionConditionReferencesResolved, reason, messageFormat, messageA...) +} + +// MarkChannelNotReady sets the ChannelReady condition to False state. +func (ss *SubscriptionStatus) MarkChannelNotReady(reason, messageFormat string, messageA ...interface{}) { + subCondSet.Manage(ss).MarkFalse(SubscriptionConditionChannelReady, reason, messageFormat, messageA) +} + +// MarkNotAddedToChannel sets the AddedToChannel condition to False state. +func (ss *SubscriptionStatus) MarkNotAddedToChannel(reason, messageFormat string, messageA ...interface{}) { + subCondSet.Manage(ss).MarkFalse(SubscriptionConditionAddedToChannel, reason, messageFormat, messageA) +} diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/subscription_types.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/subscription_types.go index e43377c021..d09ddf90b8 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/subscription_types.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/subscription_types.go @@ -17,12 +17,13 @@ package v1alpha1 import ( - "github.com/knative/pkg/apis" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" - "github.com/knative/pkg/webhook" + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/webhook" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" ) // +genclient @@ -49,7 +50,7 @@ var _ webhook.GenericCRD = (*Subscription)(nil) // for processing those events and where to put the result of the processing. Only // From (where the events are coming from) is always required. You can optionally // only Process the events (results in no output events) by leaving out the Result. -// You can also perform an identity transformation on the invoming events by leaving +// You can also perform an identity transformation on the incoming events by leaving // out the Subscriber and only specifying Result. // // The following are all valid specifications: @@ -76,9 +77,10 @@ type SubscriptionSpec struct { // - Kind // - APIVersion // - Name - // Kind must be "Channel" and APIVersion must be - // "eventing.knative.dev/v1alpha1" - // + // The resource pointed by this ObjectReference must meet the Subscribable contract + // with a pointer to the Subscribable duck type. If the resource does not meet this contract, + // it will be reflected in the Subscription's status. + // This field is immutable. We have no good answer on what happens to // the events that are currently in the channel being consumed from // and what the semantics there should be. For now, you can always @@ -153,28 +155,23 @@ type SubscriberSpec struct { // ReplyStrategy specifies the handling of the SubscriberSpec's returned replies. // If no SubscriberSpec is specified, the identity function is assumed. type ReplyStrategy struct { - // This object must be a Channel. - // // You can specify only the following fields of the ObjectReference: // - Kind // - APIVersion // - Name - // Kind must be "Channel" and APIVersion must be - // "eventing.knative.dev/v1alpha1" + // The resource pointed by this ObjectReference must meet the Addressable contract + // with a reference to the Addressable duck type. If the resource does not meet this contract, + // it will be reflected in the Subscription's status. // +optional Channel *corev1.ObjectReference `json:"channel,omitempty"` } -// subCondSet is a condition set with Ready as the happy condition and -// ReferencesResolved and ChannelReady as the dependent conditions. -var subCondSet = duckv1alpha1.NewLivingConditionSet(SubscriptionConditionReferencesResolved, SubscriptionConditionChannelReady) - // SubscriptionStatus (computed) for a subscription type SubscriptionStatus struct { - // inherits duck/v1alpha1 Status, which currently provides: + // inherits duck/v1beta1 Status, which currently provides: // * ObservedGeneration - the 'Generation' of the Service that was last processed by the controller. // * Conditions - the latest available observations of a resource's current state. - duckv1alpha1.Status `json:",inline"` + duckv1beta1.Status `json:",inline"` // PhysicalSubscription is the fully resolved values that this Subscription represents. PhysicalSubscription SubscriptionStatusPhysicalSubscription `json:"physicalSubscription,omitempty"` @@ -198,3 +195,13 @@ type SubscriptionList struct { metav1.ListMeta `json:"metadata"` Items []Subscription `json:"items"` } + +// GetGroupVersionKind returns GroupVersionKind for Subscriptions +func (t *Subscription) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Subscription") +} + +// GetSpec returns the spec of the Subscription. +func (s *Subscription) GetSpec() interface{} { + return s.Spec +} diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/subscription_validation.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/subscription_validation.go index abed237e2b..648e0fcfc7 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/subscription_validation.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/subscription_validation.go @@ -20,8 +20,8 @@ import ( "context" "github.com/google/go-cmp/cmp/cmpopts" - "github.com/knative/pkg/apis" - "github.com/knative/pkg/kmp" + "knative.dev/pkg/apis" + "knative.dev/pkg/kmp" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/equality" ) @@ -52,7 +52,7 @@ func (ss *SubscriptionSpec) Validate(ctx context.Context) *apis.FieldError { } if !missingSubscriber { - if fe := isValidSubscriberSpec(*ss.Subscriber); fe != nil { + if fe := IsValidSubscriberSpec(*ss.Subscriber); fe != nil { errs = errs.Also(fe.ViaField("subscriber")) } } @@ -78,7 +78,7 @@ func isSubscriberSpecNilOrEmpty(s *SubscriberSpec) bool { return false } -func isValidSubscriberSpec(s SubscriberSpec) *apis.FieldError { +func IsValidSubscriberSpec(s SubscriberSpec) *apis.FieldError { var errs *apis.FieldError fieldsSet := make([]string, 0, 0) @@ -99,7 +99,7 @@ func isValidSubscriberSpec(s SubscriberSpec) *apis.FieldError { // If Ref given, check the fields. if s.Ref != nil && !equality.Semantic.DeepEqual(s.Ref, &corev1.ObjectReference{}) { - fe := isValidObjectReference(*s.Ref) + fe := IsValidObjectReference(*s.Ref) if fe != nil { errs = errs.Also(fe.ViaField("ref")) } @@ -112,20 +112,9 @@ func isReplyStrategyNilOrEmpty(r *ReplyStrategy) bool { } func isValidReply(r ReplyStrategy) *apis.FieldError { - if fe := isValidObjectReference(*r.Channel); fe != nil { + if fe := IsValidObjectReference(*r.Channel); fe != nil { return fe.ViaField("channel") } - if r.Channel.Kind != "Channel" { - fe := apis.ErrInvalidValue(r.Channel.Kind, "kind") - fe.Paths = []string{"kind"} - fe.Details = "only 'Channel' kind is allowed" - return fe - } - if r.Channel.APIVersion != "eventing.knative.dev/v1alpha1" { - fe := apis.ErrInvalidValue(r.Channel.APIVersion, "apiVersion") - fe.Details = "only eventing.knative.dev/v1alpha1 is allowed for apiVersion" - return fe - } return nil } diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/test_helper.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/test_helper.go index 3cbbea8716..2f31eb67e1 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/test_helper.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/test_helper.go @@ -17,6 +17,10 @@ limitations under the License. package v1alpha1 import ( + duckv1alpha1 "github.com/knative/eventing/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis" + pkgduckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" v1 "k8s.io/api/apps/v1" ) @@ -29,7 +33,7 @@ func (testHelper) ReadyChannelStatus() *ChannelStatus { cs := &ChannelStatus{} cs.MarkProvisionerInstalled() cs.MarkProvisioned() - cs.SetAddress("foo") + cs.SetAddress(&apis.URL{Scheme: "http", Host: "foo"}) return cs } @@ -39,10 +43,30 @@ func (t testHelper) NotReadyChannelStatus() *ChannelStatus { return cs } +func (testHelper) ReadyChannelStatusCRD() *duckv1alpha1.ChannelableStatus { + cs := &duckv1alpha1.ChannelableStatus{ + Status: duckv1beta1.Status{}, + AddressStatus: pkgduckv1alpha1.AddressStatus{ + Address: &pkgduckv1alpha1.Addressable{ + Addressable: duckv1beta1.Addressable{ + URL: &apis.URL{Scheme: "http", Host: "foo"}, + }, + Hostname: "foo", + }, + }, + SubscribableTypeStatus: duckv1alpha1.SubscribableTypeStatus{}} + return cs +} + +func (t testHelper) NotReadyChannelStatusCRD() *duckv1alpha1.ChannelableStatus { + return &duckv1alpha1.ChannelableStatus{} +} + func (testHelper) ReadySubscriptionStatus() *SubscriptionStatus { ss := &SubscriptionStatus{} ss.MarkChannelReady() ss.MarkReferencesResolved() + ss.MarkAddedToChannel() return ss } @@ -59,7 +83,19 @@ func (t testHelper) ReadyBrokerStatus() *BrokerStatus { bs.PropagateTriggerChannelReadiness(t.ReadyChannelStatus()) bs.PropagateIngressSubscriptionReadiness(t.ReadySubscriptionStatus()) bs.PropagateFilterDeploymentAvailability(t.AvailableDeployment()) - bs.SetAddress("foo") + bs.SetAddress(&apis.URL{Scheme: "http", Host: "foo"}) + return bs +} + +func (t testHelper) ReadyBrokerStatusDeprecated() *BrokerStatus { + bs := &BrokerStatus{} + bs.MarkDeprecated("ClusterChannelProvisionerDeprecated", "Provisioners are deprecated and will be removed in 0.8. Recommended replacement is CRD based channels using spec.channelTemplateSpec.") + bs.PropagateIngressDeploymentAvailability(t.AvailableDeployment()) + bs.PropagateIngressChannelReadiness(t.ReadyChannelStatus()) + bs.PropagateTriggerChannelReadiness(t.ReadyChannelStatus()) + bs.PropagateIngressSubscriptionReadiness(t.ReadySubscriptionStatus()) + bs.PropagateFilterDeploymentAvailability(t.AvailableDeployment()) + bs.SetAddress(&apis.URL{Scheme: "http", Host: "foo"}) return bs } diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/trigger_defaults.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/trigger_defaults.go index 46ee6b032c..40f7c02547 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/trigger_defaults.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/trigger_defaults.go @@ -16,10 +16,13 @@ limitations under the License. package v1alpha1 -import "context" +import ( + "context" +) func (t *Trigger) SetDefaults(ctx context.Context) { t.Spec.SetDefaults(ctx) + setUserInfoAnnotations(t, ctx) } func (ts *TriggerSpec) SetDefaults(ctx context.Context) { diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/trigger_lifecycle.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/trigger_lifecycle.go index 5e7e5997b3..647c812557 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/trigger_lifecycle.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/trigger_lifecycle.go @@ -16,24 +16,26 @@ package v1alpha1 -import duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" +import ( + "knative.dev/pkg/apis" +) -var triggerCondSet = duckv1alpha1.NewLivingConditionSet(TriggerConditionBroker, TriggerConditionSubscribed) +var triggerCondSet = apis.NewLivingConditionSet(TriggerConditionBroker, TriggerConditionSubscribed) const ( // TriggerConditionReady has status True when all subconditions below have been set to True. - TriggerConditionReady = duckv1alpha1.ConditionReady + TriggerConditionReady = apis.ConditionReady - TriggerConditionBroker duckv1alpha1.ConditionType = "Broker" + TriggerConditionBroker apis.ConditionType = "Broker" - TriggerConditionSubscribed duckv1alpha1.ConditionType = "Subscribed" + TriggerConditionSubscribed apis.ConditionType = "Subscribed" // TriggerAnyFilter Constant to represent that we should allow anything. TriggerAnyFilter = "" ) // GetCondition returns the condition currently associated with the given type, or nil. -func (ts *TriggerStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition { +func (ts *TriggerStatus) GetCondition(t apis.ConditionType) *apis.Condition { return triggerCondSet.Manage(ts).GetCondition(t) } diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/trigger_types.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/trigger_types.go index e2d4e927a1..228875849b 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/trigger_types.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/trigger_types.go @@ -17,10 +17,10 @@ package v1alpha1 import ( - "github.com/knative/pkg/apis" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" - "github.com/knative/pkg/kmeta" - "github.com/knative/pkg/webhook" + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/kmeta" + "knative.dev/pkg/webhook" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -29,6 +29,8 @@ import ( // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// Trigger represents a request to have events delivered to a consumer from a +// Broker's event pool. type Trigger struct { metav1.TypeMeta `json:",inline"` // +optional @@ -85,10 +87,10 @@ type TriggerFilterSourceAndType struct { // TriggerStatus represents the current state of a Trigger. type TriggerStatus struct { - // inherits duck/v1alpha1 Status, which currently provides: + // inherits duck/v1beta1 Status, which currently provides: // * ObservedGeneration - the 'Generation' of the Service that was last processed by the controller. // * Conditions - the latest available observations of a resource's current state. - duckv1alpha1.Status `json:",inline"` + duckv1beta1.Status `json:",inline"` // SubscriberURI is the resolved URI of the receiver for this Trigger. SubscriberURI string `json:"subscriberURI,omitempty"` @@ -108,3 +110,8 @@ type TriggerList struct { func (t *Trigger) GetGroupVersionKind() schema.GroupVersionKind { return SchemeGroupVersion.WithKind("Trigger") } + +// GetSpec returns the spec of the Trigger. +func (t *Trigger) GetSpec() interface{} { + return t.Spec +} diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/trigger_validation.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/trigger_validation.go index 79aed96f71..cdae0d296f 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/trigger_validation.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/trigger_validation.go @@ -19,8 +19,8 @@ package v1alpha1 import ( "context" - "github.com/knative/pkg/apis" - "github.com/knative/pkg/kmp" + "knative.dev/pkg/apis" + "knative.dev/pkg/kmp" ) func (t *Trigger) Validate(ctx context.Context) *apis.FieldError { @@ -47,7 +47,7 @@ func (ts *TriggerSpec) Validate(ctx context.Context) *apis.FieldError { if isSubscriberSpecNilOrEmpty(ts.Subscriber) { fe := apis.ErrMissingField("subscriber") errs = errs.Also(fe) - } else if fe := isValidSubscriberSpec(*ts.Subscriber); fe != nil { + } else if fe := IsValidSubscriberSpec(*ts.Subscriber); fe != nil { errs = errs.Also(fe.ViaField("subscriber")) } diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/user_info.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/user_info.go new file mode 100644 index 0000000000..54362ce156 --- /dev/null +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/user_info.go @@ -0,0 +1,58 @@ +/* +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" + + "github.com/knative/eventing/pkg/apis/eventing" + "knative.dev/pkg/apis" + "k8s.io/apimachinery/pkg/api/equality" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type HasSpec interface { + // GetSpec returns the spec of the resource. + GetSpec() interface{} +} + +// setUserInfoAnnotations sets creator and updater annotations on a resource. +func setUserInfoAnnotations(resource HasSpec, ctx context.Context) { + if ui := apis.GetUserInfo(ctx); ui != nil { + objectMetaAccessor, ok := resource.(metav1.ObjectMetaAccessor) + if !ok { + return + } + + annotations := objectMetaAccessor.GetObjectMeta().GetAnnotations() + if annotations == nil { + annotations = map[string]string{} + defer objectMetaAccessor.GetObjectMeta().SetAnnotations(annotations) + } + + if apis.IsInUpdate(ctx) { + old := apis.GetBaseline(ctx).(HasSpec) + if equality.Semantic.DeepEqual(old.GetSpec(), resource.GetSpec()) { + return + } + annotations[eventing.UpdaterAnnotation] = ui.Username + } else { + annotations[eventing.CreatorAnnotation] = ui.Username + annotations[eventing.UpdaterAnnotation] = ui.Username + } + } +} diff --git a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/zz_generated.deepcopy.go index 0c7c002bb4..c79033073f 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/github.com/knative/eventing/pkg/apis/eventing/v1alpha1/zz_generated.deepcopy.go @@ -22,7 +22,6 @@ package v1alpha1 import ( duckv1alpha1 "github.com/knative/eventing/pkg/apis/duck/v1alpha1" - apisduckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -91,11 +90,12 @@ func (in *BrokerList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *BrokerSpec) DeepCopyInto(out *BrokerSpec) { *out = *in - if in.ChannelTemplate != nil { - in, out := &in.ChannelTemplate, &out.ChannelTemplate + if in.DeprecatedChannelTemplate != nil { + in, out := &in.DeprecatedChannelTemplate, &out.DeprecatedChannelTemplate *out = new(ChannelSpec) (*in).DeepCopyInto(*out) } + in.ChannelTemplate.DeepCopyInto(&out.ChannelTemplate) return } @@ -114,6 +114,16 @@ func (in *BrokerStatus) DeepCopyInto(out *BrokerStatus) { *out = *in in.Status.DeepCopyInto(&out.Status) in.Address.DeepCopyInto(&out.Address) + if in.TriggerChannel != nil { + in, out := &in.TriggerChannel, &out.TriggerChannel + *out = new(v1.ObjectReference) + **out = **in + } + if in.IngressChannel != nil { + in, out := &in.IngressChannel, &out.IngressChannel + *out = new(v1.ObjectReference) + **out = **in + } return } @@ -229,6 +239,7 @@ func (in *ChannelStatus) DeepCopyInto(out *ChannelStatus) { *out = new(runtime.RawExtension) (*in).DeepCopyInto(*out) } + in.SubscribableTypeStatus.DeepCopyInto(&out.SubscribableTypeStatus) return } @@ -242,6 +253,59 @@ func (in *ChannelStatus) DeepCopy() *ChannelStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ChannelTemplateSpec) DeepCopyInto(out *ChannelTemplateSpec) { + *out = *in + out.TypeMeta = in.TypeMeta + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChannelTemplateSpec. +func (in *ChannelTemplateSpec) DeepCopy() *ChannelTemplateSpec { + if in == nil { + return nil + } + out := new(ChannelTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ChannelTemplateSpec) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ChannelTemplateSpecInternal) DeepCopyInto(out *ChannelTemplateSpecInternal) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChannelTemplateSpecInternal. +func (in *ChannelTemplateSpecInternal) DeepCopy() *ChannelTemplateSpecInternal { + if in == nil { + return nil + } + out := new(ChannelTemplateSpecInternal) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ChannelTemplateSpecInternal) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterChannelProvisioner) DeepCopyInto(out *ClusterChannelProvisioner) { *out = *in @@ -322,13 +386,7 @@ func (in *ClusterChannelProvisionerSpec) DeepCopy() *ClusterChannelProvisionerSp // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterChannelProvisionerStatus) DeepCopyInto(out *ClusterChannelProvisionerStatus) { *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make(apisduckv1alpha1.Conditions, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } + in.Status.DeepCopyInto(&out.Status) return } diff --git a/vendor/github.com/knative/build/pkg/apis/build/register.go b/vendor/github.com/knative/eventing/pkg/apis/messaging/register.go similarity index 77% rename from vendor/github.com/knative/build/pkg/apis/build/register.go rename to vendor/github.com/knative/eventing/pkg/apis/messaging/register.go index 379817b13c..8f678adcd2 100644 --- a/vendor/github.com/knative/build/pkg/apis/build/register.go +++ b/vendor/github.com/knative/eventing/pkg/apis/messaging/register.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Knative Authors +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. @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ -package build +package messaging -// GroupName is the Kubernetes resource group name for Build types. -const GroupName = "build.knative.dev" +const ( + GroupName = "messaging.knative.dev" +) diff --git a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/doc.go b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/doc.go similarity index 89% rename from vendor/github.com/knative/build/pkg/apis/build/v1alpha1/doc.go rename to vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/doc.go index df551590c0..64e1d2ec05 100644 --- a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/doc.go +++ b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/doc.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Knative Authors +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. @@ -14,8 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// +k8s:deepcopy-gen=package - // Package v1alpha1 is the v1alpha1 version of the API. -// +groupName=build.knative.dev +// +k8s:deepcopy-gen=package +// +groupName=messaging.knative.dev package v1alpha1 diff --git a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/cluster_build_template_validation.go b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_defaults.go similarity index 63% rename from vendor/github.com/knative/build/pkg/apis/build/v1alpha1/cluster_build_template_validation.go rename to vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_defaults.go index fc2287a3eb..7b51ec14cf 100644 --- a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/cluster_build_template_validation.go +++ b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_defaults.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Knative Authors +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. @@ -16,13 +16,12 @@ limitations under the License. package v1alpha1 -import ( - "context" +import "context" - "github.com/knative/pkg/apis" -) +func (imc *InMemoryChannel) SetDefaults(ctx context.Context) { + imc.Spec.SetDefaults(ctx) +} -// Validate ClusterBuildTemplate -func (b *ClusterBuildTemplate) Validate(ctx context.Context) *apis.FieldError { - return validateObjectMetadata(b.GetObjectMeta()).ViaField("metadata").Also(b.Spec.Validate(ctx).ViaField("spec")) +func (imcs *InMemoryChannelSpec) SetDefaults(ctx context.Context) { + // TODO: Nothing to default here... } diff --git a/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_lifecycle.go b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_lifecycle.go new file mode 100644 index 0000000000..e908097e1d --- /dev/null +++ b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_lifecycle.go @@ -0,0 +1,125 @@ +/* + * 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 ( + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck/v1alpha1" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" +) + +var imcCondSet = apis.NewLivingConditionSet(InMemoryChannelConditionDispatcherReady, InMemoryChannelConditionServiceReady, InMemoryChannelConditionEndpointsReady, InMemoryChannelConditionAddressable, InMemoryChannelConditionChannelServiceReady) + +const ( + // InMemoryChannelConditionReady has status True when all subconditions below have been set to True. + InMemoryChannelConditionReady = apis.ConditionReady + + // InMemoryChannelConditionDispatcherReady has status True when a Dispatcher deployment is ready + // Keyed off appsv1.DeploymentAvaialble, which means minimum available replicas required are up + // and running for at least minReadySeconds. + InMemoryChannelConditionDispatcherReady apis.ConditionType = "DispatcherReady" + + // InMemoryChannelConditionServiceReady has status True when a k8s Service is ready. This + // basically just means it exists because there's no meaningful status in Service. See Endpoints + // below. + InMemoryChannelConditionServiceReady apis.ConditionType = "ServiceReady" + + // InMemoryChannelConditionEndpointsReady has status True when a k8s Service Endpoints are backed + // by at least one endpoint. + InMemoryChannelConditionEndpointsReady apis.ConditionType = "EndpointsReady" + + // InMemoryChannelConditionAddressable has status true when this InMemoryChannel meets + // the Addressable contract and has a non-empty hostname. + InMemoryChannelConditionAddressable apis.ConditionType = "Addressable" + + // InMemoryChannelConditionServiceReady has status True when a k8s Service representing the channel is ready. + // Because this uses ExternalName, there are no endpoints to check. + InMemoryChannelConditionChannelServiceReady apis.ConditionType = "ChannelServiceReady" +) + +// GetCondition returns the condition currently associated with the given type, or nil. +func (imcs *InMemoryChannelStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return imcCondSet.Manage(imcs).GetCondition(t) +} + +// IsReady returns true if the resource is ready overall. +func (imcs *InMemoryChannelStatus) IsReady() bool { + return imcCondSet.Manage(imcs).IsHappy() +} + +// InitializeConditions sets relevant unset conditions to Unknown state. +func (imcs *InMemoryChannelStatus) InitializeConditions() { + imcCondSet.Manage(imcs).InitializeConditions() +} + +// TODO: Use the new beta duck types. +func (imcs *InMemoryChannelStatus) SetAddress(url *apis.URL) { + if imcs.Address == nil { + imcs.Address = &v1alpha1.Addressable{} + } + if url != nil { + imcs.Address.Hostname = url.Host + imcs.Address.URL = url + imcCondSet.Manage(imcs).MarkTrue(InMemoryChannelConditionAddressable) + } else { + imcs.Address.Hostname = "" + imcs.Address.URL = nil + imcCondSet.Manage(imcs).MarkFalse(InMemoryChannelConditionAddressable, "emptyHostname", "hostname is the empty string") + } +} + +func (imcs *InMemoryChannelStatus) MarkDispatcherFailed(reason, messageFormat string, messageA ...interface{}) { + imcCondSet.Manage(imcs).MarkFalse(InMemoryChannelConditionDispatcherReady, reason, messageFormat, messageA...) +} + +// TODO: Unify this with the ones from Eventing. Say: Broker, Trigger. +func (imcs *InMemoryChannelStatus) PropagateDispatcherStatus(ds *appsv1.DeploymentStatus) { + for _, cond := range ds.Conditions { + if cond.Type == appsv1.DeploymentAvailable { + if cond.Status != corev1.ConditionTrue { + imcs.MarkDispatcherFailed("DispatcherNotReady", "Dispatcher Deployment is not ready: %s : %s", cond.Reason, cond.Message) + } else { + imcCondSet.Manage(imcs).MarkTrue(InMemoryChannelConditionDispatcherReady) + } + } + } +} + +func (imcs *InMemoryChannelStatus) MarkServiceFailed(reason, messageFormat string, messageA ...interface{}) { + imcCondSet.Manage(imcs).MarkFalse(InMemoryChannelConditionServiceReady, reason, messageFormat, messageA...) +} + +func (imcs *InMemoryChannelStatus) MarkServiceTrue() { + imcCondSet.Manage(imcs).MarkTrue(InMemoryChannelConditionServiceReady) +} + +func (imcs *InMemoryChannelStatus) MarkChannelServiceFailed(reason, messageFormat string, messageA ...interface{}) { + imcCondSet.Manage(imcs).MarkFalse(InMemoryChannelConditionChannelServiceReady, reason, messageFormat, messageA...) +} + +func (imcs *InMemoryChannelStatus) MarkChannelServiceTrue() { + imcCondSet.Manage(imcs).MarkTrue(InMemoryChannelConditionChannelServiceReady) +} + +func (imcs *InMemoryChannelStatus) MarkEndpointsFailed(reason, messageFormat string, messageA ...interface{}) { + imcCondSet.Manage(imcs).MarkFalse(InMemoryChannelConditionEndpointsReady, reason, messageFormat, messageA...) +} + +func (imcs *InMemoryChannelStatus) MarkEndpointsTrue() { + imcCondSet.Manage(imcs).MarkTrue(InMemoryChannelConditionEndpointsReady) +} diff --git a/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_types.go b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_types.go new file mode 100644 index 0000000000..27062910da --- /dev/null +++ b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_types.go @@ -0,0 +1,93 @@ +/* + * 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 ( + eventingduck "github.com/knative/eventing/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/webhook" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// InMemoryChannel is a resource representing an in memory channel +type InMemoryChannel struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec defines the desired state of the Channel. + Spec InMemoryChannelSpec `json:"spec,omitempty"` + + // Status represents the current state of the Channel. This data may be out of + // date. + // +optional + Status InMemoryChannelStatus `json:"status,omitempty"` +} + +// Check that Channel can be validated, can be defaulted, and has immutable fields. +var _ apis.Validatable = (*InMemoryChannel)(nil) +var _ apis.Defaultable = (*InMemoryChannel)(nil) +var _ runtime.Object = (*InMemoryChannel)(nil) +var _ webhook.GenericCRD = (*InMemoryChannel)(nil) + +// InMemoryChannelSpec defines which subscribers have expressed interest in +// receiving events from this InMemoryChannel. +// arguments for a Channel. +type InMemoryChannelSpec struct { + // Channel conforms to Duck type Subscribable. + Subscribable *eventingduck.Subscribable `json:"subscribable,omitempty"` +} + +// ChannelStatus represents the current state of a Channel. +type InMemoryChannelStatus struct { + // inherits duck/v1beta1 Status, which currently provides: + // * ObservedGeneration - the 'Generation' of the Service that was last processed by the controller. + // * Conditions - the latest available observations of a resource's current state. + duckv1beta1.Status `json:",inline"` + + // InMemoryChannel is Addressable. It currently exposes the endpoint as a + // fully-qualified DNS name which will distribute traffic over the + // provided targets from inside the cluster. + // + // It generally has the form {channel}.{namespace}.svc.{cluster domain name} + duckv1alpha1.AddressStatus `json:",inline"` + + // Subscribers is populated with the statuses of each of the Channelable's subscribers. + eventingduck.SubscribableTypeStatus `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// InMemoryChannelList is a collection of in-memory channels. +type InMemoryChannelList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []InMemoryChannel `json:"items"` +} + +// GetGroupVersionKind returns GroupVersionKind for InMemoryChannels +func (imc *InMemoryChannel) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("InMemoryChannel") +} diff --git a/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_validation.go b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_validation.go new file mode 100644 index 0000000000..f330b2661f --- /dev/null +++ b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_validation.go @@ -0,0 +1,44 @@ +/* +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" + "fmt" + + "knative.dev/pkg/apis" +) + +func (imc *InMemoryChannel) Validate(ctx context.Context) *apis.FieldError { + return imc.Spec.Validate(ctx).ViaField("spec") +} + +func (imcs *InMemoryChannelSpec) Validate(ctx context.Context) *apis.FieldError { + var errs *apis.FieldError + + if imcs.Subscribable != nil { + for i, subscriber := range imcs.Subscribable.Subscribers { + if subscriber.ReplyURI == "" && subscriber.SubscriberURI == "" { + fe := apis.ErrMissingField("replyURI", "subscriberURI") + fe.Details = "expected at least one of, got none" + errs = errs.Also(fe.ViaField(fmt.Sprintf("subscriber[%d]", i)).ViaField("subscribable")) + } + } + } + + return errs +} diff --git a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/register.go b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/register.go similarity index 75% rename from vendor/github.com/knative/build/pkg/apis/build/v1alpha1/register.go rename to vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/register.go index c2b2c6512c..e17f69322a 100644 --- a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/register.go +++ b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/register.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Knative Authors +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. @@ -17,15 +17,15 @@ limitations under the License. package v1alpha1 import ( + "github.com/knative/eventing/pkg/apis/messaging" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - - "github.com/knative/build/pkg/apis/build" ) // SchemeGroupVersion is group version used to register these objects -var SchemeGroupVersion = schema.GroupVersion{Group: build.GroupName, Version: "v1alpha1"} +var SchemeGroupVersion = schema.GroupVersion{Group: messaging.GroupName, Version: "v1alpha1"} // Kind takes an unqualified kind and returns back a Group qualified GroupKind func Kind(kind string) schema.GroupKind { @@ -38,21 +38,17 @@ func Resource(resource string) schema.GroupResource { } var ( - schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) - - // AddToScheme adds Build types to the scheme. - AddToScheme = schemeBuilder.AddToScheme + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme ) // Adds the list of known types to Scheme. func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, - &Build{}, - &BuildList{}, - &BuildTemplate{}, - &BuildTemplateList{}, - &ClusterBuildTemplate{}, - &ClusterBuildTemplateList{}, + &InMemoryChannel{}, + &InMemoryChannelList{}, + &Sequence{}, + &Sequence{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil diff --git a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_template_interface.go b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/sequence_defaults.go similarity index 71% rename from vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_template_interface.go rename to vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/sequence_defaults.go index a14dba3b73..79c0cbe4f4 100644 --- a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_template_interface.go +++ b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/sequence_defaults.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Knative Authors +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. @@ -16,8 +16,12 @@ limitations under the License. package v1alpha1 -// BuildTemplateInterface is implemented by BuildTemplate and ClusterBuildTemplate -type BuildTemplateInterface interface { - TemplateSpec() BuildTemplateSpec - Copy() BuildTemplateInterface +import "context" + +func (s *Sequence) SetDefaults(ctx context.Context) { + s.Spec.SetDefaults(ctx) +} + +func (ss *SequenceSpec) SetDefaults(ctx context.Context) { + // TODO anything? } diff --git a/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/sequence_lifecycle.go b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/sequence_lifecycle.go new file mode 100644 index 0000000000..f6a17a2fb5 --- /dev/null +++ b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/sequence_lifecycle.go @@ -0,0 +1,165 @@ +/* + * 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 ( + duckv1alpha1 "github.com/knative/eventing/pkg/apis/duck/v1alpha1" + eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1" + "knative.dev/pkg/apis" + pkgduckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + corev1 "k8s.io/api/core/v1" +) + +var pCondSet = apis.NewLivingConditionSet(SequenceConditionReady, SequenceConditionChannelsReady, SequenceConditionSubscriptionsReady, SequenceConditionAddressable) + +const ( + // SequenceConditionReady has status True when all subconditions below have been set to True. + SequenceConditionReady = apis.ConditionReady + + // SequenceChannelsReady has status True when all the channels created as part of + // this sequence are ready. + SequenceConditionChannelsReady apis.ConditionType = "ChannelsReady" + + // SequenceSubscriptionsReady has status True when all the subscriptions created as part of + // this sequence are ready. + SequenceConditionSubscriptionsReady apis.ConditionType = "SubscriptionsReady" + + // SequenceConditionAddressable has status true when this Sequence meets + // the Addressable contract and has a non-empty hostname. + SequenceConditionAddressable apis.ConditionType = "Addressable" +) + +// GetCondition returns the condition currently associated with the given type, or nil. +func (ps *SequenceStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return pCondSet.Manage(ps).GetCondition(t) +} + +// IsReady returns true if the resource is ready overall. +func (ps *SequenceStatus) IsReady() bool { + return pCondSet.Manage(ps).IsHappy() +} + +// InitializeConditions sets relevant unset conditions to Unknown state. +func (ps *SequenceStatus) InitializeConditions() { + pCondSet.Manage(ps).InitializeConditions() +} + +// PropagateSubscriptionStatuses sets the SubscriptionStatuses and SequenceConditionSubscriptionsReady based on +// the status of the incoming subscriptions. +func (ps *SequenceStatus) PropagateSubscriptionStatuses(subscriptions []*eventingv1alpha1.Subscription) { + ps.SubscriptionStatuses = make([]SequenceSubscriptionStatus, len(subscriptions)) + allReady := true + // If there are no subscriptions, treat that as a False case. Could go either way, but this seems right. + if len(subscriptions) == 0 { + allReady = false + + } + for i, s := range subscriptions { + ps.SubscriptionStatuses[i] = SequenceSubscriptionStatus{ + Subscription: corev1.ObjectReference{ + APIVersion: s.APIVersion, + Kind: s.Kind, + Name: s.Name, + Namespace: s.Namespace, + }, + } + readyCondition := s.Status.GetCondition(eventingv1alpha1.SubscriptionConditionReady) + if readyCondition != nil { + ps.SubscriptionStatuses[i].ReadyCondition = *readyCondition + if readyCondition.Status != corev1.ConditionTrue { + allReady = false + } + } else { + allReady = false + } + + } + if allReady { + pCondSet.Manage(ps).MarkTrue(SequenceConditionSubscriptionsReady) + } else { + ps.MarkSubscriptionsNotReady("SubscriptionsNotReady", "Subscriptions are not ready yet, or there are none") + } +} + +// PropagateChannelStatuses sets the ChannelStatuses and SequenceConditionChannelsReady based on the +// status of the incoming channels. +func (ps *SequenceStatus) PropagateChannelStatuses(channels []*duckv1alpha1.Channelable) { + ps.ChannelStatuses = make([]SequenceChannelStatus, len(channels)) + allReady := true + // If there are no channels, treat that as a False case. Could go either way, but this seems right. + if len(channels) == 0 { + allReady = false + + } + for i, c := range channels { + ps.ChannelStatuses[i] = SequenceChannelStatus{ + Channel: corev1.ObjectReference{ + APIVersion: c.APIVersion, + Kind: c.Kind, + Name: c.Name, + Namespace: c.Namespace, + }, + } + // TODO: Once the addressable has a real status to dig through, use that here instead of + // addressable, because it might be addressable but not ready. + address := c.Status.AddressStatus.Address + if address != nil { + ps.ChannelStatuses[i].ReadyCondition = apis.Condition{Type: apis.ConditionReady, Status: corev1.ConditionTrue} + } else { + ps.ChannelStatuses[i].ReadyCondition = apis.Condition{Type: apis.ConditionReady, Status: corev1.ConditionFalse, Reason: "NotAddressable", Message: "Channel is not addressable"} + allReady = false + } + + // Mark the Sequence address as the Address of the first channel. + if i == 0 { + ps.setAddress(address) + } + } + if allReady { + pCondSet.Manage(ps).MarkTrue(SequenceConditionChannelsReady) + } else { + ps.MarkChannelsNotReady("ChannelsNotReady", "Channels are not ready yet, or there are none") + } +} + +func (ps *SequenceStatus) MarkChannelsNotReady(reason, messageFormat string, messageA ...interface{}) { + pCondSet.Manage(ps).MarkFalse(SequenceConditionChannelsReady, reason, messageFormat, messageA...) +} + +func (ps *SequenceStatus) MarkSubscriptionsNotReady(reason, messageFormat string, messageA ...interface{}) { + pCondSet.Manage(ps).MarkFalse(SequenceConditionSubscriptionsReady, reason, messageFormat, messageA...) +} + +func (ps *SequenceStatus) MarkAddressableNotReady(reason, messageFormat string, messageA ...interface{}) { + pCondSet.Manage(ps).MarkFalse(SequenceConditionAddressable, reason, messageFormat, messageA...) +} + +func (ps *SequenceStatus) setAddress(address *pkgduckv1alpha1.Addressable) { + ps.Address = address + + if address == nil { + pCondSet.Manage(ps).MarkFalse(SequenceConditionAddressable, "emptyHostname", "hostname is the empty string") + return + } + if address.URL != nil || address.Hostname != "" { + pCondSet.Manage(ps).MarkTrue(SequenceConditionAddressable) + } else { + ps.Address.Hostname = "" + ps.Address.URL = nil + pCondSet.Manage(ps).MarkFalse(SequenceConditionAddressable, "emptyHostname", "hostname is the empty string") + } +} diff --git a/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/sequence_types.go b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/sequence_types.go new file mode 100644 index 0000000000..40a6cc0d3d --- /dev/null +++ b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/sequence_types.go @@ -0,0 +1,156 @@ +/* + * 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 ( + eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1" + "knative.dev/pkg/apis" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/webhook" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// Sequence defines a sequence of Subscribers that will be wired in +// series through Channels and Subscriptions. +type Sequence struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec defines the desired state of the Sequence. + Spec SequenceSpec `json:"spec,omitempty"` + + // Status represents the current state of the Sequence. This data may be out of + // date. + // +optional + Status SequenceStatus `json:"status,omitempty"` +} + +// Check that Sequence can be validated, can be defaulted, and has immutable fields. +var _ apis.Validatable = (*Sequence)(nil) +var _ apis.Defaultable = (*Sequence)(nil) + +// TODO: make appropriate fields immutable. +//var _ apis.Immutable = (*Sequence)(nil) +var _ runtime.Object = (*Sequence)(nil) +var _ webhook.GenericCRD = (*Sequence)(nil) + +// This should be duck so that Broker can also use this +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type ChannelTemplateSpec struct { + metav1.TypeMeta `json:",inline"` + + // Spec defines the Spec to use for each channel created. Passed + // in verbatim to the Channel CRD as Spec section. + // +optional + Spec *runtime.RawExtension `json:"spec,omitempty"` +} + +// Internal version of ChannelTemplateSpec that includes ObjectMeta so that +// we can easily create new Channels off of it. +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type ChannelTemplateSpecInternal struct { + metav1.TypeMeta `json:",inline"` + + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec defines the Spec to use for each channel created. Passed + // in verbatim to the Channel CRD as Spec section. + // +optional + Spec *runtime.RawExtension `json:"spec,omitempty"` +} + +type SequenceSpec struct { + // Steps is the list of Subscribers (processors / functions) that will be called in the order + // provided. + Steps []eventingv1alpha1.SubscriberSpec `json:"steps"` + + // ChannelTemplate specifies which Channel CRD to use + ChannelTemplate ChannelTemplateSpec `json:"channelTemplate"` + + // Reply is a Reference to where the result of the last Subscriber gets sent to. + // + // You can specify only the following fields of the ObjectReference: + // - Kind + // - APIVersion + // - Name + // + // The resource pointed by this ObjectReference must meet the Addressable contract + // with a reference to the Addressable duck type. If the resource does not meet this contract, + // it will be reflected in the Subscription's status. + // +optional + Reply *corev1.ObjectReference `json:"reply,omitempty"` +} + +type SequenceChannelStatus struct { + // Channel is the reference to the underlying channel. + Channel corev1.ObjectReference `json:"channel"` + + // ReadyCondition indicates whether the Channel is ready or not. + ReadyCondition apis.Condition `json:"ready"` +} + +type SequenceSubscriptionStatus struct { + // Subscription is the reference to the underlying Subscription. + Subscription corev1.ObjectReference `json:"subscription"` + + // ReadyCondition indicates whether the Subscription is ready or not. + ReadyCondition apis.Condition `json:"ready"` +} + +// SequenceStatus represents the current state of a Sequence. +type SequenceStatus struct { + // inherits duck/v1alpha1 Status, which currently provides: + // * ObservedGeneration - the 'Generation' of the Service that was last processed by the controller. + // * Conditions - the latest available observations of a resource's current state. + duckv1beta1.Status `json:",inline"` + + // SubscriptionStatuses is an array of corresponding Subscription statuses. + // Matches the Spec.Steps array in the order. + SubscriptionStatuses []SequenceSubscriptionStatus + + // ChannelStatuses is an array of corresponding Channel statuses. + // Matches the Spec.Steps array in the order. + ChannelStatuses []SequenceChannelStatus + + // AddressStatus is the starting point to this Sequence. Sending to this + // will target the first subscriber. + // It generally has the form {channel}.{namespace}.svc.{cluster domain name} + duckv1alpha1.AddressStatus `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// SequenceList is a collection of Sequences. +type SequenceList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []Sequence `json:"items"` +} + +// GetGroupVersionKind returns GroupVersionKind for InMemoryChannels +func (p *Sequence) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Sequence") +} diff --git a/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/sequence_validation.go b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/sequence_validation.go new file mode 100644 index 0000000000..95002b92c4 --- /dev/null +++ b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/sequence_validation.go @@ -0,0 +1,62 @@ +/* +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" + + eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1" + "knative.dev/pkg/apis" + "k8s.io/apimachinery/pkg/api/equality" +) + +func (p *Sequence) Validate(ctx context.Context) *apis.FieldError { + return p.Spec.Validate(ctx).ViaField("spec") +} + +func (ps *SequenceSpec) Validate(ctx context.Context) *apis.FieldError { + var errs *apis.FieldError + + if len(ps.Steps) == 0 { + errs = errs.Also(apis.ErrMissingField("steps")) + } + + for i, s := range ps.Steps { + if e := eventingv1alpha1.IsValidSubscriberSpec(s); e != nil { + errs = errs.Also(apis.ErrInvalidArrayValue(s, "steps", i)) + } + } + + if equality.Semantic.DeepEqual(ps.ChannelTemplate, ChannelTemplateSpec{}) { + errs = errs.Also(apis.ErrMissingField("channelTemplate")) + return errs + } + + if len(ps.ChannelTemplate.APIVersion) == 0 { + errs = errs.Also(apis.ErrMissingField("channelTemplate.apiVersion")) + } + + if len(ps.ChannelTemplate.Kind) == 0 { + errs = errs.Also(apis.ErrMissingField("channelTemplate.kind")) + } + if ps.Reply != nil { + if err := eventingv1alpha1.IsValidObjectReference(*ps.Reply); err != nil { + errs = errs.Also(err.ViaField("reply")) + } + } + return errs +} diff --git a/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..7df53c750b --- /dev/null +++ b/vendor/github.com/knative/eventing/pkg/apis/messaging/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,348 @@ +// +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 ( + duckv1alpha1 "github.com/knative/eventing/pkg/apis/duck/v1alpha1" + eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1" + v1 "k8s.io/api/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ChannelTemplateSpec) DeepCopyInto(out *ChannelTemplateSpec) { + *out = *in + out.TypeMeta = in.TypeMeta + if in.Spec != nil { + in, out := &in.Spec, &out.Spec + *out = new(runtime.RawExtension) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChannelTemplateSpec. +func (in *ChannelTemplateSpec) DeepCopy() *ChannelTemplateSpec { + if in == nil { + return nil + } + out := new(ChannelTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ChannelTemplateSpec) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ChannelTemplateSpecInternal) DeepCopyInto(out *ChannelTemplateSpecInternal) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.Spec != nil { + in, out := &in.Spec, &out.Spec + *out = new(runtime.RawExtension) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChannelTemplateSpecInternal. +func (in *ChannelTemplateSpecInternal) DeepCopy() *ChannelTemplateSpecInternal { + if in == nil { + return nil + } + out := new(ChannelTemplateSpecInternal) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ChannelTemplateSpecInternal) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InMemoryChannel) DeepCopyInto(out *InMemoryChannel) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InMemoryChannel. +func (in *InMemoryChannel) DeepCopy() *InMemoryChannel { + if in == nil { + return nil + } + out := new(InMemoryChannel) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *InMemoryChannel) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InMemoryChannelList) DeepCopyInto(out *InMemoryChannelList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]InMemoryChannel, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InMemoryChannelList. +func (in *InMemoryChannelList) DeepCopy() *InMemoryChannelList { + if in == nil { + return nil + } + out := new(InMemoryChannelList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *InMemoryChannelList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InMemoryChannelSpec) DeepCopyInto(out *InMemoryChannelSpec) { + *out = *in + if in.Subscribable != nil { + in, out := &in.Subscribable, &out.Subscribable + *out = new(duckv1alpha1.Subscribable) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InMemoryChannelSpec. +func (in *InMemoryChannelSpec) DeepCopy() *InMemoryChannelSpec { + if in == nil { + return nil + } + out := new(InMemoryChannelSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InMemoryChannelStatus) DeepCopyInto(out *InMemoryChannelStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + in.AddressStatus.DeepCopyInto(&out.AddressStatus) + in.SubscribableTypeStatus.DeepCopyInto(&out.SubscribableTypeStatus) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InMemoryChannelStatus. +func (in *InMemoryChannelStatus) DeepCopy() *InMemoryChannelStatus { + if in == nil { + return nil + } + out := new(InMemoryChannelStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Sequence) DeepCopyInto(out *Sequence) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Sequence. +func (in *Sequence) DeepCopy() *Sequence { + if in == nil { + return nil + } + out := new(Sequence) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Sequence) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SequenceChannelStatus) DeepCopyInto(out *SequenceChannelStatus) { + *out = *in + out.Channel = in.Channel + in.ReadyCondition.DeepCopyInto(&out.ReadyCondition) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SequenceChannelStatus. +func (in *SequenceChannelStatus) DeepCopy() *SequenceChannelStatus { + if in == nil { + return nil + } + out := new(SequenceChannelStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SequenceList) DeepCopyInto(out *SequenceList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Sequence, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SequenceList. +func (in *SequenceList) DeepCopy() *SequenceList { + if in == nil { + return nil + } + out := new(SequenceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SequenceList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SequenceSpec) DeepCopyInto(out *SequenceSpec) { + *out = *in + if in.Steps != nil { + in, out := &in.Steps, &out.Steps + *out = make([]eventingv1alpha1.SubscriberSpec, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.ChannelTemplate.DeepCopyInto(&out.ChannelTemplate) + if in.Reply != nil { + in, out := &in.Reply, &out.Reply + *out = new(v1.ObjectReference) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SequenceSpec. +func (in *SequenceSpec) DeepCopy() *SequenceSpec { + if in == nil { + return nil + } + out := new(SequenceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SequenceStatus) DeepCopyInto(out *SequenceStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + if in.SubscriptionStatuses != nil { + in, out := &in.SubscriptionStatuses, &out.SubscriptionStatuses + *out = make([]SequenceSubscriptionStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ChannelStatuses != nil { + in, out := &in.ChannelStatuses, &out.ChannelStatuses + *out = make([]SequenceChannelStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.AddressStatus.DeepCopyInto(&out.AddressStatus) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SequenceStatus. +func (in *SequenceStatus) DeepCopy() *SequenceStatus { + if in == nil { + return nil + } + out := new(SequenceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SequenceSubscriptionStatus) DeepCopyInto(out *SequenceSubscriptionStatus) { + *out = *in + out.Subscription = in.Subscription + in.ReadyCondition.DeepCopyInto(&out.ReadyCondition) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SequenceSubscriptionStatus. +func (in *SequenceSubscriptionStatus) DeepCopy() *SequenceSubscriptionStatus { + if in == nil { + return nil + } + out := new(SequenceSubscriptionStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/apiserver_lifecycle.go b/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/apiserver_lifecycle.go index 29c2ba9e3b..1a13394077 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/apiserver_lifecycle.go +++ b/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/apiserver_lifecycle.go @@ -17,40 +17,30 @@ limitations under the License. package v1alpha1 import ( - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis" ) const ( // ApiServerConditionReady has status True when the ApiServerSource is ready to send events. - ApiServerConditionReady = duckv1alpha1.ConditionReady + ApiServerConditionReady = apis.ConditionReady // ApiServerConditionSinkProvided has status True when the ApiServerSource has been configured with a sink target. - ApiServerConditionSinkProvided duckv1alpha1.ConditionType = "SinkProvided" + ApiServerConditionSinkProvided apis.ConditionType = "SinkProvided" // ApiServerConditionDeployed has status True when the ApiServerSource has had it's deployment created. - ApiServerConditionDeployed duckv1alpha1.ConditionType = "Deployed" + ApiServerConditionDeployed apis.ConditionType = "Deployed" // ApiServerConditionEventTypeProvided has status True when the ApiServerSource has been configured with its event types. - ApiServerConditionEventTypeProvided duckv1alpha1.ConditionType = "EventTypesProvided" + ApiServerConditionEventTypeProvided apis.ConditionType = "EventTypesProvided" ) -var apiserverCondSet = duckv1alpha1.NewLivingConditionSet( +var apiserverCondSet = apis.NewLivingConditionSet( ApiServerConditionSinkProvided, ApiServerConditionDeployed, ) -// GetConditions returns Conditions -func (s *ApiServerSourceStatus) GetConditions() duckv1alpha1.Conditions { - return s.Conditions -} - -// SetConditions sets Conditions -func (s *ApiServerSourceStatus) SetConditions(conditions duckv1alpha1.Conditions) { - s.Conditions = conditions -} - // GetCondition returns the condition currently associated with the given type, or nil. -func (s *ApiServerSourceStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition { +func (s *ApiServerSourceStatus) GetCondition(t apis.ConditionType) *apis.Condition { return apiserverCondSet.Manage(s).GetCondition(t) } diff --git a/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/apiserver_types.go b/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/apiserver_types.go index 5c8a9d128e..ded5508878 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/apiserver_types.go +++ b/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/apiserver_types.go @@ -17,8 +17,8 @@ limitations under the License. package v1alpha1 import ( - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" - "github.com/knative/pkg/kmeta" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/kmeta" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" @@ -92,10 +92,10 @@ type ApiServerSourceSpec struct { // ApiServerSourceStatus defines the observed state of ApiServerSource type ApiServerSourceStatus struct { - // inherits duck/v1alpha1 Status, which currently provides: + // inherits duck/v1beta1 Status, which currently provides: // * ObservedGeneration - the 'Generation' of the Service that was last processed by the controller. // * Conditions - the latest available observations of a resource's current state. - duckv1alpha1.Status `json:",inline"` + duckv1beta1.Status `json:",inline"` // SinkURI is the current active sink URI that has been configured for the ApiServerSource. // +optional diff --git a/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/containersource_lifecycle.go b/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/containersource_lifecycle.go index 5848f9511b..1a749b32b3 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/containersource_lifecycle.go +++ b/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/containersource_lifecycle.go @@ -17,27 +17,27 @@ limitations under the License. package v1alpha1 import ( - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis" ) const ( // ContainerSourceConditionReady has status True when the ContainerSource is ready to send events. - ContainerConditionReady = duckv1alpha1.ConditionReady + ContainerConditionReady = apis.ConditionReady // ContainerConditionSinkProvided has status True when the ContainerSource has been configured with a sink target. - ContainerConditionSinkProvided duckv1alpha1.ConditionType = "SinkProvided" + ContainerConditionSinkProvided apis.ConditionType = "SinkProvided" // ContainerConditionDeployed has status True when the ContainerSource has had it's deployment created. - ContainerConditionDeployed duckv1alpha1.ConditionType = "Deployed" + ContainerConditionDeployed apis.ConditionType = "Deployed" ) -var containerCondSet = duckv1alpha1.NewLivingConditionSet( +var containerCondSet = apis.NewLivingConditionSet( ContainerConditionSinkProvided, ContainerConditionDeployed, ) // GetCondition returns the condition currently associated with the given type, or nil. -func (s *ContainerSourceStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition { +func (s *ContainerSourceStatus) GetCondition(t apis.ConditionType) *apis.Condition { return containerCondSet.Manage(s).GetCondition(t) } diff --git a/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/containersource_types.go b/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/containersource_types.go index 24f53e198d..db2adde6bc 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/containersource_types.go +++ b/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/containersource_types.go @@ -17,9 +17,8 @@ limitations under the License. package v1alpha1 import ( - "github.com/knative/pkg/apis/duck" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" - "github.com/knative/pkg/kmeta" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/kmeta" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -43,33 +42,42 @@ var ( // Check that ContainerSource can be validated and can be defaulted. _ runtime.Object = (*ContainerSource)(nil) - // Check that ContainerSource implements the Conditions duck type. - _ = duck.VerifyType(&ContainerSource{}, &duckv1alpha1.Conditions{}) - // Check that we can create OwnerReferences to a ContainerSource. _ kmeta.OwnerRefable = (*ContainerSource)(nil) ) // ContainerSourceSpec defines the desired state of ContainerSource type ContainerSourceSpec struct { - // Image is the image to run inside of the container. + // Template describes the pods that will be created + // +optional + Template *corev1.PodTemplateSpec `json:"template,omitempty"` + + // DeprecatedImage is the image to run inside of the container. + // This field is to be deprecated. Use `Template` instead. + // When `Template` is set, this field is ignored. // +kubebuilder:validation:MinLength=1 - Image string `json:"image,omitempty"` + DeprecatedImage string `json:"image,omitempty"` - // Args are passed to the ContainerSpec as they are. - Args []string `json:"args,omitempty"` + // DeprecatedArgs are passed to the ContainerSpec as they are. + // This field is to be deprecated. Use `Template` instead. + // When `Template` is set, this field is ignored. + DeprecatedArgs []string `json:"args,omitempty"` - // Env is the list of environment variables to set in the container. + // DeprecatedEnv is the list of environment variables to set in the container. // Cannot be updated. + // This field is to be deprecated. Use `Template` instead. + // When `Template` is set, this field is ignored. // +optional // +patchMergeKey=name // +patchStrategy=merge - Env []corev1.EnvVar `json:"env,omitempty" patchStrategy:"merge" patchMergeKey:"name"` + DeprecatedEnv []corev1.EnvVar `json:"env,omitempty" patchStrategy:"merge" patchMergeKey:"name"` - // ServiceAccountName is the name of the ServiceAccount to use to run this + // DeprecatedServiceAccountName is the name of the ServiceAccount to use to run this // source. + // This field is to be deprecated. Use `Template` instead. + // When `Template` is set, this field is ignored. // +optional - ServiceAccountName string `json:"serviceAccountName,omitempty"` + DeprecatedServiceAccountName string `json:"serviceAccountName,omitempty"` // Sink is a reference to an object that will resolve to a domain name to use as the sink. // +optional @@ -83,10 +91,10 @@ func (s *ContainerSource) GetGroupVersionKind() schema.GroupVersionKind { // ContainerSourceStatus defines the observed state of ContainerSource type ContainerSourceStatus struct { - // inherits duck/v1alpha1 Status, which currently provides: + // inherits duck/v1beta1 Status, which currently provides: // * ObservedGeneration - the 'Generation' of the Service that was last processed by the controller. // * Conditions - the latest available observations of a resource's current state. - duckv1alpha1.Status `json:",inline"` + duckv1beta1.Status `json:",inline"` // SinkURI is the current active sink URI that has been configured for the ContainerSource. // +optional diff --git a/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/cron_job_lifecycle.go b/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/cron_job_lifecycle.go index 80a2b0b0bd..fca95d287f 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/cron_job_lifecycle.go +++ b/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/cron_job_lifecycle.go @@ -17,33 +17,37 @@ limitations under the License. package v1alpha1 import ( - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis" ) const ( // CronJobConditionReady has status True when the CronJobSource is ready to send events. - CronJobConditionReady = duckv1alpha1.ConditionReady + CronJobConditionReady = apis.ConditionReady // CronJobConditionValidSchedule has status True when the CronJobSource has been configured with a valid schedule. - CronJobConditionValidSchedule duckv1alpha1.ConditionType = "ValidSchedule" + CronJobConditionValidSchedule apis.ConditionType = "ValidSchedule" // CronJobConditionSinkProvided has status True when the CronJobSource has been configured with a sink target. - CronJobConditionSinkProvided duckv1alpha1.ConditionType = "SinkProvided" + CronJobConditionSinkProvided apis.ConditionType = "SinkProvided" // CronJobConditionDeployed has status True when the CronJobSource has had it's receive adapter deployment created. - CronJobConditionDeployed duckv1alpha1.ConditionType = "Deployed" + CronJobConditionDeployed apis.ConditionType = "Deployed" // CronJobConditionEventTypeProvided has status True when the CronJobSource has been configured with its event type. - CronJobConditionEventTypeProvided duckv1alpha1.ConditionType = "EventTypeProvided" + CronJobConditionEventTypeProvided apis.ConditionType = "EventTypeProvided" + + // CronJobConditionResources is True when the resources listed for the CronJobSource have been properly + // parsed and match specified syntax for resource quantities + CronJobConditionResources apis.ConditionType = "ResourcesCorrect" ) -var cronJobSourceCondSet = duckv1alpha1.NewLivingConditionSet( +var cronJobSourceCondSet = apis.NewLivingConditionSet( CronJobConditionValidSchedule, CronJobConditionSinkProvided, CronJobConditionDeployed) // GetCondition returns the condition currently associated with the given type, or nil. -func (s *CronJobSourceStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition { +func (s *CronJobSourceStatus) GetCondition(t apis.ConditionType) *apis.Condition { return cronJobSourceCondSet.Manage(s).GetCondition(t) } @@ -107,3 +111,13 @@ func (s *CronJobSourceStatus) MarkEventType() { func (s *CronJobSourceStatus) MarkNoEventType(reason, messageFormat string, messageA ...interface{}) { cronJobSourceCondSet.Manage(s).MarkFalse(CronJobConditionEventTypeProvided, reason, messageFormat, messageA...) } + +// MarkResourcesCorrect sets the condtion that the source resources are properly parsable quantities +func (s *CronJobSourceStatus) MarkResourcesCorrect() { + cronJobSourceCondSet.Manage(s).MarkTrue(CronJobConditionResources) +} + +// MarkResourcesInorrect sets the condtion that the source resources are not properly parsable quantities +func (s *CronJobSourceStatus) MarkResourcesIncorrect(reason, messageFormat string, messageA ...interface{}) { + cronJobSourceCondSet.Manage(s).MarkFalse(CronJobConditionResources, reason, messageFormat, messageA...) +} diff --git a/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/cron_job_types.go b/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/cron_job_types.go index 24606569a6..5e1dc60d79 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/cron_job_types.go +++ b/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/cron_job_types.go @@ -18,9 +18,9 @@ package v1alpha1 import ( "fmt" - "github.com/knative/pkg/apis/duck" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" - "github.com/knative/pkg/kmeta" + + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/kmeta" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -48,9 +48,6 @@ var ( // Check that we can create OwnerReferences to a Configuration. _ kmeta.OwnerRefable = (*CronJobSource)(nil) - - // Check that CronJobSource implements the Conditions duck type. - _ = duck.VerifyType(&CronJobSource{}, &duckv1alpha1.Conditions{}) ) const ( @@ -63,6 +60,21 @@ func CronJobEventSource(namespace, cronJobName string) string { return fmt.Sprintf("/apis/v1/namespaces/%s/cronjobsources/%s", namespace, cronJobName) } +type CronJobRequestsSpec struct { + ResourceCPU string `json:"cpu,omitempty"` + ResourceMemory string `json:"memory,omitempty"` +} + +type CronJobLimitsSpec struct { + ResourceCPU string `json:"cpu,omitempty"` + ResourceMemory string `json:"memory,omitempty"` +} + +type CronJobResourceSpec struct { + Requests CronJobRequestsSpec `json:"requests,omitempty"` + Limits CronJobLimitsSpec `json:"limits,omitempty"` +} + // CronJobSourceSpec defines the desired state of the CronJobSource. type CronJobSourceSpec struct { // Schedule is the cronjob schedule. @@ -79,6 +91,9 @@ type CronJobSourceSpec struct { // ServiceAccoutName is the name of the ServiceAccount that will be used to run the Receive // Adapter Deployment. ServiceAccountName string `json:"serviceAccountName,omitempty"` + + // Resource limits and Request specifications of the Receive Adapter Deployment + Resources CronJobResourceSpec `json:"resources,omitempty"` } // GetGroupVersionKind returns the GroupVersionKind. @@ -88,10 +103,10 @@ func (s *CronJobSource) GetGroupVersionKind() schema.GroupVersionKind { // CronJobSourceStatus defines the observed state of CronJobSource. type CronJobSourceStatus struct { - // inherits duck/v1alpha1 Status, which currently provides: + // inherits duck/v1beta1 Status, which currently provides: // * ObservedGeneration - the 'Generation' of the Service that was last processed by the controller. // * Conditions - the latest available observations of a resource's current state. - duckv1alpha1.Status `json:",inline"` + duckv1beta1.Status `json:",inline"` // SinkURI is the current active sink URI that has been configured for the CronJobSource. // +optional diff --git a/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/zz_generated.deepcopy.go index 134c8cad29..84b79ee882 100644 --- a/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/github.com/knative/eventing/pkg/apis/sources/v1alpha1/zz_generated.deepcopy.go @@ -209,13 +209,18 @@ func (in *ContainerSourceList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ContainerSourceSpec) DeepCopyInto(out *ContainerSourceSpec) { *out = *in - if in.Args != nil { - in, out := &in.Args, &out.Args + if in.Template != nil { + in, out := &in.Template, &out.Template + *out = new(v1.PodTemplateSpec) + (*in).DeepCopyInto(*out) + } + if in.DeprecatedArgs != nil { + in, out := &in.DeprecatedArgs, &out.DeprecatedArgs *out = make([]string, len(*in)) copy(*out, *in) } - if in.Env != nil { - in, out := &in.Env, &out.Env + if in.DeprecatedEnv != nil { + in, out := &in.DeprecatedEnv, &out.DeprecatedEnv *out = make([]v1.EnvVar, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) @@ -256,6 +261,56 @@ func (in *ContainerSourceStatus) DeepCopy() *ContainerSourceStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CronJobLimitsSpec) DeepCopyInto(out *CronJobLimitsSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CronJobLimitsSpec. +func (in *CronJobLimitsSpec) DeepCopy() *CronJobLimitsSpec { + if in == nil { + return nil + } + out := new(CronJobLimitsSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CronJobRequestsSpec) DeepCopyInto(out *CronJobRequestsSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CronJobRequestsSpec. +func (in *CronJobRequestsSpec) DeepCopy() *CronJobRequestsSpec { + if in == nil { + return nil + } + out := new(CronJobRequestsSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CronJobResourceSpec) DeepCopyInto(out *CronJobResourceSpec) { + *out = *in + out.Requests = in.Requests + out.Limits = in.Limits + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CronJobResourceSpec. +func (in *CronJobResourceSpec) DeepCopy() *CronJobResourceSpec { + if in == nil { + return nil + } + out := new(CronJobResourceSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CronJobSource) DeepCopyInto(out *CronJobSource) { *out = *in @@ -325,6 +380,7 @@ func (in *CronJobSourceSpec) DeepCopyInto(out *CronJobSourceSpec) { *out = new(v1.ObjectReference) **out = **in } + out.Resources = in.Resources return } diff --git a/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/clientset.go b/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/clientset.go index 526251ec43..ff2c79bda6 100644 --- a/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/clientset.go +++ b/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/clientset.go @@ -20,6 +20,7 @@ package versioned import ( eventingv1alpha1 "github.com/knative/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1" + messagingv1alpha1 "github.com/knative/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1" sourcesv1alpha1 "github.com/knative/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" @@ -31,6 +32,9 @@ type Interface interface { EventingV1alpha1() eventingv1alpha1.EventingV1alpha1Interface // Deprecated: please explicitly pick a version if possible. Eventing() eventingv1alpha1.EventingV1alpha1Interface + MessagingV1alpha1() messagingv1alpha1.MessagingV1alpha1Interface + // Deprecated: please explicitly pick a version if possible. + Messaging() messagingv1alpha1.MessagingV1alpha1Interface SourcesV1alpha1() sourcesv1alpha1.SourcesV1alpha1Interface // Deprecated: please explicitly pick a version if possible. Sources() sourcesv1alpha1.SourcesV1alpha1Interface @@ -40,8 +44,9 @@ type Interface interface { // version included in a Clientset. type Clientset struct { *discovery.DiscoveryClient - eventingV1alpha1 *eventingv1alpha1.EventingV1alpha1Client - sourcesV1alpha1 *sourcesv1alpha1.SourcesV1alpha1Client + eventingV1alpha1 *eventingv1alpha1.EventingV1alpha1Client + messagingV1alpha1 *messagingv1alpha1.MessagingV1alpha1Client + sourcesV1alpha1 *sourcesv1alpha1.SourcesV1alpha1Client } // EventingV1alpha1 retrieves the EventingV1alpha1Client @@ -55,6 +60,17 @@ func (c *Clientset) Eventing() eventingv1alpha1.EventingV1alpha1Interface { return c.eventingV1alpha1 } +// MessagingV1alpha1 retrieves the MessagingV1alpha1Client +func (c *Clientset) MessagingV1alpha1() messagingv1alpha1.MessagingV1alpha1Interface { + return c.messagingV1alpha1 +} + +// Deprecated: Messaging retrieves the default version of MessagingClient. +// Please explicitly pick a version. +func (c *Clientset) Messaging() messagingv1alpha1.MessagingV1alpha1Interface { + return c.messagingV1alpha1 +} + // SourcesV1alpha1 retrieves the SourcesV1alpha1Client func (c *Clientset) SourcesV1alpha1() sourcesv1alpha1.SourcesV1alpha1Interface { return c.sourcesV1alpha1 @@ -86,6 +102,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } + cs.messagingV1alpha1, err = messagingv1alpha1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } cs.sourcesV1alpha1, err = sourcesv1alpha1.NewForConfig(&configShallowCopy) if err != nil { return nil, err @@ -103,6 +123,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset cs.eventingV1alpha1 = eventingv1alpha1.NewForConfigOrDie(c) + cs.messagingV1alpha1 = messagingv1alpha1.NewForConfigOrDie(c) cs.sourcesV1alpha1 = sourcesv1alpha1.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) @@ -113,6 +134,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { func New(c rest.Interface) *Clientset { var cs Clientset cs.eventingV1alpha1 = eventingv1alpha1.New(c) + cs.messagingV1alpha1 = messagingv1alpha1.New(c) cs.sourcesV1alpha1 = sourcesv1alpha1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) diff --git a/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/scheme/register.go b/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/scheme/register.go index b78dadc4c6..070743b51d 100644 --- a/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/scheme/register.go +++ b/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/scheme/register.go @@ -20,6 +20,7 @@ package scheme import ( eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1" + messagingv1alpha1 "github.com/knative/eventing/pkg/apis/messaging/v1alpha1" sourcesv1alpha1 "github.com/knative/eventing/pkg/apis/sources/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" @@ -33,6 +34,7 @@ var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ eventingv1alpha1.AddToScheme, + messagingv1alpha1.AddToScheme, sourcesv1alpha1.AddToScheme, } diff --git a/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1/doc.go b/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1/doc.go new file mode 100644 index 0000000000..a1c6bb9fe8 --- /dev/null +++ b/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +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 client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1/generated_expansion.go b/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1/generated_expansion.go new file mode 100644 index 0000000000..107a069c11 --- /dev/null +++ b/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1/generated_expansion.go @@ -0,0 +1,23 @@ +/* +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 client-gen. DO NOT EDIT. + +package v1alpha1 + +type InMemoryChannelExpansion interface{} + +type SequenceExpansion interface{} diff --git a/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1/inmemorychannel.go b/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1/inmemorychannel.go new file mode 100644 index 0000000000..d5ae425fef --- /dev/null +++ b/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1/inmemorychannel.go @@ -0,0 +1,174 @@ +/* +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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/knative/eventing/pkg/apis/messaging/v1alpha1" + scheme "github.com/knative/eventing/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// InMemoryChannelsGetter has a method to return a InMemoryChannelInterface. +// A group's client should implement this interface. +type InMemoryChannelsGetter interface { + InMemoryChannels(namespace string) InMemoryChannelInterface +} + +// InMemoryChannelInterface has methods to work with InMemoryChannel resources. +type InMemoryChannelInterface interface { + Create(*v1alpha1.InMemoryChannel) (*v1alpha1.InMemoryChannel, error) + Update(*v1alpha1.InMemoryChannel) (*v1alpha1.InMemoryChannel, error) + UpdateStatus(*v1alpha1.InMemoryChannel) (*v1alpha1.InMemoryChannel, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.InMemoryChannel, error) + List(opts v1.ListOptions) (*v1alpha1.InMemoryChannelList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.InMemoryChannel, err error) + InMemoryChannelExpansion +} + +// inMemoryChannels implements InMemoryChannelInterface +type inMemoryChannels struct { + client rest.Interface + ns string +} + +// newInMemoryChannels returns a InMemoryChannels +func newInMemoryChannels(c *MessagingV1alpha1Client, namespace string) *inMemoryChannels { + return &inMemoryChannels{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the inMemoryChannel, and returns the corresponding inMemoryChannel object, and an error if there is any. +func (c *inMemoryChannels) Get(name string, options v1.GetOptions) (result *v1alpha1.InMemoryChannel, err error) { + result = &v1alpha1.InMemoryChannel{} + err = c.client.Get(). + Namespace(c.ns). + Resource("inmemorychannels"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of InMemoryChannels that match those selectors. +func (c *inMemoryChannels) List(opts v1.ListOptions) (result *v1alpha1.InMemoryChannelList, err error) { + result = &v1alpha1.InMemoryChannelList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("inmemorychannels"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested inMemoryChannels. +func (c *inMemoryChannels) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("inmemorychannels"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a inMemoryChannel and creates it. Returns the server's representation of the inMemoryChannel, and an error, if there is any. +func (c *inMemoryChannels) Create(inMemoryChannel *v1alpha1.InMemoryChannel) (result *v1alpha1.InMemoryChannel, err error) { + result = &v1alpha1.InMemoryChannel{} + err = c.client.Post(). + Namespace(c.ns). + Resource("inmemorychannels"). + Body(inMemoryChannel). + Do(). + Into(result) + return +} + +// Update takes the representation of a inMemoryChannel and updates it. Returns the server's representation of the inMemoryChannel, and an error, if there is any. +func (c *inMemoryChannels) Update(inMemoryChannel *v1alpha1.InMemoryChannel) (result *v1alpha1.InMemoryChannel, err error) { + result = &v1alpha1.InMemoryChannel{} + err = c.client.Put(). + Namespace(c.ns). + Resource("inmemorychannels"). + Name(inMemoryChannel.Name). + Body(inMemoryChannel). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *inMemoryChannels) UpdateStatus(inMemoryChannel *v1alpha1.InMemoryChannel) (result *v1alpha1.InMemoryChannel, err error) { + result = &v1alpha1.InMemoryChannel{} + err = c.client.Put(). + Namespace(c.ns). + Resource("inmemorychannels"). + Name(inMemoryChannel.Name). + SubResource("status"). + Body(inMemoryChannel). + Do(). + Into(result) + return +} + +// Delete takes name of the inMemoryChannel and deletes it. Returns an error if one occurs. +func (c *inMemoryChannels) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("inmemorychannels"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *inMemoryChannels) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("inmemorychannels"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched inMemoryChannel. +func (c *inMemoryChannels) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.InMemoryChannel, err error) { + result = &v1alpha1.InMemoryChannel{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("inmemorychannels"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1/messaging_client.go b/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1/messaging_client.go new file mode 100644 index 0000000000..762dcbf29e --- /dev/null +++ b/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1/messaging_client.go @@ -0,0 +1,95 @@ +/* +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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/knative/eventing/pkg/apis/messaging/v1alpha1" + "github.com/knative/eventing/pkg/client/clientset/versioned/scheme" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" +) + +type MessagingV1alpha1Interface interface { + RESTClient() rest.Interface + InMemoryChannelsGetter + SequencesGetter +} + +// MessagingV1alpha1Client is used to interact with features provided by the messaging.knative.dev group. +type MessagingV1alpha1Client struct { + restClient rest.Interface +} + +func (c *MessagingV1alpha1Client) InMemoryChannels(namespace string) InMemoryChannelInterface { + return newInMemoryChannels(c, namespace) +} + +func (c *MessagingV1alpha1Client) Sequences(namespace string) SequenceInterface { + return newSequences(c, namespace) +} + +// NewForConfig creates a new MessagingV1alpha1Client for the given config. +func NewForConfig(c *rest.Config) (*MessagingV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &MessagingV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new MessagingV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *MessagingV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new MessagingV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *MessagingV1alpha1Client { + return &MessagingV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *MessagingV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1/sequence.go b/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1/sequence.go new file mode 100644 index 0000000000..88d513cc5d --- /dev/null +++ b/vendor/github.com/knative/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1/sequence.go @@ -0,0 +1,174 @@ +/* +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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/knative/eventing/pkg/apis/messaging/v1alpha1" + scheme "github.com/knative/eventing/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// SequencesGetter has a method to return a SequenceInterface. +// A group's client should implement this interface. +type SequencesGetter interface { + Sequences(namespace string) SequenceInterface +} + +// SequenceInterface has methods to work with Sequence resources. +type SequenceInterface interface { + Create(*v1alpha1.Sequence) (*v1alpha1.Sequence, error) + Update(*v1alpha1.Sequence) (*v1alpha1.Sequence, error) + UpdateStatus(*v1alpha1.Sequence) (*v1alpha1.Sequence, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.Sequence, error) + List(opts v1.ListOptions) (*v1alpha1.SequenceList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Sequence, err error) + SequenceExpansion +} + +// sequences implements SequenceInterface +type sequences struct { + client rest.Interface + ns string +} + +// newSequences returns a Sequences +func newSequences(c *MessagingV1alpha1Client, namespace string) *sequences { + return &sequences{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the sequence, and returns the corresponding sequence object, and an error if there is any. +func (c *sequences) Get(name string, options v1.GetOptions) (result *v1alpha1.Sequence, err error) { + result = &v1alpha1.Sequence{} + err = c.client.Get(). + Namespace(c.ns). + Resource("sequences"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Sequences that match those selectors. +func (c *sequences) List(opts v1.ListOptions) (result *v1alpha1.SequenceList, err error) { + result = &v1alpha1.SequenceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("sequences"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested sequences. +func (c *sequences) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("sequences"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a sequence and creates it. Returns the server's representation of the sequence, and an error, if there is any. +func (c *sequences) Create(sequence *v1alpha1.Sequence) (result *v1alpha1.Sequence, err error) { + result = &v1alpha1.Sequence{} + err = c.client.Post(). + Namespace(c.ns). + Resource("sequences"). + Body(sequence). + Do(). + Into(result) + return +} + +// Update takes the representation of a sequence and updates it. Returns the server's representation of the sequence, and an error, if there is any. +func (c *sequences) Update(sequence *v1alpha1.Sequence) (result *v1alpha1.Sequence, err error) { + result = &v1alpha1.Sequence{} + err = c.client.Put(). + Namespace(c.ns). + Resource("sequences"). + Name(sequence.Name). + Body(sequence). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *sequences) UpdateStatus(sequence *v1alpha1.Sequence) (result *v1alpha1.Sequence, err error) { + result = &v1alpha1.Sequence{} + err = c.client.Put(). + Namespace(c.ns). + Resource("sequences"). + Name(sequence.Name). + SubResource("status"). + Body(sequence). + Do(). + Into(result) + return +} + +// Delete takes name of the sequence and deletes it. Returns an error if one occurs. +func (c *sequences) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("sequences"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *sequences) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("sequences"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched sequence. +func (c *sequences) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Sequence, err error) { + result = &v1alpha1.Sequence{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("sequences"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/github.com/knative/eventing/test/test_images/logevents/kodata/LICENSE b/vendor/github.com/knative/eventing/test/test_images/logevents/kodata/LICENSE deleted file mode 120000 index 1477615432..0000000000 --- a/vendor/github.com/knative/eventing/test/test_images/logevents/kodata/LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../../LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/eventing/test/test_images/logevents/kodata/LICENSE b/vendor/github.com/knative/eventing/test/test_images/logevents/kodata/LICENSE new file mode 100644 index 0000000000..1477615432 --- /dev/null +++ b/vendor/github.com/knative/eventing/test/test_images/logevents/kodata/LICENSE @@ -0,0 +1 @@ +../../../../LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/serving/cmd/networking/certmanager/kodata/HEAD b/vendor/github.com/knative/serving/cmd/networking/certmanager/kodata/HEAD new file mode 120000 index 0000000000..481bd4eff4 --- /dev/null +++ b/vendor/github.com/knative/serving/cmd/networking/certmanager/kodata/HEAD @@ -0,0 +1 @@ +../../../../.git/HEAD \ No newline at end of file diff --git a/vendor/github.com/knative/serving/cmd/networking/certmanager/kodata/LICENSE b/vendor/github.com/knative/serving/cmd/networking/certmanager/kodata/LICENSE new file mode 120000 index 0000000000..1477615432 --- /dev/null +++ b/vendor/github.com/knative/serving/cmd/networking/certmanager/kodata/LICENSE @@ -0,0 +1 @@ +../../../../LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/eventing/test/test_images/logevents/kodata/VENDOR-LICENSE b/vendor/github.com/knative/serving/cmd/networking/certmanager/kodata/VENDOR-LICENSE similarity index 100% rename from vendor/github.com/knative/eventing/test/test_images/logevents/kodata/VENDOR-LICENSE rename to vendor/github.com/knative/serving/cmd/networking/certmanager/kodata/VENDOR-LICENSE diff --git a/vendor/github.com/knative/serving/cmd/networking/istio/kodata/HEAD b/vendor/github.com/knative/serving/cmd/networking/istio/kodata/HEAD new file mode 120000 index 0000000000..481bd4eff4 --- /dev/null +++ b/vendor/github.com/knative/serving/cmd/networking/istio/kodata/HEAD @@ -0,0 +1 @@ +../../../../.git/HEAD \ No newline at end of file diff --git a/vendor/github.com/knative/serving/cmd/networking/istio/kodata/LICENSE b/vendor/github.com/knative/serving/cmd/networking/istio/kodata/LICENSE new file mode 120000 index 0000000000..1477615432 --- /dev/null +++ b/vendor/github.com/knative/serving/cmd/networking/istio/kodata/LICENSE @@ -0,0 +1 @@ +../../../../LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/serving/cmd/networking/istio/kodata/VENDOR-LICENSE b/vendor/github.com/knative/serving/cmd/networking/istio/kodata/VENDOR-LICENSE new file mode 120000 index 0000000000..7322c09d95 --- /dev/null +++ b/vendor/github.com/knative/serving/cmd/networking/istio/kodata/VENDOR-LICENSE @@ -0,0 +1 @@ +../../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/apis/autoscaling/annotation_validation.go b/vendor/github.com/knative/serving/pkg/apis/autoscaling/annotation_validation.go new file mode 100644 index 0000000000..3c6bb07fb8 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/autoscaling/annotation_validation.go @@ -0,0 +1,63 @@ +/* +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 autoscaling + +import ( + "fmt" + "strconv" + + "knative.dev/pkg/apis" +) + +func getIntGE0(m map[string]string, k string) (int64, *apis.FieldError) { + v, ok := m[k] + if !ok { + return 0, nil + } + i, err := strconv.ParseInt(v, 10, 32) + if err != nil || i < 0 { + return 0, &apis.FieldError{ + Message: fmt.Sprintf("Invalid %s annotation value: must be an integer equal or greater than 0", k), + Paths: []string{k}, + } + } + return i, nil +} + +func ValidateAnnotations(annotations map[string]string) *apis.FieldError { + if len(annotations) == 0 { + return nil + } + + min, err := getIntGE0(annotations, MinScaleAnnotationKey) + if err != nil { + return err + } + max, err := getIntGE0(annotations, MaxScaleAnnotationKey) + if err != nil { + return err + } + + if max != 0 && max < min { + return &apis.FieldError{ + Message: fmt.Sprintf("%s=%v is less than %s=%v", MaxScaleAnnotationKey, max, MinScaleAnnotationKey, min), + Paths: []string{MaxScaleAnnotationKey, MinScaleAnnotationKey}, + } + } + + return nil +} diff --git a/vendor/github.com/knative/serving/pkg/apis/autoscaling/register.go b/vendor/github.com/knative/serving/pkg/apis/autoscaling/register.go index 90c8201a80..6807e7194a 100644 --- a/vendor/github.com/knative/serving/pkg/apis/autoscaling/register.go +++ b/vendor/github.com/knative/serving/pkg/apis/autoscaling/register.go @@ -16,6 +16,8 @@ limitations under the License. package autoscaling +import "time" + const ( InternalGroupName = "autoscaling.internal.knative.dev" @@ -52,8 +54,80 @@ const ( // TargetAnnotationKey is the annotation to specify what metric value the // PodAutoscaler should attempt to maintain. For example, // autoscaling.knative.dev/metric: cpu - // autoscaling.knative.dev/target: 75 # target 75% cpu utilization + // autoscaling.knative.dev/target: "75" # target 75% cpu utilization TargetAnnotationKey = GroupName + "/target" + // TargetMin is the minimum allowable target. Values less than + // zero don't make sense. + TargetMin = 1 + + // WindowAnnotationKey is the annotation to specify the time + // interval over which to calculate the average metric. Larger + // values result in more smoothing. For example, + // autoscaling.knative.dev/metric: concurrency + // autoscaling.knative.dev/window: "2m" + // Only the kpa.autoscaling.knative.dev class autoscaler supports + // the window annotation. + WindowAnnotationKey = GroupName + "/window" + // WindowMin is the minimum allowable stable autoscaling + // window. KPA-class autoscalers calculate the desired replica + // count every 2 seconds (tick-interval in config-autoscaler) so + // the closer the window gets to that value, the more likely data + // points will be missed entirely by the panic window which is + // smaller than the stable window. Anything less than 6 second + // isn't going to work well. + WindowMin = 6 * time.Second + + // PanicWindowPercentageAnnotationKey is the annotation to + // specify the time interval over which to calculate the average + // metric during a spike. Where a spike is defined as the metric + // reaching panic level within the panic window (e.g. panic + // mode). Lower values make panic mode more sensitive. Note: + // Panic threshold can be overridden with the + // PanicThresholdPercentageAnnotationKey. For example, + // autoscaling.knative.dev/panicWindowPercentage: "5.0" + // autoscaling.knative.dev/panicThresholdPercentage: "150.0" + // Only the kpa.autoscaling.knative.dev class autoscaler supports + // the panicWindowPercentage annotation. + // Panic window is specified as a percentag to maintain the + // autoscaler's algorithm behavior when only the stable window is + // specified. The panic window will change along with the stable + // window at the default percentage. + PanicWindowPercentageAnnotationKey = GroupName + "/panicWindowPercentage" + // PanicWindowPercentageMin is the minimum allowable panic window + // percentage. The autoscaler calculates desired replicas every 2 + // seconds (tick-interval in config-autoscaler), so a panic + // window less than 2 seconds will be missing data points. One + // percent is a very small ratio and would require a stable + // window of at least 3.4 minutes. Anything less doesn't make + // sense. + PanicWindowPercentageMin = 1.0 + // PanicWindowPercentageMax is the maximum allowable panic window + // percentage. The KPA autoscaler's panic feature allows the + // autoscaler to be more responsive over a smaller time scale + // when necessary. So the panic window cannot be larger than the + // stable window. + PanicWindowPercentageMax = 100.0 + + // PanicThresholdPercentageAnnotationKey is the annotation to specify + // the level at what level panic mode will engage when reached within + // in the panic window. The level is defined as a percentage of + // the metric target. Lower values make panic mode more + // sensitive. For example, + // autoscaling.knative.dev/panicWindowPercentage: "5.0" + // autoscaling.knative.dev/panicThresholdPercentage: "150.0" + // Only the kpa.autoscaling.knative.dev class autoscaler supports + // the panicThresholdPercentage annotation + PanicThresholdPercentageAnnotationKey = GroupName + "/panicThresholdPercentage" + // PanicThresholdPercentageMin is the minimum allowable panic + // threshold percentage. The KPA autoscaler's panic feature + // allows the autoscaler to be more responsive over a smaller + // time scale when necessary. To prevent flapping, during panic + // mode the autoscaler never decreases the number of replicas. If + // the panic threshold was as small as the stable target, the + // autoscaler would always be panicking and the autoscaler would + // never scale down. One hundred and ten percent is about the + // smallest useful value. + PanicThresholdPercentageMin = 110.0 // KPALabelKey is the label key attached to a K8s Service to hint to the KPA // which services/endpoints should trigger reconciles. diff --git a/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/pa_defaults.go b/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/pa_defaults.go index 5ab0f2ac88..a08ae95e55 100644 --- a/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/pa_defaults.go +++ b/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/pa_defaults.go @@ -19,12 +19,23 @@ package v1alpha1 import ( "context" + "knative.dev/pkg/apis" "github.com/knative/serving/pkg/apis/autoscaling" - servingv1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" ) +func defaultMetric(class string) string { + switch class { + case autoscaling.KPA: + return autoscaling.Concurrency + case autoscaling.HPA: + return autoscaling.CPU + default: + return "" + } +} + func (r *PodAutoscaler) SetDefaults(ctx context.Context) { - r.Spec.SetDefaults(ctx) + r.Spec.SetDefaults(apis.WithinSpec(ctx)) if r.Annotations == nil { r.Annotations = make(map[string]string) } @@ -33,22 +44,9 @@ func (r *PodAutoscaler) SetDefaults(ctx context.Context) { r.Annotations[autoscaling.ClassAnnotationKey] = autoscaling.KPA } // Default metric per class - switch r.Class() { - case autoscaling.KPA: - if _, ok := r.Annotations[autoscaling.MetricAnnotationKey]; !ok { - r.Annotations[autoscaling.MetricAnnotationKey] = autoscaling.Concurrency - } - case autoscaling.HPA: - if _, ok := r.Annotations[autoscaling.MetricAnnotationKey]; !ok { - r.Annotations[autoscaling.MetricAnnotationKey] = autoscaling.CPU - } + if _, ok := r.Annotations[autoscaling.MetricAnnotationKey]; !ok { + r.Annotations[autoscaling.MetricAnnotationKey] = defaultMetric(r.Class()) } } -func (rs *PodAutoscalerSpec) SetDefaults(ctx context.Context) { - // When ConcurrencyModel is specified but ContainerConcurrency - // is not (0), use the ConcurrencyModel value. - if rs.ConcurrencyModel == servingv1alpha1.RevisionRequestConcurrencyModelSingle && rs.ContainerConcurrency == 0 { - rs.ContainerConcurrency = 1 - } -} +func (rs *PodAutoscalerSpec) SetDefaults(ctx context.Context) {} diff --git a/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/pa_lifecycle.go b/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/pa_lifecycle.go index 8153f7ab6f..03e7c36a28 100644 --- a/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/pa_lifecycle.go +++ b/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/pa_lifecycle.go @@ -18,16 +18,18 @@ package v1alpha1 import ( "fmt" + "math" "strconv" "time" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "github.com/knative/serving/pkg/apis/autoscaling" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime/schema" ) -var podCondSet = duckv1alpha1.NewLivingConditionSet( +var podCondSet = apis.NewLivingConditionSet( PodAutoscalerConditionActive, ) @@ -43,6 +45,15 @@ func (pa *PodAutoscaler) Class() string { return autoscaling.KPA } +// Metric returns the contents of the metric annotation or a default. +func (pa *PodAutoscaler) Metric() string { + if m, ok := pa.Annotations[autoscaling.MetricAnnotationKey]; ok { + return m + } + // TODO: defaulting here is awkward and is already taken care of by defaulting logic. + return defaultMetric(pa.Class()) +} + func (pa *PodAutoscaler) annotationInt32(key string) int32 { if s, ok := pa.Annotations[key]; ok { // no error check: relying on validation @@ -55,6 +66,15 @@ func (pa *PodAutoscaler) annotationInt32(key string) int32 { return 0 } +func (pa *PodAutoscaler) annotationFloat64(key string) (float64, bool) { + if s, ok := pa.Annotations[key]; ok { + if f, err := strconv.ParseFloat(s, 64); err == nil { + return f, true + } + } + return 0.0, false +} + // ScaleBounds returns scale bounds annotations values as a tuple: // `(min, max int32)`. The value of 0 for any of min or max means the bound is // not set @@ -64,91 +84,132 @@ func (pa *PodAutoscaler) ScaleBounds() (min, max int32) { return } -// Target returns the target annotation value or false if not present. -func (pa *PodAutoscaler) Target() (target int32, ok bool) { +// Target returns the target annotation value or false if not present, or invalid. +func (pa *PodAutoscaler) Target() (float64, bool) { if s, ok := pa.Annotations[autoscaling.TargetAnnotationKey]; ok { - if i, err := strconv.Atoi(s); err == nil { - if i < 1 { + if ta, err := strconv.ParseFloat(s, 64 /*width*/); err == nil { + // Max check for backwards compatibility. + if ta < 1 || ta > math.MaxInt32 { return 0, false } - return int32(i), true + return ta, true } } return 0, false } +// Window returns the window annotation value or false if not present. +func (pa *PodAutoscaler) Window() (window time.Duration, ok bool) { + if s, ok := pa.Annotations[autoscaling.WindowAnnotationKey]; ok { + d, err := time.ParseDuration(s) + if err != nil { + return 0, false + } + if d < autoscaling.WindowMin { + return 0, false + } + return d, true + } + return 0, false +} + +// PanicWindowPercentage returns panic window annotation value or false if not present. +func (pa *PodAutoscaler) PanicWindowPercentage() (percentage float64, ok bool) { + percentage, ok = pa.annotationFloat64(autoscaling.PanicWindowPercentageAnnotationKey) + if !ok || percentage > autoscaling.PanicWindowPercentageMax || + percentage < autoscaling.PanicWindowPercentageMin { + return 0, false + } + return percentage, ok +} + +// PanicThresholdPercentage return the panic target annotation value or false if not present. +func (pa *PodAutoscaler) PanicThresholdPercentage() (percentage float64, ok bool) { + percentage, ok = pa.annotationFloat64(autoscaling.PanicThresholdPercentageAnnotationKey) + if !ok || percentage < autoscaling.PanicThresholdPercentageMin { + return 0, false + } + return percentage, ok +} + // IsReady looks at the conditions and if the Status has a condition // PodAutoscalerConditionReady returns true if ConditionStatus is True -func (rs *PodAutoscalerStatus) IsReady() bool { - return podCondSet.Manage(rs).IsHappy() +func (pas *PodAutoscalerStatus) IsReady() bool { + return podCondSet.Manage(pas.duck()).IsHappy() } -// IsActivating assumes the pod autoscaler is Activating if it is neither +// IsActivating returns true if the pod autoscaler is Activating if it is neither // Active nor Inactive -func (rs *PodAutoscalerStatus) IsActivating() bool { - cond := rs.GetCondition(PodAutoscalerConditionActive) - +func (pas *PodAutoscalerStatus) IsActivating() bool { + cond := pas.GetCondition(PodAutoscalerConditionActive) return cond != nil && cond.Status == corev1.ConditionUnknown } -func (rs *PodAutoscalerStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition { - return podCondSet.Manage(rs).GetCondition(t) +// IsInactive returns true if the pod autoscaler is Inactive. +func (pas *PodAutoscalerStatus) IsInactive() bool { + cond := pas.GetCondition(PodAutoscalerConditionActive) + return cond != nil && cond.Status == corev1.ConditionFalse +} + +// GetCondition gets the condition `t`. +func (pas *PodAutoscalerStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return podCondSet.Manage(pas.duck()).GetCondition(t) } -func (rs *PodAutoscalerStatus) InitializeConditions() { - podCondSet.Manage(rs).InitializeConditions() +// InitializeConditions initializes the conditionhs of the PA. +func (pas *PodAutoscalerStatus) InitializeConditions() { + podCondSet.Manage(pas.duck()).InitializeConditions() } -func (rs *PodAutoscalerStatus) MarkActive() { - podCondSet.Manage(rs).MarkTrue(PodAutoscalerConditionActive) +// MarkActive marks the PA active. +func (pas *PodAutoscalerStatus) MarkActive() { + podCondSet.Manage(pas.duck()).MarkTrue(PodAutoscalerConditionActive) } -func (rs *PodAutoscalerStatus) MarkActivating(reason, message string) { - podCondSet.Manage(rs).MarkUnknown(PodAutoscalerConditionActive, reason, message) +// MarkActivating marks the PA as activating. +func (pas *PodAutoscalerStatus) MarkActivating(reason, message string) { + podCondSet.Manage(pas.duck()).MarkUnknown(PodAutoscalerConditionActive, reason, message) } -func (rs *PodAutoscalerStatus) MarkInactive(reason, message string) { - podCondSet.Manage(rs).MarkFalse(PodAutoscalerConditionActive, reason, message) +// MarkInactive marks the PA as inactive. +func (pas *PodAutoscalerStatus) MarkInactive(reason, message string) { + podCondSet.Manage(pas.duck()).MarkFalse(PodAutoscalerConditionActive, reason, message) } // MarkResourceNotOwned changes the "Active" condition to false to reflect that the // resource of the given kind and name has already been created, and we do not own it. -func (rs *PodAutoscalerStatus) MarkResourceNotOwned(kind, name string) { - rs.MarkInactive("NotOwned", +func (pas *PodAutoscalerStatus) MarkResourceNotOwned(kind, name string) { + pas.MarkInactive("NotOwned", fmt.Sprintf("There is an existing %s %q that we do not own.", kind, name)) } // MarkResourceFailedCreation changes the "Active" condition to false to reflect that a // critical resource of the given kind and name was unable to be created. -func (rs *PodAutoscalerStatus) MarkResourceFailedCreation(kind, name string) { - rs.MarkInactive("FailedCreate", +func (pas *PodAutoscalerStatus) MarkResourceFailedCreation(kind, name string) { + pas.MarkInactive("FailedCreate", fmt.Sprintf("Failed to create %s %q.", kind, name)) } // CanScaleToZero checks whether the pod autoscaler has been in an inactive state // for at least the specified grace period. -func (rs *PodAutoscalerStatus) CanScaleToZero(gracePeriod time.Duration) bool { - if cond := rs.GetCondition(PodAutoscalerConditionActive); cond != nil { - switch cond.Status { - case corev1.ConditionFalse: - // Check that this PodAutoscaler has been inactive for - // at least the grace period. - return time.Now().After(cond.LastTransitionTime.Inner.Add(gracePeriod)) - } - } - return false +func (pas *PodAutoscalerStatus) CanScaleToZero(gracePeriod time.Duration) bool { + return pas.inStatusFor(corev1.ConditionFalse, gracePeriod) } // CanMarkInactive checks whether the pod autoscaler has been in an active state // for at least the specified idle period. -func (rs *PodAutoscalerStatus) CanMarkInactive(idlePeriod time.Duration) bool { - if cond := rs.GetCondition(PodAutoscalerConditionActive); cond != nil { - switch cond.Status { - case corev1.ConditionTrue: - // Check that this PodAutoscaler has been active for - // at least the grace period. - return time.Now().After(cond.LastTransitionTime.Inner.Add(idlePeriod)) - } - } - return false +func (pas *PodAutoscalerStatus) CanMarkInactive(idlePeriod time.Duration) bool { + return pas.inStatusFor(corev1.ConditionTrue, idlePeriod) +} + +// inStatusFor returns true if the PodAutoscalerStatus's Active condition has stayed in +// the specified status for at least the specified duration. Otherwise it returns false, +// including when the status is undetermined (Active condition is not found.) +func (pas *PodAutoscalerStatus) inStatusFor(status corev1.ConditionStatus, dur time.Duration) bool { + cond := pas.GetCondition(PodAutoscalerConditionActive) + return cond != nil && cond.Status == status && time.Now().After(cond.LastTransitionTime.Inner.Add(dur)) +} + +func (pas *PodAutoscalerStatus) duck() *duckv1beta1.Status { + return (*duckv1beta1.Status)(&pas.Status) } diff --git a/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/pa_types.go b/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/pa_types.go index eeee538a97..18229f71f6 100644 --- a/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/pa_types.go +++ b/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/pa_types.go @@ -17,12 +17,13 @@ limitations under the License. package v1alpha1 import ( - "github.com/knative/pkg/apis" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" - "github.com/knative/pkg/kmeta" + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/kmeta" net "github.com/knative/serving/pkg/apis/networking" servingv1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" - autoscalingv1 "k8s.io/api/autoscaling/v1" + servingv1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -49,10 +50,9 @@ type PodAutoscaler struct { // Verify that PodAutoscaler adheres to the appropriate interfaces. var ( - // Check that PodAutoscaler can be validated, can be defaulted, and has immutable fields. + // Check that PodAutoscaler can be validated and can be defaulted. _ apis.Validatable = (*PodAutoscaler)(nil) _ apis.Defaultable = (*PodAutoscaler)(nil) - _ apis.Immutable = (*PodAutoscaler)(nil) // Check that we can create OwnerReferences to a PodAutoscaler. _ kmeta.OwnerRefable = (*PodAutoscaler)(nil) @@ -71,11 +71,9 @@ type PodAutoscalerSpec struct { // +optional DeprecatedGeneration int64 `json:"generation,omitempty"` - // ConcurrencyModel specifies the desired concurrency model - // (Single or Multi) for the scale target. Defaults to Multi. - // Deprecated in favor of ContainerConcurrency. + // DeprecatedConcurrencyModel no longer does anything, use ContainerConcurrency. // +optional - ConcurrencyModel servingv1alpha1.RevisionRequestConcurrencyModelType `json:"concurrencyModel,omitempty"` + DeprecatedConcurrencyModel servingv1alpha1.RevisionRequestConcurrencyModelType `json:"concurrencyModel,omitempty"` // ContainerConcurrency specifies the maximum allowed // in-flight (concurrent) requests per container of the Revision. @@ -83,15 +81,15 @@ type PodAutoscalerSpec struct { // This field replaces ConcurrencyModel. A value of `1` // is equivalent to `Single` and `0` is equivalent to `Multi`. // +optional - ContainerConcurrency servingv1alpha1.RevisionContainerConcurrencyType `json:"containerConcurrency,omitempty"` + ContainerConcurrency servingv1beta1.RevisionContainerConcurrencyType `json:"containerConcurrency,omitempty"` // ScaleTargetRef defines the /scale-able resource that this PodAutoscaler // is responsible for quickly right-sizing. - ScaleTargetRef autoscalingv1.CrossVersionObjectReference `json:"scaleTargetRef"` + ScaleTargetRef corev1.ObjectReference `json:"scaleTargetRef"` - // ServiceName holds the name of a core Kubernetes Service resource that + // DeprecatedServiceName holds the name of a core Kubernetes Service resource that // load balances over the pods referenced by the ScaleTargetRef. - ServiceName string `json:"serviceName"` + DeprecatedServiceName string `json:"serviceName"` // The application-layer protocol. Matches `ProtocolType` inferred from the revision spec. ProtocolType net.ProtocolType @@ -100,13 +98,23 @@ type PodAutoscalerSpec struct { const ( // PodAutoscalerConditionReady is set when the revision is starting to materialize // runtime resources, and becomes true when those resources are ready. - PodAutoscalerConditionReady = duckv1alpha1.ConditionReady + PodAutoscalerConditionReady = apis.ConditionReady // PodAutoscalerConditionActive is set when the PodAutoscaler's ScaleTargetRef is receiving traffic. - PodAutoscalerConditionActive duckv1alpha1.ConditionType = "Active" + PodAutoscalerConditionActive apis.ConditionType = "Active" ) // PodAutoscalerStatus communicates the observed state of the PodAutoscaler (from the controller). -type PodAutoscalerStatus duckv1alpha1.Status +type PodAutoscalerStatus struct { + duckv1beta1.Status + + // ServiceName is the K8s Service name that serves the revision, scaled by this PA. + // The service is created and owned by the ServerlessService object owned by this PA. + ServiceName string `json:"serviceName"` + + // MetricsServiceName is the K8s Service name that provides revision metrics. + // The service is managed by the PA object. + MetricsServiceName string `json:"metricsServiceName"` +} // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/pa_validation.go b/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/pa_validation.go index 688e6eee99..7355f474d0 100644 --- a/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/pa_validation.go +++ b/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/pa_validation.go @@ -20,20 +20,16 @@ import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/knative/pkg/apis" - "github.com/knative/pkg/kmp" + "knative.dev/pkg/apis" "github.com/knative/serving/pkg/apis/autoscaling" - servingv1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" - autoscalingv1 "k8s.io/api/autoscaling/v1" + "github.com/knative/serving/pkg/apis/serving" "k8s.io/apimachinery/pkg/api/equality" ) func (pa *PodAutoscaler) Validate(ctx context.Context) *apis.FieldError { - return servingv1alpha1.ValidateObjectMetadata(pa.GetObjectMeta()). - ViaField("metadata"). - Also(pa.Spec.Validate(ctx).ViaField("spec")). - Also(pa.validateMetric()) + errs := serving.ValidateObjectMetadata(pa.GetObjectMeta()).ViaField("metadata") + errs = errs.Also(pa.validateMetric()) + return errs.Also(pa.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) } // Validate validates PodAutoscaler Spec. @@ -41,44 +37,21 @@ func (rs *PodAutoscalerSpec) Validate(ctx context.Context) *apis.FieldError { if equality.Semantic.DeepEqual(rs, &PodAutoscalerSpec{}) { return apis.ErrMissingField(apis.CurrentField) } - errs := validateReference(rs.ScaleTargetRef).ViaField("scaleTargetRef") - if rs.ServiceName == "" { - errs = errs.Also(apis.ErrMissingField("serviceName")) - } - if err := rs.ConcurrencyModel.Validate(ctx); err != nil { - errs = errs.Also(err.ViaField("concurrencyModel")) - } else if err := servingv1alpha1.ValidateContainerConcurrency(rs.ContainerConcurrency, rs.ConcurrencyModel); err != nil { - errs = errs.Also(err) - } - return errs.Also(validateSKSFields(rs)) + errs := serving.ValidateNamespacedObjectReference(&rs.ScaleTargetRef).ViaField("scaleTargetRef") + errs = errs.Also(rs.ContainerConcurrency.Validate(ctx). + ViaField("containerConcurrency")) + return errs.Also(validateSKSFields(ctx, rs)) } -func validateSKSFields(rs *PodAutoscalerSpec) *apis.FieldError { +func validateSKSFields(ctx context.Context, rs *PodAutoscalerSpec) *apis.FieldError { var all *apis.FieldError // TODO(vagababov) stop permitting empty protocol type, once SKS controller is live. if string(rs.ProtocolType) != "" { - all = all.Also(rs.ProtocolType.Validate()).ViaField("protocolType") + all = all.Also(rs.ProtocolType.Validate(ctx)).ViaField("protocolType") } return all } -func validateReference(ref autoscalingv1.CrossVersionObjectReference) *apis.FieldError { - if equality.Semantic.DeepEqual(ref, autoscalingv1.CrossVersionObjectReference{}) { - return apis.ErrMissingField(apis.CurrentField) - } - var errs *apis.FieldError - if ref.Kind == "" { - errs = errs.Also(apis.ErrMissingField("kind")) - } - if ref.Name == "" { - errs = errs.Also(apis.ErrMissingField("name")) - } - if ref.APIVersion == "" { - errs = errs.Also(apis.ErrMissingField("apiVersion")) - } - return errs -} - func (pa *PodAutoscaler) validateMetric() *apis.FieldError { if metric, ok := pa.Annotations[autoscaling.MetricAnnotationKey]; ok { switch pa.Class() { @@ -89,7 +62,7 @@ func (pa *PodAutoscaler) validateMetric() *apis.FieldError { } case autoscaling.HPA: switch metric { - case autoscaling.CPU: + case autoscaling.CPU, autoscaling.Concurrency: return nil } // TODO: implement OPS autoscaling. @@ -105,43 +78,3 @@ func (pa *PodAutoscaler) validateMetric() *apis.FieldError { } return nil } - -// CheckImmutableFields checks the immutability of the PodAutoscaler. -func (current *PodAutoscaler) CheckImmutableFields(ctx context.Context, og apis.Immutable) *apis.FieldError { - original, ok := og.(*PodAutoscaler) - if !ok { - return &apis.FieldError{Message: "The provided original was not a PodAutoscaler"} - } - - // TODO(vagababov): remove after 0.6. This is temporary plug for backwards compatibility. - opt := cmp.FilterPath( - func(p cmp.Path) bool { - return p.String() == "ProtocolType" - }, - cmp.Ignore(), - ) - if diff, err := kmp.SafeDiff(original.Spec, current.Spec, opt); err != nil { - return &apis.FieldError{ - Message: "Failed to diff PodAutoscaler", - Paths: []string{"spec"}, - Details: err.Error(), - } - } else if diff != "" { - return &apis.FieldError{ - Message: "Immutable fields changed (-old +new)", - Paths: []string{"spec"}, - Details: diff, - } - } - // Verify the PA class does not change. - // For backward compatibility, we allow a new class where there was none before. - if oldClass, ok := original.Annotations[autoscaling.ClassAnnotationKey]; ok { - if newClass, ok := current.Annotations[autoscaling.ClassAnnotationKey]; !ok || oldClass != newClass { - return &apis.FieldError{ - Message: fmt.Sprintf("Immutable class annotation changed (-%q +%q)", oldClass, newClass), - Paths: []string{"annotations[autoscaling.knative.dev/class]"}, - } - } - } - return nil -} diff --git a/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/podscalable_types.go b/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/podscalable_types.go new file mode 100644 index 0000000000..2f06e01078 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/podscalable_types.go @@ -0,0 +1,112 @@ +/* +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 ( + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// PodScalable is a duck type that the resources referenced by the +// PodAutoscaler's ScaleTargetRef must implement. They must also +// implement the `/scale` sub-resource for use with `/scale` based +// implementations (e.g. HPA), but this further constrains the shape +// the referenced resources may take. +type PodScalable struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec PodScalableSpec `json:"spec"` + Status PodScalableStatus `json:"status"` +} + +// PodScalableSpec is the specification for the desired state of a +// PodScalable (or at least our shared portion). +type PodScalableSpec struct { + Replicas *int32 `json:"replicas,omitempty"` + Selector *metav1.LabelSelector `json:"selector"` + Template corev1.PodTemplateSpec `json:"template"` +} + +// PodScalableStatus is the observed state of a PodScalable (or at +// least our shared portion). +type PodScalableStatus struct { + Replicas int32 `json:"replicas,omitempty"` +} + +var _ duck.Populatable = (*PodScalable)(nil) +var _ duck.Implementable = (*PodScalable)(nil) +var _ apis.Listable = (*PodScalable)(nil) + +// GetFullType implements duck.Implementable +func (*PodScalable) GetFullType() duck.Populatable { + return &PodScalable{} +} + +// Populate implements duck.Populatable +func (t *PodScalable) Populate() { + twelve := int32(12) + t.Spec = PodScalableSpec{ + Replicas: &twelve, + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "foo": "bar", + }, + MatchExpressions: []metav1.LabelSelectorRequirement{{ + Key: "foo", + Operator: "In", + Values: []string{"baz", "blah"}, + }}, + }, + Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{ + "foo": "bar", + }, + }, + Spec: corev1.PodSpec{ + Containers: []corev1.Container{{ + Name: "container-name", + Image: "container-image:latest", + }}, + }, + }, + } + t.Status = PodScalableStatus{ + Replicas: 42, + } +} + +// GetListType implements apis.Listable +func (*PodScalable) GetListType() runtime.Object { + return &PodScalableList{} +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// PodScalableList is a list of PodScalable resources +type PodScalableList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []PodScalable `json:"items"` +} diff --git a/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go index b797cae946..2c4a511221 100644 --- a/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go @@ -16,12 +16,12 @@ See the License for the specific language governing permissions and limitations under the License. */ -// This file was autogenerated by deepcopy-gen. Do not edit it manually! +// Code generated by deepcopy-gen. DO NOT EDIT. package v1alpha1 import ( - duck_v1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -49,9 +49,8 @@ func (in *PodAutoscaler) DeepCopy() *PodAutoscaler { func (in *PodAutoscaler) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c - } else { - return nil } + return nil } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -83,9 +82,8 @@ func (in *PodAutoscalerList) DeepCopy() *PodAutoscalerList { func (in *PodAutoscalerList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c - } else { - return nil } + return nil } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -108,9 +106,56 @@ func (in *PodAutoscalerSpec) DeepCopy() *PodAutoscalerSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PodAutoscalerStatus) DeepCopyInto(out *PodAutoscalerStatus) { *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make(duck_v1alpha1.Conditions, len(*in)) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodAutoscalerStatus. +func (in *PodAutoscalerStatus) DeepCopy() *PodAutoscalerStatus { + if in == nil { + return nil + } + out := new(PodAutoscalerStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodScalable) DeepCopyInto(out *PodScalable) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodScalable. +func (in *PodScalable) DeepCopy() *PodScalable { + if in == nil { + return nil + } + out := new(PodScalable) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PodScalable) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodScalableList) DeepCopyInto(out *PodScalableList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]PodScalable, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -118,12 +163,63 @@ func (in *PodAutoscalerStatus) DeepCopyInto(out *PodAutoscalerStatus) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodAutoscalerStatus. -func (in *PodAutoscalerStatus) DeepCopy() *PodAutoscalerStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodScalableList. +func (in *PodScalableList) DeepCopy() *PodScalableList { if in == nil { return nil } - out := new(PodAutoscalerStatus) + out := new(PodScalableList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PodScalableList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodScalableSpec) DeepCopyInto(out *PodScalableSpec) { + *out = *in + if in.Replicas != nil { + in, out := &in.Replicas, &out.Replicas + *out = new(int32) + **out = **in + } + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + in.Template.DeepCopyInto(&out.Template) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodScalableSpec. +func (in *PodScalableSpec) DeepCopy() *PodScalableSpec { + if in == nil { + return nil + } + out := new(PodScalableSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodScalableStatus) DeepCopyInto(out *PodScalableStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodScalableStatus. +func (in *PodScalableStatus) DeepCopy() *PodScalableStatus { + if in == nil { + return nil + } + out := new(PodScalableStatus) in.DeepCopyInto(out) return out } diff --git a/vendor/github.com/knative/serving/pkg/apis/config/defaults.go b/vendor/github.com/knative/serving/pkg/apis/config/defaults.go index 7791a33206..5799eb62e4 100644 --- a/vendor/github.com/knative/serving/pkg/apis/config/defaults.go +++ b/vendor/github.com/knative/serving/pkg/apis/config/defaults.go @@ -17,15 +17,33 @@ limitations under the License. package config import ( + "bytes" + "context" + "fmt" + "io/ioutil" "strconv" + "text/template" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "knative.dev/pkg/apis" ) const ( // DefaultsConfigName is the name of config map for the defaults. DefaultsConfigName = "config-defaults" + + // DefaultRevisionTimeoutSeconds will be set if timeoutSeconds not specified. + DefaultRevisionTimeoutSeconds = 5 * 60 + + // DefaultMaxRevisionTimeoutSeconds will be set if MaxRevisionTimeoutSeconds is not specified. + DefaultMaxRevisionTimeoutSeconds = 10 * 60 + + // DefaultUserContainerName is the default name we give to the container + // specified by the user, if `name:` is omitted. + DefaultUserContainerName = "user-container" ) // NewDefaultsConfigFromMap creates a Defaults from the supplied Map @@ -42,6 +60,10 @@ func NewDefaultsConfigFromMap(data map[string]string) (*Defaults, error) { key: "revision-timeout-seconds", field: &nc.RevisionTimeoutSeconds, defaultValue: DefaultRevisionTimeoutSeconds, + }, { + key: "max-revision-timeout-seconds", + field: &nc.MaxRevisionTimeoutSeconds, + defaultValue: DefaultMaxRevisionTimeoutSeconds, }} { if raw, ok := data[i64.key]; !ok { *i64.field = i64.defaultValue @@ -52,26 +74,52 @@ func NewDefaultsConfigFromMap(data map[string]string) (*Defaults, error) { } } + if nc.RevisionTimeoutSeconds > nc.MaxRevisionTimeoutSeconds { + return nil, fmt.Errorf("revision-timeout-seconds (%d) cannot be greater than max-revision-timeout-seconds (%d)", nc.RevisionTimeoutSeconds, nc.MaxRevisionTimeoutSeconds) + } + // Process resource quantity fields for _, rsrc := range []struct { key string - field *resource.Quantity - // specified exactly when optional - defaultValue resource.Quantity + field **resource.Quantity }{{ - key: "revision-cpu-request", - field: &nc.RevisionCPURequest, - defaultValue: DefaultRevisionCPURequest, + key: "revision-cpu-request", + field: &nc.RevisionCPURequest, + }, { + key: "revision-memory-request", + field: &nc.RevisionMemoryRequest, + }, { + key: "revision-cpu-limit", + field: &nc.RevisionCPULimit, + }, { + key: "revision-memory-limit", + field: &nc.RevisionMemoryLimit, }} { if raw, ok := data[rsrc.key]; !ok { - *rsrc.field = rsrc.defaultValue + *rsrc.field = nil } else if val, err := resource.ParseQuantity(raw); err != nil { return nil, err } else { - *rsrc.field = val + *rsrc.field = &val } } + if raw, ok := data["container-name-template"]; !ok { + nc.UserContainerNameTemplate = DefaultUserContainerName + } else { + tmpl, err := template.New("user-container").Parse(raw) + if err != nil { + return nil, err + } + // Check that the template properly applies to ObjectMeta. + if err := tmpl.Execute(ioutil.Discard, metav1.ObjectMeta{}); err != nil { + return nil, fmt.Errorf("error executing template: %v", err) + } + // We store the raw template because we run deepcopy-gen on the + // config and that doesn't copy nicely. + nc.UserContainerNameTemplate = raw + } + return nc, nil } @@ -80,20 +128,28 @@ func NewDefaultsConfigFromConfigMap(config *corev1.ConfigMap) (*Defaults, error) return NewDefaultsConfigFromMap(config.Data) } -const ( - // DefaultRevisionTimeoutSeconds will be set if timeoutSeconds not specified. - DefaultRevisionTimeoutSeconds = 5 * 60 -) - -// Pseudo-constants -var ( - // DefaultRevisionCPURequest will be set if resources.requests.cpu is not specified. - DefaultRevisionCPURequest = resource.MustParse("400m") -) - // Defaults includes the default values to be populated by the webhook. type Defaults struct { RevisionTimeoutSeconds int64 + // This is the timeout set for cluster ingress. + // RevisionTimeoutSeconds must be less than this value. + MaxRevisionTimeoutSeconds int64 + + UserContainerNameTemplate string - RevisionCPURequest resource.Quantity + RevisionCPURequest *resource.Quantity + RevisionCPULimit *resource.Quantity + RevisionMemoryRequest *resource.Quantity + RevisionMemoryLimit *resource.Quantity +} + +// UserContainerName returns the name of the user container based on the context. +func (d *Defaults) UserContainerName(ctx context.Context) string { + tmpl := template.Must( + template.New("user-container").Parse(d.UserContainerNameTemplate)) + buf := &bytes.Buffer{} + if err := tmpl.Execute(buf, apis.ParentMeta(ctx)); err != nil { + return "" + } + return buf.String() } diff --git a/vendor/github.com/knative/serving/pkg/apis/config/store.go b/vendor/github.com/knative/serving/pkg/apis/config/store.go index 7d7f519d9a..38f21bc66d 100644 --- a/vendor/github.com/knative/serving/pkg/apis/config/store.go +++ b/vendor/github.com/knative/serving/pkg/apis/config/store.go @@ -19,7 +19,7 @@ package config import ( "context" - "github.com/knative/pkg/configmap" + "knative.dev/pkg/configmap" ) type cfgKey struct{} diff --git a/vendor/github.com/knative/serving/pkg/apis/config/zz_generated.deepcopy.go b/vendor/github.com/knative/serving/pkg/apis/config/zz_generated.deepcopy.go index 2f56851274..d0e78d8c0d 100644 --- a/vendor/github.com/knative/serving/pkg/apis/config/zz_generated.deepcopy.go +++ b/vendor/github.com/knative/serving/pkg/apis/config/zz_generated.deepcopy.go @@ -16,14 +16,33 @@ See the License for the specific language governing permissions and limitations under the License. */ -// This file was autogenerated by deepcopy-gen. Do not edit it manually! +// Code generated by deepcopy-gen. DO NOT EDIT. package config // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Defaults) DeepCopyInto(out *Defaults) { *out = *in - out.RevisionCPURequest = in.RevisionCPURequest.DeepCopy() + if in.RevisionCPURequest != nil { + in, out := &in.RevisionCPURequest, &out.RevisionCPURequest + x := (*in).DeepCopy() + *out = &x + } + if in.RevisionCPULimit != nil { + in, out := &in.RevisionCPULimit, &out.RevisionCPULimit + x := (*in).DeepCopy() + *out = &x + } + if in.RevisionMemoryRequest != nil { + in, out := &in.RevisionMemoryRequest, &out.RevisionMemoryRequest + x := (*in).DeepCopy() + *out = &x + } + if in.RevisionMemoryLimit != nil { + in, out := &in.RevisionMemoryLimit, &out.RevisionMemoryLimit + x := (*in).DeepCopy() + *out = &x + } return } diff --git a/vendor/github.com/knative/serving/pkg/apis/networking/generic_types.go b/vendor/github.com/knative/serving/pkg/apis/networking/generic_types.go index d13cbf1a19..59adf41001 100644 --- a/vendor/github.com/knative/serving/pkg/apis/networking/generic_types.go +++ b/vendor/github.com/knative/serving/pkg/apis/networking/generic_types.go @@ -16,7 +16,11 @@ limitations under the License. package networking -import "github.com/knative/pkg/apis" +import ( + "context" + + "knative.dev/pkg/apis" +) // This files contains the versionless types and enums that are strongly // unlikely to change from version to version. @@ -33,10 +37,10 @@ const ( ) // Validate validates that ProtocolType has a correct enum value. -func (p ProtocolType) Validate() *apis.FieldError { +func (p ProtocolType) Validate(context.Context) *apis.FieldError { switch p { case ProtocolH2C, ProtocolHTTP1: return nil } - return apis.ErrInvalidValue(string(p), apis.CurrentField) + return apis.ErrInvalidValue(p, apis.CurrentField) } diff --git a/vendor/github.com/knative/serving/pkg/apis/networking/ports.go b/vendor/github.com/knative/serving/pkg/apis/networking/ports.go new file mode 100644 index 0000000000..c8f19bb20b --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/ports.go @@ -0,0 +1,68 @@ +/* +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 networking + +// The ports we setup on our services. +const ( + // ServiceHTTPPort is the port that we setup our Serving and Activator K8s services for + // HTTP/1 endpoints. + ServiceHTTPPort = 80 + + // ServiceHTTP2Port is the port that we setup our Serving and Activator K8s services for + // HTTP/2 endpoints. + ServiceHTTP2Port = 81 + + // BackendHTTPPort is the backend, i.e. `targetPort` that we setup for HTTP services. + BackendHTTPPort = 8012 + + // BackendHTTP2Port is the backend, i.e. `targetPort` that we setup for HTTP services. + BackendHTTP2Port = 8013 + + // QueueAdminPort specifies the port number for + // health check and lifecycle hooks for queue-proxy. + QueueAdminPort = 8022 + + // AutoscalingQueueMetricsPort specifies the port number for metrics emitted + // by queue-proxy for autoscaler. + AutoscalingQueueMetricsPort = 9090 + + // UserQueueMetricsPort specifies the port number for metrics emitted + // by queue-proxy for end user. + UserQueueMetricsPort = 9091 + + // ServicePortNameHTTP1 is the name of the external port of the service for HTTP/1.1 + ServicePortNameHTTP1 = "http" + + // ServicePortNameH2C is the name of the external port of the service for HTTP/2 + ServicePortNameH2C = "http2" +) + +// ServicePortName returns the port for the app level protocol. +func ServicePortName(proto ProtocolType) string { + if proto == ProtocolH2C { + return ServicePortNameH2C + } + return ServicePortNameHTTP1 +} + +// ServicePort chooses the service (load balancer) port for the public service. +func ServicePort(proto ProtocolType) int { + if proto == ProtocolH2C { + return ServiceHTTP2Port + } + return ServiceHTTPPort +} diff --git a/vendor/github.com/knative/serving/pkg/apis/networking/register.go b/vendor/github.com/knative/serving/pkg/apis/networking/register.go index a430d55d2c..83f80b42f1 100644 --- a/vendor/github.com/knative/serving/pkg/apis/networking/register.go +++ b/vendor/github.com/knative/serving/pkg/apis/networking/register.go @@ -17,6 +17,7 @@ limitations under the License. package networking const ( + // GroupName is the name for the networking API group. GroupName = "networking.internal.knative.dev" // IngressClassAnnotationKey is the annotation for the @@ -34,7 +35,45 @@ const ( // Istio-based ClusterIngress will reconcile into a VirtualService). IngressClassAnnotationKey = "networking.knative.dev/ingress.class" - // IngressLabelKey is the label key attached to underlying network programming + // ClusterIngressLabelKey is the label key attached to underlying network programming // resources to indicate which ClusterIngress triggered their creation. - IngressLabelKey = GroupName + "/clusteringress" + ClusterIngressLabelKey = GroupName + "/clusteringress" + + // SKSLabelKey is the label key that SKS Controller attaches to the + // underlying resources it controls. + SKSLabelKey = GroupName + "/serverlessservice" + + // ServiceTypeKey is the label key attached to a service specifying the type of service. + // e.g. Public, Metrics + ServiceTypeKey = GroupName + "/serviceType" + + // OriginSecretNameLabelKey is the label key attached to the TLS secret to indicate + // the name of the origin secret that the TLS secret is copied from. + OriginSecretNameLabelKey = GroupName + "/originSecretName" + + // OriginSecretNamespaceLabelKey is the label key attached to the TLS secret + // to indicate the namespace of the origin secret that the TLS secret is copied from. + OriginSecretNamespaceLabelKey = GroupName + "/originSecretNamespace" +) + +// ServiceType is the enumeration type for the Kubernetes services +// that we have in our system, classified by usage purpose. +type ServiceType string + +const ( + // ServiceTypePrivate is the label value for internal only services + // for user applications. + ServiceTypePrivate ServiceType = "Private" + // ServiceTypePublic is the label value for externally reachable + // services for user applications. + ServiceTypePublic ServiceType = "Public" + // ServiceTypeMetrics is the label value for Metrics services. Such services + // are used for meric scraping. + ServiceTypeMetrics ServiceType = "Metrics" +) + +// Pseudo-constants +var ( + // DefaultRetryCount will be set if Attempts not specified. + DefaultRetryCount = 3 ) diff --git a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/certificate_lifecycle.go b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/certificate_lifecycle.go index 90c4464154..2fd73f017d 100644 --- a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/certificate_lifecycle.go +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/certificate_lifecycle.go @@ -17,7 +17,10 @@ limitations under the License. package v1alpha1 import ( - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "fmt" + + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "k8s.io/apimachinery/pkg/runtime/schema" ) @@ -28,7 +31,24 @@ func (cs *CertificateStatus) InitializeConditions() { // MarkReady marks the certificate as ready to use. func (cs *CertificateStatus) MarkReady() { - certificateCondSet.Manage(cs).MarkTrue(CertificateCondidtionReady) + certificateCondSet.Manage(cs).MarkTrue(CertificateConditionReady) +} + +// MarkUnknown marks the certificate status as unknown. +func (cs *CertificateStatus) MarkUnknown(reason, message string) { + certificateCondSet.Manage(cs).MarkUnknown(CertificateConditionReady, reason, message) +} + +// MarkNotReady marks the certificate as not ready. +func (cs *CertificateStatus) MarkNotReady(reason, message string) { + certificateCondSet.Manage(cs).MarkFalse(CertificateConditionReady, reason, message) +} + +// MarkResourceNotOwned changes the ready condition to false to reflect that we don't own the +// resource of the given kind and name. +func (cs *CertificateStatus) MarkResourceNotOwned(kind, name string) { + certificateCondSet.Manage(cs).MarkFalse(CertificateConditionReady, "NotOwned", + fmt.Sprintf("There is an existing %s %q that we do not own.", kind, name)) } // IsReady returns true is the Certificate is ready. @@ -37,7 +57,7 @@ func (cs *CertificateStatus) IsReady() bool { } // GetCondition gets a speicifc condition of the Certificate status. -func (cs *CertificateStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition { +func (cs *CertificateStatus) GetCondition(t apis.ConditionType) *apis.Condition { return certificateCondSet.Manage(cs).GetCondition(t) } @@ -45,12 +65,16 @@ func (cs *CertificateStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1a const ( // CertificateConditionReady is set when the requested certificate // is provioned and valid. - CertificateCondidtionReady = duckv1alpha1.ConditionReady + CertificateConditionReady = apis.ConditionReady ) -var certificateCondSet = duckv1alpha1.NewLivingConditionSet(CertificateCondidtionReady) +var certificateCondSet = apis.NewLivingConditionSet(CertificateConditionReady) // GetGroupVersionKind returns the GroupVersionKind of Certificate. func (c *Certificate) GetGroupVersionKind() schema.GroupVersionKind { return SchemeGroupVersion.WithKind("Certificate") } + +func (cs *CertificateStatus) duck() *duckv1beta1.Status { + return &cs.Status +} diff --git a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/certificate_types.go b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/certificate_types.go index 49bf5c0ea2..6e817a8b08 100644 --- a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/certificate_types.go +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/certificate_types.go @@ -17,10 +17,11 @@ limitations under the License. package v1alpha1 import ( - "github.com/knative/pkg/apis" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" - "github.com/knative/pkg/kmeta" + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/kmeta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/intstr" ) // +genclient @@ -83,10 +84,34 @@ type CertificateSpec struct { // CertificateStatus defines the observed state of a `Certificate`. type CertificateStatus struct { - duckv1alpha1.Status `json:",inline"` + // When Certificate status is ready, it means: + // - The target secret exists + // - The target secret contains a certificate that has not expired + // - The target secret contains a private key valid for the certificate + duckv1beta1.Status `json:",inline"` // The expiration time of the TLS certificate stored in the secret named // by this resource in spec.secretName. // +optional NotAfter *metav1.Time `json:"notAfter,omitempty"` + + // HTTP01Challenges is a list of HTTP01 challenges that need to be fulfilled + // in order to get the TLS certificate.. + HTTP01Challenges []HTTP01Challenge `json:"http01Challenges,omitempty"` +} + +// HTTP01Challenge defines the status of a HTTP01 challenge that a certificate needs +// to fulfill. +type HTTP01Challenge struct { + // URL is the URL that the HTTP01 challenge is expected to serve on. + URL *apis.URL `json:"url,omitempty"` + + // ServiceName is the name of the service to serve HTTP01 challenge requests. + ServiceName string `json:"serviceName,omitempty"` + + // ServiceNamespace is the namespace of the service to serve HTTP01 challenge requests. + ServiceNamespace string `json:"serviceNamespace,omitempty"` + + // ServicePort is the port of the service to serve HTTP01 challenge requests. + ServicePort intstr.IntOrString `json:"servicePort,omitempty"` } diff --git a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/certificate_validation.go b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/certificate_validation.go index b99d4879d3..e529bc169a 100644 --- a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/certificate_validation.go +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/certificate_validation.go @@ -19,12 +19,12 @@ package v1alpha1 import ( "context" - "github.com/knative/pkg/apis" + "knative.dev/pkg/apis" ) // Validate inspects and validates Certificate object. func (c *Certificate) Validate(ctx context.Context) *apis.FieldError { - return c.Spec.Validate(ctx).ViaField("spec") + return c.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec") } // Validate inspects and validates CertificateSpec object. diff --git a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/clusteringress_defaults.go b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/clusteringress_defaults.go index a015794d79..46ba152550 100644 --- a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/clusteringress_defaults.go +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/clusteringress_defaults.go @@ -18,72 +18,10 @@ package v1alpha1 import ( "context" - "time" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -const ( - // DefaultTimeout will be set if timeout not specified. - DefaultTimeout = 10 * time.Minute - // DefaultRetryCount will be set if Attempts not specified. - DefaultRetryCount = 3 + "knative.dev/pkg/apis" ) func (c *ClusterIngress) SetDefaults(ctx context.Context) { - c.Spec.SetDefaults(ctx) -} - -func (c *IngressSpec) SetDefaults(ctx context.Context) { - for i := range c.TLS { - c.TLS[i].SetDefaults(ctx) - } - for i := range c.Rules { - c.Rules[i].SetDefaults(ctx) - } - if c.Visibility == "" { - c.Visibility = IngressVisibilityExternalIP - } -} - -func (t *ClusterIngressTLS) SetDefaults(ctx context.Context) { - // Default Secret key for ServerCertificate is `tls.crt`. - if t.ServerCertificate == "" { - t.ServerCertificate = "tls.crt" - } - // Default Secret key for PrivateKey is `tls.key`. - if t.PrivateKey == "" { - t.PrivateKey = "tls.key" - } -} - -func (r *ClusterIngressRule) SetDefaults(ctx context.Context) { - r.HTTP.SetDefaults(ctx) -} - -func (r *HTTPClusterIngressRuleValue) SetDefaults(ctx context.Context) { - for i := range r.Paths { - r.Paths[i].SetDefaults(ctx) - } -} - -func (p *HTTPClusterIngressPath) SetDefaults(ctx context.Context) { - // If only one split is specified, we default to 100. - if len(p.Splits) == 1 && p.Splits[0].Percent == 0 { - p.Splits[0].Percent = 100 - } - - if p.Timeout == nil { - p.Timeout = &metav1.Duration{Duration: DefaultTimeout} - } - - if p.Retries == nil { - p.Retries = &HTTPRetry{ - PerTryTimeout: &metav1.Duration{Duration: DefaultTimeout}, - Attempts: DefaultRetryCount, - } - } - if p.Retries.PerTryTimeout == nil { - p.Retries.PerTryTimeout = &metav1.Duration{Duration: DefaultTimeout} - } + c.Spec.SetDefaults(apis.WithinSpec(ctx)) } diff --git a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/clusteringress_lifecycle.go b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/clusteringress_lifecycle.go index 98391afb2d..92fefe85d9 100644 --- a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/clusteringress_lifecycle.go +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/clusteringress_lifecycle.go @@ -17,17 +17,9 @@ limitations under the License. package v1alpha1 import ( - "fmt" - - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" "k8s.io/apimachinery/pkg/runtime/schema" ) -var clusterIngressCondSet = duckv1alpha1.NewLivingConditionSet( - ClusterIngressConditionNetworkConfigured, - ClusterIngressConditionLoadBalancerReady, -) - func (ci *ClusterIngress) GetGroupVersionKind() schema.GroupVersionKind { return SchemeGroupVersion.WithKind("ClusterIngress") } @@ -36,38 +28,3 @@ func (ci *ClusterIngress) GetGroupVersionKind() schema.GroupVersionKind { func (ci *ClusterIngress) IsPublic() bool { return ci.Spec.Visibility == "" || ci.Spec.Visibility == IngressVisibilityExternalIP } - -func (cis *IngressStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition { - return clusterIngressCondSet.Manage(cis).GetCondition(t) -} - -func (cis *IngressStatus) InitializeConditions() { - clusterIngressCondSet.Manage(cis).InitializeConditions() -} - -func (cis *IngressStatus) MarkNetworkConfigured() { - clusterIngressCondSet.Manage(cis).MarkTrue(ClusterIngressConditionNetworkConfigured) -} - -// MarkResourceNotOwned changes the "NetworkConfigured" condition to false to reflect that the -// resource of the given kind and name has already been created, and we do not own it. -func (cis *IngressStatus) MarkResourceNotOwned(kind, name string) { - clusterIngressCondSet.Manage(cis).MarkFalse(ClusterIngressConditionNetworkConfigured, "NotOwned", - fmt.Sprintf("There is an existing %s %q that we do not own.", kind, name)) -} - -// MarkLoadBalancerReady marks the Ingress with ClusterIngressConditionLoadBalancerReady, -// and also populate the address of the load balancer. -func (cis *IngressStatus) MarkLoadBalancerReady(lbs []LoadBalancerIngressStatus) { - cis.LoadBalancer = &LoadBalancerStatus{ - Ingress: []LoadBalancerIngressStatus{}, - } - cis.LoadBalancer.Ingress = append(cis.LoadBalancer.Ingress, lbs...) - clusterIngressCondSet.Manage(cis).MarkTrue(ClusterIngressConditionLoadBalancerReady) -} - -// IsReady looks at the conditions and if the Status has a condition -// ClusterIngressConditionReady returns true if ConditionStatus is True -func (cis *IngressStatus) IsReady() bool { - return clusterIngressCondSet.Manage(cis).IsHappy() -} diff --git a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/clusteringress_types.go b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/clusteringress_types.go index 4e09a0dad6..e9fc07bab9 100644 --- a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/clusteringress_types.go +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/clusteringress_types.go @@ -17,11 +17,9 @@ limitations under the License. package v1alpha1 import ( - "github.com/knative/pkg/apis" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" - "github.com/knative/pkg/kmeta" + "knative.dev/pkg/apis" + "knative.dev/pkg/kmeta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" ) // +genclient @@ -75,250 +73,3 @@ type ClusterIngressList struct { // Items is the list of ClusterIngress objects. Items []ClusterIngress `json:"items"` } - -// IngressSpec describes the ClusterIngress the user wishes to exist. -// -// In general this follows the same shape as K8s Ingress. -// Some notable differences: -// - Backends now can have namespace: -// - Traffic can be split across multiple backends. -// - Timeout & Retry can be configured. -// - Headers can be appended. -type IngressSpec struct { - // DeprecatedGeneration was used prior in Kubernetes versions <1.11 - // when metadata.generation was not being incremented by the api server - // - // This property will be dropped in future Knative releases and should - // not be used - use metadata.generation - // - // Tracking issue: https://github.com/knative/serving/issues/643 - // - // +optional - DeprecatedGeneration int64 `json:"generation,omitempty"` - - // TLS configuration. Currently ClusterIngress only supports a single TLS - // port: 443. If multiple members of this list specify different hosts, they - // will be multiplexed on the same port according to the hostname specified - // through the SNI TLS extension, if the ingress controller fulfilling the - // ingress supports SNI. - // +optional - TLS []ClusterIngressTLS `json:"tls,omitempty"` - - // A list of host rules used to configure the ClusterIngress. - // +optional - Rules []ClusterIngressRule `json:"rules,omitempty"` - - // Visibility setting. - Visibility IngressVisibility `json:"visibility,omitempty"` -} - -// IngressVisibility describes whether the Ingress should be exposed to -// public gateways or not. -type IngressVisibility string - -const ( - // IngressVisibilityExternalIP is used to denote that the Ingress - // should be exposed via an external IP, for example a LoadBalancer - // Service. This is the default value for IngressVisibility. - IngressVisibilityExternalIP IngressVisibility = "ExternalIP" - // IngressVisibilityClusterLocal is used to denote that the Ingress - // should be only be exposed locally to the cluster. - IngressVisibilityClusterLocal IngressVisibility = "ClusterLocal" -) - -// ClusterIngressTLS describes the transport layer security associated with an ClusterIngress. -type ClusterIngressTLS struct { - // Hosts is a list of hosts included in the TLS certificate. The values in - // this list must match the name/s used in the tlsSecret. Defaults to the - // wildcard host setting for the loadbalancer controller fulfilling this - // ClusterIngress, if left unspecified. - // +optional - Hosts []string `json:"hosts,omitempty"` - - // SecretName is the name of the secret used to terminate SSL traffic. - SecretName string `json:"secretName,omitempty"` - - // SecretNamespace is the namespace of the secret used to terminate SSL traffic. - SecretNamespace string `json:"secretNamespace,omitempty"` - - // ServerCertificate identifies the certificate filename in the secret. - // Defaults to `tls.cert`. - // +optional - ServerCertificate string `json:"serverCertificate,omitempty"` - - // PrivateKey identifies the private key filename in the secret. - // Defaults to `tls.key`. - // +optional - PrivateKey string `json:"privateKey,omitempty"` -} - -// ClusterIngressRule represents the rules mapping the paths under a specified host to -// the related backend services. Incoming requests are first evaluated for a host -// match, then routed to the backend associated with the matching ClusterIngressRuleValue. -type ClusterIngressRule struct { - // Host is the fully qualified domain name of a network host, as defined - // by RFC 3986. Note the following deviations from the "host" part of the - // URI as defined in the RFC: - // 1. IPs are not allowed. Currently a rule value can only apply to the - // IP in the Spec of the parent ClusterIngress. - // 2. The `:` delimiter is not respected because ports are not allowed. - // Currently the port of an ClusterIngress is implicitly :80 for http and - // :443 for https. - // Both these may change in the future. - // If the host is unspecified, the ClusterIngress routes all traffic based on the - // specified ClusterIngressRuleValue. - // If multiple matching Hosts were provided, the first rule will take precedent. - // +optional - Hosts []string `json:"hosts,omitempty"` - - // HTTP represents a rule to apply against incoming requests. If the - // rule is satisfied, the request is routed to the specified backend. - HTTP *HTTPClusterIngressRuleValue `json:"http,omitempty"` -} - -// HTTPClusterIngressRuleValue is a list of http selectors pointing to backends. -// In the example: http:///? -> backend where -// where parts of the url correspond to RFC 3986, this resource will be used -// to match against everything after the last '/' and before the first '?' -// or '#'. -type HTTPClusterIngressRuleValue struct { - // A collection of paths that map requests to backends. - // - // If they are multiple matching paths, the first match takes precendent. - Paths []HTTPClusterIngressPath `json:"paths"` - - // TODO: Consider adding fields for ingress-type specific global - // options usable by a loadbalancer, like http keep-alive. -} - -// HTTPClusterIngressPath associates a path regex with a backend. Incoming URLs matching -// the path are forwarded to the backend. -type HTTPClusterIngressPath struct { - // Path is an extended POSIX regex as defined by IEEE Std 1003.1, - // (i.e this follows the egrep/unix syntax, not the perl syntax) - // matched against the path of an incoming request. Currently it can - // contain characters disallowed from the conventional "path" - // part of a URL as defined by RFC 3986. Paths must begin with - // a '/'. If unspecified, the path defaults to a catch all sending - // traffic to the backend. - // +optional - Path string `json:"path,omitempty"` - - // Splits defines the referenced service endpoints to which the traffic - // will be forwarded to. - Splits []ClusterIngressBackendSplit `json:"splits"` - - // AppendHeaders allow specifying additional HTTP headers to add - // before forwarding a request to the destination service. - // - // NOTE: This differs from K8s Ingress which doesn't allow header appending. - // +optional - AppendHeaders map[string]string `json:"appendHeaders,omitempty"` - - // Timeout for HTTP requests. - // - // NOTE: This differs from K8s Ingress which doesn't allow setting timeouts. - // +optional - Timeout *metav1.Duration `json:"timeout,omitempty"` - - // Retry policy for HTTP requests. - // - // NOTE: This differs from K8s Ingress which doesn't allow retry settings. - // +optional - Retries *HTTPRetry `json:"retries,omitempty"` -} - -// ClusterIngressBackendSplit describes all endpoints for a given service and port. -type ClusterIngressBackendSplit struct { - // Specifies the backend receiving the traffic split. - ClusterIngressBackend `json:",inline"` - - // Specifies the split percentage, a number between 0 and 100. If - // only one split is specified, we default to 100. - // - // NOTE: This differs from K8s Ingress to allow percentage split. - Percent int `json:"percent,omitempty"` -} - -// ClusterIngressBackend describes all endpoints for a given service and port. -type ClusterIngressBackend struct { - // Specifies the namespace of the referenced service. - // - // NOTE: This differs from K8s Ingress to allow routing to different namespaces. - ServiceNamespace string `json:"serviceNamespace"` - - // Specifies the name of the referenced service. - ServiceName string `json:"serviceName"` - - // Specifies the port of the referenced service. - ServicePort intstr.IntOrString `json:"servicePort"` -} - -// HTTPRetry describes the retry policy to use when a HTTP request fails. -type HTTPRetry struct { - // Number of retries for a given request. - Attempts int `json:"attempts"` - - // Timeout per retry attempt for a given request. format: 1h/1m/1s/1ms. MUST BE >=1ms. - PerTryTimeout *metav1.Duration `json:"perTryTimeout"` -} - -// IngressStatus describe the current state of the ClusterIngress. -type IngressStatus struct { - duckv1alpha1.Status `json:",inline"` - - // LoadBalancer contains the current status of the load-balancer. - // +optional - LoadBalancer *LoadBalancerStatus `json:"loadBalancer,omitempty"` -} - -// LoadBalancerStatus represents the status of a load-balancer. -type LoadBalancerStatus struct { - // Ingress is a list containing ingress points for the load-balancer. - // Traffic intended for the service should be sent to these ingress points. - // +optional - Ingress []LoadBalancerIngressStatus `json:"ingress,omitempty"` -} - -// LoadBalancerIngress represents the status of a load-balancer ingress point: -// traffic intended for the service should be sent to an ingress point. -type LoadBalancerIngressStatus struct { - // IP is set for load-balancer ingress points that are IP based - // (typically GCE or OpenStack load-balancers) - // +optional - IP string `json:"ip,omitempty"` - - // Domain is set for load-balancer ingress points that are DNS based - // (typically AWS load-balancers) - // +optional - Domain string `json:"domain,omitempty"` - - // DomainInternal is set if there is a cluster-local DNS name to access the Ingress. - // - // NOTE: This differs from K8s Ingress, since we also desire to have a cluster-local - // DNS name to allow routing in case of not having a mesh. - // - // +optional - DomainInternal string `json:"domainInternal,omitempty"` - - // MeshOnly is set if the ClusterIngress is only load-balanced through a Service mesh. - // +optional - MeshOnly bool `json:"meshOnly,omitempty"` -} - -// ConditionType represents a ClusterIngress condition value -const ( - // ClusterIngressConditionReady is set when the clusterIngress networking setting is - // configured and it has a load balancer address. - ClusterIngressConditionReady = duckv1alpha1.ConditionReady - - // ClusterIngressConditionNetworkConfigured is set when the ClusterIngress's underlying - // network programming has been configured. This doesn't include conditions of the - // backends, so even if this should remain true when network is configured and backends - // are not ready. - ClusterIngressConditionNetworkConfigured duckv1alpha1.ConditionType = "NetworkConfigured" - - // ClusterIngressConditionLoadBalancerReady is set when the ClusterIngress has - // a ready LoadBalancer. - ClusterIngressConditionLoadBalancerReady duckv1alpha1.ConditionType = "LoadBalancerReady" -) diff --git a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/clusteringress_validation.go b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/clusteringress_validation.go index 024e379053..6a59bc15b3 100644 --- a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/clusteringress_validation.go +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/clusteringress_validation.go @@ -18,157 +18,11 @@ package v1alpha1 import ( "context" - "strconv" - "github.com/knative/pkg/apis" - "k8s.io/apimachinery/pkg/api/equality" - "k8s.io/apimachinery/pkg/util/intstr" + "knative.dev/pkg/apis" ) // Validate inspects and validates ClusterIngress object. func (ci *ClusterIngress) Validate(ctx context.Context) *apis.FieldError { - return ci.Spec.Validate(ctx).ViaField("spec") -} - -// Validate inspects and validates IngressSpec object. -func (spec *IngressSpec) Validate(ctx context.Context) *apis.FieldError { - // Spec must not be empty. - if equality.Semantic.DeepEqual(spec, &IngressSpec{}) { - return apis.ErrMissingField(apis.CurrentField) - } - var all *apis.FieldError - // Spec must have at least one rule. - if len(spec.Rules) == 0 { - all = all.Also(apis.ErrMissingField("rules")) - } - // Validate each rule. - for idx, rule := range spec.Rules { - all = all.Also(rule.Validate(ctx).ViaFieldIndex("rules", idx)) - } - // TLS settings are optional. However, all provided settings should be valid. - for idx, tls := range spec.TLS { - all = all.Also(tls.Validate(ctx).ViaFieldIndex("tls", idx)) - } - return all -} - -// Validate inspects and validates ClusterIngressRule object. -func (r *ClusterIngressRule) Validate(ctx context.Context) *apis.FieldError { - // Provided rule must not be empty. - if equality.Semantic.DeepEqual(r, &ClusterIngressRule{}) { - return apis.ErrMissingField(apis.CurrentField) - } - var all *apis.FieldError - if r.HTTP == nil { - all = all.Also(apis.ErrMissingField("http")) - } else { - all = all.Also(r.HTTP.Validate(ctx).ViaField("http")) - } - return all -} - -// Validate inspects and validates HTTPClusterIngressRuleValue object. -func (h *HTTPClusterIngressRuleValue) Validate(ctx context.Context) *apis.FieldError { - if len(h.Paths) == 0 { - return apis.ErrMissingField("paths") - } - var all *apis.FieldError - for idx, path := range h.Paths { - all = all.Also(path.Validate(ctx).ViaFieldIndex("paths", idx)) - } - return all -} - -// Validate inspects and validates HTTPClusterIngressPath object. -func (h HTTPClusterIngressPath) Validate(ctx context.Context) *apis.FieldError { - // Provided rule must not be empty. - if equality.Semantic.DeepEqual(h, HTTPClusterIngressPath{}) { - return apis.ErrMissingField(apis.CurrentField) - } - var all *apis.FieldError - // Must provide as least one split. - if len(h.Splits) == 0 { - all = all.Also(apis.ErrMissingField("splits")) - } else { - totalPct := 0 - for idx, split := range h.Splits { - if err := split.Validate(ctx); err != nil { - return err.ViaFieldIndex("splits", idx) - } - totalPct += split.Percent - } - // If a single split is provided we allow missing Percent, and - // interpret as 100%. - if (len(h.Splits) != 1 || totalPct != 0) && totalPct != 100 { - // Total traffic split percentage must sum up to 100%. - all = all.Also(&apis.FieldError{ - Message: "Traffic split percentage must total to 100, but was " + strconv.Itoa(totalPct), - Paths: []string{"splits"}, - }) - } - } - if h.Retries != nil { - all = all.Also(h.Retries.Validate(ctx).ViaField("retries")) - } - return all -} - -// Validate inspects and validates HTTPClusterIngressPath object. -func (s ClusterIngressBackendSplit) Validate(ctx context.Context) *apis.FieldError { - // Must not be empty. - if equality.Semantic.DeepEqual(s, ClusterIngressBackendSplit{}) { - return apis.ErrMissingField(apis.CurrentField) - } - var all *apis.FieldError - // Percent must be between 0 and 100. - if s.Percent < 0 || s.Percent > 100 { - all = all.Also(apis.ErrInvalidValue(strconv.Itoa(s.Percent), "percent")) - } - return all.Also(s.ClusterIngressBackend.Validate(ctx)) -} - -// Validate inspects the fields of the type ClusterIngressBackend -// to determine if they are valid. -func (b ClusterIngressBackend) Validate(ctx context.Context) *apis.FieldError { - // Must not be empty. - if equality.Semantic.DeepEqual(b, ClusterIngressBackend{}) { - return apis.ErrMissingField(apis.CurrentField) - } - var all *apis.FieldError - if b.ServiceNamespace == "" { - all = all.Also(apis.ErrMissingField("serviceNamespace")) - } - if b.ServiceName == "" { - all = all.Also(apis.ErrMissingField("serviceName")) - } - if equality.Semantic.DeepEqual(b.ServicePort, intstr.IntOrString{}) { - all = all.Also(apis.ErrMissingField("servicePort")) - } - return all -} - -// Validate inspects and validates HTTPRetry object. -func (r *HTTPRetry) Validate(ctx context.Context) *apis.FieldError { - // Attempts must be greater than 0. - if r.Attempts < 0 { - return apis.ErrInvalidValue(strconv.Itoa(r.Attempts), "attempts") - } - return nil -} - -// Validate inspects and validates ClusterIngressTLS object. -func (t *ClusterIngressTLS) Validate(ctx context.Context) *apis.FieldError { - // Provided TLS setting must not be empty. - if equality.Semantic.DeepEqual(t, &ClusterIngressTLS{}) { - return apis.ErrMissingField(apis.CurrentField) - } - var all *apis.FieldError - // SecretName and SecretNamespace must not be empty. - if t.SecretName == "" { - all = all.Also(apis.ErrMissingField("secretName")) - } - if t.SecretNamespace == "" { - all = all.Also(apis.ErrMissingField("secretNamespace")) - } - return all + return ci.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec") } diff --git a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/ingress_defaults.go b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/ingress_defaults.go new file mode 100644 index 0000000000..ac06eb1243 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/ingress_defaults.go @@ -0,0 +1,99 @@ +/* +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" + "time" + + "knative.dev/pkg/apis" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/knative/serving/pkg/apis/config" + "github.com/knative/serving/pkg/apis/networking" +) + +var ( + defaultMaxRevisionTimeout = time.Duration(config.DefaultMaxRevisionTimeoutSeconds) * time.Second +) + +// SetDefaults populates default values in Ingress +func (i *Ingress) SetDefaults(ctx context.Context) { + i.Spec.SetDefaults(apis.WithinSpec(ctx)) +} + +// SetDefaults populates default values in IngressSpec +func (s *IngressSpec) SetDefaults(ctx context.Context) { + for i := range s.TLS { + s.TLS[i].SetDefaults(ctx) + } + for i := range s.Rules { + s.Rules[i].SetDefaults(ctx) + } + if s.Visibility == "" { + s.Visibility = IngressVisibilityExternalIP + } +} + +// SetDefaults populates default values in IngressTLS +func (t *IngressTLS) SetDefaults(ctx context.Context) { + // Default Secret key for ServerCertificate is `tls.crt`. + if t.ServerCertificate == "" { + t.ServerCertificate = "tls.crt" + } + // Default Secret key for PrivateKey is `tls.key`. + if t.PrivateKey == "" { + t.PrivateKey = "tls.key" + } +} + +// SetDefaults populates default values in IngressRule +func (r *IngressRule) SetDefaults(ctx context.Context) { + r.HTTP.SetDefaults(ctx) +} + +// SetDefaults populates default values in HTTPIngressRuleValue +func (r *HTTPIngressRuleValue) SetDefaults(ctx context.Context) { + for i := range r.Paths { + r.Paths[i].SetDefaults(ctx) + } +} + +// SetDefaults populates default values in HTTPIngressPath +func (p *HTTPIngressPath) SetDefaults(ctx context.Context) { + // If only one split is specified, we default to 100. + if len(p.Splits) == 1 && p.Splits[0].Percent == 0 { + p.Splits[0].Percent = 100 + } + + cfg := config.FromContextOrDefaults(ctx) + maxTimeout := time.Duration(cfg.Defaults.MaxRevisionTimeoutSeconds) * time.Second + + if p.Timeout == nil { + p.Timeout = &metav1.Duration{Duration: maxTimeout} + } + + if p.Retries == nil { + p.Retries = &HTTPRetry{ + PerTryTimeout: &metav1.Duration{Duration: maxTimeout}, + Attempts: networking.DefaultRetryCount, + } + } + if p.Retries.PerTryTimeout == nil { + p.Retries.PerTryTimeout = &metav1.Duration{Duration: maxTimeout} + } +} diff --git a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/ingress_lifecycle.go b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/ingress_lifecycle.go new file mode 100644 index 0000000000..c130af3482 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/ingress_lifecycle.go @@ -0,0 +1,82 @@ +/* +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 ( + "fmt" + + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var ingressCondSet = apis.NewLivingConditionSet( + IngressConditionNetworkConfigured, + IngressConditionLoadBalancerReady, +) + +// GetGroupVersionKind returns SchemeGroupVersion of an Ingress +func (i *Ingress) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Ingress") +} + +// IsPublic returns whether the Ingress should be exposed publicly. +func (i *Ingress) IsPublic() bool { + return i.Spec.Visibility == "" || i.Spec.Visibility == IngressVisibilityExternalIP +} + +// GetCondition returns the current condition of a given condition type +func (is *IngressStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return ingressCondSet.Manage(is).GetCondition(t) +} + +// InitializeConditions initializes conditions of an IngressStatus +func (is *IngressStatus) InitializeConditions() { + ingressCondSet.Manage(is).InitializeConditions() +} + +// MarkNetworkConfigured set IngressConditionNetworkConfigured in IngressStatus as true +func (is *IngressStatus) MarkNetworkConfigured() { + ingressCondSet.Manage(is).MarkTrue(IngressConditionNetworkConfigured) +} + +// MarkResourceNotOwned changes the "NetworkConfigured" condition to false to reflect that the +// resource of the given kind and name has already been created, and we do not own it. +func (is *IngressStatus) MarkResourceNotOwned(kind, name string) { + ingressCondSet.Manage(is).MarkFalse(IngressConditionNetworkConfigured, "NotOwned", + fmt.Sprintf("There is an existing %s %q that we do not own.", kind, name)) +} + +// MarkLoadBalancerReady marks the Ingress with IngressConditionLoadBalancerReady, +// and also populate the address of the load balancer. +func (is *IngressStatus) MarkLoadBalancerReady(lbs []LoadBalancerIngressStatus) { + is.LoadBalancer = &LoadBalancerStatus{ + Ingress: []LoadBalancerIngressStatus{}, + } + is.LoadBalancer.Ingress = append(is.LoadBalancer.Ingress, lbs...) + ingressCondSet.Manage(is).MarkTrue(IngressConditionLoadBalancerReady) +} + +// IsReady looks at the conditions and if the Status has a condition +// IngressConditionReady returns true if ConditionStatus is True +func (is *IngressStatus) IsReady() bool { + return ingressCondSet.Manage(is).IsHappy() +} + +func (is *IngressStatus) duck() *duckv1beta1.Status { + return &is.Status +} diff --git a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/ingress_types.go b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/ingress_types.go new file mode 100644 index 0000000000..c2cc20fb4f --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/ingress_types.go @@ -0,0 +1,329 @@ +/* +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 ( + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/kmeta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/intstr" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Ingress is a collection of rules that allow inbound connections to reach the endpoints defined +// by a backend. An Ingress can be configured to give services externally-reachable URLs, load +// balance traffic, offer name based virtual hosting, etc. +// +// This is heavily based on K8s Ingress https://godoc.org/k8s.io/api/extensions/v1beta1#Ingress +// which some highlighted modifications. +type Ingress struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec is the desired state of the Ingress. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status + // +optional + Spec IngressSpec `json:"spec,omitempty"` + + // Status is the current state of the ClusterIngress. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status + // +optional + Status IngressStatus `json:"status,omitempty"` +} + +// Verify that Ingress adheres to the appropriate interfaces. +var ( + // Check that Ingress may be validated and defaulted. + _ apis.Validatable = (*Ingress)(nil) + _ apis.Defaultable = (*Ingress)(nil) + + // Check that we can create OwnerReferences to a Ingress. + _ kmeta.OwnerRefable = (*Ingress)(nil) +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// IngressList is a collection of Ingress objects. +type IngressList struct { + metav1.TypeMeta `json:",inline"` + // Standard object metadata. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + // Items is the list of Ingress objects. + Items []Ingress `json:"items"` +} + +// IngressSpec describes the Ingress the user wishes to exist. +// +// In general this follows the same shape as K8s Ingress. +// Some notable differences: +// - Backends now can have namespace: +// - Traffic can be split across multiple backends. +// - Timeout & Retry can be configured. +// - Headers can be appended. +type IngressSpec struct { + // DeprecatedGeneration was used prior in Kubernetes versions <1.11 + // when metadata.generation was not being incremented by the api server + // + // This property will be dropped in future Knative releases and should + // not be used - use metadata.generation + // + // Tracking issue: https://github.com/knative/serving/issues/643 + // + // +optional + DeprecatedGeneration int64 `json:"generation,omitempty"` + + // TLS configuration. Currently ClusterIngress only supports a single TLS + // port: 443. If multiple members of this list specify different hosts, they + // will be multiplexed on the same port according to the hostname specified + // through the SNI TLS extension, if the ingress controller fulfilling the + // ingress supports SNI. + // +optional + TLS []IngressTLS `json:"tls,omitempty"` + + // A list of host rules used to configure the Ingress. + // +optional + Rules []IngressRule `json:"rules,omitempty"` + + // Visibility setting. + Visibility IngressVisibility `json:"visibility,omitempty"` +} + +// IngressVisibility describes whether the Ingress should be exposed to +// public gateways or not. +type IngressVisibility string + +const ( + // IngressVisibilityExternalIP is used to denote that the Ingress + // should be exposed via an external IP, for example a LoadBalancer + // Service. This is the default value for IngressVisibility. + IngressVisibilityExternalIP IngressVisibility = "ExternalIP" + // IngressVisibilityClusterLocal is used to denote that the Ingress + // should be only be exposed locally to the cluster. + IngressVisibilityClusterLocal IngressVisibility = "ClusterLocal" +) + +// IngressTLS describes the transport layer security associated with an Ingress. +type IngressTLS struct { + // Hosts is a list of hosts included in the TLS certificate. The values in + // this list must match the name/s used in the tlsSecret. Defaults to the + // wildcard host setting for the loadbalancer controller fulfilling this + // ClusterIngress, if left unspecified. + // +optional + Hosts []string `json:"hosts,omitempty"` + + // SecretName is the name of the secret used to terminate SSL traffic. + SecretName string `json:"secretName,omitempty"` + + // SecretNamespace is the namespace of the secret used to terminate SSL traffic. + SecretNamespace string `json:"secretNamespace,omitempty"` + + // ServerCertificate identifies the certificate filename in the secret. + // Defaults to `tls.crt`. + // +optional + ServerCertificate string `json:"serverCertificate,omitempty"` + + // PrivateKey identifies the private key filename in the secret. + // Defaults to `tls.key`. + // +optional + PrivateKey string `json:"privateKey,omitempty"` +} + +// IngressRule represents the rules mapping the paths under a specified host to +// the related backend services. Incoming requests are first evaluated for a host +// match, then routed to the backend associated with the matching IngressRuleValue. +type IngressRule struct { + // Host is the fully qualified domain name of a network host, as defined + // by RFC 3986. Note the following deviations from the "host" part of the + // URI as defined in the RFC: + // 1. IPs are not allowed. Currently a rule value can only apply to the + // IP in the Spec of the parent ClusterIngress. + // 2. The `:` delimiter is not respected because ports are not allowed. + // Currently the port of an ClusterIngress is implicitly :80 for http and + // :443 for https. + // Both these may change in the future. + // If the host is unspecified, the ClusterIngress routes all traffic based on the + // specified IngressRuleValue. + // If multiple matching Hosts were provided, the first rule will take precedent. + // +optional + Hosts []string `json:"hosts,omitempty"` + + // HTTP represents a rule to apply against incoming requests. If the + // rule is satisfied, the request is routed to the specified backend. + HTTP *HTTPIngressRuleValue `json:"http,omitempty"` +} + +// HTTPIngressRuleValue is a list of http selectors pointing to backends. +// In the example: http:///? -> backend where +// where parts of the url correspond to RFC 3986, this resource will be used +// to match against everything after the last '/' and before the first '?' +// or '#'. +type HTTPIngressRuleValue struct { + // A collection of paths that map requests to backends. + // + // If they are multiple matching paths, the first match takes precendent. + Paths []HTTPIngressPath `json:"paths"` + + // TODO: Consider adding fields for ingress-type specific global + // options usable by a loadbalancer, like http keep-alive. +} + +// HTTPIngressPath associates a path regex with a backend. Incoming URLs matching +// the path are forwarded to the backend. +type HTTPIngressPath struct { + // Path is an extended POSIX regex as defined by IEEE Std 1003.1, + // (i.e this follows the egrep/unix syntax, not the perl syntax) + // matched against the path of an incoming request. Currently it can + // contain characters disallowed from the conventional "path" + // part of a URL as defined by RFC 3986. Paths must begin with + // a '/'. If unspecified, the path defaults to a catch all sending + // traffic to the backend. + // +optional + Path string `json:"path,omitempty"` + + // Splits defines the referenced service endpoints to which the traffic + // will be forwarded to. + Splits []IngressBackendSplit `json:"splits"` + + // AppendHeaders allow specifying additional HTTP headers to add + // before forwarding a request to the destination service. + // + // NOTE: This differs from K8s Ingress which doesn't allow header appending. + // +optional + AppendHeaders map[string]string `json:"appendHeaders,omitempty"` + + // Timeout for HTTP requests. + // + // NOTE: This differs from K8s Ingress which doesn't allow setting timeouts. + // +optional + Timeout *metav1.Duration `json:"timeout,omitempty"` + + // Retry policy for HTTP requests. + // + // NOTE: This differs from K8s Ingress which doesn't allow retry settings. + // +optional + Retries *HTTPRetry `json:"retries,omitempty"` +} + +// IngressBackendSplit describes all endpoints for a given service and port. +type IngressBackendSplit struct { + // Specifies the backend receiving the traffic split. + IngressBackend `json:",inline"` + + // Specifies the split percentage, a number between 0 and 100. If + // only one split is specified, we default to 100. + // + // NOTE: This differs from K8s Ingress to allow percentage split. + Percent int `json:"percent,omitempty"` + + // AppendHeaders allow specifying additional HTTP headers to add + // before forwarding a request to the destination service. + // + // NOTE: This differs from K8s Ingress which doesn't allow header appending. + // +optional + AppendHeaders map[string]string `json:"appendHeaders,omitempty"` +} + +// IngressBackend describes all endpoints for a given service and port. +type IngressBackend struct { + // Specifies the namespace of the referenced service. + // + // NOTE: This differs from K8s Ingress to allow routing to different namespaces. + ServiceNamespace string `json:"serviceNamespace"` + + // Specifies the name of the referenced service. + ServiceName string `json:"serviceName"` + + // Specifies the port of the referenced service. + ServicePort intstr.IntOrString `json:"servicePort"` +} + +// HTTPRetry describes the retry policy to use when a HTTP request fails. +type HTTPRetry struct { + // Number of retries for a given request. + Attempts int `json:"attempts"` + + // Timeout per retry attempt for a given request. format: 1h/1m/1s/1ms. MUST BE >=1ms. + PerTryTimeout *metav1.Duration `json:"perTryTimeout"` +} + +// IngressStatus describe the current state of the Ingress. +type IngressStatus struct { + duckv1beta1.Status `json:",inline"` + + // LoadBalancer contains the current status of the load-balancer. + // +optional + LoadBalancer *LoadBalancerStatus `json:"loadBalancer,omitempty"` +} + +// LoadBalancerStatus represents the status of a load-balancer. +type LoadBalancerStatus struct { + // Ingress is a list containing ingress points for the load-balancer. + // Traffic intended for the service should be sent to these ingress points. + // +optional + Ingress []LoadBalancerIngressStatus `json:"ingress,omitempty"` +} + +// LoadBalancerIngressStatus represents the status of a load-balancer ingress point: +// traffic intended for the service should be sent to an ingress point. +type LoadBalancerIngressStatus struct { + // IP is set for load-balancer ingress points that are IP based + // (typically GCE or OpenStack load-balancers) + // +optional + IP string `json:"ip,omitempty"` + + // Domain is set for load-balancer ingress points that are DNS based + // (typically AWS load-balancers) + // +optional + Domain string `json:"domain,omitempty"` + + // DomainInternal is set if there is a cluster-local DNS name to access the Ingress. + // + // NOTE: This differs from K8s Ingress, since we also desire to have a cluster-local + // DNS name to allow routing in case of not having a mesh. + // + // +optional + DomainInternal string `json:"domainInternal,omitempty"` + + // MeshOnly is set if the ClusterIngress is only load-balanced through a Service mesh. + // +optional + MeshOnly bool `json:"meshOnly,omitempty"` +} + +// ConditionType represents a Ingress condition value +const ( + // IngressConditionReady is set when the Ingress networking setting is + // configured and it has a load balancer address. + IngressConditionReady = apis.ConditionReady + + // IngressConditionNetworkConfigured is set when the Ingress's underlying + // network programming has been configured. This doesn't include conditions of the + // backends, so even if this should remain true when network is configured and backends + // are not ready. + IngressConditionNetworkConfigured apis.ConditionType = "NetworkConfigured" + + // IngressConditionLoadBalancerReady is set when the Ingress has a ready LoadBalancer. + IngressConditionLoadBalancerReady apis.ConditionType = "LoadBalancerReady" +) diff --git a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/ingress_validation.go b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/ingress_validation.go new file mode 100644 index 0000000000..fbfa40ad58 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/ingress_validation.go @@ -0,0 +1,174 @@ +/* +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" + "strconv" + + "knative.dev/pkg/apis" + "k8s.io/apimachinery/pkg/api/equality" + "k8s.io/apimachinery/pkg/util/intstr" +) + +// Validate inspects and validates Ingress object. +func (i *Ingress) Validate(ctx context.Context) *apis.FieldError { + return i.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec") +} + +// Validate inspects and validates IngressSpec object. +func (spec *IngressSpec) Validate(ctx context.Context) *apis.FieldError { + // Spec must not be empty. + if equality.Semantic.DeepEqual(spec, &IngressSpec{}) { + return apis.ErrMissingField(apis.CurrentField) + } + var all *apis.FieldError + // Spec must have at least one rule. + if len(spec.Rules) == 0 { + all = all.Also(apis.ErrMissingField("rules")) + } + // Validate each rule. + for idx, rule := range spec.Rules { + all = all.Also(rule.Validate(ctx).ViaFieldIndex("rules", idx)) + } + // TLS settings are optional. However, all provided settings should be valid. + for idx, tls := range spec.TLS { + all = all.Also(tls.Validate(ctx).ViaFieldIndex("tls", idx)) + } + return all +} + +// Validate inspects and validates IngressRule object. +func (r *IngressRule) Validate(ctx context.Context) *apis.FieldError { + // Provided rule must not be empty. + if equality.Semantic.DeepEqual(r, &IngressRule{}) { + return apis.ErrMissingField(apis.CurrentField) + } + var all *apis.FieldError + if r.HTTP == nil { + all = all.Also(apis.ErrMissingField("http")) + } else { + all = all.Also(r.HTTP.Validate(ctx).ViaField("http")) + } + return all +} + +// Validate inspects and validates HTTPClusterIngressRuleValue object. +func (h *HTTPIngressRuleValue) Validate(ctx context.Context) *apis.FieldError { + if len(h.Paths) == 0 { + return apis.ErrMissingField("paths") + } + var all *apis.FieldError + for idx, path := range h.Paths { + all = all.Also(path.Validate(ctx).ViaFieldIndex("paths", idx)) + } + return all +} + +// Validate inspects and validates HTTPClusterIngressPath object. +func (h HTTPIngressPath) Validate(ctx context.Context) *apis.FieldError { + // Provided rule must not be empty. + if equality.Semantic.DeepEqual(h, HTTPIngressPath{}) { + return apis.ErrMissingField(apis.CurrentField) + } + var all *apis.FieldError + // Must provide as least one split. + if len(h.Splits) == 0 { + all = all.Also(apis.ErrMissingField("splits")) + } else { + totalPct := 0 + for idx, split := range h.Splits { + if err := split.Validate(ctx); err != nil { + return err.ViaFieldIndex("splits", idx) + } + totalPct += split.Percent + } + // If a single split is provided we allow missing Percent, and + // interpret as 100%. + if (len(h.Splits) != 1 || totalPct != 0) && totalPct != 100 { + // Total traffic split percentage must sum up to 100%. + all = all.Also(&apis.FieldError{ + Message: "Traffic split percentage must total to 100, but was " + strconv.Itoa(totalPct), + Paths: []string{"splits"}, + }) + } + } + if h.Retries != nil { + all = all.Also(h.Retries.Validate(ctx).ViaField("retries")) + } + return all +} + +// Validate inspects and validates HTTPIngressPath object. +func (s IngressBackendSplit) Validate(ctx context.Context) *apis.FieldError { + // Must not be empty. + if equality.Semantic.DeepEqual(s, IngressBackendSplit{}) { + return apis.ErrMissingField(apis.CurrentField) + } + var all *apis.FieldError + // Percent must be between 0 and 100. + if s.Percent < 0 || s.Percent > 100 { + all = all.Also(apis.ErrInvalidValue(s.Percent, "percent")) + } + return all.Also(s.IngressBackend.Validate(ctx)) +} + +// Validate inspects the fields of the type IngressBackend +// to determine if they are valid. +func (b IngressBackend) Validate(ctx context.Context) *apis.FieldError { + // Must not be empty. + if equality.Semantic.DeepEqual(b, IngressBackend{}) { + return apis.ErrMissingField(apis.CurrentField) + } + var all *apis.FieldError + if b.ServiceNamespace == "" { + all = all.Also(apis.ErrMissingField("serviceNamespace")) + } + if b.ServiceName == "" { + all = all.Also(apis.ErrMissingField("serviceName")) + } + if equality.Semantic.DeepEqual(b.ServicePort, intstr.IntOrString{}) { + all = all.Also(apis.ErrMissingField("servicePort")) + } + return all +} + +// Validate inspects and validates HTTPRetry object. +func (r *HTTPRetry) Validate(ctx context.Context) *apis.FieldError { + // Attempts must be greater than 0. + if r.Attempts < 0 { + return apis.ErrInvalidValue(r.Attempts, "attempts") + } + return nil +} + +// Validate inspects and validates IngressTLS object. +func (t *IngressTLS) Validate(ctx context.Context) *apis.FieldError { + // Provided TLS setting must not be empty. + if equality.Semantic.DeepEqual(t, &IngressTLS{}) { + return apis.ErrMissingField(apis.CurrentField) + } + var all *apis.FieldError + // SecretName and SecretNamespace must not be empty. + if t.SecretName == "" { + all = all.Also(apis.ErrMissingField("secretName")) + } + if t.SecretNamespace == "" { + all = all.Also(apis.ErrMissingField("secretNamespace")) + } + return all +} diff --git a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/register.go b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/register.go index 381fdb9843..4c4b7302c0 100644 --- a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/register.go +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/register.go @@ -46,6 +46,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &ClusterIngress{}, &ClusterIngressList{}, + &Ingress{}, + &IngressList{}, &ServerlessService{}, &ServerlessServiceList{}, &Certificate{}, diff --git a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/serverlessservice_lifecycle.go b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/serverlessservice_lifecycle.go index c264a1521f..47441aa680 100644 --- a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/serverlessservice_lifecycle.go +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/serverlessservice_lifecycle.go @@ -17,11 +17,12 @@ limitations under the License. package v1alpha1 import ( - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "k8s.io/apimachinery/pkg/runtime/schema" ) -var serverlessServiceCondSet = duckv1alpha1.NewLivingConditionSet( +var serverlessServiceCondSet = apis.NewLivingConditionSet( ServerlessServiceConditionEndspointsPopulated, ) @@ -31,7 +32,7 @@ func (ss *ServerlessService) GetGroupVersionKind() schema.GroupVersionKind { } // GetCondition returns the value of the condition `t`. -func (sss *ServerlessServiceStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition { +func (sss *ServerlessServiceStatus) GetCondition(t apis.ConditionType) *apis.Condition { return serverlessServiceCondSet.Manage(sss).GetCondition(t) } @@ -40,12 +41,30 @@ func (sss *ServerlessServiceStatus) InitializeConditions() { serverlessServiceCondSet.Manage(sss).InitializeConditions() } -// MarkEndpointsPopulated marks the ServerlessServiceStatus endpoints populated condition to true. -func (sss *ServerlessServiceStatus) MarkEndpointsPopulated() { +// MarkEndpointsReady marks the ServerlessServiceStatus endpoints populated condition to true. +func (sss *ServerlessServiceStatus) MarkEndpointsReady() { serverlessServiceCondSet.Manage(sss).MarkTrue(ServerlessServiceConditionEndspointsPopulated) } +// MarkEndpointsNotOwned marks that we don't own K8s service. +func (sss *ServerlessServiceStatus) MarkEndpointsNotOwned(kind, name string) { + serverlessServiceCondSet.Manage(sss).MarkFalse( + ServerlessServiceConditionEndspointsPopulated, "NotOwned", + "Resource %s of type %s is not owned by SKS", name, kind) +} + +// MarkEndpointsNotReady marks the ServerlessServiceStatus endpoints populated condition to unknown. +func (sss *ServerlessServiceStatus) MarkEndpointsNotReady(reason string) { + serverlessServiceCondSet.Manage(sss).MarkUnknown( + ServerlessServiceConditionEndspointsPopulated, reason, + "K8s Service is not ready") +} + // IsReady returns true if ServerlessService is ready. func (sss *ServerlessServiceStatus) IsReady() bool { return serverlessServiceCondSet.Manage(sss).IsHappy() } + +func (sss *ServerlessServiceStatus) duck() *duckv1beta1.Status { + return &sss.Status +} diff --git a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/serverlessservice_types.go b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/serverlessservice_types.go index 75a186d479..494b31a5ce 100644 --- a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/serverlessservice_types.go +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/serverlessservice_types.go @@ -17,10 +17,11 @@ limitations under the License. package v1alpha1 import ( - "github.com/knative/pkg/apis" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" - "github.com/knative/pkg/kmeta" + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/kmeta" networking "github.com/knative/serving/pkg/apis/networking" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -92,10 +93,9 @@ type ServerlessServiceSpec struct { // Mode describes the mode of operation of the ServerlessService. Mode ServerlessServiceOperationMode `json:"mode,omitempty"` - // Selector describes the pod labels for selection of pods for the - // revision. Same as K8s service selector. - // See: https://kubernetes.io/docs/concepts/services-networking/service/. - Selector map[string]string `json:"selector,omitempty"` + // ObjectRef defines the resource that this ServerlessService + // is responsible for making "serverless". + ObjectRef corev1.ObjectReference `json:"objectRef"` // The application-layer protocol. Matches `RevisionProtocolType` set on the owning pa/revision. // serving imports networking, so just use string. @@ -104,21 +104,26 @@ type ServerlessServiceSpec struct { // ServerlessServiceStatus describes the current state of the ServerlessService. type ServerlessServiceStatus struct { - duckv1alpha1.Status `json:",inline"` + duckv1beta1.Status `json:",inline"` // ServiceName holds the name of a core K8s Service resource that // load balances over the pods backing this Revision (activator or revision). // +optional ServiceName string `json:"serviceName,omitempty"` + + // PrivateServiceName holds the name of a core K8s Service resource that + // load balances over the user service pods backing this Revision. + // +optional + PrivateServiceName string `json:"privateServiceName,omitempty"` } // ConditionType represents a ServerlessService condition value const ( // ServerlessServiceConditionReady is set when the clusterIngress networking setting is // configured and it has a load balancer address. - ServerlessServiceConditionReady = duckv1alpha1.ConditionReady + ServerlessServiceConditionReady = apis.ConditionReady // ServerlessServiceConditionEndspointsPopulated is set when the ServerlessService's underlying // Revision K8s Service has been populated with endpoints. - ServerlessServiceConditionEndspointsPopulated duckv1alpha1.ConditionType = "EndpointsPopulated" + ServerlessServiceConditionEndspointsPopulated apis.ConditionType = "EndpointsPopulated" ) diff --git a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/serverlessservice_validation.go b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/serverlessservice_validation.go index 2b8a647c2f..1b1ed19bf9 100644 --- a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/serverlessservice_validation.go +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/serverlessservice_validation.go @@ -19,13 +19,14 @@ package v1alpha1 import ( "context" - "github.com/knative/pkg/apis" + "knative.dev/pkg/apis" + "github.com/knative/serving/pkg/apis/serving" "k8s.io/apimachinery/pkg/api/equality" ) // Validate inspects and validates ClusterServerlessService object. func (ci *ServerlessService) Validate(ctx context.Context) *apis.FieldError { - return ci.Spec.Validate(ctx).ViaField("spec") + return ci.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec") } // Validate inspects and validates ServerlessServiceSpec object. @@ -42,20 +43,10 @@ func (spec *ServerlessServiceSpec) Validate(ctx context.Context) *apis.FieldErro case "": all = all.Also(apis.ErrMissingField("mode")) default: - all = all.Also(apis.ErrInvalidValue(string(spec.Mode), "mode")) - } - if len(spec.Selector) == 0 { - all = all.Also(apis.ErrMissingField("selector")) - } else { - for k, v := range spec.Selector { - if k == "" { - all = all.Also(apis.ErrInvalidKeyName(k, "selector", "empty key is not permitted")) - } - if v == "" { - all = all.Also(apis.ErrInvalidValue(v, apis.CurrentField).ViaKey(k).ViaField("selector")) - } - } + all = all.Also(apis.ErrInvalidValue(spec.Mode, "mode")) } - return all.Also(spec.ProtocolType.Validate().ViaField("protocolType")) + all = all.Also(serving.ValidateNamespacedObjectReference(&spec.ObjectRef).ViaField("objectRef")) + + return all.Also(spec.ProtocolType.Validate(ctx).ViaField("protocolType")) } diff --git a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go index 026e3a7dec..e8bc6efe82 100644 --- a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go @@ -16,13 +16,14 @@ See the License for the specific language governing permissions and limitations under the License. */ -// This file was autogenerated by deepcopy-gen. Do not edit it manually! +// Code generated by deepcopy-gen. DO NOT EDIT. package v1alpha1 import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" + apis "knative.dev/pkg/apis" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -49,9 +50,8 @@ func (in *Certificate) DeepCopy() *Certificate { func (in *Certificate) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c - } else { - return nil } + return nil } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -83,9 +83,8 @@ func (in *CertificateList) DeepCopy() *CertificateList { func (in *CertificateList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c - } else { - return nil } + return nil } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -115,11 +114,13 @@ func (in *CertificateStatus) DeepCopyInto(out *CertificateStatus) { in.Status.DeepCopyInto(&out.Status) if in.NotAfter != nil { in, out := &in.NotAfter, &out.NotAfter - if *in == nil { - *out = nil - } else { - *out = new(v1.Time) - (*in).DeepCopyInto(*out) + *out = (*in).DeepCopy() + } + if in.HTTP01Challenges != nil { + in, out := &in.HTTP01Challenges, &out.HTTP01Challenges + *out = make([]HTTP01Challenge, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) } } return @@ -159,138 +160,198 @@ func (in *ClusterIngress) DeepCopy() *ClusterIngress { func (in *ClusterIngress) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c - } else { - return nil } + return nil } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterIngressBackend) DeepCopyInto(out *ClusterIngressBackend) { +func (in *ClusterIngressList) DeepCopyInto(out *ClusterIngressList) { *out = *in - out.ServicePort = in.ServicePort + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterIngress, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterIngressBackend. -func (in *ClusterIngressBackend) DeepCopy() *ClusterIngressBackend { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterIngressList. +func (in *ClusterIngressList) DeepCopy() *ClusterIngressList { if in == nil { return nil } - out := new(ClusterIngressBackend) + out := new(ClusterIngressList) in.DeepCopyInto(out) return out } +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterIngressList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterIngressBackendSplit) DeepCopyInto(out *ClusterIngressBackendSplit) { +func (in *HTTP01Challenge) DeepCopyInto(out *HTTP01Challenge) { *out = *in - out.ClusterIngressBackend = in.ClusterIngressBackend + if in.URL != nil { + in, out := &in.URL, &out.URL + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } + out.ServicePort = in.ServicePort return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterIngressBackendSplit. -func (in *ClusterIngressBackendSplit) DeepCopy() *ClusterIngressBackendSplit { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTP01Challenge. +func (in *HTTP01Challenge) DeepCopy() *HTTP01Challenge { if in == nil { return nil } - out := new(ClusterIngressBackendSplit) + out := new(HTTP01Challenge) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterIngressList) DeepCopyInto(out *ClusterIngressList) { +func (in *HTTPIngressPath) DeepCopyInto(out *HTTPIngressPath) { *out = *in - out.TypeMeta = in.TypeMeta - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]ClusterIngress, len(*in)) + if in.Splits != nil { + in, out := &in.Splits, &out.Splits + *out = make([]IngressBackendSplit, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.AppendHeaders != nil { + in, out := &in.AppendHeaders, &out.AppendHeaders + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Timeout != nil { + in, out := &in.Timeout, &out.Timeout + *out = new(v1.Duration) + **out = **in + } + if in.Retries != nil { + in, out := &in.Retries, &out.Retries + *out = new(HTTPRetry) + (*in).DeepCopyInto(*out) + } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterIngressList. -func (in *ClusterIngressList) DeepCopy() *ClusterIngressList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPIngressPath. +func (in *HTTPIngressPath) DeepCopy() *HTTPIngressPath { if in == nil { return nil } - out := new(ClusterIngressList) + out := new(HTTPIngressPath) in.DeepCopyInto(out) return out } -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ClusterIngressList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } else { +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HTTPIngressRuleValue) DeepCopyInto(out *HTTPIngressRuleValue) { + *out = *in + if in.Paths != nil { + in, out := &in.Paths, &out.Paths + *out = make([]HTTPIngressPath, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPIngressRuleValue. +func (in *HTTPIngressRuleValue) DeepCopy() *HTTPIngressRuleValue { + if in == nil { return nil } + out := new(HTTPIngressRuleValue) + in.DeepCopyInto(out) + return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterIngressRule) DeepCopyInto(out *ClusterIngressRule) { +func (in *HTTPRetry) DeepCopyInto(out *HTTPRetry) { *out = *in - if in.Hosts != nil { - in, out := &in.Hosts, &out.Hosts - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.HTTP != nil { - in, out := &in.HTTP, &out.HTTP - if *in == nil { - *out = nil - } else { - *out = new(HTTPClusterIngressRuleValue) - (*in).DeepCopyInto(*out) - } + if in.PerTryTimeout != nil { + in, out := &in.PerTryTimeout, &out.PerTryTimeout + *out = new(v1.Duration) + **out = **in } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterIngressRule. -func (in *ClusterIngressRule) DeepCopy() *ClusterIngressRule { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPRetry. +func (in *HTTPRetry) DeepCopy() *HTTPRetry { if in == nil { return nil } - out := new(ClusterIngressRule) + out := new(HTTPRetry) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterIngressTLS) DeepCopyInto(out *ClusterIngressTLS) { +func (in *Ingress) DeepCopyInto(out *Ingress) { *out = *in - if in.Hosts != nil { - in, out := &in.Hosts, &out.Hosts - *out = make([]string, len(*in)) - copy(*out, *in) - } + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterIngressTLS. -func (in *ClusterIngressTLS) DeepCopy() *ClusterIngressTLS { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Ingress. +func (in *Ingress) DeepCopy() *Ingress { if in == nil { return nil } - out := new(ClusterIngressTLS) + out := new(Ingress) in.DeepCopyInto(out) return out } +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Ingress) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *HTTPClusterIngressPath) DeepCopyInto(out *HTTPClusterIngressPath) { +func (in *IngressBackend) DeepCopyInto(out *IngressBackend) { *out = *in - if in.Splits != nil { - in, out := &in.Splits, &out.Splits - *out = make([]ClusterIngressBackendSplit, len(*in)) - copy(*out, *in) + out.ServicePort = in.ServicePort + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressBackend. +func (in *IngressBackend) DeepCopy() *IngressBackend { + if in == nil { + return nil } + out := new(IngressBackend) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IngressBackendSplit) DeepCopyInto(out *IngressBackendSplit) { + *out = *in + out.IngressBackend = in.IngressBackend if in.AppendHeaders != nil { in, out := &in.AppendHeaders, &out.AppendHeaders *out = make(map[string]string, len(*in)) @@ -298,43 +359,27 @@ func (in *HTTPClusterIngressPath) DeepCopyInto(out *HTTPClusterIngressPath) { (*out)[key] = val } } - if in.Timeout != nil { - in, out := &in.Timeout, &out.Timeout - if *in == nil { - *out = nil - } else { - *out = new(v1.Duration) - **out = **in - } - } - if in.Retries != nil { - in, out := &in.Retries, &out.Retries - if *in == nil { - *out = nil - } else { - *out = new(HTTPRetry) - (*in).DeepCopyInto(*out) - } - } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPClusterIngressPath. -func (in *HTTPClusterIngressPath) DeepCopy() *HTTPClusterIngressPath { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressBackendSplit. +func (in *IngressBackendSplit) DeepCopy() *IngressBackendSplit { if in == nil { return nil } - out := new(HTTPClusterIngressPath) + out := new(IngressBackendSplit) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *HTTPClusterIngressRuleValue) DeepCopyInto(out *HTTPClusterIngressRuleValue) { +func (in *IngressList) DeepCopyInto(out *IngressList) { *out = *in - if in.Paths != nil { - in, out := &in.Paths, &out.Paths - *out = make([]HTTPClusterIngressPath, len(*in)) + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Ingress, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -342,37 +387,46 @@ func (in *HTTPClusterIngressRuleValue) DeepCopyInto(out *HTTPClusterIngressRuleV return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPClusterIngressRuleValue. -func (in *HTTPClusterIngressRuleValue) DeepCopy() *HTTPClusterIngressRuleValue { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressList. +func (in *IngressList) DeepCopy() *IngressList { if in == nil { return nil } - out := new(HTTPClusterIngressRuleValue) + out := new(IngressList) in.DeepCopyInto(out) return out } +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IngressList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *HTTPRetry) DeepCopyInto(out *HTTPRetry) { +func (in *IngressRule) DeepCopyInto(out *IngressRule) { *out = *in - if in.PerTryTimeout != nil { - in, out := &in.PerTryTimeout, &out.PerTryTimeout - if *in == nil { - *out = nil - } else { - *out = new(v1.Duration) - **out = **in - } + if in.Hosts != nil { + in, out := &in.Hosts, &out.Hosts + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.HTTP != nil { + in, out := &in.HTTP, &out.HTTP + *out = new(HTTPIngressRuleValue) + (*in).DeepCopyInto(*out) } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPRetry. -func (in *HTTPRetry) DeepCopy() *HTTPRetry { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressRule. +func (in *IngressRule) DeepCopy() *IngressRule { if in == nil { return nil } - out := new(HTTPRetry) + out := new(IngressRule) in.DeepCopyInto(out) return out } @@ -382,14 +436,14 @@ func (in *IngressSpec) DeepCopyInto(out *IngressSpec) { *out = *in if in.TLS != nil { in, out := &in.TLS, &out.TLS - *out = make([]ClusterIngressTLS, len(*in)) + *out = make([]IngressTLS, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } if in.Rules != nil { in, out := &in.Rules, &out.Rules - *out = make([]ClusterIngressRule, len(*in)) + *out = make([]IngressRule, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -413,12 +467,8 @@ func (in *IngressStatus) DeepCopyInto(out *IngressStatus) { in.Status.DeepCopyInto(&out.Status) if in.LoadBalancer != nil { in, out := &in.LoadBalancer, &out.LoadBalancer - if *in == nil { - *out = nil - } else { - *out = new(LoadBalancerStatus) - (*in).DeepCopyInto(*out) - } + *out = new(LoadBalancerStatus) + (*in).DeepCopyInto(*out) } return } @@ -433,6 +483,27 @@ func (in *IngressStatus) DeepCopy() *IngressStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IngressTLS) DeepCopyInto(out *IngressTLS) { + *out = *in + if in.Hosts != nil { + in, out := &in.Hosts, &out.Hosts + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressTLS. +func (in *IngressTLS) DeepCopy() *IngressTLS { + if in == nil { + return nil + } + out := new(IngressTLS) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *LoadBalancerIngressStatus) DeepCopyInto(out *LoadBalancerIngressStatus) { *out = *in @@ -475,7 +546,7 @@ func (in *ServerlessService) DeepCopyInto(out *ServerlessService) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) + out.Spec = in.Spec in.Status.DeepCopyInto(&out.Status) return } @@ -494,9 +565,8 @@ func (in *ServerlessService) DeepCopy() *ServerlessService { func (in *ServerlessService) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c - } else { - return nil } + return nil } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -528,21 +598,14 @@ func (in *ServerlessServiceList) DeepCopy() *ServerlessServiceList { func (in *ServerlessServiceList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c - } else { - return nil } + return nil } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ServerlessServiceSpec) DeepCopyInto(out *ServerlessServiceSpec) { *out = *in - if in.Selector != nil { - in, out := &in.Selector, &out.Selector - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } + out.ObjectRef = in.ObjectRef return } diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/fieldmask.go b/vendor/github.com/knative/serving/pkg/apis/serving/fieldmask.go new file mode 100644 index 0000000000..fe958373cb --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/fieldmask.go @@ -0,0 +1,569 @@ +/* +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 serving + +import ( + corev1 "k8s.io/api/core/v1" +) + +// VolumeMask performs a _shallow_ copy of the Kubernetes Volume object to a new +// Kubernetes Volume object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func VolumeMask(in *corev1.Volume) *corev1.Volume { + if in == nil { + return nil + } + + out := new(corev1.Volume) + + // Allowed fields + out.Name = in.Name + out.VolumeSource = in.VolumeSource + + return out +} + +// VolumeSourceMask performs a _shallow_ copy of the Kubernetes VolumeSource object to a new +// Kubernetes VolumeSource object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func VolumeSourceMask(in *corev1.VolumeSource) *corev1.VolumeSource { + if in == nil { + return nil + } + + out := new(corev1.VolumeSource) + + // Allowed fields + out.Secret = in.Secret + out.ConfigMap = in.ConfigMap + out.Projected = in.Projected + + // Too many disallowed fields to list + + return out +} + +// VolumeProjectionMask performs a _shallow_ copy of the Kubernetes VolumeProjection +// object to a new Kubernetes VolumeProjection object bringing over only the fields allowed +// in the Knative API. This does not validate the contents or the bounds of the provided fields. +func VolumeProjectionMask(in *corev1.VolumeProjection) *corev1.VolumeProjection { + if in == nil { + return nil + } + + out := new(corev1.VolumeProjection) + + // Allowed fields + out.Secret = in.Secret + out.ConfigMap = in.ConfigMap + + // Disallowed fields + // This list is unnecessary, but added here for clarity + out.DownwardAPI = nil + out.ServiceAccountToken = nil + + return out +} + +// ConfigMapProjectionMask performs a _shallow_ copy of the Kubernetes ConfigMapProjection +// object to a new Kubernetes ConfigMapProjection object bringing over only the fields allowed +// in the Knative API. This does not validate the contents or the bounds of the provided fields. +func ConfigMapProjectionMask(in *corev1.ConfigMapProjection) *corev1.ConfigMapProjection { + if in == nil { + return nil + } + + out := new(corev1.ConfigMapProjection) + + // Allowed fields + out.LocalObjectReference = in.LocalObjectReference + out.Items = in.Items + out.Optional = in.Optional + + return out +} + +// SecretProjectionMask performs a _shallow_ copy of the Kubernetes SecretProjection +// object to a new Kubernetes SecretProjection object bringing over only the fields allowed +// in the Knative API. This does not validate the contents or the bounds of the provided fields. +func SecretProjectionMask(in *corev1.SecretProjection) *corev1.SecretProjection { + if in == nil { + return nil + } + + out := new(corev1.SecretProjection) + + // Allowed fields + out.LocalObjectReference = in.LocalObjectReference + out.Items = in.Items + out.Optional = in.Optional + + return out +} + +// KeyToPathMask performs a _shallow_ copy of the Kubernetes KeyToPath +// object to a new Kubernetes KeyToPath object bringing over only the fields allowed +// in the Knative API. This does not validate the contents or the bounds of the provided fields. +func KeyToPathMask(in *corev1.KeyToPath) *corev1.KeyToPath { + if in == nil { + return nil + } + + out := new(corev1.KeyToPath) + + // Allowed fields + out.Key = in.Key + out.Path = in.Path + out.Mode = in.Mode + + return out +} + +// PodSpecMask performs a _shallow_ copy of the Kubernetes PodSpec object to a new +// Kubernetes PodSpec object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func PodSpecMask(in *corev1.PodSpec) *corev1.PodSpec { + if in == nil { + return nil + } + + out := new(corev1.PodSpec) + + // Allowed fields + out.ServiceAccountName = in.ServiceAccountName + out.Containers = in.Containers + out.Volumes = in.Volumes + + // Disallowed fields + // This list is unnecessary, but added here for clarity + out.InitContainers = nil + out.RestartPolicy = "" + out.TerminationGracePeriodSeconds = nil + out.ActiveDeadlineSeconds = nil + out.DNSPolicy = "" + out.NodeSelector = nil + out.AutomountServiceAccountToken = nil + out.NodeName = "" + out.HostNetwork = false + out.HostPID = false + out.HostIPC = false + out.ShareProcessNamespace = nil + out.SecurityContext = nil + out.ImagePullSecrets = nil + out.Hostname = "" + out.Subdomain = "" + out.Affinity = nil + out.SchedulerName = "" + out.Tolerations = nil + out.HostAliases = nil + out.PriorityClassName = "" + out.Priority = nil + out.DNSConfig = nil + out.ReadinessGates = nil + out.RuntimeClassName = nil + // TODO(mattmoor): Coming in 1.13: out.EnableServiceLinks = nil + + return out +} + +// ContainerMask performs a _shallow_ copy of the Kubernetes Container object to a new +// Kubernetes Container object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func ContainerMask(in *corev1.Container) *corev1.Container { + if in == nil { + return nil + } + + out := new(corev1.Container) + + // Allowed fields + out.Name = in.Name + out.Args = in.Args + out.Command = in.Command + out.Env = in.Env + out.WorkingDir = in.WorkingDir + out.EnvFrom = in.EnvFrom + out.Image = in.Image + out.ImagePullPolicy = in.ImagePullPolicy + out.LivenessProbe = in.LivenessProbe + out.Ports = in.Ports + out.ReadinessProbe = in.ReadinessProbe + out.Resources = in.Resources + out.SecurityContext = in.SecurityContext + out.TerminationMessagePath = in.TerminationMessagePath + out.TerminationMessagePolicy = in.TerminationMessagePolicy + out.VolumeMounts = in.VolumeMounts + + // Disallowed fields + // This list is unnecessary, but added here for clarity + out.Lifecycle = nil + out.Stdin = false + out.StdinOnce = false + out.TTY = false + out.VolumeDevices = nil + + return out +} + +// VolumeMountMask performs a _shallow_ copy of the Kubernetes VolumeMount object to a new +// Kubernetes VolumeMount object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func VolumeMountMask(in *corev1.VolumeMount) *corev1.VolumeMount { + if in == nil { + return nil + } + + out := new(corev1.VolumeMount) + + // Allowed fields + out.Name = in.Name + out.ReadOnly = in.ReadOnly + out.MountPath = in.MountPath + out.SubPath = in.SubPath + + // Disallowed fields + // This list is unnecessary, but added here for clarity + out.MountPropagation = nil + + return out +} + +// ProbeMask performs a _shallow_ copy of the Kubernetes Probe object to a new +// Kubernetes Probe object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func ProbeMask(in *corev1.Probe) *corev1.Probe { + if in == nil { + return nil + } + out := new(corev1.Probe) + + // Allowed fields + out.Handler = in.Handler + out.InitialDelaySeconds = in.InitialDelaySeconds + out.TimeoutSeconds = in.TimeoutSeconds + out.PeriodSeconds = in.PeriodSeconds + out.SuccessThreshold = in.SuccessThreshold + out.FailureThreshold = in.FailureThreshold + + return out +} + +// HandlerMask performs a _shallow_ copy of the Kubernetes Handler object to a new +// Kubernetes Handler object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func HandlerMask(in *corev1.Handler) *corev1.Handler { + if in == nil { + return nil + } + out := new(corev1.Handler) + + // Allowed fields + out.Exec = in.Exec + out.HTTPGet = in.HTTPGet + out.TCPSocket = in.TCPSocket + + return out + +} + +// ExecActionMask performs a _shallow_ copy of the Kubernetes ExecAction object to a new +// Kubernetes ExecAction object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func ExecActionMask(in *corev1.ExecAction) *corev1.ExecAction { + if in == nil { + return nil + } + out := new(corev1.ExecAction) + + // Allowed fields + out.Command = in.Command + + return out +} + +// HTTPGetActionMask performs a _shallow_ copy of the Kubernetes HTTPGetAction object to a new +// Kubernetes HTTPGetAction object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func HTTPGetActionMask(in *corev1.HTTPGetAction) *corev1.HTTPGetAction { + if in == nil { + return nil + } + out := new(corev1.HTTPGetAction) + + // Allowed fields + out.Host = in.Host + out.Path = in.Path + out.Scheme = in.Scheme + out.HTTPHeaders = in.HTTPHeaders + + return out +} + +// TCPSocketActionMask performs a _shallow_ copy of the Kubernetes TCPSocketAction object to a new +// Kubernetes TCPSocketAction object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func TCPSocketActionMask(in *corev1.TCPSocketAction) *corev1.TCPSocketAction { + if in == nil { + return nil + } + out := new(corev1.TCPSocketAction) + + // Allowed fields + out.Host = in.Host + + return out +} + +// ContainerPortMask performs a _shallow_ copy of the Kubernetes ContainerPort object to a new +// Kubernetes ContainerPort object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func ContainerPortMask(in *corev1.ContainerPort) *corev1.ContainerPort { + if in == nil { + return nil + } + + out := new(corev1.ContainerPort) + + // Allowed fields + out.ContainerPort = in.ContainerPort + out.Name = in.Name + out.Protocol = in.Protocol + + //Disallowed fields + // This list is unnecessary, but added here for clarity + out.HostIP = "" + out.HostPort = 0 + + return out +} + +// EnvVarMask performs a _shallow_ copy of the Kubernetes EnvVar object to a new +// Kubernetes EnvVar object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func EnvVarMask(in *corev1.EnvVar) *corev1.EnvVar { + if in == nil { + return nil + } + + out := new(corev1.EnvVar) + + // Allowed fields + out.Name = in.Name + out.Value = in.Value + out.ValueFrom = in.ValueFrom + + return out +} + +// EnvVarSourceMask performs a _shallow_ copy of the Kubernetes EnvVarSource object to a new +// Kubernetes EnvVarSource object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func EnvVarSourceMask(in *corev1.EnvVarSource) *corev1.EnvVarSource { + if in == nil { + return nil + } + + out := new(corev1.EnvVarSource) + + // Allowed fields + out.ConfigMapKeyRef = in.ConfigMapKeyRef + out.SecretKeyRef = in.SecretKeyRef + + // Disallowed + // This list is unnecessary, but added here for clarity + out.FieldRef = nil + out.ResourceFieldRef = nil + + return out +} + +// LocalObjectReferenceMask performs a _shallow_ copy of the Kubernetes LocalObjectReference object to a new +// Kubernetes LocalObjectReference object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func LocalObjectReferenceMask(in *corev1.LocalObjectReference) *corev1.LocalObjectReference { + if in == nil { + return nil + } + + out := new(corev1.LocalObjectReference) + + out.Name = in.Name + + return out +} + +// ConfigMapKeySelectorMask performs a _shallow_ copy of the Kubernetes ConfigMapKeySelector object to a new +// Kubernetes ConfigMapKeySelector object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func ConfigMapKeySelectorMask(in *corev1.ConfigMapKeySelector) *corev1.ConfigMapKeySelector { + if in == nil { + return nil + } + + out := new(corev1.ConfigMapKeySelector) + + // Allowed fields + out.Key = in.Key + out.Optional = in.Optional + out.LocalObjectReference = in.LocalObjectReference + + return out + +} + +// SecretKeySelectorMask performs a _shallow_ copy of the Kubernetes SecretKeySelector object to a new +// Kubernetes SecretKeySelector object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func SecretKeySelectorMask(in *corev1.SecretKeySelector) *corev1.SecretKeySelector { + if in == nil { + return nil + } + + out := new(corev1.SecretKeySelector) + + // Allowed fields + out.Key = in.Key + out.Optional = in.Optional + out.LocalObjectReference = in.LocalObjectReference + + return out + +} + +// ConfigMapEnvSourceMask performs a _shallow_ copy of the Kubernetes ConfigMapEnvSource object to a new +// Kubernetes ConfigMapEnvSource object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func ConfigMapEnvSourceMask(in *corev1.ConfigMapEnvSource) *corev1.ConfigMapEnvSource { + if in == nil { + return nil + } + + out := new(corev1.ConfigMapEnvSource) + + // Allowed fields + out.Optional = in.Optional + out.LocalObjectReference = in.LocalObjectReference + + return out + +} + +// SecretEnvSourceMask performs a _shallow_ copy of the Kubernetes SecretEnvSource object to a new +// Kubernetes SecretEnvSource object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func SecretEnvSourceMask(in *corev1.SecretEnvSource) *corev1.SecretEnvSource { + if in == nil { + return nil + } + + out := new(corev1.SecretEnvSource) + + // Allowed fields + out.Optional = in.Optional + out.LocalObjectReference = in.LocalObjectReference + + return out + +} + +// EnvFromSourceMask performs a _shallow_ copy of the Kubernetes EnvFromSource object to a new +// Kubernetes EnvFromSource object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func EnvFromSourceMask(in *corev1.EnvFromSource) *corev1.EnvFromSource { + if in == nil { + return nil + } + + out := new(corev1.EnvFromSource) + + // Allowed fields + out.Prefix = in.Prefix + out.ConfigMapRef = in.ConfigMapRef + out.SecretRef = in.SecretRef + + return out +} + +// ResourceRequirementsMask performs a _shallow_ copy of the Kubernetes ResourceRequirements object to a new +// Kubernetes ResourceRequirements object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func ResourceRequirementsMask(in *corev1.ResourceRequirements) *corev1.ResourceRequirements { + if in == nil { + return nil + } + + out := new(corev1.ResourceRequirements) + + // Allowed fields + out.Limits = in.Limits + out.Requests = in.Requests + + return out + +} + +// SecurityContextMask performs a _shallow_ copy of the Kubernetes SecurityContext object to a new +// Kubernetes SecurityContext object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func SecurityContextMask(in *corev1.SecurityContext) *corev1.SecurityContext { + if in == nil { + return nil + } + + out := new(corev1.SecurityContext) + + // Allowed fields + out.RunAsUser = in.RunAsUser + + // Disallowed + // This list is unnecessary, but added here for clarity + out.Capabilities = nil + out.Privileged = nil + out.SELinuxOptions = nil + out.RunAsGroup = nil + out.RunAsNonRoot = nil + out.ReadOnlyRootFilesystem = nil + out.AllowPrivilegeEscalation = nil + out.ProcMount = nil + + return out +} + +// NamespacedObjectReferenceMask performs a _shallow_ copy of the Kubernetes ObjectReference +// object to a new Kubernetes ObjectReference object bringing over only the fields allowed in +// the Knative API. This does not validate the contents or the bounds of the provided fields. +func NamespacedObjectReferenceMask(in *corev1.ObjectReference) *corev1.ObjectReference { + if in == nil { + return nil + } + + out := new(corev1.ObjectReference) + + // Allowed fields + out.APIVersion = in.APIVersion + out.Kind = in.Kind + out.Name = in.Name + + // Disallowed + // This list is unnecessary, but added here for clarity + out.Namespace = "" + out.FieldPath = "" + out.ResourceVersion = "" + out.UID = "" + + return out +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/k8s_validation.go b/vendor/github.com/knative/serving/pkg/apis/serving/k8s_validation.go new file mode 100644 index 0000000000..77f1737657 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/k8s_validation.go @@ -0,0 +1,459 @@ +/* +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 serving + +import ( + "fmt" + "math" + "path/filepath" + "strings" + + "github.com/google/go-containerregistry/pkg/name" + "knative.dev/pkg/apis" + "github.com/knative/serving/pkg/apis/networking" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/equality" + "k8s.io/apimachinery/pkg/util/sets" + "k8s.io/apimachinery/pkg/util/validation" +) + +const ( + minUserID = 0 + maxUserID = math.MaxInt32 +) + +var ( + reservedPaths = sets.NewString( + "/", + "/dev", + "/dev/log", // Should be a domain socket + "/tmp", + "/var", + "/var/log", + ) + + reservedContainerNames = sets.NewString( + "queue-proxy", + ) + + reservedEnvVars = sets.NewString( + "PORT", + "K_SERVICE", + "K_CONFIGURATION", + "K_REVISION", + ) + + // The port is named "user-port" on the deployment, but a user cannot set an arbitrary name on the port + // in Configuration. The name field is reserved for content-negotiation. Currently 'h2c' and 'http1' are + // allowed. + // https://github.com/knative/serving/blob/master/docs/runtime-contract.md#inbound-network-connectivity + validPortNames = sets.NewString( + "h2c", + "http1", + "", + ) +) + +func ValidateVolumes(vs []corev1.Volume) (sets.String, *apis.FieldError) { + volumes := sets.NewString() + var errs *apis.FieldError + for i, volume := range vs { + if volumes.Has(volume.Name) { + errs = errs.Also((&apis.FieldError{ + Message: fmt.Sprintf("duplicate volume name %q", volume.Name), + Paths: []string{"name"}, + }).ViaIndex(i)) + } + errs = errs.Also(validateVolume(volume).ViaIndex(i)) + volumes.Insert(volume.Name) + } + return volumes, errs +} + +func validateVolume(volume corev1.Volume) *apis.FieldError { + errs := apis.CheckDisallowedFields(volume, *VolumeMask(&volume)) + if volume.Name == "" { + errs = apis.ErrMissingField("name") + } else if len(validation.IsDNS1123Label(volume.Name)) != 0 { + errs = apis.ErrInvalidValue(volume.Name, "name") + } + + vs := volume.VolumeSource + errs = errs.Also(apis.CheckDisallowedFields(vs, *VolumeSourceMask(&vs))) + specified := []string{} + if vs.Secret != nil { + specified = append(specified, "secret") + } + if vs.ConfigMap != nil { + specified = append(specified, "configMap") + } + if vs.Projected != nil { + specified = append(specified, "projected") + for i, proj := range vs.Projected.Sources { + errs = errs.Also(validateProjectedVolumeSource(proj).ViaFieldIndex("projected", i)) + } + } + if len(specified) == 0 { + errs = errs.Also(apis.ErrMissingOneOf("secret", "configMap", "projected")) + } else if len(specified) > 1 { + errs = errs.Also(apis.ErrMultipleOneOf(specified...)) + } + + return errs +} + +func validateProjectedVolumeSource(vp corev1.VolumeProjection) *apis.FieldError { + errs := apis.CheckDisallowedFields(vp, *VolumeProjectionMask(&vp)) + specified := []string{} + if vp.Secret != nil { + specified = append(specified, "secret") + errs = errs.Also(validateSecretProjection(vp.Secret).ViaField("secret")) + } + if vp.ConfigMap != nil { + specified = append(specified, "configMap") + errs = errs.Also(validateConfigMapProjection(vp.ConfigMap).ViaField("configMap")) + } + if len(specified) == 0 { + errs = errs.Also(apis.ErrMissingOneOf("secret", "configMap")) + } else if len(specified) > 1 { + errs = errs.Also(apis.ErrMultipleOneOf(specified...)) + } + return errs +} + +func validateConfigMapProjection(cmp *corev1.ConfigMapProjection) *apis.FieldError { + errs := apis.CheckDisallowedFields(*cmp, *ConfigMapProjectionMask(cmp)) + errs = errs.Also(apis.CheckDisallowedFields( + cmp.LocalObjectReference, *LocalObjectReferenceMask(&cmp.LocalObjectReference))) + if cmp.Name == "" { + errs = errs.Also(apis.ErrMissingField("name")) + } + for i, item := range cmp.Items { + errs = errs.Also(apis.CheckDisallowedFields(item, *KeyToPathMask(&item)).ViaIndex(i)) + } + return errs +} + +func validateSecretProjection(sp *corev1.SecretProjection) *apis.FieldError { + errs := apis.CheckDisallowedFields(*sp, *SecretProjectionMask(sp)) + errs = errs.Also(apis.CheckDisallowedFields( + sp.LocalObjectReference, *LocalObjectReferenceMask(&sp.LocalObjectReference))) + if sp.Name == "" { + errs = errs.Also(apis.ErrMissingField("name")) + } + for i, item := range sp.Items { + errs = errs.Also(apis.CheckDisallowedFields(item, *KeyToPathMask(&item)).ViaIndex(i)) + } + return errs +} + +func validateEnvValueFrom(source *corev1.EnvVarSource) *apis.FieldError { + if source == nil { + return nil + } + return apis.CheckDisallowedFields(*source, *EnvVarSourceMask(source)) +} + +func validateEnvVar(env corev1.EnvVar) *apis.FieldError { + errs := apis.CheckDisallowedFields(env, *EnvVarMask(&env)) + + if env.Name == "" { + errs = errs.Also(apis.ErrMissingField("name")) + } else if reservedEnvVars.Has(env.Name) { + errs = errs.Also(&apis.FieldError{ + Message: fmt.Sprintf("%q is a reserved environment variable", env.Name), + Paths: []string{"name"}, + }) + } + + return errs.Also(validateEnvValueFrom(env.ValueFrom).ViaField("valueFrom")) +} + +func validateEnv(envVars []corev1.EnvVar) *apis.FieldError { + var errs *apis.FieldError + for i, env := range envVars { + errs = errs.Also(validateEnvVar(env).ViaIndex(i)) + } + return errs +} + +func validateEnvFrom(envFromList []corev1.EnvFromSource) *apis.FieldError { + var errs *apis.FieldError + for i, envFrom := range envFromList { + errs = errs.Also(apis.CheckDisallowedFields(envFrom, *EnvFromSourceMask(&envFrom)).ViaIndex(i)) + + cm := envFrom.ConfigMapRef + sm := envFrom.SecretRef + if sm != nil { + errs = errs.Also(apis.CheckDisallowedFields(*sm, *SecretEnvSourceMask(sm)).ViaIndex(i)) + errs = errs.Also(apis.CheckDisallowedFields( + sm.LocalObjectReference, *LocalObjectReferenceMask(&sm.LocalObjectReference))).ViaIndex(i).ViaField("secretRef") + } + + if cm != nil { + errs = errs.Also(apis.CheckDisallowedFields(*cm, *ConfigMapEnvSourceMask(cm)).ViaIndex(i)) + errs = errs.Also(apis.CheckDisallowedFields( + cm.LocalObjectReference, *LocalObjectReferenceMask(&cm.LocalObjectReference))).ViaIndex(i).ViaField("configMapRef") + } + if cm != nil && sm != nil { + errs = errs.Also(apis.ErrMultipleOneOf("configMapRef", "secretRef")) + } else if cm == nil && sm == nil { + errs = errs.Also(apis.ErrMissingOneOf("configMapRef", "secretRef")) + } + } + return errs +} + +func ValidatePodSpec(ps corev1.PodSpec) *apis.FieldError { + // This is inlined, and so it makes for a less meaningful + // error message. + // if equality.Semantic.DeepEqual(ps, corev1.PodSpec{}) { + // return apis.ErrMissingField(apis.CurrentField) + // } + + errs := apis.CheckDisallowedFields(ps, *PodSpecMask(&ps)) + + volumes, err := ValidateVolumes(ps.Volumes) + if err != nil { + errs = errs.Also(err.ViaField("volumes")) + } + + switch len(ps.Containers) { + case 0: + errs = errs.Also(apis.ErrMissingField("containers")) + case 1: + errs = errs.Also(ValidateContainer(ps.Containers[0], volumes). + ViaFieldIndex("containers", 0)) + default: + errs = errs.Also(apis.ErrMultipleOneOf("containers")) + } + return errs +} + +func ValidateContainer(container corev1.Container, volumes sets.String) *apis.FieldError { + if equality.Semantic.DeepEqual(container, corev1.Container{}) { + return apis.ErrMissingField(apis.CurrentField) + } + + errs := apis.CheckDisallowedFields(container, *ContainerMask(&container)) + + if reservedContainerNames.Has(container.Name) { + errs = errs.Also(&apis.FieldError{ + Message: fmt.Sprintf("%q is a reserved container name", container.Name), + Paths: []string{"name"}, + }) + } + + // Env + errs = errs.Also(validateEnv(container.Env).ViaField("env")) + // EnvFrom + errs = errs.Also(validateEnvFrom(container.EnvFrom).ViaField("envFrom")) + // Image + if container.Image == "" { + errs = errs.Also(apis.ErrMissingField("image")) + } else if _, err := name.ParseReference(container.Image, name.WeakValidation); err != nil { + fe := &apis.FieldError{ + Message: "Failed to parse image reference", + Paths: []string{"image"}, + Details: fmt.Sprintf("image: %q, error: %v", container.Image, err), + } + errs = errs.Also(fe) + } + // Liveness Probes + errs = errs.Also(validateProbe(container.LivenessProbe).ViaField("livenessProbe")) + // Ports + errs = errs.Also(validateContainerPorts(container.Ports).ViaField("ports")) + // Readiness Probes + errs = errs.Also(validateProbe(container.ReadinessProbe).ViaField("readinessProbe")) + // Resources + errs = errs.Also(validateResources(&container.Resources).ViaField("resources")) + // SecurityContext + errs = errs.Also(validateSecurityContext(container.SecurityContext).ViaField("securityContext")) + // TerminationMessagePolicy + switch container.TerminationMessagePolicy { + case corev1.TerminationMessageReadFile, corev1.TerminationMessageFallbackToLogsOnError, "": + default: + errs = errs.Also(apis.ErrInvalidValue(container.TerminationMessagePolicy, "terminationMessagePolicy")) + } + // VolumeMounts + errs = errs.Also(validateVolumeMounts(container.VolumeMounts, volumes).ViaField("volumeMounts")) + + return errs +} + +func validateResources(resources *corev1.ResourceRequirements) *apis.FieldError { + if resources == nil { + return nil + } + return apis.CheckDisallowedFields(*resources, *ResourceRequirementsMask(resources)) +} + +func validateSecurityContext(sc *corev1.SecurityContext) *apis.FieldError { + if sc == nil { + return nil + } + errs := apis.CheckDisallowedFields(*sc, *SecurityContextMask(sc)) + + if sc.RunAsUser != nil { + uid := *sc.RunAsUser + if uid < minUserID || uid > maxUserID { + errs = errs.Also(apis.ErrOutOfBoundsValue(uid, minUserID, maxUserID, "runAsUser")) + } + } + return errs +} + +func validateVolumeMounts(mounts []corev1.VolumeMount, volumes sets.String) *apis.FieldError { + var errs *apis.FieldError + // Check that volume mounts match names in "volumes", that "volumes" has 100% + // coverage, and the field restrictions. + seenName := sets.NewString() + seenMountPath := sets.NewString() + for i, vm := range mounts { + errs = errs.Also(apis.CheckDisallowedFields(vm, *VolumeMountMask(&vm)).ViaIndex(i)) + // This effectively checks that Name is non-empty because Volume name must be non-empty. + if !volumes.Has(vm.Name) { + errs = errs.Also((&apis.FieldError{ + Message: "volumeMount has no matching volume", + Paths: []string{"name"}, + }).ViaIndex(i)) + } + seenName.Insert(vm.Name) + + if vm.MountPath == "" { + errs = errs.Also(apis.ErrMissingField("mountPath").ViaIndex(i)) + } else if reservedPaths.Has(filepath.Clean(vm.MountPath)) { + errs = errs.Also((&apis.FieldError{ + Message: fmt.Sprintf("mountPath %q is a reserved path", filepath.Clean(vm.MountPath)), + Paths: []string{"mountPath"}, + }).ViaIndex(i)) + } else if !filepath.IsAbs(vm.MountPath) { + errs = errs.Also(apis.ErrInvalidValue(vm.MountPath, "mountPath").ViaIndex(i)) + } else if seenMountPath.Has(filepath.Clean(vm.MountPath)) { + errs = errs.Also(apis.ErrInvalidValue( + fmt.Sprintf("%q must be unique", vm.MountPath), "mountPath").ViaIndex(i)) + } + seenMountPath.Insert(filepath.Clean(vm.MountPath)) + + if !vm.ReadOnly { + errs = errs.Also(apis.ErrMissingField("readOnly").ViaIndex(i)) + } + + } + + if missing := volumes.Difference(seenName); missing.Len() > 0 { + errs = errs.Also(&apis.FieldError{ + Message: fmt.Sprintf("volumes not mounted: %v", missing.List()), + Paths: []string{apis.CurrentField}, + }) + } + return errs +} + +func validateContainerPorts(ports []corev1.ContainerPort) *apis.FieldError { + if len(ports) == 0 { + return nil + } + + var errs *apis.FieldError + + // user can set container port which names "user-port" to define application's port. + // Queue-proxy will use it to send requests to application + // if user didn't set any port, it will set default port user-port=8080. + if len(ports) > 1 { + errs = errs.Also(&apis.FieldError{ + Message: "More than one container port is set", + Paths: []string{apis.CurrentField}, + Details: "Only a single port is allowed", + }) + } + + userPort := ports[0] + + errs = errs.Also(apis.CheckDisallowedFields(userPort, *ContainerPortMask(&userPort))) + + // Only allow empty (defaulting to "TCP") or explicit TCP for protocol + if userPort.Protocol != "" && userPort.Protocol != corev1.ProtocolTCP { + errs = errs.Also(apis.ErrInvalidValue(userPort.Protocol, "protocol")) + } + + // Don't allow userPort to conflict with QueueProxy sidecar + if userPort.ContainerPort == networking.BackendHTTPPort || + userPort.ContainerPort == networking.BackendHTTP2Port || + userPort.ContainerPort == networking.QueueAdminPort || + userPort.ContainerPort == networking.AutoscalingQueueMetricsPort || + userPort.ContainerPort == networking.UserQueueMetricsPort { + errs = errs.Also(apis.ErrInvalidValue(userPort.ContainerPort, "containerPort")) + } + + if userPort.ContainerPort < 0 || userPort.ContainerPort > 65535 { + errs = errs.Also(apis.ErrOutOfBoundsValue(userPort.ContainerPort, + 0, 65535, "containerPort")) + } + + if !validPortNames.Has(userPort.Name) { + errs = errs.Also(&apis.FieldError{ + Message: fmt.Sprintf("Port name %v is not allowed", ports[0].Name), + Paths: []string{apis.CurrentField}, + Details: "Name must be empty, or one of: 'h2c', 'http1'", + }) + } + + return errs +} + +func validateProbe(p *corev1.Probe) *apis.FieldError { + if p == nil { + return nil + } + errs := apis.CheckDisallowedFields(*p, *ProbeMask(p)) + + h := p.Handler + errs = errs.Also(apis.CheckDisallowedFields(h, *HandlerMask(&h))) + + switch { + case h.HTTPGet != nil: + errs = errs.Also(apis.CheckDisallowedFields(*h.HTTPGet, *HTTPGetActionMask(h.HTTPGet))).ViaField("httpGet") + case h.TCPSocket != nil: + errs = errs.Also(apis.CheckDisallowedFields(*h.TCPSocket, *TCPSocketActionMask(h.TCPSocket))).ViaField("tcpSocket") + } + return errs +} + +func ValidateNamespacedObjectReference(p *corev1.ObjectReference) *apis.FieldError { + if p == nil { + return nil + } + errs := apis.CheckDisallowedFields(*p, *NamespacedObjectReferenceMask(p)) + + if p.APIVersion == "" { + errs = errs.Also(apis.ErrMissingField("apiVersion")) + } else if verrs := validation.IsQualifiedName(p.APIVersion); len(verrs) != 0 { + errs = errs.Also(apis.ErrInvalidValue(strings.Join(verrs, ", "), "apiVersion")) + } + if p.Kind == "" { + errs = errs.Also(apis.ErrMissingField("kind")) + } else if verrs := validation.IsCIdentifier(p.Kind); len(verrs) != 0 { + errs = errs.Also(apis.ErrInvalidValue(strings.Join(verrs, ", "), "kind")) + } + if p.Name == "" { + errs = errs.Also(apis.ErrMissingField("name")) + } else if verrs := validation.IsDNS1123Label(p.Name); len(verrs) != 0 { + errs = errs.Also(apis.ErrInvalidValue(strings.Join(verrs, ", "), "name")) + } + return errs +} diff --git a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_defaults.go b/vendor/github.com/knative/serving/pkg/apis/serving/metadata_validation.go similarity index 53% rename from vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_defaults.go rename to vendor/github.com/knative/serving/pkg/apis/serving/metadata_validation.go index 738ec88a37..1625c5a428 100644 --- a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_defaults.go +++ b/vendor/github.com/knative/serving/pkg/apis/serving/metadata_validation.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Knative Authors +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. @@ -14,30 +14,17 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package serving import ( - "context" - "time" - + "knative.dev/pkg/apis" + "github.com/knative/serving/pkg/apis/autoscaling" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// DefaultTimeout is 10min -const DefaultTimeout = 10 * time.Minute - -// SetDefaults for build -func (b *Build) SetDefaults(ctx context.Context) { - if b == nil { - return - } - if b.Spec.ServiceAccountName == "" { - b.Spec.ServiceAccountName = "default" - } - if b.Spec.Timeout == nil { - b.Spec.Timeout = &metav1.Duration{Duration: DefaultTimeout} - } - if b.Spec.Template != nil && b.Spec.Template.Kind == "" { - b.Spec.Template.Kind = BuildTemplateKind - } +// ValidateObjectMetadata validates that `metadata` stanza of the +// resources is correct. +func ValidateObjectMetadata(meta metav1.Object) *apis.FieldError { + return apis.ValidateObjectMetadata(meta).Also( + autoscaling.ValidateAnnotations(meta.GetAnnotations()).ViaField("annotations")) } diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/register.go b/vendor/github.com/knative/serving/pkg/apis/serving/register.go index 1034e480a6..c11e02f890 100644 --- a/vendor/github.com/knative/serving/pkg/apis/serving/register.go +++ b/vendor/github.com/knative/serving/pkg/apis/serving/register.go @@ -45,10 +45,6 @@ const ( // its unique identifier RevisionUID = GroupName + "/revisionUID" - // AutoscalerLabelKey is the label key attached to a autoscaler pod indicating by - // which Autoscaler deployment it is created. - AutoscalerLabelKey = GroupName + "/autoscaler" - // ServiceLabelKey is the label key attached to a Route and Configuration indicating by // which Service they are created. ServiceLabelKey = GroupName + "/service" @@ -57,11 +53,14 @@ const ( // metadata generation of the Configuration that created this revision ConfigurationGenerationLabelKey = GroupName + "/configurationGeneration" - // DeprecatedConfigurationMetadataGenerationLabelKey is the label key attached to a Revision indicating the - // metadata generation of the Configuration that created this revision - DeprecatedConfigurationMetadataGenerationLabelKey = GroupName + "/configurationMetadataGeneration" + // CreatorAnnotation is the annotation key to describe the user that + // created the resource. + CreatorAnnotation = GroupName + "/creator" + // UpdaterAnnotation is the annotation key to describe the user that + // last updated the resource. + UpdaterAnnotation = GroupName + "/lastModifier" - // BuildHashLabelKey is the label key attached to a Build indicating the - // hash of the spec from which they were created. - BuildHashLabelKey = GroupName + "/buildHash" + // QueueSideCarResourcePercentageAnnotation is the percentage of user container resources to be used for queue-proxy + // It has to be in [0.1,100] + QueueSideCarResourcePercentageAnnotation = "queue.sidecar." + GroupName + "/resourcePercentage" ) diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/build_compat.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/build_compat.go deleted file mode 100644 index 3069caec0e..0000000000 --- a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/build_compat.go +++ /dev/null @@ -1,101 +0,0 @@ -/* -Copyright 2018 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 ( - "bytes" - "encoding/json" - "errors" - - "k8s.io/apimachinery/pkg/runtime" - - buildv1alpha1 "github.com/knative/build/pkg/apis/build/v1alpha1" -) - -// RawExtension is modeled after runtime.RawExtension, and should be -// replaced with it (or an alias) once we can stop supporting embedded -// BuildSpecs. -type RawExtension struct { - // Field order is the precedence for JSON marshaling if multiple - // fields are set. - Raw []byte - Object runtime.Object - BuildSpec *buildv1alpha1.BuildSpec -} - -var _ json.Unmarshaler = (*RawExtension)(nil) -var _ json.Marshaler = (*RawExtension)(nil) - -func (re *RawExtension) UnmarshalJSON(in []byte) error { - if re == nil { - return errors.New("RawExtension: UnmarshalJSON on nil pointer") - } - if !bytes.Equal(in, []byte("null")) { - re.Raw = append(re.Raw[0:0], in...) - } - return nil -} - -// MarshalJSON may get called on pointers or values, so implement MarshalJSON on value. -// http://stackoverflow.com/questions/21390979/custom-marshaljson-never-gets-called-in-go -func (re RawExtension) MarshalJSON() ([]byte, error) { - switch { - case re.Raw != nil: - return re.Raw, nil - - case re.Object != nil: - return json.Marshal(re.Object) - - case re.BuildSpec != nil: - return json.Marshal(re.BuildSpec) - - default: - return []byte("null"), nil - } -} - -func (re *RawExtension) ensureRaw() (err error) { - switch { - case re.Raw != nil: - // Nothing to do. - case re.Object != nil, re.BuildSpec != nil: - re.Raw, err = re.MarshalJSON() - } - return -} - -// As is a helper to decode the raw object into a particular type. -// The type is expected to exhaustively specify the fields encountered. -func (re *RawExtension) As(x interface{}) error { - if err := re.ensureRaw(); err != nil { - return err - } - decoder := json.NewDecoder(bytes.NewBuffer(re.Raw)) - decoder.DisallowUnknownFields() - return decoder.Decode(&x) -} - -// AsDuck is a helper to decode the raw object into a particular duck type. -// The type may only represent a subset of the fields present. -func (re *RawExtension) AsDuck(x interface{}) error { - if err := re.ensureRaw(); err != nil { - return err - } - decoder := json.NewDecoder(bytes.NewBuffer(re.Raw)) - // Allow unknown fields. - return decoder.Decode(&x) -} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_conversion.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_conversion.go new file mode 100644 index 0000000000..afcf7e4608 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_conversion.go @@ -0,0 +1,104 @@ +/* +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" + "fmt" + + "knative.dev/pkg/apis" + "github.com/knative/serving/pkg/apis/serving/v1beta1" +) + +// ConvertUp implements apis.Convertible +func (source *Configuration) ConvertUp(ctx context.Context, obj apis.Convertible) error { + switch sink := obj.(type) { + case *v1beta1.Configuration: + sink.ObjectMeta = source.ObjectMeta + if err := source.Spec.ConvertUp(ctx, &sink.Spec); err != nil { + return err + } + return source.Status.ConvertUp(ctx, &sink.Status) + default: + return fmt.Errorf("unknown version, got: %T", sink) + } +} + +// ConvertUp helps implement apis.Convertible +func (source *ConfigurationSpec) ConvertUp(ctx context.Context, sink *v1beta1.ConfigurationSpec) error { + if source.DeprecatedBuild != nil { + return ConvertErrorf("build", "build cannot be migrated forward.") + } + switch { + case source.DeprecatedRevisionTemplate != nil && source.Template != nil: + return apis.ErrMultipleOneOf("revisionTemplate", "template") + case source.DeprecatedRevisionTemplate != nil: + return source.DeprecatedRevisionTemplate.ConvertUp(ctx, &sink.Template) + case source.Template != nil: + return source.Template.ConvertUp(ctx, &sink.Template) + default: + return apis.ErrMissingOneOf("revisionTemplate", "template") + } +} + +// ConvertUp helps implement apis.Convertible +func (source *ConfigurationStatus) ConvertUp(ctx context.Context, sink *v1beta1.ConfigurationStatus) error { + source.Status.ConvertTo(ctx, &sink.Status) + + return source.ConfigurationStatusFields.ConvertUp(ctx, &sink.ConfigurationStatusFields) +} + +// ConvertUp helps implement apis.Convertible +func (source *ConfigurationStatusFields) ConvertUp(ctx context.Context, sink *v1beta1.ConfigurationStatusFields) error { + sink.LatestReadyRevisionName = source.LatestReadyRevisionName + sink.LatestCreatedRevisionName = source.LatestCreatedRevisionName + return nil +} + +// ConvertDown implements apis.Convertible +func (sink *Configuration) ConvertDown(ctx context.Context, obj apis.Convertible) error { + switch source := obj.(type) { + case *v1beta1.Configuration: + sink.ObjectMeta = source.ObjectMeta + if err := sink.Spec.ConvertDown(ctx, source.Spec); err != nil { + return err + } + return sink.Status.ConvertDown(ctx, source.Status) + default: + return fmt.Errorf("unknown version, got: %T", source) + } +} + +// ConvertDown helps implement apis.Convertible +func (sink *ConfigurationSpec) ConvertDown(ctx context.Context, source v1beta1.ConfigurationSpec) error { + sink.Template = &RevisionTemplateSpec{} + return sink.Template.ConvertDown(ctx, source.Template) +} + +// ConvertDown helps implement apis.Convertible +func (sink *ConfigurationStatus) ConvertDown(ctx context.Context, source v1beta1.ConfigurationStatus) error { + source.Status.ConvertTo(ctx, &sink.Status) + + return sink.ConfigurationStatusFields.ConvertDown(ctx, source.ConfigurationStatusFields) +} + +// ConvertDown helps implement apis.Convertible +func (sink *ConfigurationStatusFields) ConvertDown(ctx context.Context, source v1beta1.ConfigurationStatusFields) error { + sink.LatestReadyRevisionName = source.LatestReadyRevisionName + sink.LatestCreatedRevisionName = source.LatestCreatedRevisionName + return nil +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_defaults.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_defaults.go index 8a89379102..2164605e37 100644 --- a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_defaults.go +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_defaults.go @@ -16,12 +16,29 @@ limitations under the License. package v1alpha1 -import "context" +import ( + "context" + + "knative.dev/pkg/apis" + + "github.com/knative/serving/pkg/apis/serving/v1beta1" +) func (c *Configuration) SetDefaults(ctx context.Context) { - c.Spec.SetDefaults(ctx) + ctx = apis.WithinParent(ctx, c.ObjectMeta) + c.Spec.SetDefaults(apis.WithinSpec(ctx)) } func (cs *ConfigurationSpec) SetDefaults(ctx context.Context) { - cs.RevisionTemplate.Spec.SetDefaults(ctx) + if v1beta1.IsUpgradeViaDefaulting(ctx) { + beta := v1beta1.ConfigurationSpec{} + if cs.ConvertUp(ctx, &beta) == nil { + alpha := ConfigurationSpec{} + if alpha.ConvertDown(ctx, beta) == nil { + *cs = alpha + } + } + } + + cs.GetTemplate().Spec.SetDefaults(ctx) } diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_lifecycle.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_lifecycle.go index 8814fb7d2b..532cbc3f6b 100644 --- a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_lifecycle.go +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_lifecycle.go @@ -17,16 +17,44 @@ limitations under the License. package v1alpha1 import ( - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime/schema" ) -var confCondSet = duckv1alpha1.NewLivingConditionSet() +var confCondSet = apis.NewLivingConditionSet() func (r *Configuration) GetGroupVersionKind() schema.GroupVersionKind { return SchemeGroupVersion.WithKind("Configuration") } +// MarkResourceNotConvertible adds a Warning-severity condition to the resource noting that +// it cannot be converted to a higher version. +func (cs *ConfigurationStatus) MarkResourceNotConvertible(err *CannotConvertError) { + confCondSet.Manage(cs).SetCondition(apis.Condition{ + Type: ConditionTypeConvertible, + Status: corev1.ConditionFalse, + Severity: apis.ConditionSeverityWarning, + Reason: err.Field, + Message: err.Message, + }) +} + +// GetTemplate returns a pointer to the relevant RevisionTemplateSpec field. +// It is never nil and should be exactly the specified template as guaranteed +// by validation. +func (cs *ConfigurationSpec) GetTemplate() *RevisionTemplateSpec { + if cs.DeprecatedRevisionTemplate != nil { + return cs.DeprecatedRevisionTemplate + } + if cs.Template != nil { + return cs.Template + } + // Should be unreachable post-validation, but here to ease testing. + return &RevisionTemplateSpec{} +} + // IsReady looks at the conditions to see if they are happy. func (cs *ConfigurationStatus) IsReady() bool { return confCondSet.Manage(cs).IsHappy() @@ -40,7 +68,7 @@ func (cs *ConfigurationStatus) IsLatestReadyRevisionNameUpToDate() bool { cs.LatestCreatedRevisionName == cs.LatestReadyRevisionName } -func (cs *ConfigurationStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition { +func (cs *ConfigurationStatus) GetCondition(t apis.ConditionType) *apis.Condition { return confCondSet.Manage(cs).GetCondition(t) } @@ -83,3 +111,7 @@ func (cs *ConfigurationStatus) MarkLatestReadyDeleted() { "RevisionDeleted", "Revision %q was deleted.", cs.LatestReadyRevisionName) } + +func (cs *ConfigurationStatus) duck() *duckv1beta1.Status { + return &cs.Status +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_types.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_types.go index 7fabcb773d..84922ded3b 100644 --- a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_types.go +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_types.go @@ -17,10 +17,11 @@ limitations under the License. package v1alpha1 import ( - "github.com/knative/pkg/apis" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" - "github.com/knative/pkg/kmeta" + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/kmeta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" ) // +genclient @@ -52,6 +53,9 @@ var ( _ apis.Validatable = (*Configuration)(nil) _ apis.Defaultable = (*Configuration)(nil) + // Check that Configuration can be converted to higher versions. + _ apis.Convertible = (*Configuration)(nil) + // Check that we can create OwnerReferences to a Configuration. _ kmeta.OwnerRefable = (*Configuration)(nil) ) @@ -72,23 +76,29 @@ type ConfigurationSpec struct { // Build optionally holds the specification for the build to // perform to produce the Revision's container image. // +optional - Build *RawExtension `json:"build,omitempty"` + DeprecatedBuild *runtime.RawExtension `json:"build,omitempty"` - // RevisionTemplate holds the latest specification for the Revision to + // DeprecatedRevisionTemplate holds the latest specification for the Revision to // be stamped out. If a Build specification is provided, then the - // RevisionTemplate's BuildName field will be populated with the name of + // DeprecatedRevisionTemplate's BuildName field will be populated with the name of // the Build object created to produce the container for the Revision. + // DEPRECATED Use Template instead. + // +optional + DeprecatedRevisionTemplate *RevisionTemplateSpec `json:"revisionTemplate,omitempty"` + + // Template holds the latest specification for the Revision to + // be stamped out. // +optional - RevisionTemplate RevisionTemplateSpec `json:"revisionTemplate"` + Template *RevisionTemplateSpec `json:"template,omitempty"` } const ( // ConfigurationConditionReady is set when the configuration's latest // underlying revision has reported readiness. - ConfigurationConditionReady = duckv1alpha1.ConditionReady + ConfigurationConditionReady = apis.ConditionReady ) -// ConfigurationStatusFields holds all of the non-duckv1alpha1.Status status fields of a Route. +// ConfigurationStatusFields holds all of the non-duckv1beta1.Status status fields of a Route. // These are defined outline so that we can also inline them into Service, and more easily // copy them. type ConfigurationStatusFields struct { @@ -105,7 +115,7 @@ type ConfigurationStatusFields struct { // ConfigurationStatus communicates the observed state of the Configuration (from the controller). type ConfigurationStatus struct { - duckv1alpha1.Status `json:",inline"` + duckv1beta1.Status `json:",inline"` ConfigurationStatusFields `json:",inline"` } diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_validation.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_validation.go index 4221657f08..d06a9290af 100644 --- a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_validation.go +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_validation.go @@ -20,16 +20,32 @@ import ( "context" "k8s.io/apimachinery/pkg/api/equality" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - buildv1alpha1 "github.com/knative/build/pkg/apis/build/v1alpha1" - "github.com/knative/pkg/apis" + "knative.dev/pkg/apis" + "github.com/knative/serving/pkg/apis/serving" ) // Validate makes sure that Configuration is properly configured. -func (c *Configuration) Validate(ctx context.Context) *apis.FieldError { - return ValidateObjectMetadata(c.GetObjectMeta()).ViaField("metadata"). - Also(c.Spec.Validate(ctx).ViaField("spec")) +func (c *Configuration) Validate(ctx context.Context) (errs *apis.FieldError) { + // If we are in a status sub resource update, the metadata and spec cannot change. + // So, to avoid rejecting controller status updates due to validations that may + // have changed (i.e. due to config-defaults changes), we elide the metadata and + // spec validation. + if !apis.IsInStatusUpdate(ctx) { + errs = errs.Also(serving.ValidateObjectMetadata(c.GetObjectMeta()).ViaField("metadata")) + ctx = apis.WithinParent(ctx, c.ObjectMeta) + errs = errs.Also(c.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + } + + if apis.IsInUpdate(ctx) { + original := apis.GetBaseline(ctx).(*Configuration) + + err := c.Spec.GetTemplate().VerifyNameChange(ctx, + original.Spec.GetTemplate()) + errs = errs.Also(err.ViaField("spec.revisionTemplate")) + } + + return errs } // Validate makes sure that ConfigurationSpec is properly configured. @@ -37,18 +53,27 @@ func (cs *ConfigurationSpec) Validate(ctx context.Context) *apis.FieldError { if equality.Semantic.DeepEqual(cs, &ConfigurationSpec{}) { return apis.ErrMissingField(apis.CurrentField) } - var errs *apis.FieldError - // TODO(mattmoor): Check ObjectMeta for Name/Namespace/GenerateName - - if cs.Build == nil { - // No build was specified. - } else if err := cs.Build.As(&buildv1alpha1.BuildSpec{}); err == nil { - // It is a BuildSpec, this is the legacy path. - } else if err = cs.Build.As(&unstructured.Unstructured{}); err == nil { - // It is an unstructured.Unstructured. - } else { - errs = errs.Also(apis.ErrInvalidValue(err.Error(), "build")) + + errs := apis.CheckDeprecated(ctx, cs) + + // Build support is now disabled. + if cs.DeprecatedBuild != nil { + errs = errs.Also(apis.ErrDisallowedFields("build")) + } + + var templateField string + switch { + case cs.DeprecatedRevisionTemplate != nil && cs.Template != nil: + return apis.ErrMultipleOneOf("revisionTemplate", "template") + case cs.DeprecatedRevisionTemplate != nil: + templateField = "revisionTemplate" + case cs.Template != nil: + templateField = "template" + // Disallow the use of deprecated fields under "template". + ctx = apis.DisallowDeprecated(ctx) + default: + return apis.ErrMissingOneOf("revisionTemplate", "template") } - return errs.Also(cs.RevisionTemplate.Validate(ctx).ViaField("revisionTemplate")) + return errs.Also(cs.GetTemplate().Validate(ctx).ViaField(templateField)) } diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/conversion_error.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/conversion_error.go new file mode 100644 index 0000000000..ddad8e3b22 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/conversion_error.go @@ -0,0 +1,51 @@ +/* +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 ( + "fmt" + + "knative.dev/pkg/apis" +) + +const ( + // ConditionTypeConvertible is a Warning condition that is set on + // resources when they cannot be converted to warn of a forthcoming + // breakage. + ConditionTypeConvertible apis.ConditionType = "Convertible" +) + +// CannotConvertError is returned when a field cannot be converted. +type CannotConvertError struct { + Message string + Field string +} + +var _ error = (*CannotConvertError)(nil) + +// Error implements error +func (cce *CannotConvertError) Error() string { + return cce.Message +} + +// ConvertErrorf creates a CannotConvertError from the field name and format string. +func ConvertErrorf(field, msg string, args ...interface{}) error { + return &CannotConvertError{ + Message: fmt.Sprintf(msg, args...), + Field: field, + } +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/metadata_validation.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/metadata_validation.go deleted file mode 100644 index e14c24a9a0..0000000000 --- a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/metadata_validation.go +++ /dev/null @@ -1,108 +0,0 @@ -/* -Copyright 2018 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 ( - "fmt" - "strconv" - - "github.com/knative/pkg/apis" - "github.com/knative/serving/pkg/apis/autoscaling" - "k8s.io/apimachinery/pkg/api/validation" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// ValidateObjectMetadata validates that `metadata` stanza of the -// resources is correct. -func ValidateObjectMetadata(meta metav1.Object) *apis.FieldError { - name := meta.GetName() - generateName := meta.GetGenerateName() - - if generateName != "" { - msgs := validation.NameIsDNS1035Label(generateName, true) - - if len(msgs) > 0 { - return &apis.FieldError{ - Message: fmt.Sprintf("not a DNS 1035 label prefix: %v", msgs), - Paths: []string{"generateName"}, - } - } - } - - if name != "" { - msgs := validation.NameIsDNS1035Label(name, false) - - if len(msgs) > 0 { - return &apis.FieldError{ - Message: fmt.Sprintf("not a DNS 1035 label: %v", msgs), - Paths: []string{"name"}, - } - } - } - - if generateName == "" && name == "" { - return &apis.FieldError{ - Message: "name or generateName is required", - Paths: []string{"name"}, - } - } - - if err := validateScaleBoundsAnnotations(meta.GetAnnotations()); err != nil { - return err.ViaField("annotations") - } - - return nil -} - -func getIntGT0(m map[string]string, k string) (int64, *apis.FieldError) { - v, ok := m[k] - if ok { - i, err := strconv.ParseInt(v, 10, 32) - if err != nil || i < 1 { - return 0, &apis.FieldError{ - Message: fmt.Sprintf("Invalid %s annotation value: must be an integer greater than 0", k), - Paths: []string{k}, - } - } - return i, nil - } - return 0, nil -} - -func validateScaleBoundsAnnotations(annotations map[string]string) *apis.FieldError { - if annotations == nil { - return nil - } - - min, err := getIntGT0(annotations, autoscaling.MinScaleAnnotationKey) - if err != nil { - return err - } - max, err := getIntGT0(annotations, autoscaling.MaxScaleAnnotationKey) - if err != nil { - return err - } - - if max != 0 && max < min { - return &apis.FieldError{ - Message: fmt.Sprintf("%s=%v is less than %s=%v", autoscaling.MaxScaleAnnotationKey, max, autoscaling.MinScaleAnnotationKey, min), - Paths: []string{autoscaling.MaxScaleAnnotationKey, autoscaling.MinScaleAnnotationKey}, - } - } - - return nil -} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_conversion.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_conversion.go new file mode 100644 index 0000000000..57abbbc394 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_conversion.go @@ -0,0 +1,117 @@ +/* +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" + "fmt" + + "knative.dev/pkg/apis" + "knative.dev/pkg/ptr" + "github.com/knative/serving/pkg/apis/serving/v1beta1" + corev1 "k8s.io/api/core/v1" +) + +// ConvertUp implements apis.Convertible +func (source *Revision) ConvertUp(ctx context.Context, obj apis.Convertible) error { + switch sink := obj.(type) { + case *v1beta1.Revision: + sink.ObjectMeta = source.ObjectMeta + source.Status.ConvertUp(ctx, &sink.Status) + return source.Spec.ConvertUp(ctx, &sink.Spec) + default: + return fmt.Errorf("unknown version, got: %T", sink) + } +} + +// ConvertUp helps implement apis.Convertible +func (source *RevisionTemplateSpec) ConvertUp(ctx context.Context, sink *v1beta1.RevisionTemplateSpec) error { + sink.ObjectMeta = source.ObjectMeta + return source.Spec.ConvertUp(ctx, &sink.Spec) +} + +// ConvertUp helps implement apis.Convertible +func (source *RevisionSpec) ConvertUp(ctx context.Context, sink *v1beta1.RevisionSpec) error { + sink.ContainerConcurrency = v1beta1.RevisionContainerConcurrencyType( + source.ContainerConcurrency) + if source.TimeoutSeconds != nil { + sink.TimeoutSeconds = ptr.Int64(*source.TimeoutSeconds) + } + switch { + case source.DeprecatedContainer != nil && len(source.Containers) > 0: + return apis.ErrMultipleOneOf("container", "containers") + case source.DeprecatedContainer != nil: + sink.PodSpec = corev1.PodSpec{ + ServiceAccountName: source.ServiceAccountName, + Containers: []corev1.Container{*source.DeprecatedContainer}, + Volumes: source.Volumes, + } + case len(source.Containers) == 1: + sink.PodSpec = source.PodSpec + case len(source.Containers) > 1: + return apis.ErrMultipleOneOf("containers") + default: + return apis.ErrMissingOneOf("container", "containers") + } + if source.DeprecatedBuildRef != nil { + return ConvertErrorf("buildRef", + "buildRef cannot be migrated forward, got: %#v", source.DeprecatedBuildRef) + } + return nil +} + +// ConvertUp helps implement apis.Convertible +func (source *RevisionStatus) ConvertUp(ctx context.Context, sink *v1beta1.RevisionStatus) { + source.Status.ConvertTo(ctx, &sink.Status) + + sink.ServiceName = source.ServiceName + sink.LogURL = source.LogURL + // TODO(mattmoor): ImageDigest? +} + +// ConvertDown implements apis.Convertible +func (sink *Revision) ConvertDown(ctx context.Context, obj apis.Convertible) error { + switch source := obj.(type) { + case *v1beta1.Revision: + sink.ObjectMeta = source.ObjectMeta + sink.Status.ConvertDown(ctx, source.Status) + return sink.Spec.ConvertDown(ctx, source.Spec) + default: + return fmt.Errorf("unknown version, got: %T", source) + } +} + +// ConvertDown helps implement apis.Convertible +func (sink *RevisionTemplateSpec) ConvertDown(ctx context.Context, source v1beta1.RevisionTemplateSpec) error { + sink.ObjectMeta = source.ObjectMeta + return sink.Spec.ConvertDown(ctx, source.Spec) +} + +// ConvertDown helps implement apis.Convertible +func (sink *RevisionSpec) ConvertDown(ctx context.Context, source v1beta1.RevisionSpec) error { + sink.RevisionSpec = *source.DeepCopy() + return nil +} + +// ConvertDown helps implement apis.Convertible +func (sink *RevisionStatus) ConvertDown(ctx context.Context, source v1beta1.RevisionStatus) { + source.Status.ConvertTo(ctx, &sink.Status) + + sink.ServiceName = source.ServiceName + sink.LogURL = source.LogURL + // TODO(mattmoor): ImageDigest? +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_defaults.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_defaults.go index 8b203293d2..72169b001f 100644 --- a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_defaults.go +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_defaults.go @@ -19,17 +19,26 @@ package v1alpha1 import ( "context" + "knative.dev/pkg/apis" corev1 "k8s.io/api/core/v1" - "github.com/knative/serving/pkg/apis/config" + "github.com/knative/serving/pkg/apis/serving/v1beta1" ) func (r *Revision) SetDefaults(ctx context.Context) { - r.Spec.SetDefaults(ctx) + r.Spec.SetDefaults(apis.WithinSpec(ctx)) } func (rs *RevisionSpec) SetDefaults(ctx context.Context) { - cfg := config.FromContextOrDefaults(ctx) + if v1beta1.IsUpgradeViaDefaulting(ctx) { + beta := v1beta1.RevisionSpec{} + if rs.ConvertUp(ctx, &beta) == nil { + alpha := RevisionSpec{} + if alpha.ConvertDown(ctx, beta) == nil { + *rs = alpha + } + } + } // When ConcurrencyModel is specified but ContainerConcurrency // is not (0), use the ConcurrencyModel value. @@ -37,19 +46,18 @@ func (rs *RevisionSpec) SetDefaults(ctx context.Context) { rs.ContainerConcurrency = 1 } - if rs.TimeoutSeconds == 0 { - rs.TimeoutSeconds = cfg.Defaults.RevisionTimeoutSeconds - } - - if rs.Container.Resources.Requests == nil { - rs.Container.Resources.Requests = corev1.ResourceList{} - } - if _, ok := rs.Container.Resources.Requests[corev1.ResourceCPU]; !ok { - rs.Container.Resources.Requests[corev1.ResourceCPU] = cfg.Defaults.RevisionCPURequest - } - - vms := rs.Container.VolumeMounts - for i := range vms { - vms[i].ReadOnly = true + // When the PodSpec has no containers, move the single Container + // into the PodSpec for the scope of defaulting and then move + // it back as we return. + if len(rs.Containers) == 0 { + if rs.DeprecatedContainer == nil { + rs.DeprecatedContainer = &corev1.Container{} + } + rs.Containers = []corev1.Container{*rs.DeprecatedContainer} + defer func() { + rs.DeprecatedContainer = &rs.Containers[0] + rs.Containers = nil + }() } + rs.RevisionSpec.SetDefaults(ctx) } diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_lifecycle.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_lifecycle.go index 830d7bcd58..4e81022625 100644 --- a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_lifecycle.go +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_lifecycle.go @@ -21,7 +21,8 @@ import ( "strconv" "time" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" net "github.com/knative/serving/pkg/apis/networking" "github.com/knative/serving/pkg/apis/serving" corev1 "k8s.io/api/core/v1" @@ -38,46 +39,49 @@ const ( // use for connecting to the user container. DefaultUserPort = 8080 - // RequestQueuePortName specifies the port name to use for http requests - // in queue-proxy container. - RequestQueuePortName string = "queue-port" + // QueueAdminPortName specifies the port name for + // health check and lifecycle hooks for queue-proxy. + QueueAdminPortName string = "queueadm-port" - // RequestQueuePort specifies the port number to use for http requests - // in queue-proxy container. - RequestQueuePort = 8012 + // AutoscalingQueueMetricsPortName specifies the port name to use for metrics + // emitted by queue-proxy for autoscaler. + AutoscalingQueueMetricsPortName = "queue-metrics" - // RequestQueueAdminPortName specifies the port name for - // health check and lifecyle hooks for queue-proxy. - RequestQueueAdminPortName string = "queueadm-port" + // UserQueueMetricsPortName specifies the port name to use for metrics + // emitted by queue-proxy for end user. + UserQueueMetricsPortName = "user-metrics" - // RequestQueueAdminPort specifies the port number for - // health check and lifecyle hooks for queue-proxy. - RequestQueueAdminPort = 8022 - - // RequestQueueMetricsPort specifies the port number for metrics emitted - // by queue-proxy. - RequestQueueMetricsPort = 9090 - - // RequestQueueMetricsPortName specifies the port name to use for metrics - // emitted by queue-proxy. - RequestQueueMetricsPortName = "queue-metrics" + // ServiceQueueMetricsPortName is the name of the port that serves metrics + // on the Kubernetes service. + ServiceQueueMetricsPortName = "metrics" ) -var revCondSet = duckv1alpha1.NewLivingConditionSet( +var revCondSet = apis.NewLivingConditionSet( RevisionConditionResourcesAvailable, RevisionConditionContainerHealthy, - RevisionConditionBuildSucceeded, ) -var buildCondSet = duckv1alpha1.NewBatchConditionSet() - func (r *Revision) GetGroupVersionKind() schema.GroupVersionKind { return SchemeGroupVersion.WithKind("Revision") } -func (r *Revision) BuildRef() *corev1.ObjectReference { - if r.Spec.BuildRef != nil { - buildRef := r.Spec.BuildRef.DeepCopy() +// GetContainer returns a pointer to the relevant corev1.Container field. +// It is never nil and should be exactly the specified container as guaranteed +// by validation. +func (rs *RevisionSpec) GetContainer() *corev1.Container { + if rs.DeprecatedContainer != nil { + return rs.DeprecatedContainer + } + if len(rs.Containers) > 0 { + return &rs.Containers[0] + } + // Should be unreachable post-validation, but here to ease testing. + return &corev1.Container{} +} + +func (r *Revision) DeprecatedBuildRef() *corev1.ObjectReference { + if r.Spec.DeprecatedBuildRef != nil { + buildRef := r.Spec.DeprecatedBuildRef.DeepCopy() if buildRef.Namespace == "" { buildRef.Namespace = r.Namespace } @@ -98,7 +102,7 @@ func (r *Revision) BuildRef() *corev1.ObjectReference { // GetProtocol returns the app level network protocol. func (r *Revision) GetProtocol() net.ProtocolType { - ports := r.Spec.Container.Ports + ports := r.Spec.GetContainer().Ports if len(ports) > 0 && ports[0].Name == string(net.ProtocolH2C) { return net.ProtocolH2C } @@ -120,7 +124,7 @@ func (rs *RevisionStatus) IsActivationRequired() bool { return false } -func (rs *RevisionStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition { +func (rs *RevisionStatus) GetCondition(t apis.ConditionType) *apis.Condition { return revCondSet.Manage(rs).GetCondition(t) } @@ -128,19 +132,16 @@ func (rs *RevisionStatus) InitializeConditions() { revCondSet.Manage(rs).InitializeConditions() } -func (rs *RevisionStatus) PropagateBuildStatus(bs duckv1alpha1.Status) { - bc := buildCondSet.Manage(&bs).GetCondition(duckv1alpha1.ConditionSucceeded) - if bc == nil { - return - } - switch { - case bc.Status == corev1.ConditionUnknown: - revCondSet.Manage(rs).MarkUnknown(RevisionConditionBuildSucceeded, "Building", bc.Message) - case bc.Status == corev1.ConditionTrue: - revCondSet.Manage(rs).MarkTrue(RevisionConditionBuildSucceeded) - case bc.Status == corev1.ConditionFalse: - revCondSet.Manage(rs).MarkFalse(RevisionConditionBuildSucceeded, bc.Reason, bc.Message) - } +// MarkResourceNotConvertible adds a Warning-severity condition to the resource noting that +// it cannot be converted to a higher version. +func (rs *RevisionStatus) MarkResourceNotConvertible(err *CannotConvertError) { + revCondSet.Manage(rs).SetCondition(apis.Condition{ + Type: ConditionTypeConvertible, + Status: corev1.ConditionFalse, + Severity: apis.ConditionSeverityWarning, + Reason: err.Field, + Message: err.Message, + }) } // MarkResourceNotOwned changes the "ResourcesAvailable" condition to false to reflect that the @@ -155,11 +156,6 @@ func (rs *RevisionStatus) MarkDeploying(reason string) { revCondSet.Manage(rs).MarkUnknown(RevisionConditionContainerHealthy, reason, "") } -func (rs *RevisionStatus) MarkServiceTimeout() { - revCondSet.Manage(rs).MarkFalse(RevisionConditionResourcesAvailable, "ServiceTimeout", - "Timed out waiting for a service endpoint to become ready") -} - func (rs *RevisionStatus) MarkProgressDeadlineExceeded(message string) { revCondSet.Manage(rs).MarkFalse(RevisionConditionResourcesAvailable, "ProgressDeadlineExceeded", message) } @@ -177,6 +173,12 @@ func (rs *RevisionStatus) MarkResourcesAvailable() { revCondSet.Manage(rs).MarkTrue(RevisionConditionResourcesAvailable) } +// MarkResourcesUnavailable changes "ResourcesAvailable" condition to false to reflect that the +// resources of the given kind and name cannot be created. +func (rs *RevisionStatus) MarkResourcesUnavailable(reason, message string) { + revCondSet.Manage(rs).MarkFalse(RevisionConditionResourcesAvailable, reason, message) +} + func (rs *RevisionStatus) MarkActive() { revCondSet.Manage(rs).MarkTrue(RevisionConditionActive) } @@ -226,13 +228,6 @@ func (e LastPinnedParseError) Error() string { return fmt.Sprintf("%v lastPinned value: %q", e.Type, e.Value) } -// +k8s:deepcopy-gen=false -type configurationGenerationParseError AnnotationParseError - -func (e configurationGenerationParseError) Error() string { - return fmt.Sprintf("%v configurationGeneration value: %q", e.Type, e.Value) -} - func RevisionLastPinnedString(t time.Time) string { return fmt.Sprintf("%d", t.Unix()) } @@ -271,3 +266,7 @@ func (r *Revision) GetLastPinned() (time.Time, error) { return time.Unix(secs, 0), nil } + +func (rs *RevisionStatus) duck() *duckv1beta1.Status { + return &rs.Status +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_types.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_types.go index 5a3f55d455..69d06faf80 100644 --- a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_types.go +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_types.go @@ -17,11 +17,13 @@ limitations under the License. package v1alpha1 import ( - "github.com/knative/pkg/apis" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" - "github.com/knative/pkg/kmeta" + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/kmeta" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/knative/serving/pkg/apis/serving/v1beta1" ) // +genclient @@ -52,7 +54,9 @@ var ( // Check that Revision can be validated, can be defaulted, and has immutable fields. _ apis.Validatable = (*Revision)(nil) _ apis.Defaultable = (*Revision)(nil) - _ apis.Immutable = (*Revision)(nil) + + // Check that Revision can be converted to higher versions. + _ apis.Convertible = (*Revision)(nil) // Check that we can create OwnerReferences to a Revision. _ kmeta.OwnerRefable = (*Revision)(nil) @@ -89,7 +93,7 @@ const ( // RevisionRequestConcurrencyModelType is an enumeration of the // concurrency models supported by a Revision. -// Deprecated in favor of RevisionContainerConcurrencyType. +// DEPRECATED in favor of RevisionContainerConcurrencyType. type RevisionRequestConcurrencyModelType string const ( @@ -103,17 +107,10 @@ const ( RevisionRequestConcurrencyModelMulti RevisionRequestConcurrencyModelType = "Multi" ) -// RevisionContainerConcurrencyType is an integer expressing a number of -// in-flight (concurrent) requests. -type RevisionContainerConcurrencyType int64 - -const ( - // The maximum configurable container concurrency. - RevisionContainerConcurrencyMax RevisionContainerConcurrencyType = 1000 -) - // RevisionSpec holds the desired state of the Revision (from the client). type RevisionSpec struct { + v1beta1.RevisionSpec `json:",inline"` + // DeprecatedGeneration was used prior in Kubernetes versions <1.11 // when metadata.generation was not being incremented by the api server // @@ -139,34 +136,16 @@ type RevisionSpec struct { // +optional DeprecatedConcurrencyModel RevisionRequestConcurrencyModelType `json:"concurrencyModel,omitempty"` - // ContainerConcurrency specifies the maximum allowed - // in-flight (concurrent) requests per container of the Revision. - // Defaults to `0` which means unlimited concurrency. - // This field replaces ConcurrencyModel. A value of `1` - // is equivalent to `Single` and `0` is equivalent to `Multi`. - // +optional - ContainerConcurrency RevisionContainerConcurrencyType `json:"containerConcurrency,omitempty"` - - // ServiceAccountName holds the name of the Kubernetes service account - // as which the underlying K8s resources should be run. If unspecified - // this will default to the "default" service account for the namespace - // in which the Revision exists. - // This may be used to provide access to private container images by - // following: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#add-imagepullsecrets-to-a-service-account - // TODO(ZhiminXiang): verify the corresponding service account exists. - // +optional - ServiceAccountName string `json:"serviceAccountName,omitempty"` - // DeprecatedBuildName optionally holds the name of the Build responsible for // producing the container image for its Revision. - // DEPRECATED: Use BuildRef instead. + // DEPRECATED: Use DeprecatedBuildRef instead. // +optional DeprecatedBuildName string `json:"buildName,omitempty"` - // BuildRef holds the reference to the build (if there is one) responsible + // DeprecatedBuildRef holds the reference to the build (if there is one) responsible // for producing the container image for this Revision. Otherwise, nil // +optional - BuildRef *corev1.ObjectReference `json:"buildRef,omitempty"` + DeprecatedBuildRef *corev1.ObjectReference `json:"buildRef,omitempty"` // Container defines the unit of execution for this Revision. // In the context of a Revision, we disallow a number of the fields of @@ -175,42 +154,28 @@ type RevisionSpec struct { // environment: // https://github.com/knative/serving/blob/master/docs/runtime-contract.md // +optional - Container corev1.Container `json:"container,omitempty"` - - // Volumes defines a set of Kubernetes volumes to be mounted into the - // specified Container. Currently only ConfigMap and Secret volumes are - // supported. - Volumes []corev1.Volume `json:"volumes,omitempty"` - - // TimeoutSeconds holds the max duration the instance is allowed for responding to a request. - // +optional - TimeoutSeconds int64 `json:"timeoutSeconds,omitempty"` + DeprecatedContainer *corev1.Container `json:"container,omitempty"` } const ( // RevisionConditionReady is set when the revision is starting to materialize // runtime resources, and becomes true when those resources are ready. - RevisionConditionReady = duckv1alpha1.ConditionReady - // RevisionConditionBuildSucceeded is set when the revision has an associated build - // and is marked True if/once the Build has completed successfully. - RevisionConditionBuildSucceeded duckv1alpha1.ConditionType = "BuildSucceeded" + RevisionConditionReady = apis.ConditionReady // RevisionConditionResourcesAvailable is set when underlying // Kubernetes resources have been provisioned. - RevisionConditionResourcesAvailable duckv1alpha1.ConditionType = "ResourcesAvailable" + RevisionConditionResourcesAvailable apis.ConditionType = "ResourcesAvailable" // RevisionConditionContainerHealthy is set when the revision readiness check completes. - RevisionConditionContainerHealthy duckv1alpha1.ConditionType = "ContainerHealthy" + RevisionConditionContainerHealthy apis.ConditionType = "ContainerHealthy" // RevisionConditionActive is set when the revision is receiving traffic. - RevisionConditionActive duckv1alpha1.ConditionType = "Active" + RevisionConditionActive apis.ConditionType = "Active" ) // RevisionStatus communicates the observed state of the Revision (from the controller). type RevisionStatus struct { - duckv1alpha1.Status `json:",inline"` + duckv1beta1.Status `json:",inline"` // ServiceName holds the name of a core Kubernetes Service resource that - // load balances over the pods backing this Revision. When the Revision - // is Active, this service would be an appropriate ingress target for - // targeting the revision. + // load balances over the pods backing this Revision. // +optional ServiceName string `json:"serviceName,omitempty"` diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_validation.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_validation.go index 7dc1308088..169ad87745 100644 --- a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_validation.go +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_validation.go @@ -19,378 +19,201 @@ package v1alpha1 import ( "context" "fmt" - "path/filepath" "strconv" + "strings" - "github.com/google/go-containerregistry/pkg/name" - "github.com/knative/pkg/apis" - "github.com/knative/pkg/kmp" - networkingv1alpha1 "github.com/knative/serving/pkg/apis/networking/v1alpha1" - corev1 "k8s.io/api/core/v1" + "github.com/knative/serving/pkg/apis/config" + + "knative.dev/pkg/apis" + "knative.dev/pkg/kmp" + "github.com/knative/serving/pkg/apis/serving" "k8s.io/apimachinery/pkg/api/equality" - "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/apimachinery/pkg/util/sets" - "k8s.io/apimachinery/pkg/util/validation" ) -var ( - reservedPaths = sets.NewString( - "/", - "/dev", - "/dev/log", // Should be a domain socket - "/tmp", - "/var", - "/var/log", - ) -) +func (r *Revision) checkImmutableFields(ctx context.Context, original *Revision) *apis.FieldError { + if diff, err := kmp.ShortDiff(original.Spec, r.Spec); err != nil { + return &apis.FieldError{ + Message: "Failed to diff Revision", + Paths: []string{"spec"}, + Details: err.Error(), + } + } else if diff != "" { + return &apis.FieldError{ + Message: "Immutable fields changed (-old +new)", + Paths: []string{"spec"}, + Details: diff, + } + } + return nil +} // Validate ensures Revision is properly configured. -func (rt *Revision) Validate(ctx context.Context) *apis.FieldError { - return ValidateObjectMetadata(rt.GetObjectMeta()).ViaField("metadata"). - Also(rt.Spec.Validate(ctx).ViaField("spec")) +func (r *Revision) Validate(ctx context.Context) *apis.FieldError { + errs := serving.ValidateObjectMetadata(r.GetObjectMeta()).ViaField("metadata") + if apis.IsInUpdate(ctx) { + old := apis.GetBaseline(ctx).(*Revision) + errs = errs.Also(r.checkImmutableFields(ctx, old)) + } else { + errs = errs.Also(r.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + } + return errs } // Validate ensures RevisionTemplateSpec is properly configured. func (rt *RevisionTemplateSpec) Validate(ctx context.Context) *apis.FieldError { - var errs *apis.FieldError - if rt.GetName() != "" { - errs = errs.Also(apis.ErrDisallowedFields(apis.CurrentField).ViaField("metadata", "name")) - } - return errs.Also(rt.Spec.Validate(ctx).ViaField("spec")) -} - -// Validate ensures RevisionSpec is properly configured. -func (rs *RevisionSpec) Validate(ctx context.Context) *apis.FieldError { - if equality.Semantic.DeepEqual(rs, &RevisionSpec{}) { - return apis.ErrMissingField(apis.CurrentField) - } - - volumes := sets.NewString() - var errs *apis.FieldError - for i, volume := range rs.Volumes { - if volumes.Has(volume.Name) { - errs = errs.Also((&apis.FieldError{ - Message: fmt.Sprintf("duplicate volume name %q", volume.Name), - Paths: []string{"name"}, - }).ViaFieldIndex("volumes", i)) + errs := rt.Spec.Validate(ctx).ViaField("spec") + + // If the DeprecatedRevisionTemplate has a name specified, then check that + // it follows the requirements on the name. + if rt.Name != "" { + om := apis.ParentMeta(ctx) + prefix := om.Name + "-" + if om.Name != "" { + // Even if there is GenerateName, allow the use + // of Name post-creation. + } else if om.GenerateName != "" { + // We disallow bringing your own name when the parent + // resource uses generateName (at creation). + return apis.ErrDisallowedFields("metadata.name") } - errs = errs.Also(validateVolume(volume).ViaFieldIndex("volumes", i)) - volumes.Insert(volume.Name) - } - - errs = errs.Also(validateContainer(rs.Container, volumes).ViaField("container")) - errs = errs.Also(validateBuildRef(rs.BuildRef).ViaField("buildRef")) - if err := rs.DeprecatedConcurrencyModel.Validate(ctx).ViaField("concurrencyModel"); err != nil { - errs = errs.Also(err) - } else { - errs = errs.Also(ValidateContainerConcurrency( - rs.ContainerConcurrency, rs.DeprecatedConcurrencyModel)) - } - - return errs.Also(validateTimeoutSeconds(rs.TimeoutSeconds)) -} - -func validateTimeoutSeconds(timeoutSeconds int64) *apis.FieldError { - if timeoutSeconds != 0 { - if timeoutSeconds > int64(networkingv1alpha1.DefaultTimeout.Seconds()) || timeoutSeconds < 0 { - return apis.ErrOutOfBoundsValue(fmt.Sprintf("%ds", timeoutSeconds), "0s", - fmt.Sprintf("%ds", int(networkingv1alpha1.DefaultTimeout.Seconds())), - "timeoutSeconds") + if !strings.HasPrefix(rt.Name, prefix) { + errs = errs.Also(apis.ErrInvalidValue( + fmt.Sprintf("%q must have prefix %q", rt.Name, prefix), + "metadata.name")) } } - return nil -} -// Validate ensures RevisionRequestConcurrencyModelType is properly configured. -func (ss DeprecatedRevisionServingStateType) Validate(ctx context.Context) *apis.FieldError { - switch ss { - case DeprecatedRevisionServingStateType(""), - DeprecatedRevisionServingStateRetired, - DeprecatedRevisionServingStateReserve, - DeprecatedRevisionServingStateActive: - return nil - default: - return apis.ErrInvalidValue(string(ss), apis.CurrentField) - } + errs = errs.Also(validateAnnotations(rt.Annotations)) + return errs } -// Validate ensures RevisionRequestConcurrencyModelType is properly configured. -func (cm RevisionRequestConcurrencyModelType) Validate(ctx context.Context) *apis.FieldError { - switch cm { - case RevisionRequestConcurrencyModelType(""), - RevisionRequestConcurrencyModelMulti, - RevisionRequestConcurrencyModelSingle: +// VerifyNameChange checks that if a user brought their own name previously that it +// changes at the appropriate times. +func (current *RevisionTemplateSpec) VerifyNameChange(ctx context.Context, og *RevisionTemplateSpec) *apis.FieldError { + if current.Name == "" { + // We only check that Name changes when the DeprecatedRevisionTemplate changes. return nil - default: - return apis.ErrInvalidValue(string(cm), apis.CurrentField) } -} - -// ValidateContainerConcurrency ensures ContainerConcurrency is properly configured. -func ValidateContainerConcurrency(cc RevisionContainerConcurrencyType, cm RevisionRequestConcurrencyModelType) *apis.FieldError { - // Validate ContainerConcurrency alone - if cc < 0 || cc > RevisionContainerConcurrencyMax { - return apis.ErrInvalidValue(strconv.Itoa(int(cc)), "containerConcurrency") + if current.Name != og.Name { + // The name changed, so we're good. + return nil } - // Validate combinations of ConcurrencyModel and ContainerConcurrency - if cc == 0 && cm != RevisionRequestConcurrencyModelMulti && cm != RevisionRequestConcurrencyModelType("") { - return apis.ErrMultipleOneOf("containerConcurrency", "concurrencyModel") - } - if cc == 1 && cm != RevisionRequestConcurrencyModelSingle && cm != RevisionRequestConcurrencyModelType("") { - return apis.ErrMultipleOneOf("containerConcurrency", "concurrencyModel") - } - if cc > 1 && cm != RevisionRequestConcurrencyModelType("") { - return apis.ErrMultipleOneOf("containerConcurrency", "concurrencyModel") + if diff, err := kmp.ShortDiff(og, current); err != nil { + return &apis.FieldError{ + Message: "Failed to diff DeprecatedRevisionTemplate", + Paths: []string{apis.CurrentField}, + Details: err.Error(), + } + } else if diff != "" { + return &apis.FieldError{ + Message: "Saw the following changes without a name change (-old +new)", + Paths: []string{apis.CurrentField}, + Details: diff, + } } - return nil } -func validateVolume(volume corev1.Volume) *apis.FieldError { - var errs *apis.FieldError - if volume.Name == "" { - errs = apis.ErrMissingField("name") - } else if len(validation.IsDNS1123Label(volume.Name)) != 0 { - errs = apis.ErrInvalidValue(volume.Name, "name") - } - - vs := volume.VolumeSource - switch { - case vs.Secret != nil, vs.ConfigMap != nil: - // These are fine. - default: - errs = errs.Also(apis.ErrMissingOneOf("secret", "configMap")) - } - return errs -} - -func validateContainer(container corev1.Container, volumes sets.String) *apis.FieldError { - if equality.Semantic.DeepEqual(container, corev1.Container{}) { +// Validate ensures RevisionSpec is properly configured. +func (rs *RevisionSpec) Validate(ctx context.Context) *apis.FieldError { + if equality.Semantic.DeepEqual(rs, &RevisionSpec{}) { return apis.ErrMissingField(apis.CurrentField) } - // Check that volume mounts match names in "volumes", that "volumes" has 100% - // coverage, and the field restrictions. - seen := sets.NewString() - var errs *apis.FieldError - for i, vm := range container.VolumeMounts { - // This effectively checks that Name is non-empty because Volume name must be non-empty. - if !volumes.Has(vm.Name) { - errs = errs.Also((&apis.FieldError{ - Message: "volumeMount has no matching volume", - Paths: []string{"name"}, - }).ViaFieldIndex("volumeMounts", i)) - } - seen.Insert(vm.Name) - - if vm.MountPath == "" { - errs = errs.Also(apis.ErrMissingField("mountPath").ViaFieldIndex("volumeMounts", i)) - } else if reservedPaths.Has(filepath.Clean(vm.MountPath)) { - errs = errs.Also((&apis.FieldError{ - Message: fmt.Sprintf("mountPath %q is a reserved path", filepath.Clean(vm.MountPath)), - Paths: []string{"mountPath"}, - }).ViaFieldIndex("volumeMounts", i)) - } else if !filepath.IsAbs(vm.MountPath) { - errs = errs.Also(apis.ErrInvalidValue(vm.MountPath, "mountPath").ViaFieldIndex("volumeMounts", i)) - } - if !vm.ReadOnly { - errs = errs.Also(apis.ErrMissingField("readOnly").ViaFieldIndex("volumeMounts", i)) - } + errs := apis.CheckDeprecated(ctx, rs) - if vm.SubPath != "" { - errs = errs.Also( - apis.ErrDisallowedFields("subPath").ViaFieldIndex("volumeMounts", i)) - } - if vm.MountPropagation != nil { - errs = errs.Also( - apis.ErrDisallowedFields("mountPropagation").ViaFieldIndex("volumeMounts", i)) + switch { + case len(rs.PodSpec.Containers) > 0 && rs.DeprecatedContainer != nil: + errs = errs.Also(apis.ErrMultipleOneOf("container", "containers")) + case len(rs.PodSpec.Containers) > 0: + errs = errs.Also(rs.RevisionSpec.Validate(ctx)) + case rs.DeprecatedContainer != nil: + volumes, err := serving.ValidateVolumes(rs.Volumes) + if err != nil { + errs = errs.Also(err.ViaField("volumes")) } + errs = errs.Also(serving.ValidateContainer( + *rs.DeprecatedContainer, volumes).ViaField("container")) + default: + errs = errs.Also(apis.ErrMissingOneOf("container", "containers")) } - if missing := volumes.Difference(seen); missing.Len() > 0 { - errs = errs.Also(&apis.FieldError{ - Message: fmt.Sprintf("volumes not mounted: %v", missing.List()), - Paths: []string{"volumeMounts"}, - }) - } - - // Some corev1.Container fields are set by Knative Serving controller. We disallow them - // here to avoid silently overwriting these fields and causing confusions for - // the users. See pkg/controller/revision/resources/deploy.go#makePodSpec. - var ignoredFields []string - if container.Name != "" { - ignoredFields = append(ignoredFields, "name") + if rs.DeprecatedBuildRef != nil { + errs = errs.Also(apis.ErrDisallowedFields("buildRef")) } - if container.Lifecycle != nil { - ignoredFields = append(ignoredFields, "lifecycle") - } - if len(ignoredFields) > 0 { - // Complain about all ignored fields so that user can remove them all at once. - errs = errs.Also(apis.ErrDisallowedFields(ignoredFields...)) - } - if err := validateContainerPorts(container.Ports); err != nil { - errs = errs.Also(err.ViaField("ports")) - } - // Validate our probes - if err := validateProbe(container.ReadinessProbe).ViaField("readinessProbe"); err != nil { - errs = errs.Also(err) - } - if err := validateProbe(container.LivenessProbe).ViaField("livenessProbe"); err != nil { + if err := rs.DeprecatedConcurrencyModel.Validate(ctx).ViaField("concurrencyModel"); err != nil { errs = errs.Also(err) + } else { + errs = errs.Also(rs.ContainerConcurrency.Validate(ctx).ViaField("containerConcurrency")) } - if _, err := name.ParseReference(container.Image, name.WeakValidation); err != nil { - fe := &apis.FieldError{ - Message: "Failed to parse image reference", - Paths: []string{"image"}, - Details: fmt.Sprintf("image: %q, error: %v", container.Image, err), - } - errs = errs.Also(fe) + + if rs.TimeoutSeconds != nil { + errs = errs.Also(validateTimeoutSeconds(ctx, *rs.TimeoutSeconds)) } return errs } -// The port is named "user-port" on the deployment, but a user cannot set an arbitrary name on the port -// in Configuration. The name field is reserved for content-negotiation. Currently 'h2c' and 'http1' are -// allowed. -// https://github.com/knative/serving/blob/master/docs/runtime-contract.md#inbound-network-connectivity -var validPortNames = sets.NewString( - "h2c", - "http1", - "", -) +func validateAnnotations(annotations map[string]string) *apis.FieldError { + return validatePercentageAnnotationKey(annotations, serving.QueueSideCarResourcePercentageAnnotation) +} -func validateContainerPorts(ports []corev1.ContainerPort) *apis.FieldError { - if len(ports) == 0 { +func validatePercentageAnnotationKey(annotations map[string]string, resourcePercentageAnnotationKey string) *apis.FieldError { + if len(annotations) == 0 { return nil } - var errs *apis.FieldError - - // user can set container port which names "user-port" to define application's port. - // Queue-proxy will use it to send requests to application - // if user didn't set any port, it will set default port user-port=8080. - if len(ports) > 1 { - errs = errs.Also(&apis.FieldError{ - Message: "More than one container port is set", - Paths: []string{apis.CurrentField}, - Details: "Only a single port is allowed", - }) - } - - userPort := ports[0] - // Only allow empty (defaulting to "TCP") or explicit TCP for protocol - if userPort.Protocol != "" && userPort.Protocol != corev1.ProtocolTCP { - errs = errs.Also(apis.ErrInvalidValue(string(userPort.Protocol), "Protocol")) - } - - // Don't allow HostIP or HostPort to be set - var disallowedFields []string - if userPort.HostIP != "" { - disallowedFields = append(disallowedFields, "HostIP") - - } - if userPort.HostPort != 0 { - disallowedFields = append(disallowedFields, "HostPort") + v, ok := annotations[resourcePercentageAnnotationKey] + if !ok { + return nil } - if len(disallowedFields) != 0 { - errs = errs.Also(apis.ErrDisallowedFields(disallowedFields...)) + value, err := strconv.ParseFloat(v, 32) + if err != nil { + return apis.ErrInvalidValue(v, apis.CurrentField).ViaKey(resourcePercentageAnnotationKey) } - // Don't allow userPort to conflict with QueueProxy sidecar - if userPort.ContainerPort == RequestQueuePort || - userPort.ContainerPort == RequestQueueAdminPort || - userPort.ContainerPort == RequestQueueMetricsPort { - errs = errs.Also(apis.ErrInvalidValue(strconv.Itoa(int(userPort.ContainerPort)), "ContainerPort")) + if value <= float64(0.1) || value > float64(100) { + return apis.ErrOutOfBoundsValue(value, 0.1, 100.0, resourcePercentageAnnotationKey) } - if userPort.ContainerPort < 1 || userPort.ContainerPort > 65535 { - errs = errs.Also(apis.ErrOutOfBoundsValue(strconv.Itoa(int(userPort.ContainerPort)), "1", "65535", "ContainerPort")) - } - - if !validPortNames.Has(userPort.Name) { - errs = errs.Also(&apis.FieldError{ - Message: fmt.Sprintf("Port name %v is not allowed", ports[0].Name), - Paths: []string{apis.CurrentField}, - Details: "Name must be empty, or one of: 'h2c', 'http1'", - }) - } - - return errs -} - -func validateBuildRef(buildRef *corev1.ObjectReference) *apis.FieldError { - if buildRef == nil { - return nil - } - if len(validation.IsQualifiedName(buildRef.APIVersion)) != 0 { - return apis.ErrInvalidValue(buildRef.APIVersion, "apiVersion") - } - if len(validation.IsCIdentifier(buildRef.Kind)) != 0 { - return apis.ErrInvalidValue(buildRef.Kind, "kind") - } - if len(validation.IsDNS1123Label(buildRef.Name)) != 0 { - return apis.ErrInvalidValue(buildRef.Name, "name") - } - var disallowedFields []string - if buildRef.Namespace != "" { - disallowedFields = append(disallowedFields, "namespace") - } - if buildRef.FieldPath != "" { - disallowedFields = append(disallowedFields, "fieldPath") - } - if buildRef.ResourceVersion != "" { - disallowedFields = append(disallowedFields, "resourceVersion") - } - if buildRef.UID != "" { - disallowedFields = append(disallowedFields, "uid") - } - if len(disallowedFields) != 0 { - return apis.ErrDisallowedFields(disallowedFields...) - } return nil } -func validateProbe(p *corev1.Probe) *apis.FieldError { - if p == nil { - return nil - } - emptyPort := intstr.IntOrString{} - switch { - case p.Handler.HTTPGet != nil: - if p.Handler.HTTPGet.Port != emptyPort { - return apis.ErrDisallowedFields("httpGet.port") - } - case p.Handler.TCPSocket != nil: - if p.Handler.TCPSocket.Port != emptyPort { - return apis.ErrDisallowedFields("tcpSocket.port") +func validateTimeoutSeconds(ctx context.Context, timeoutSeconds int64) *apis.FieldError { + if timeoutSeconds != 0 { + cfg := config.FromContextOrDefaults(ctx) + if timeoutSeconds > cfg.Defaults.MaxRevisionTimeoutSeconds || timeoutSeconds < 0 { + return apis.ErrOutOfBoundsValue(timeoutSeconds, 0, + cfg.Defaults.MaxRevisionTimeoutSeconds, + "timeoutSeconds") } } return nil } -// CheckImmutableFields checks the immutable fields are not modified. -func (current *Revision) CheckImmutableFields(ctx context.Context, og apis.Immutable) *apis.FieldError { - original, ok := og.(*Revision) - if !ok { - return &apis.FieldError{Message: "The provided original was not a Revision"} +// Validate ensures DeprecatedRevisionServingStateType is properly configured. +func (ss DeprecatedRevisionServingStateType) Validate(ctx context.Context) *apis.FieldError { + switch ss { + case DeprecatedRevisionServingStateType(""), + DeprecatedRevisionServingStateRetired, + DeprecatedRevisionServingStateReserve, + DeprecatedRevisionServingStateActive: + return nil + default: + return apis.ErrInvalidValue(ss, apis.CurrentField) } +} - if diff, err := kmp.SafeDiff(original.Spec, current.Spec); err != nil { - return &apis.FieldError{ - Message: "Failed to diff Revision", - Paths: []string{"spec"}, - Details: err.Error(), - } - } else if diff != "" { - return &apis.FieldError{ - Message: "Immutable fields changed (-old +new)", - Paths: []string{"spec"}, - Details: diff, - } +// Validate ensures RevisionRequestConcurrencyModelType is properly configured. +func (cm RevisionRequestConcurrencyModelType) Validate(ctx context.Context) *apis.FieldError { + switch cm { + case RevisionRequestConcurrencyModelType(""), + RevisionRequestConcurrencyModelMulti, + RevisionRequestConcurrencyModelSingle: + return nil + default: + return apis.ErrInvalidValue(cm, apis.CurrentField) } - - return nil } diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_conversion.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_conversion.go new file mode 100644 index 0000000000..cec81bbc09 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_conversion.go @@ -0,0 +1,137 @@ +/* +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" + "fmt" + + "knative.dev/pkg/apis" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + "github.com/knative/serving/pkg/apis/serving/v1beta1" +) + +// ConvertUp implements apis.Convertible +func (source *Route) ConvertUp(ctx context.Context, obj apis.Convertible) error { + switch sink := obj.(type) { + case *v1beta1.Route: + sink.ObjectMeta = source.ObjectMeta + source.Status.ConvertUp(apis.WithinStatus(ctx), &sink.Status) + return source.Spec.ConvertUp(apis.WithinSpec(ctx), &sink.Spec) + default: + return fmt.Errorf("unknown version, got: %T", sink) + } +} + +// ConvertUp helps implement apis.Convertible +func (source *RouteSpec) ConvertUp(ctx context.Context, sink *v1beta1.RouteSpec) error { + sink.Traffic = make([]v1beta1.TrafficTarget, len(source.Traffic)) + for i := range source.Traffic { + if err := source.Traffic[i].ConvertUp(ctx, &sink.Traffic[i]); err != nil { + return err + } + } + return nil +} + +// ConvertUp helps implement apis.Convertible +func (source *TrafficTarget) ConvertUp(ctx context.Context, sink *v1beta1.TrafficTarget) error { + *sink = source.TrafficTarget + switch { + case source.Tag != "" && source.DeprecatedName != "": + if apis.IsInSpec(ctx) { + return apis.ErrMultipleOneOf("name", "tag") + } + case source.DeprecatedName != "": + sink.Tag = source.DeprecatedName + } + return nil +} + +// ConvertUp helps implement apis.Convertible +func (source *RouteStatus) ConvertUp(ctx context.Context, sink *v1beta1.RouteStatus) { + source.Status.ConvertTo(ctx, &sink.Status) + + source.RouteStatusFields.ConvertUp(ctx, &sink.RouteStatusFields) +} + +// ConvertUp helps implement apis.Convertible +func (source *RouteStatusFields) ConvertUp(ctx context.Context, sink *v1beta1.RouteStatusFields) { + if source.URL != nil { + sink.URL = source.URL.DeepCopy() + } + + if source.Address != nil { + sink.Address = source.Address.Addressable.DeepCopy() + } + + sink.Traffic = make([]v1beta1.TrafficTarget, len(source.Traffic)) + for i := range source.Traffic { + source.Traffic[i].ConvertUp(ctx, &sink.Traffic[i]) + } +} + +// ConvertDown implements apis.Convertible +func (sink *Route) ConvertDown(ctx context.Context, obj apis.Convertible) error { + switch source := obj.(type) { + case *v1beta1.Route: + sink.ObjectMeta = source.ObjectMeta + sink.Spec.ConvertDown(ctx, source.Spec) + sink.Status.ConvertDown(ctx, source.Status) + return nil + default: + return fmt.Errorf("unknown version, got: %T", source) + } +} + +// ConvertDown helps implement apis.Convertible +func (sink *RouteSpec) ConvertDown(ctx context.Context, source v1beta1.RouteSpec) { + sink.Traffic = make([]TrafficTarget, len(source.Traffic)) + for i := range source.Traffic { + sink.Traffic[i].ConvertDown(ctx, source.Traffic[i]) + } +} + +// ConvertDown helps implement apis.Convertible +func (sink *TrafficTarget) ConvertDown(ctx context.Context, source v1beta1.TrafficTarget) { + sink.TrafficTarget = source +} + +// ConvertDown helps implement apis.Convertible +func (sink *RouteStatus) ConvertDown(ctx context.Context, source v1beta1.RouteStatus) { + source.Status.ConvertTo(ctx, &sink.Status) + + sink.RouteStatusFields.ConvertDown(ctx, source.RouteStatusFields) +} + +// ConvertDown helps implement apis.Convertible +func (sink *RouteStatusFields) ConvertDown(ctx context.Context, source v1beta1.RouteStatusFields) { + if source.URL != nil { + sink.URL = source.URL.DeepCopy() + } + + if source.Address != nil { + sink.Address = &duckv1alpha1.Addressable{ + Addressable: *source.Address, + } + } + + sink.Traffic = make([]TrafficTarget, len(source.Traffic)) + for i := range source.Traffic { + sink.Traffic[i].ConvertDown(ctx, source.Traffic[i]) + } +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_defaults.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_defaults.go index e320558364..3e1e024a32 100644 --- a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_defaults.go +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_defaults.go @@ -16,11 +16,38 @@ limitations under the License. package v1alpha1 -import "context" +import ( + "context" + + "knative.dev/pkg/apis" + "knative.dev/pkg/ptr" + "github.com/knative/serving/pkg/apis/serving/v1beta1" +) func (r *Route) SetDefaults(ctx context.Context) { - r.Spec.SetDefaults(ctx) + r.Spec.SetDefaults(apis.WithinSpec(ctx)) } func (rs *RouteSpec) SetDefaults(ctx context.Context) { + if v1beta1.IsUpgradeViaDefaulting(ctx) { + beta := v1beta1.RouteSpec{} + if rs.ConvertUp(ctx, &beta) == nil { + alpha := RouteSpec{} + alpha.ConvertDown(ctx, beta) + *rs = alpha + } + } + + if len(rs.Traffic) == 0 && v1beta1.HasDefaultConfigurationName(ctx) { + rs.Traffic = []TrafficTarget{{ + TrafficTarget: v1beta1.TrafficTarget{ + Percent: 100, + LatestRevision: ptr.Bool(true), + }, + }} + } + + for i := range rs.Traffic { + rs.Traffic[i].SetDefaults(ctx) + } } diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_lifecycle.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_lifecycle.go index 8c89decfc0..b8a846e217 100644 --- a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_lifecycle.go +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_lifecycle.go @@ -22,11 +22,12 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime/schema" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "github.com/knative/serving/pkg/apis/networking/v1alpha1" ) -var routeCondSet = duckv1alpha1.NewLivingConditionSet( +var routeCondSet = apis.NewLivingConditionSet( RouteConditionAllTrafficAssigned, RouteConditionIngressReady, ) @@ -39,7 +40,7 @@ func (rs *RouteStatus) IsReady() bool { return routeCondSet.Manage(rs).IsHappy() } -func (rs *RouteStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition { +func (rs *RouteStatus) GetCondition(t apis.ConditionType) *apis.Condition { return routeCondSet.Manage(rs).GetCondition(t) } @@ -47,6 +48,18 @@ func (rs *RouteStatus) InitializeConditions() { routeCondSet.Manage(rs).InitializeConditions() } +// // MarkResourceNotConvertible adds a Warning-severity condition to the resource noting that +// // it cannot be converted to a higher version. +// func (rs *RouteStatus) MarkResourceNotConvertible(err *CannotConvertError) { +// routeCondSet.Manage(rs).SetCondition(apis.Condition{ +// Type: ConditionTypeConvertible, +// Status: corev1.ConditionFalse, +// Severity: apis.ConditionSeverityWarning, +// Reason: err.Field, +// Message: err.Message, +// }) +// } + // MarkServiceNotOwned changes the IngressReady status to be false with the reason being that // there is a pre-existing placeholder service with the name we wanted to use. func (rs *RouteStatus) MarkServiceNotOwned(name string) { @@ -54,6 +67,13 @@ func (rs *RouteStatus) MarkServiceNotOwned(name string) { fmt.Sprintf("There is an existing placeholder Service %q that we do not own.", name)) } +// MarkIngressNotConfigured changes the IngressReady condition to be unknown to reflect +// that the Ingress does not yet have a Status +func (rs *RouteStatus) MarkIngressNotConfigured() { + routeCondSet.Manage(rs).MarkUnknown(RouteConditionIngressReady, + "IngressNotConfigured", "Ingress has not yet been reconciled.") +} + func (rs *RouteStatus) MarkTrafficAssigned() { routeCondSet.Manage(rs).MarkTrue(RouteConditionAllTrafficAssigned) } @@ -92,11 +112,52 @@ func (rs *RouteStatus) MarkMissingTrafficTarget(kind, name string) { "%s %q referenced in traffic not found.", kind, name) } +func (rs *RouteStatus) MarkCertificateProvisionFailed(name string) { + routeCondSet.Manage(rs).SetCondition(apis.Condition{ + Type: RouteConditionCertificateProvisioned, + Status: corev1.ConditionFalse, + Severity: apis.ConditionSeverityWarning, + Reason: "CertificateProvisionFailed", + Message: fmt.Sprintf("Certificate %s fails to be provisioned.", name), + }) +} + +func (rs *RouteStatus) MarkCertificateReady(name string) { + routeCondSet.Manage(rs).SetCondition(apis.Condition{ + Type: RouteConditionCertificateProvisioned, + Status: corev1.ConditionTrue, + Severity: apis.ConditionSeverityWarning, + Reason: "CertificateReady", + Message: fmt.Sprintf("Certificate %s is successfully provisioned", name), + }) +} + +func (rs *RouteStatus) MarkCertificateNotReady(name string) { + routeCondSet.Manage(rs).SetCondition(apis.Condition{ + Type: RouteConditionCertificateProvisioned, + Status: corev1.ConditionUnknown, + Severity: apis.ConditionSeverityWarning, + Reason: "CertificateNotReady", + Message: fmt.Sprintf("Certificate %s is not ready.", name), + }) +} + +func (rs *RouteStatus) MarkCertificateNotOwned(name string) { + routeCondSet.Manage(rs).SetCondition(apis.Condition{ + Type: RouteConditionCertificateProvisioned, + Status: corev1.ConditionFalse, + Severity: apis.ConditionSeverityWarning, + Reason: "CertificateNotOwned", + Message: fmt.Sprintf("There is an existing certificate %s that we don't own.", name), + }) +} + // PropagateClusterIngressStatus update RouteConditionIngressReady condition // in RouteStatus according to IngressStatus. func (rs *RouteStatus) PropagateClusterIngressStatus(cs v1alpha1.IngressStatus) { - cc := cs.GetCondition(v1alpha1.ClusterIngressConditionReady) + cc := cs.GetCondition(v1alpha1.IngressConditionReady) if cc == nil { + rs.MarkIngressNotConfigured() return } switch { @@ -108,3 +169,7 @@ func (rs *RouteStatus) PropagateClusterIngressStatus(cs v1alpha1.IngressStatus) routeCondSet.Manage(rs).MarkFalse(RouteConditionIngressReady, cc.Reason, cc.Message) } } + +func (rs *RouteStatus) duck() *duckv1beta1.Status { + return &rs.Status +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_types.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_types.go index e4c0269d45..0d86035d4b 100644 --- a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_types.go +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_types.go @@ -19,9 +19,12 @@ package v1alpha1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/knative/pkg/apis" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" - "github.com/knative/pkg/kmeta" + "knative.dev/pkg/apis" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/kmeta" + + "github.com/knative/serving/pkg/apis/serving/v1beta1" ) // +genclient @@ -53,6 +56,9 @@ var ( _ apis.Validatable = (*Route)(nil) _ apis.Defaultable = (*Route)(nil) + // Check that Route can be converted to higher versions. + _ apis.Convertible = (*Route)(nil) + // Check that we can create OwnerReferences to a Route. _ kmeta.OwnerRefable = (*Route)(nil) ) @@ -62,30 +68,11 @@ type TrafficTarget struct { // Name is optionally used to expose a dedicated hostname for referencing this // target exclusively. It has the form: {name}.${route.status.domain} // +optional - Name string `json:"name,omitempty"` - - // RevisionName of a specific revision to which to send this portion of traffic. - // This is mutually exclusive with ConfigurationName. - // +optional - RevisionName string `json:"revisionName,omitempty"` - - // ConfigurationName of a configuration to whose latest revision we will send - // this portion of traffic. When the "status.latestReadyRevisionName" of the - // referenced configuration changes, we will automatically migrate traffic - // from the prior "latest ready" revision to the new one. - // This field is never set in Route's status, only its spec. - // This is mutually exclusive with RevisionName. - // +optional - ConfigurationName string `json:"configurationName,omitempty"` + DeprecatedName string `json:"name,omitempty"` - // Percent specifies percent of the traffic to this Revision or Configuration. - // This defaults to zero if unspecified. - Percent int `json:"percent"` - - // URL displays the URL for accessing named traffic targets. URL is displayed in - // status, and is disallowed on spec. URL must contain a scheme (e.g. http://) and - // a hostname, but may not contain anything else (e.g. basic auth, url path, etc.) - URL string `json:"url,omitempty"` + // We inherit most of our fields by inlining the v1beta1 type. + // Ultimately all non-v1beta1 fields will be deprecated. + v1beta1.TrafficTarget `json:",inline"` } // RouteSpec holds the desired state of the Route (from the client). @@ -109,26 +96,35 @@ type RouteSpec struct { const ( // RouteConditionReady is set when the service is configured // and has available backends ready to receive traffic. - RouteConditionReady = duckv1alpha1.ConditionReady + RouteConditionReady = apis.ConditionReady // RouteConditionAllTrafficAssigned is set to False when the // service is not configured properly or has no available // backends ready to receive traffic. - RouteConditionAllTrafficAssigned duckv1alpha1.ConditionType = "AllTrafficAssigned" + RouteConditionAllTrafficAssigned apis.ConditionType = "AllTrafficAssigned" // RouteConditionIngressReady is set to False when the // ClusterIngress fails to become Ready. - RouteConditionIngressReady duckv1alpha1.ConditionType = "IngressReady" + RouteConditionIngressReady apis.ConditionType = "IngressReady" + + // RouteConditionCertificateProvisioned is set to False when the + // Knative Certificates fail to be provisioned for the Route. + RouteConditionCertificateProvisioned apis.ConditionType = "CertificateProvisioned" ) -// RouteStatusFields holds all of the non-duckv1alpha1.Status status fields of a Route. +// RouteStatusFields holds all of the non-duckv1beta1.Status status fields of a Route. // These are defined outline so that we can also inline them into Service, and more easily // copy them. type RouteStatusFields struct { - // Domain holds the top-level domain that will distribute traffic over the provided targets. + // URL holds the url that will distribute traffic over the provided traffic targets. + // It generally has the form http[s]://{route-name}.{route-namespace}.{cluster-level-suffix} + // +optional + URL *apis.URL `json:"url,omitempty"` + + // DeprecatedDomain holds the top-level domain that will distribute traffic over the provided targets. // It generally has the form {route-name}.{route-namespace}.{cluster-level-suffix} // +optional - Domain string `json:"domain,omitempty"` + DeprecatedDomain string `json:"domain,omitempty"` // DeprecatedDomainInternal holds the top-level domain that will distribute traffic over the provided // targets from inside the cluster. It generally has the form @@ -151,7 +147,7 @@ type RouteStatusFields struct { // RouteStatus communicates the observed state of the Route (from the controller). type RouteStatus struct { - duckv1alpha1.Status `json:",inline"` + duckv1beta1.Status `json:",inline"` RouteStatusFields `json:",inline"` } diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_validation.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_validation.go index 3550a9d11b..d1ce8193ee 100644 --- a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_validation.go +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_validation.go @@ -19,17 +19,16 @@ package v1alpha1 import ( "context" "fmt" - "strconv" + "knative.dev/pkg/apis" + "github.com/knative/serving/pkg/apis/serving" "k8s.io/apimachinery/pkg/api/equality" - - "github.com/knative/pkg/apis" - "k8s.io/apimachinery/pkg/util/validation" ) func (r *Route) Validate(ctx context.Context) *apis.FieldError { - return ValidateObjectMetadata(r.GetObjectMeta()).ViaField("metadata"). - Also(r.Spec.Validate(ctx).ViaField("spec")) + errs := serving.ValidateObjectMetadata(r.GetObjectMeta()).ViaField("metadata") + errs = errs.Also(r.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + return errs } func (rs *RouteSpec) Validate(ctx context.Context) *apis.FieldError { @@ -37,43 +36,50 @@ func (rs *RouteSpec) Validate(ctx context.Context) *apis.FieldError { return apis.ErrMissingField(apis.CurrentField) } - // Where a named traffic target points - type namedTarget struct { - r string // revision name - c string // config name - i int // index of first occurrence - } + errs := apis.CheckDeprecated(ctx, rs) + type diagnostic struct { + index int + field string + } // Track the targets of named TrafficTarget entries (to detect duplicates). - trafficMap := make(map[string]namedTarget) + trafficMap := make(map[string]diagnostic) - var errs *apis.FieldError percentSum := 0 for i, tt := range rs.Traffic { - errs = errs.Also(tt.Validate(ctx).ViaFieldIndex("traffic", i)) + // Delegate to the v1beta1 validation. + errs = errs.Also(tt.TrafficTarget.Validate(ctx).ViaFieldIndex("traffic", i)) percentSum += tt.Percent - if tt.Name == "" { + if tt.DeprecatedName != "" && tt.Tag != "" { + errs = errs.Also(apis.ErrMultipleOneOf("name", "tag"). + ViaFieldIndex("traffic", i)) + } else if tt.DeprecatedName == "" && tt.Tag == "" { // No Name field, so skip the uniqueness check. continue } - nt := namedTarget{ - r: tt.RevisionName, - c: tt.ConfigurationName, - i: i, + + errs = errs.Also(apis.CheckDeprecated(ctx, tt).ViaFieldIndex("traffic", i)) + + name := tt.DeprecatedName + field := "name" + if name == "" { + name = tt.Tag + field = "tag" } - if ent, ok := trafficMap[tt.Name]; !ok { + + if d, ok := trafficMap[name]; !ok { // No entry exists, so add ours - trafficMap[tt.Name] = nt + trafficMap[name] = diagnostic{i, field} } else { // We want only single definition of the route, even if it points // to the same config or revision. errs = errs.Also(&apis.FieldError{ - Message: fmt.Sprintf("Multiple definitions for %q", tt.Name), + Message: fmt.Sprintf("Multiple definitions for %q", name), Paths: []string{ - fmt.Sprintf("traffic[%d].name", ent.i), - fmt.Sprintf("traffic[%d].name", nt.i), + fmt.Sprintf("traffic[%d].%s", d.index, d.field), + fmt.Sprintf("traffic[%d].%s", i, field), }, }) } @@ -87,29 +93,3 @@ func (rs *RouteSpec) Validate(ctx context.Context) *apis.FieldError { } return errs } - -// Validate verifies that TrafficTarget is properly configured. -func (tt *TrafficTarget) Validate(ctx context.Context) *apis.FieldError { - var errs *apis.FieldError - switch { - case tt.RevisionName != "" && tt.ConfigurationName != "": - errs = apis.ErrMultipleOneOf("revisionName", "configurationName") - case tt.RevisionName != "": - if verrs := validation.IsQualifiedName(tt.RevisionName); len(verrs) > 0 { - errs = apis.ErrInvalidKeyName(tt.RevisionName, "revisionName", verrs...) - } - case tt.ConfigurationName != "": - if verrs := validation.IsQualifiedName(tt.ConfigurationName); len(verrs) > 0 { - errs = apis.ErrInvalidKeyName(tt.ConfigurationName, "configurationName", verrs...) - } - default: - errs = apis.ErrMissingOneOf("revisionName", "configurationName") - } - if tt.Percent < 0 || tt.Percent > 100 { - errs = errs.Also(apis.ErrOutOfBoundsValue(strconv.Itoa(tt.Percent), "0", "100", "percent")) - } - if tt.URL != "" { - errs = errs.Also(apis.ErrDisallowedFields("url")) - } - return errs -} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_conversion.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_conversion.go new file mode 100644 index 0000000000..321cd83b86 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_conversion.go @@ -0,0 +1,144 @@ +/* +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" + "fmt" + + "knative.dev/pkg/apis" + "knative.dev/pkg/ptr" + "github.com/knative/serving/pkg/apis/serving/v1beta1" +) + +// ConvertUp implements apis.Convertible +func (source *Service) ConvertUp(ctx context.Context, obj apis.Convertible) error { + switch sink := obj.(type) { + case *v1beta1.Service: + sink.ObjectMeta = source.ObjectMeta + if err := source.Spec.ConvertUp(ctx, &sink.Spec); err != nil { + return err + } + return source.Status.ConvertUp(ctx, &sink.Status) + default: + return fmt.Errorf("unknown version, got: %T", sink) + } +} + +// ConvertUp helps implement apis.Convertible +func (source *ServiceSpec) ConvertUp(ctx context.Context, sink *v1beta1.ServiceSpec) error { + switch { + case source.DeprecatedRunLatest != nil: + sink.RouteSpec = v1beta1.RouteSpec{ + Traffic: []v1beta1.TrafficTarget{{ + Percent: 100, + LatestRevision: ptr.Bool(true), + }}, + } + return source.DeprecatedRunLatest.Configuration.ConvertUp(ctx, &sink.ConfigurationSpec) + + case source.DeprecatedRelease != nil: + if len(source.DeprecatedRelease.Revisions) == 2 { + sink.RouteSpec = v1beta1.RouteSpec{ + Traffic: []v1beta1.TrafficTarget{{ + RevisionName: source.DeprecatedRelease.Revisions[0], + Percent: 100 - source.DeprecatedRelease.RolloutPercent, + Tag: "current", + }, { + RevisionName: source.DeprecatedRelease.Revisions[1], + Percent: source.DeprecatedRelease.RolloutPercent, + Tag: "candidate", + }, { + Percent: 0, + Tag: "latest", + LatestRevision: ptr.Bool(true), + }}, + } + } else { + sink.RouteSpec = v1beta1.RouteSpec{ + Traffic: []v1beta1.TrafficTarget{{ + RevisionName: source.DeprecatedRelease.Revisions[0], + Percent: 100, + Tag: "current", + }, { + Percent: 0, + Tag: "latest", + LatestRevision: ptr.Bool(true), + }}, + } + } + for i, tt := range sink.RouteSpec.Traffic { + if tt.RevisionName == "@latest" { + sink.RouteSpec.Traffic[i].RevisionName = "" + sink.RouteSpec.Traffic[i].LatestRevision = ptr.Bool(true) + } + } + return source.DeprecatedRelease.Configuration.ConvertUp(ctx, &sink.ConfigurationSpec) + + case source.DeprecatedPinned != nil: + sink.RouteSpec = v1beta1.RouteSpec{ + Traffic: []v1beta1.TrafficTarget{{ + RevisionName: source.DeprecatedPinned.RevisionName, + Percent: 100, + }}, + } + return source.DeprecatedPinned.Configuration.ConvertUp(ctx, &sink.ConfigurationSpec) + + case source.DeprecatedManual != nil: + return ConvertErrorf("manual", "manual mode cannot be migrated forward.") + + default: + source.RouteSpec.ConvertUp(ctx, &sink.RouteSpec) + return source.ConfigurationSpec.ConvertUp(ctx, &sink.ConfigurationSpec) + } +} + +// ConvertUp helps implement apis.Convertible +func (source *ServiceStatus) ConvertUp(ctx context.Context, sink *v1beta1.ServiceStatus) error { + source.Status.ConvertTo(ctx, &sink.Status) + + source.RouteStatusFields.ConvertUp(ctx, &sink.RouteStatusFields) + return source.ConfigurationStatusFields.ConvertUp(ctx, &sink.ConfigurationStatusFields) +} + +// ConvertDown implements apis.Convertible +func (sink *Service) ConvertDown(ctx context.Context, obj apis.Convertible) error { + switch source := obj.(type) { + case *v1beta1.Service: + sink.ObjectMeta = source.ObjectMeta + if err := sink.Spec.ConvertDown(ctx, source.Spec); err != nil { + return err + } + return sink.Status.ConvertDown(ctx, source.Status) + default: + return fmt.Errorf("unknown version, got: %T", source) + } +} + +// ConvertDown helps implement apis.Convertible +func (sink *ServiceSpec) ConvertDown(ctx context.Context, source v1beta1.ServiceSpec) error { + sink.RouteSpec.ConvertDown(ctx, source.RouteSpec) + return sink.ConfigurationSpec.ConvertDown(ctx, source.ConfigurationSpec) +} + +// ConvertDown helps implement apis.Convertible +func (sink *ServiceStatus) ConvertDown(ctx context.Context, source v1beta1.ServiceStatus) error { + source.Status.ConvertTo(ctx, &sink.Status) + + sink.RouteStatusFields.ConvertDown(ctx, source.RouteStatusFields) + return sink.ConfigurationStatusFields.ConvertDown(ctx, source.ConfigurationStatusFields) +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_defaults.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_defaults.go index 6bcba797e6..8dee71bc8a 100644 --- a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_defaults.go +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_defaults.go @@ -16,18 +16,60 @@ limitations under the License. package v1alpha1 -import "context" +import ( + "context" + + "knative.dev/pkg/apis" + "k8s.io/apimachinery/pkg/api/equality" + + "github.com/knative/serving/pkg/apis/serving" + "github.com/knative/serving/pkg/apis/serving/v1beta1" +) func (s *Service) SetDefaults(ctx context.Context) { - s.Spec.SetDefaults(ctx) + ctx = apis.WithinParent(ctx, s.ObjectMeta) + s.Spec.SetDefaults(apis.WithinSpec(ctx)) + + if ui := apis.GetUserInfo(ctx); ui != nil { + ans := s.GetAnnotations() + if ans == nil { + ans = map[string]string{} + defer s.SetAnnotations(ans) + } + + if apis.IsInUpdate(ctx) { + old := apis.GetBaseline(ctx).(*Service) + if equality.Semantic.DeepEqual(old.Spec, s.Spec) { + return + } + ans[serving.UpdaterAnnotation] = ui.Username + } else { + ans[serving.CreatorAnnotation] = ui.Username + ans[serving.UpdaterAnnotation] = ui.Username + } + } } func (ss *ServiceSpec) SetDefaults(ctx context.Context) { - if ss.RunLatest != nil { - ss.RunLatest.Configuration.SetDefaults(ctx) + if v1beta1.IsUpgradeViaDefaulting(ctx) { + beta := v1beta1.ServiceSpec{} + if ss.ConvertUp(ctx, &beta) == nil { + alpha := ServiceSpec{} + if alpha.ConvertDown(ctx, beta) == nil { + *ss = alpha + } + } + } + + if ss.DeprecatedRunLatest != nil { + ss.DeprecatedRunLatest.Configuration.SetDefaults(ctx) } else if ss.DeprecatedPinned != nil { ss.DeprecatedPinned.Configuration.SetDefaults(ctx) - } else if ss.Release != nil { - ss.Release.Configuration.SetDefaults(ctx) + } else if ss.DeprecatedRelease != nil { + ss.DeprecatedRelease.Configuration.SetDefaults(ctx) + } else if ss.DeprecatedManual != nil { + } else { + ss.ConfigurationSpec.SetDefaults(ctx) + ss.RouteSpec.SetDefaults(v1beta1.WithDefaultConfigurationName(ctx)) } } diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_lifecycle.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_lifecycle.go index 97684169b8..76402e6d93 100644 --- a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_lifecycle.go +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_lifecycle.go @@ -17,19 +17,16 @@ limitations under the License. package v1alpha1 import ( - "context" "fmt" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/runtime/schema" - "github.com/knative/pkg/apis" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" - authv1 "k8s.io/api/authentication/v1" + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" ) -var serviceCondSet = duckv1alpha1.NewLivingConditionSet( +var serviceCondSet = apis.NewLivingConditionSet( ServiceConditionConfigurationsReady, ServiceConditionRoutesReady, ) @@ -45,7 +42,7 @@ func (ss *ServiceStatus) IsReady() bool { } // GetCondition returns the condition by name. -func (ss *ServiceStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition { +func (ss *ServiceStatus) GetCondition(t apis.ConditionType) *apis.Condition { return serviceCondSet.Manage(ss).GetCondition(t) } @@ -54,6 +51,18 @@ func (ss *ServiceStatus) InitializeConditions() { serviceCondSet.Manage(ss).InitializeConditions() } +// MarkResourceNotConvertible adds a Warning-severity condition to the resource noting that +// it cannot be converted to a higher version. +func (ss *ServiceStatus) MarkResourceNotConvertible(err *CannotConvertError) { + serviceCondSet.Manage(ss).SetCondition(apis.Condition{ + Type: ConditionTypeConvertible, + Status: corev1.ConditionFalse, + Severity: apis.ConditionSeverityWarning, + Reason: err.Field, + Message: err.Message, + }) +} + // MarkConfigurationNotOwned surfaces a failure via the ConfigurationsReady // status noting that the Configuration with the name we want has already // been created and we do not own it. @@ -69,6 +78,13 @@ func (ss *ServiceStatus) MarkRouteNotOwned(name string) { fmt.Sprintf("There is an existing Route %q that we do not own.", name)) } +// MarkConfigurationNotReconciled notes that the Configuration controller has not yet +// caught up to the desired changes we have specified. +func (ss *ServiceStatus) MarkConfigurationNotReconciled() { + serviceCondSet.Manage(ss).MarkUnknown(ServiceConditionConfigurationsReady, + "OutOfDate", "The Configuration is still working to reflect the latest desired specification.") +} + // PropagateConfigurationStatus takes the Configuration status and applies its values // to the Service status. func (ss *ServiceStatus) PropagateConfigurationStatus(cs *ConfigurationStatus) { @@ -88,6 +104,13 @@ func (ss *ServiceStatus) PropagateConfigurationStatus(cs *ConfigurationStatus) { } } +// MarkRevisionNameTaken notes that the Route has not been programmed because the revision name is taken by a +// conflicting revision definition. +func (ss *ServiceStatus) MarkRevisionNameTaken(name string) { + serviceCondSet.Manage(ss).MarkFalse(ServiceConditionRoutesReady, "RevisionNameTaken", + "The revision name %q is taken by a conflicting Revision, so traffic will not be migrated", name) +} + const ( trafficNotMigratedReason = "TrafficNotMigrated" trafficNotMigratedMessage = "Traffic is not yet migrated to the latest revision." @@ -108,6 +131,13 @@ func (ss *ServiceStatus) MarkRouteNotYetReady() { serviceCondSet.Manage(ss).MarkUnknown(ServiceConditionRoutesReady, trafficNotMigratedReason, trafficNotMigratedMessage) } +// MarkRouteNotReconciled notes that the Route controller has not yet +// caught up to the desired changes we have specified. +func (ss *ServiceStatus) MarkRouteNotReconciled() { + serviceCondSet.Manage(ss).MarkUnknown(ServiceConditionRoutesReady, + "OutOfDate", "The Route is still working to reflect the latest desired specification.") +} + // PropagateRouteStatus propagates route's status to the service's status. func (ss *ServiceStatus) PropagateRouteStatus(rs *RouteStatus) { ss.RouteStatusFields = rs.RouteStatusFields @@ -126,60 +156,6 @@ func (ss *ServiceStatus) PropagateRouteStatus(rs *RouteStatus) { } } -// SetManualStatus updates the service conditions to unknown as the underlying Route -// can have TrafficTargets to Configurations not owned by the service. We do not want to falsely -// report Ready. -func (ss *ServiceStatus) SetManualStatus() { - const ( - reason = "Manual" - message = "Service is set to Manual, and is not managing underlying resources." - ) - - // Clear our fields by creating a new status and copying over only the fields and conditions we want - newStatus := &ServiceStatus{} - newStatus.InitializeConditions() - serviceCondSet.Manage(newStatus).MarkUnknown(ServiceConditionConfigurationsReady, reason, message) - serviceCondSet.Manage(newStatus).MarkUnknown(ServiceConditionRoutesReady, reason, message) - - newStatus.Address = ss.Address - newStatus.Domain = ss.Domain - newStatus.DeprecatedDomainInternal = ss.DeprecatedDomainInternal - - *ss = *newStatus -} - -const ( - // CreatorAnnotation is the annotation key to describe the user that - // created the resource. - CreatorAnnotation = "serving.knative.dev/creator" - // UpdaterAnnotation is the annotation key to describe the user that - // last updated the resource. - UpdaterAnnotation = "serving.knative.dev/lastModifier" -) - -// AnnotateUserInfo satisfay the apis.Annotatable interface, and set the proper annotations -// on the Service resource about the user that performed the action. -func (s *Service) AnnotateUserInfo(ctx context.Context, prev apis.Annotatable, ui *authv1.UserInfo) { - ans := s.GetAnnotations() - if ans == nil { - ans = map[string]string{} - defer s.SetAnnotations(ans) - } - - // WebHook makes sure we get the proper type here. - ps, _ := prev.(*Service) - - // Creation. - if ps == nil { - ans[CreatorAnnotation] = ui.Username - ans[UpdaterAnnotation] = ui.Username - return - } - - // Compare the Spec's, we update the `lastModifier` key iff - // there's a change in the spec. - if equality.Semantic.DeepEqual(ps.Spec, s.Spec) { - return - } - ans[UpdaterAnnotation] = ui.Username +func (ss *ServiceStatus) duck() *duckv1beta1.Status { + return &ss.Status } diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_types.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_types.go index fbd59479e1..af6d63f61e 100644 --- a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_types.go +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_types.go @@ -19,9 +19,9 @@ package v1alpha1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/knative/pkg/apis" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" - "github.com/knative/pkg/kmeta" + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/kmeta" ) // +genclient @@ -55,6 +55,9 @@ var ( _ apis.Validatable = (*Service)(nil) _ apis.Defaultable = (*Service)(nil) + // Check that Route can be converted to higher versions. + _ apis.Convertible = (*Service)(nil) + // Check that we can create OwnerReferences to a Service. _ kmeta.OwnerRefable = (*Service)(nil) ) @@ -75,32 +78,40 @@ type ServiceSpec struct { // +optional DeprecatedGeneration int64 `json:"generation,omitempty"` - // RunLatest defines a simple Service. It will automatically + // DeprecatedRunLatest defines a simple Service. It will automatically // configure a route that keeps the latest ready revision // from the supplied configuration running. // +optional - RunLatest *RunLatestType `json:"runLatest,omitempty"` + DeprecatedRunLatest *RunLatestType `json:"runLatest,omitempty"` // DeprecatedPinned is DEPRECATED in favor of ReleaseType // +optional DeprecatedPinned *PinnedType `json:"pinned,omitempty"` - // Manual mode enables users to start managing the underlying Route and Configuration + // DeprecatedManual mode enables users to start managing the underlying Route and Configuration // resources directly. This advanced usage is intended as a path for users to graduate // from the limited capabilities of Service to the full power of Route. // +optional - Manual *ManualType `json:"manual,omitempty"` + DeprecatedManual *ManualType `json:"manual,omitempty"` // Release enables gradual promotion of new revisions by allowing traffic // to be split between two revisions. This type replaces the deprecated Pinned type. // +optional - Release *ReleaseType `json:"release,omitempty"` + DeprecatedRelease *ReleaseType `json:"release,omitempty"` + + // We are moving to a shape where the Configuration and Route specifications + // are inlined into the Service, which gives them compatible shapes. We are + // staging this change here as a path to this in v1beta1, which drops the + // "mode" based specifications above. Ultimately all non-v1beta1 fields will + // be deprecated, and then dropped in v1beta1. + ConfigurationSpec `json:",inline"` + RouteSpec `json:",inline"` } // ManualType contains the options for configuring a manual service. See ServiceSpec for // more details. type ManualType struct { - // Manual type does not contain a configuration as this type provides the + // DeprecatedManual type does not contain a configuration as this type provides the // user complete control over the configuration and route. } @@ -154,18 +165,18 @@ type PinnedType struct { const ( // ServiceConditionReady is set when the service is configured // and has available backends ready to receive traffic. - ServiceConditionReady = duckv1alpha1.ConditionReady + ServiceConditionReady = apis.ConditionReady // ServiceConditionRoutesReady is set when the service's underlying // routes have reported readiness. - ServiceConditionRoutesReady duckv1alpha1.ConditionType = "RoutesReady" + ServiceConditionRoutesReady apis.ConditionType = "RoutesReady" // ServiceConditionConfigurationsReady is set when the service's underlying // configurations have reported readiness. - ServiceConditionConfigurationsReady duckv1alpha1.ConditionType = "ConfigurationsReady" + ServiceConditionConfigurationsReady apis.ConditionType = "ConfigurationsReady" ) // ServiceStatus represents the Status stanza of the Service resource. type ServiceStatus struct { - duckv1alpha1.Status `json:",inline"` + duckv1beta1.Status `json:",inline"` RouteStatusFields `json:",inline"` diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_validation.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_validation.go index f8aedba81b..d47ce57838 100644 --- a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_validation.go +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_validation.go @@ -19,16 +19,58 @@ package v1alpha1 import ( "context" "fmt" - "strconv" - "github.com/knative/pkg/apis" + "knative.dev/pkg/apis" + "github.com/knative/serving/pkg/apis/serving" + "k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/util/validation" + + "github.com/knative/serving/pkg/apis/serving/v1beta1" ) // Validate validates the fields belonging to Service -func (s *Service) Validate(ctx context.Context) *apis.FieldError { - return ValidateObjectMetadata(s.GetObjectMeta()).ViaField("metadata"). - Also(s.Spec.Validate(ctx).ViaField("spec")) +func (s *Service) Validate(ctx context.Context) (errs *apis.FieldError) { + // If we are in a status sub resource update, the metadata and spec cannot change. + // So, to avoid rejecting controller status updates due to validations that may + // have changed (i.e. due to config-defaults changes), we elide the metadata and + // spec validation. + if !apis.IsInStatusUpdate(ctx) { + errs = errs.Also(serving.ValidateObjectMetadata(s.GetObjectMeta()).ViaField("metadata")) + ctx = apis.WithinParent(ctx, s.ObjectMeta) + errs = errs.Also(s.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + } + + if apis.IsInUpdate(ctx) { + original := apis.GetBaseline(ctx).(*Service) + + field, currentConfig := s.Spec.getConfigurationSpec() + _, originalConfig := original.Spec.getConfigurationSpec() + + if currentConfig != nil && originalConfig != nil { + templateField := "template" + if currentConfig.GetTemplate() == currentConfig.DeprecatedRevisionTemplate { + templateField = "revisionTemplate" + } + err := currentConfig.GetTemplate().VerifyNameChange(ctx, + originalConfig.GetTemplate()) + errs = errs.Also(err.ViaField("spec", field, "configuration", templateField)) + } + } + + return errs +} + +func (ss *ServiceSpec) getConfigurationSpec() (string, *ConfigurationSpec) { + switch { + case ss.DeprecatedRunLatest != nil: + return "runLatest", &ss.DeprecatedRunLatest.Configuration + case ss.DeprecatedRelease != nil: + return "release", &ss.DeprecatedRelease.Configuration + case ss.DeprecatedPinned != nil: + return "pinned", &ss.DeprecatedPinned.Configuration + default: + return "", &ss.ConfigurationSpec + } } // Validate validates the fields belonging to ServiceSpec recursively @@ -40,30 +82,51 @@ func (ss *ServiceSpec) Validate(ctx context.Context) *apis.FieldError { // return apis.ErrMissingField(currentField) // } - var errs *apis.FieldError + errs := apis.CheckDeprecated(ctx, ss) + set := []string{} - if ss.RunLatest != nil { + if ss.DeprecatedRunLatest != nil { set = append(set, "runLatest") - errs = errs.Also(ss.RunLatest.Validate(ctx).ViaField("runLatest")) + errs = errs.Also(ss.DeprecatedRunLatest.Validate(ctx).ViaField("runLatest")) } - if ss.Release != nil { + if ss.DeprecatedRelease != nil { set = append(set, "release") - errs = errs.Also(ss.Release.Validate(ctx).ViaField("release")) + errs = errs.Also(ss.DeprecatedRelease.Validate(ctx).ViaField("release")) } - if ss.Manual != nil { + if ss.DeprecatedManual != nil { set = append(set, "manual") - errs = errs.Also(ss.Manual.Validate(ctx).ViaField("manual")) + errs = errs.Also(apis.ErrDisallowedFields("manual")) } if ss.DeprecatedPinned != nil { set = append(set, "pinned") errs = errs.Also(ss.DeprecatedPinned.Validate(ctx).ViaField("pinned")) } + // Before checking ConfigurationSpec, check RouteSpec. + if len(set) > 0 && len(ss.RouteSpec.Traffic) > 0 { + errs = errs.Also(apis.ErrMultipleOneOf( + append([]string{"traffic"}, set...)...)) + } + + if !equality.Semantic.DeepEqual(ss.ConfigurationSpec, ConfigurationSpec{}) { + set = append(set, "template") + + // Disallow the use of deprecated fields within our inlined + // Configuration and Route specs. + ctx = apis.DisallowDeprecated(ctx) + + errs = errs.Also(ss.ConfigurationSpec.Validate(ctx)) + errs = errs.Also(ss.RouteSpec.Validate( + // Within the context of Service, the RouteSpec has a default + // configurationName. + v1beta1.WithDefaultConfigurationName(ctx))) + } + if len(set) > 1 { errs = errs.Also(apis.ErrMultipleOneOf(set...)) } else if len(set) == 0 { - errs = errs.Also(apis.ErrMissingOneOf("runLatest", "release", "manual", "pinned")) + errs = errs.Also(apis.ErrMissingOneOf("runLatest", "release", "pinned", "template")) } return errs } @@ -82,22 +145,16 @@ func (rlt *RunLatestType) Validate(ctx context.Context) *apis.FieldError { return rlt.Configuration.Validate(ctx).ViaField("configuration") } -// Validate validates the fields belonging to ManualType -func (m *ManualType) Validate(ctx context.Context) *apis.FieldError { - return nil -} - // Validate validates the fields belonging to ReleaseType func (rt *ReleaseType) Validate(ctx context.Context) *apis.FieldError { var errs *apis.FieldError numRevisions := len(rt.Revisions) - if numRevisions == 0 { errs = errs.Also(apis.ErrMissingField("revisions")) } if numRevisions > 2 { - errs = errs.Also(apis.ErrOutOfBoundsValue(strconv.Itoa(numRevisions), "1", "2", "revisions")) + errs = errs.Also(apis.ErrOutOfBoundsValue(numRevisions, 1, 2, "revisions")) } for i, r := range rt.Revisions { // Skip over the last revision special keyword. @@ -106,16 +163,19 @@ func (rt *ReleaseType) Validate(ctx context.Context) *apis.FieldError { } if msgs := validation.IsDNS1035Label(r); len(msgs) > 0 { errs = errs.Also(apis.ErrInvalidArrayValue( - fmt.Sprintf("not a DNS 1035 label: %v", msgs), "revisions", i)) + fmt.Sprintf("not a DNS 1035 label: %v", msgs), + "revisions", i)) } } if numRevisions < 2 && rt.RolloutPercent != 0 { - errs = errs.Also(apis.ErrInvalidValue(strconv.Itoa(rt.RolloutPercent), "rolloutPercent")) + errs = errs.Also(apis.ErrInvalidValue(rt.RolloutPercent, "rolloutPercent")) } if rt.RolloutPercent < 0 || rt.RolloutPercent > 99 { - errs = errs.Also(apis.ErrOutOfBoundsValue(strconv.Itoa(rt.RolloutPercent), "0", "99", "rolloutPercent")) + errs = errs.Also(apis.ErrOutOfBoundsValue( + rt.RolloutPercent, 0, 99, + "rolloutPercent")) } return errs.Also(rt.Configuration.Validate(ctx).ViaField("configuration")) diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/zz_generated.deepcopy.go index 6d6106e15d..915e638958 100644 --- a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/zz_generated.deepcopy.go @@ -16,17 +16,33 @@ See the License for the specific language governing permissions and limitations under the License. */ -// This file was autogenerated by deepcopy-gen. Do not edit it manually! +// Code generated by deepcopy-gen. DO NOT EDIT. package v1alpha1 import ( - build_v1alpha1 "github.com/knative/build/pkg/apis/build/v1alpha1" - duck_v1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" + apis "knative.dev/pkg/apis" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CannotConvertError) DeepCopyInto(out *CannotConvertError) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CannotConvertError. +func (in *CannotConvertError) DeepCopy() *CannotConvertError { + if in == nil { + return nil + } + out := new(CannotConvertError) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Configuration) DeepCopyInto(out *Configuration) { *out = *in @@ -51,9 +67,8 @@ func (in *Configuration) DeepCopy() *Configuration { func (in *Configuration) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c - } else { - return nil } + return nil } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -85,24 +100,28 @@ func (in *ConfigurationList) DeepCopy() *ConfigurationList { func (in *ConfigurationList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c - } else { - return nil } + return nil } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ConfigurationSpec) DeepCopyInto(out *ConfigurationSpec) { *out = *in - if in.Build != nil { - in, out := &in.Build, &out.Build - if *in == nil { - *out = nil - } else { - *out = new(RawExtension) - (*in).DeepCopyInto(*out) - } + if in.DeprecatedBuild != nil { + in, out := &in.DeprecatedBuild, &out.DeprecatedBuild + *out = new(runtime.RawExtension) + (*in).DeepCopyInto(*out) + } + if in.DeprecatedRevisionTemplate != nil { + in, out := &in.DeprecatedRevisionTemplate, &out.DeprecatedRevisionTemplate + *out = new(RevisionTemplateSpec) + (*in).DeepCopyInto(*out) + } + if in.Template != nil { + in, out := &in.Template, &out.Template + *out = new(RevisionTemplateSpec) + (*in).DeepCopyInto(*out) } - in.RevisionTemplate.DeepCopyInto(&out.RevisionTemplate) return } @@ -183,41 +202,6 @@ func (in *PinnedType) DeepCopy() *PinnedType { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RawExtension) DeepCopyInto(out *RawExtension) { - *out = *in - if in.Raw != nil { - in, out := &in.Raw, &out.Raw - *out = make([]byte, len(*in)) - copy(*out, *in) - } - if in.Object == nil { - out.Object = nil - } else { - out.Object = in.Object.DeepCopyObject() - } - if in.BuildSpec != nil { - in, out := &in.BuildSpec, &out.BuildSpec - if *in == nil { - *out = nil - } else { - *out = new(build_v1alpha1.BuildSpec) - (*in).DeepCopyInto(*out) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RawExtension. -func (in *RawExtension) DeepCopy() *RawExtension { - if in == nil { - return nil - } - out := new(RawExtension) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ReleaseType) DeepCopyInto(out *ReleaseType) { *out = *in @@ -264,9 +248,8 @@ func (in *Revision) DeepCopy() *Revision { func (in *Revision) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c - } else { - return nil } + return nil } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -298,30 +281,23 @@ func (in *RevisionList) DeepCopy() *RevisionList { func (in *RevisionList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c - } else { - return nil } + return nil } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RevisionSpec) DeepCopyInto(out *RevisionSpec) { *out = *in - if in.BuildRef != nil { - in, out := &in.BuildRef, &out.BuildRef - if *in == nil { - *out = nil - } else { - *out = new(v1.ObjectReference) - **out = **in - } + in.RevisionSpec.DeepCopyInto(&out.RevisionSpec) + if in.DeprecatedBuildRef != nil { + in, out := &in.DeprecatedBuildRef, &out.DeprecatedBuildRef + *out = new(v1.ObjectReference) + **out = **in } - in.Container.DeepCopyInto(&out.Container) - if in.Volumes != nil { - in, out := &in.Volumes, &out.Volumes - *out = make([]v1.Volume, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } + if in.DeprecatedContainer != nil { + in, out := &in.DeprecatedContainer, &out.DeprecatedContainer + *out = new(v1.Container) + (*in).DeepCopyInto(*out) } return } @@ -395,9 +371,8 @@ func (in *Route) DeepCopy() *Route { func (in *Route) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c - } else { - return nil } + return nil } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -429,9 +404,8 @@ func (in *RouteList) DeepCopy() *RouteList { func (in *RouteList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c - } else { - return nil } + return nil } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -440,7 +414,9 @@ func (in *RouteSpec) DeepCopyInto(out *RouteSpec) { if in.Traffic != nil { in, out := &in.Traffic, &out.Traffic *out = make([]TrafficTarget, len(*in)) - copy(*out, *in) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } return } @@ -476,19 +452,22 @@ func (in *RouteStatus) DeepCopy() *RouteStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RouteStatusFields) DeepCopyInto(out *RouteStatusFields) { *out = *in + if in.URL != nil { + in, out := &in.URL, &out.URL + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } if in.Address != nil { in, out := &in.Address, &out.Address - if *in == nil { - *out = nil - } else { - *out = new(duck_v1alpha1.Addressable) - **out = **in - } + *out = new(duckv1alpha1.Addressable) + (*in).DeepCopyInto(*out) } if in.Traffic != nil { in, out := &in.Traffic, &out.Traffic *out = make([]TrafficTarget, len(*in)) - copy(*out, *in) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } return } @@ -544,9 +523,8 @@ func (in *Service) DeepCopy() *Service { func (in *Service) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c - } else { - return nil } + return nil } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -578,50 +556,35 @@ func (in *ServiceList) DeepCopy() *ServiceList { func (in *ServiceList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c - } else { - return nil } + return nil } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ServiceSpec) DeepCopyInto(out *ServiceSpec) { *out = *in - if in.RunLatest != nil { - in, out := &in.RunLatest, &out.RunLatest - if *in == nil { - *out = nil - } else { - *out = new(RunLatestType) - (*in).DeepCopyInto(*out) - } + if in.DeprecatedRunLatest != nil { + in, out := &in.DeprecatedRunLatest, &out.DeprecatedRunLatest + *out = new(RunLatestType) + (*in).DeepCopyInto(*out) } if in.DeprecatedPinned != nil { in, out := &in.DeprecatedPinned, &out.DeprecatedPinned - if *in == nil { - *out = nil - } else { - *out = new(PinnedType) - (*in).DeepCopyInto(*out) - } + *out = new(PinnedType) + (*in).DeepCopyInto(*out) } - if in.Manual != nil { - in, out := &in.Manual, &out.Manual - if *in == nil { - *out = nil - } else { - *out = new(ManualType) - **out = **in - } + if in.DeprecatedManual != nil { + in, out := &in.DeprecatedManual, &out.DeprecatedManual + *out = new(ManualType) + **out = **in } - if in.Release != nil { - in, out := &in.Release, &out.Release - if *in == nil { - *out = nil - } else { - *out = new(ReleaseType) - (*in).DeepCopyInto(*out) - } + if in.DeprecatedRelease != nil { + in, out := &in.DeprecatedRelease, &out.DeprecatedRelease + *out = new(ReleaseType) + (*in).DeepCopyInto(*out) } + in.ConfigurationSpec.DeepCopyInto(&out.ConfigurationSpec) + in.RouteSpec.DeepCopyInto(&out.RouteSpec) return } @@ -657,6 +620,7 @@ func (in *ServiceStatus) DeepCopy() *ServiceStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TrafficTarget) DeepCopyInto(out *TrafficTarget) { *out = *in + in.TrafficTarget.DeepCopyInto(&out.TrafficTarget) return } diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/configuration_conversion.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/configuration_conversion.go new file mode 100644 index 0000000000..ede69e83f2 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/configuration_conversion.go @@ -0,0 +1,34 @@ +/* +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 v1beta1 + +import ( + "context" + "fmt" + + "knative.dev/pkg/apis" +) + +// ConvertUp implements apis.Convertible +func (source *Configuration) ConvertUp(ctx context.Context, sink apis.Convertible) error { + return fmt.Errorf("v1beta1 is the highest known version, got: %T", sink) +} + +// ConvertDown implements apis.Convertible +func (sink *Configuration) ConvertDown(ctx context.Context, source apis.Convertible) error { + return fmt.Errorf("v1beta1 is the highest known version, got: %T", source) +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/configuration_defaults.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/configuration_defaults.go new file mode 100644 index 0000000000..926e3c09dd --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/configuration_defaults.go @@ -0,0 +1,34 @@ +/* +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 v1beta1 + +import ( + "context" + + "knative.dev/pkg/apis" +) + +// SetDefaults implements apis.Defaultable +func (c *Configuration) SetDefaults(ctx context.Context) { + ctx = apis.WithinParent(ctx, c.ObjectMeta) + c.Spec.SetDefaults(apis.WithinSpec(ctx)) +} + +// SetDefaults implements apis.Defaultable +func (cs *ConfigurationSpec) SetDefaults(ctx context.Context) { + cs.Template.SetDefaults(ctx) +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/configuration_lifecycle.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/configuration_lifecycle.go new file mode 100644 index 0000000000..2a937bfc0a --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/configuration_lifecycle.go @@ -0,0 +1,35 @@ +/* +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 v1beta1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + + "knative.dev/pkg/apis" +) + +var configurationCondSet = apis.NewLivingConditionSet() + +// GetGroupVersionKind returns the GroupVersionKind. +func (r *Configuration) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Configuration") +} + +// IsReady returns if the configuration is ready to serve the requested configuration. +func (cs *ConfigurationStatus) IsReady() bool { + return configurationCondSet.Manage(cs).IsHappy() +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/configuration_types.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/configuration_types.go new file mode 100644 index 0000000000..6f6361eb66 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/configuration_types.go @@ -0,0 +1,102 @@ +/* +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 v1beta1 + +import ( + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/kmeta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Configuration represents the "floating HEAD" of a linear history of Revisions. +// Users create new Revisions by updating the Configuration's spec. +// The "latest created" revision's name is available under status, as is the +// "latest ready" revision's name. +// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#configuration +type Configuration struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec ConfigurationSpec `json:"spec,omitempty"` + + // +optional + Status ConfigurationStatus `json:"status,omitempty"` +} + +// Verify that Configuration adheres to the appropriate interfaces. +var ( + // Check that Configuration may be validated and defaulted. + _ apis.Validatable = (*Configuration)(nil) + _ apis.Defaultable = (*Configuration)(nil) + + // Check that Configuration can be converted to higher versions. + _ apis.Convertible = (*Configuration)(nil) + + // Check that we can create OwnerReferences to a Configuration. + _ kmeta.OwnerRefable = (*Configuration)(nil) +) + +// ConfigurationSpec holds the desired state of the Configuration (from the client). +type ConfigurationSpec struct { + // Template holds the latest specification for the Revision to be stamped out. + // +optional + Template RevisionTemplateSpec `json:"template"` +} + +const ( + // ConfigurationConditionReady is set when the configuration's latest + // underlying revision has reported readiness. + ConfigurationConditionReady = apis.ConditionReady +) + +// ConfigurationStatusFields holds the fields of Configuration's status that +// are not generally shared. This is defined separately and inlined so that +// other types can readily consume these fields via duck typing. +type ConfigurationStatusFields struct { + // LatestReadyRevisionName holds the name of the latest Revision stamped out + // from this Configuration that has had its "Ready" condition become "True". + // +optional + LatestReadyRevisionName string `json:"latestReadyRevisionName,omitempty"` + + // LatestCreatedRevisionName is the last revision that was created from this + // Configuration. It might not be ready yet, for that use LatestReadyRevisionName. + // +optional + LatestCreatedRevisionName string `json:"latestCreatedRevisionName,omitempty"` +} + +// ConfigurationStatus communicates the observed state of the Configuration (from the controller). +type ConfigurationStatus struct { + duckv1beta1.Status `json:",inline"` + + ConfigurationStatusFields `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ConfigurationList is a list of Configuration resources +type ConfigurationList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Configuration `json:"items"` +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/configuration_validation.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/configuration_validation.go new file mode 100644 index 0000000000..57384796e3 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/configuration_validation.go @@ -0,0 +1,63 @@ +/* +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 v1beta1 + +import ( + "context" + + "knative.dev/pkg/apis" + "github.com/knative/serving/pkg/apis/serving" +) + +// Validate makes sure that Configuration is properly configured. +func (c *Configuration) Validate(ctx context.Context) (errs *apis.FieldError) { + // If we are in a status sub resource update, the metadata and spec cannot change. + // So, to avoid rejecting controller status updates due to validations that may + // have changed (i.e. due to config-defaults changes), we elide the metadata and + // spec validation. + if !apis.IsInStatusUpdate(ctx) { + errs = errs.Also(serving.ValidateObjectMetadata(c.GetObjectMeta()).ViaField("metadata")) + ctx = apis.WithinParent(ctx, c.ObjectMeta) + errs = errs.Also(c.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + } + + errs = errs.Also(c.Status.Validate(apis.WithinStatus(ctx)).ViaField("status")) + + if apis.IsInUpdate(ctx) { + original := apis.GetBaseline(ctx).(*Configuration) + + err := c.Spec.Template.VerifyNameChange(ctx, original.Spec.Template) + errs = errs.Also(err.ViaField("spec.template")) + } + + return errs +} + +// Validate implements apis.Validatable +func (cs *ConfigurationSpec) Validate(ctx context.Context) *apis.FieldError { + return cs.Template.Validate(ctx).ViaField("template") +} + +// Validate implements apis.Validatable +func (cs *ConfigurationStatus) Validate(ctx context.Context) *apis.FieldError { + return cs.ConfigurationStatusFields.Validate(ctx) +} + +// Validate implements apis.Validatable +func (csf *ConfigurationStatusFields) Validate(ctx context.Context) *apis.FieldError { + return nil +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/contexts.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/contexts.go new file mode 100644 index 0000000000..9cc23937ad --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/contexts.go @@ -0,0 +1,52 @@ +/* +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 v1beta1 + +import "context" + +// hdcnKey is used as the key for associating information +// with a context.Context. +type hdcnKey struct{} + +// WithDefaultConfigurationName notes on the context for nested validation +// that there is a default configuration name, which affects how an empty +// configurationName is validated. +func WithDefaultConfigurationName(ctx context.Context) context.Context { + return context.WithValue(ctx, hdcnKey{}, struct{}{}) +} + +// HasDefaultConfigurationName checks to see whether the given context has +// been marked as having a default configurationName. +func HasDefaultConfigurationName(ctx context.Context) bool { + return ctx.Value(hdcnKey{}) != nil +} + +// lemonadeKey is used as the key for associating information +// with a context.Context. +type lemonadeKey struct{} + +// WithUpgradeViaDefaulting notes on the context that we want defaulting to rewrite +// from v1alpha1 to v1beta1. +func WithUpgradeViaDefaulting(ctx context.Context) context.Context { + return context.WithValue(ctx, lemonadeKey{}, struct{}{}) +} + +// IsUpgradeViaDefaulting checks whether we should be "defaulting" from v1alpha1 to +// the v1beta1 subset. +func IsUpgradeViaDefaulting(ctx context.Context) bool { + return ctx.Value(lemonadeKey{}) != nil +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/doc.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/doc.go new file mode 100644 index 0000000000..1aad21df51 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/doc.go @@ -0,0 +1,23 @@ +/* +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. +*/ + +// Api versions allow the api contract for a resource to be changed while keeping +// backward compatibility by support multiple concurrent versions +// of the same resource + +// +k8s:deepcopy-gen=package +// +groupName=serving.knative.dev +package v1beta1 diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/register.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/register.go new file mode 100644 index 0000000000..564de10468 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/register.go @@ -0,0 +1,59 @@ +/* +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 v1beta1 + +import ( + "github.com/knative/serving/pkg/apis/serving" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: serving.GroupName, Version: "v1beta1"} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &Revision{}, + &RevisionList{}, + &Configuration{}, + &ConfigurationList{}, + &Route{}, + &RouteList{}, + &Service{}, + &ServiceList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/revision_conversion.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/revision_conversion.go new file mode 100644 index 0000000000..388cef7410 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/revision_conversion.go @@ -0,0 +1,34 @@ +/* +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 v1beta1 + +import ( + "context" + "fmt" + + "knative.dev/pkg/apis" +) + +// ConvertUp implements apis.Convertible +func (source *Revision) ConvertUp(ctx context.Context, sink apis.Convertible) error { + return fmt.Errorf("v1beta1 is the highest known version, got: %T", sink) +} + +// ConvertDown implements apis.Convertible +func (sink *Revision) ConvertDown(ctx context.Context, source apis.Convertible) error { + return fmt.Errorf("v1beta1 is the highest known version, got: %T", source) +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/revision_defaults.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/revision_defaults.go new file mode 100644 index 0000000000..44ebbc7722 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/revision_defaults.go @@ -0,0 +1,91 @@ +/* +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 v1beta1 + +import ( + "context" + + corev1 "k8s.io/api/core/v1" + + "github.com/knative/serving/pkg/apis/config" +) + +// SetDefaults implements apis.Defaultable +func (r *Revision) SetDefaults(ctx context.Context) { + r.Spec.SetDefaults(ctx) +} + +// SetDefaults implements apis.Defaultable +func (rts *RevisionTemplateSpec) SetDefaults(ctx context.Context) { + rts.Spec.SetDefaults(ctx) +} + +// SetDefaults implements apis.Defaultable +func (rs *RevisionSpec) SetDefaults(ctx context.Context) { + cfg := config.FromContextOrDefaults(ctx) + + // Default TimeoutSeconds based on our configmap + if rs.TimeoutSeconds == nil { + ts := cfg.Defaults.RevisionTimeoutSeconds + rs.TimeoutSeconds = &ts + } + + var container corev1.Container + if len(rs.PodSpec.Containers) == 1 { + container = rs.PodSpec.Containers[0] + } + defer func() { + rs.PodSpec.Containers = []corev1.Container{container} + }() + + if container.Name == "" { + container.Name = cfg.Defaults.UserContainerName(ctx) + } + + if container.Resources.Requests == nil { + container.Resources.Requests = corev1.ResourceList{} + } + if _, ok := container.Resources.Requests[corev1.ResourceCPU]; !ok { + if rsrc := cfg.Defaults.RevisionCPURequest; rsrc != nil { + container.Resources.Requests[corev1.ResourceCPU] = *rsrc + } + } + if _, ok := container.Resources.Requests[corev1.ResourceMemory]; !ok { + if rsrc := cfg.Defaults.RevisionMemoryRequest; rsrc != nil { + container.Resources.Requests[corev1.ResourceMemory] = *rsrc + } + } + + if container.Resources.Limits == nil { + container.Resources.Limits = corev1.ResourceList{} + } + if _, ok := container.Resources.Limits[corev1.ResourceCPU]; !ok { + if rsrc := cfg.Defaults.RevisionCPULimit; rsrc != nil { + container.Resources.Limits[corev1.ResourceCPU] = *rsrc + } + } + if _, ok := container.Resources.Limits[corev1.ResourceMemory]; !ok { + if rsrc := cfg.Defaults.RevisionMemoryLimit; rsrc != nil { + container.Resources.Limits[corev1.ResourceMemory] = *rsrc + } + } + + vms := container.VolumeMounts + for i := range vms { + vms[i].ReadOnly = true + } +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/revision_lifecycle.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/revision_lifecycle.go new file mode 100644 index 0000000000..27672d5930 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/revision_lifecycle.go @@ -0,0 +1,40 @@ +/* +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 v1beta1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + + "knative.dev/pkg/apis" +) + +const ( + // DefaultUserPort is the system default port value exposed on the user-container. + DefaultUserPort = 8080 +) + +var revisionCondSet = apis.NewLivingConditionSet() + +// GetGroupVersionKind returns the GroupVersionKind. +func (r *Revision) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Revision") +} + +// IsReady returns if the revision is ready to serve the requested configuration. +func (rs *RevisionStatus) IsReady() bool { + return revisionCondSet.Manage(rs).IsHappy() +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/revision_types.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/revision_types.go new file mode 100644 index 0000000000..81286bb75b --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/revision_types.go @@ -0,0 +1,134 @@ +/* +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 v1beta1 + +import ( + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/kmeta" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Revision is an immutable snapshot of code and configuration. A revision +// references a container image. Revisions are created by updates to a +// Configuration. +// +// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#revision +type Revision struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec RevisionSpec `json:"spec,omitempty"` + + // +optional + Status RevisionStatus `json:"status,omitempty"` +} + +// Verify that Revision adheres to the appropriate interfaces. +var ( + // Check that Revision can be validated, can be defaulted, and has immutable fields. + _ apis.Validatable = (*Revision)(nil) + _ apis.Defaultable = (*Revision)(nil) + + // Check that Revision can be converted to higher versions. + _ apis.Convertible = (*Revision)(nil) + + // Check that we can create OwnerReferences to a Revision. + _ kmeta.OwnerRefable = (*Revision)(nil) +) + +// RevisionTemplateSpec describes the data a revision should have when created from a template. +// Based on: https://github.com/kubernetes/api/blob/e771f807/core/v1/types.go#L3179-L3190 +type RevisionTemplateSpec struct { + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec RevisionSpec `json:"spec,omitempty"` +} + +// RevisionContainerConcurrencyType is an integer expressing the maximum number of +// in-flight (concurrent) requests. +type RevisionContainerConcurrencyType int64 + +const ( + // RevisionContainerConcurrencyMax is the maximum configurable + // container concurrency. + RevisionContainerConcurrencyMax RevisionContainerConcurrencyType = 1000 +) + +// RevisionSpec holds the desired state of the Revision (from the client). +type RevisionSpec struct { + corev1.PodSpec `json:",inline"` + + // ContainerConcurrency specifies the maximum allowed in-flight (concurrent) + // requests per container of the Revision. Defaults to `0` which means + // unlimited concurrency. + // +optional + ContainerConcurrency RevisionContainerConcurrencyType `json:"containerConcurrency,omitempty"` + + // TimeoutSeconds holds the max duration the instance is allowed for + // responding to a request. If unspecified, a system default will + // be provided. + // +optional + TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty"` +} + +const ( + // RevisionConditionReady is set when the revision is starting to materialize + // runtime resources, and becomes true when those resources are ready. + RevisionConditionReady = apis.ConditionReady +) + +// RevisionStatus communicates the observed state of the Revision (from the controller). +type RevisionStatus struct { + duckv1beta1.Status `json:",inline"` + + // ServiceName holds the name of a core Kubernetes Service resource that + // load balances over the pods backing this Revision. + // +optional + ServiceName string `json:"serviceName,omitempty"` + + // LogURL specifies the generated logging url for this particular revision + // based on the revision url template specified in the controller's config. + // +optional + LogURL string `json:"logUrl,omitempty"` + + // ImageDigest holds the resolved digest for the image specified + // within .Spec.Container.Image. The digest is resolved during the creation + // of Revision. This field holds the digest value regardless of whether + // a tag or digest was originally specified in the Container object. It + // may be empty if the image comes from a registry listed to skip resolution. + // +optional + ImageDigest string `json:"imageDigest,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// RevisionList is a list of Revision resources +type RevisionList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Revision `json:"items"` +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/revision_validation.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/revision_validation.go new file mode 100644 index 0000000000..150c56e62c --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/revision_validation.go @@ -0,0 +1,140 @@ +/* +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 v1beta1 + +import ( + "context" + "fmt" + "strings" + + "github.com/knative/serving/pkg/apis/config" + + "knative.dev/pkg/apis" + "knative.dev/pkg/kmp" + "github.com/knative/serving/pkg/apis/serving" +) + +// Validate ensures Revision is properly configured. +func (r *Revision) Validate(ctx context.Context) *apis.FieldError { + errs := serving.ValidateObjectMetadata(r.GetObjectMeta()).ViaField("metadata") + errs = errs.Also(r.Status.Validate(apis.WithinStatus(ctx)).ViaField("status")) + + if apis.IsInUpdate(ctx) { + original := apis.GetBaseline(ctx).(*Revision) + if diff, err := kmp.ShortDiff(original.Spec, r.Spec); err != nil { + return &apis.FieldError{ + Message: "Failed to diff Revision", + Paths: []string{"spec"}, + Details: err.Error(), + } + } else if diff != "" { + return &apis.FieldError{ + Message: "Immutable fields changed (-old +new)", + Paths: []string{"spec"}, + Details: diff, + } + } + } else { + errs = errs.Also(r.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + } + + return errs +} + +// Validate implements apis.Validatable +func (rts *RevisionTemplateSpec) Validate(ctx context.Context) *apis.FieldError { + errs := rts.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec") + + // If the RevisionTemplateSpec has a name specified, then check that + // it follows the requirements on the name. + if rts.Name != "" { + var prefix string + if om := apis.ParentMeta(ctx); om.Name == "" { + prefix = om.GenerateName + } else { + prefix = om.Name + "-" + } + + if !strings.HasPrefix(rts.Name, prefix) { + errs = errs.Also(apis.ErrInvalidValue( + fmt.Sprintf("%q must have prefix %q", rts.Name, prefix), + "metadata.name")) + } + } + + return errs +} + +// VerifyNameChange checks that if a user brought their own name previously that it +// changes at the appropriate times. +func (current *RevisionTemplateSpec) VerifyNameChange(ctx context.Context, og RevisionTemplateSpec) *apis.FieldError { + if current.Name == "" { + // We only check that Name changes when the RevisionTemplate changes. + return nil + } + if current.Name != og.Name { + // The name changed, so we're good. + return nil + } + + if diff, err := kmp.ShortDiff(&og, current); err != nil { + return &apis.FieldError{ + Message: "Failed to diff RevisionTemplate", + Paths: []string{apis.CurrentField}, + Details: err.Error(), + } + } else if diff != "" { + return &apis.FieldError{ + Message: "Saw the following changes without a name change (-old +new)", + Paths: []string{apis.CurrentField}, + Details: diff, + } + } + return nil +} + +// Validate implements apis.Validatable +func (rs *RevisionSpec) Validate(ctx context.Context) *apis.FieldError { + err := rs.ContainerConcurrency.Validate(ctx).ViaField("containerConcurrency") + + err = err.Also(serving.ValidatePodSpec(rs.PodSpec)) + + if rs.TimeoutSeconds != nil { + ts := *rs.TimeoutSeconds + cfg := config.FromContextOrDefaults(ctx) + if ts < 0 || ts > cfg.Defaults.MaxRevisionTimeoutSeconds { + err = err.Also(apis.ErrOutOfBoundsValue( + ts, 0, cfg.Defaults.MaxRevisionTimeoutSeconds, "timeoutSeconds")) + } + } + + return err +} + +// Validate implements apis.Validatable. +func (cc RevisionContainerConcurrencyType) Validate(ctx context.Context) *apis.FieldError { + if cc < 0 || cc > RevisionContainerConcurrencyMax { + return apis.ErrOutOfBoundsValue( + cc, 0, RevisionContainerConcurrencyMax, apis.CurrentField) + } + return nil +} + +// Validate implements apis.Validatable +func (rs *RevisionStatus) Validate(ctx context.Context) *apis.FieldError { + return nil +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/route_conversion.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/route_conversion.go new file mode 100644 index 0000000000..3fa1bb1f48 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/route_conversion.go @@ -0,0 +1,34 @@ +/* +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 v1beta1 + +import ( + "context" + "fmt" + + "knative.dev/pkg/apis" +) + +// ConvertUp implements apis.Convertible +func (source *Route) ConvertUp(ctx context.Context, sink apis.Convertible) error { + return fmt.Errorf("v1beta1 is the highest known version, got: %T", sink) +} + +// ConvertDown implements apis.Convertible +func (sink *Route) ConvertDown(ctx context.Context, source apis.Convertible) error { + return fmt.Errorf("v1beta1 is the highest known version, got: %T", source) +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/route_defaults.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/route_defaults.go new file mode 100644 index 0000000000..abb58c74e5 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/route_defaults.go @@ -0,0 +1,51 @@ +/* +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 v1beta1 + +import ( + "context" + + "knative.dev/pkg/apis" + "knative.dev/pkg/ptr" +) + +// SetDefaults implements apis.Defaultable +func (r *Route) SetDefaults(ctx context.Context) { + r.Spec.SetDefaults(apis.WithinSpec(ctx)) +} + +// SetDefaults implements apis.Defaultable +func (rs *RouteSpec) SetDefaults(ctx context.Context) { + if len(rs.Traffic) == 0 && HasDefaultConfigurationName(ctx) { + rs.Traffic = []TrafficTarget{{ + Percent: 100, + LatestRevision: ptr.Bool(true), + }} + } + + for idx := range rs.Traffic { + rs.Traffic[idx].SetDefaults(ctx) + } +} + +// SetDefaults implements apis.Defaultable +func (tt *TrafficTarget) SetDefaults(ctx context.Context) { + if tt.LatestRevision == nil { + sense := (tt.RevisionName == "") + tt.LatestRevision = &sense + } +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/route_lifecycle.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/route_lifecycle.go new file mode 100644 index 0000000000..ff50561113 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/route_lifecycle.go @@ -0,0 +1,35 @@ +/* +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 v1beta1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + + "knative.dev/pkg/apis" +) + +var routeCondSet = apis.NewLivingConditionSet() + +// GetGroupVersionKind returns the GroupVersionKind. +func (r *Route) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Route") +} + +// IsReady returns if the route is ready to serve the requested configuration. +func (rs *RouteStatus) IsReady() bool { + return routeCondSet.Manage(rs).IsHappy() +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/route_types.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/route_types.go new file mode 100644 index 0000000000..3b7f98b181 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/route_types.go @@ -0,0 +1,154 @@ +/* +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 v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/kmeta" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Route is responsible for configuring ingress over a collection of Revisions. +// Some of the Revisions a Route distributes traffic over may be specified by +// referencing the Configuration responsible for creating them; in these cases +// the Route is additionally responsible for monitoring the Configuration for +// "latest ready revision" changes, and smoothly rolling out latest revisions. +// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#route +type Route struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec holds the desired state of the Route (from the client). + // +optional + Spec RouteSpec `json:"spec,omitempty"` + + // Status communicates the observed state of the Route (from the controller). + // +optional + Status RouteStatus `json:"status,omitempty"` +} + +// Verify that Route adheres to the appropriate interfaces. +var ( + // Check that Route may be validated and defaulted. + _ apis.Validatable = (*Route)(nil) + _ apis.Defaultable = (*Route)(nil) + + // Check that Route can be converted to higher versions. + _ apis.Convertible = (*Route)(nil) + + // Check that we can create OwnerReferences to a Route. + _ kmeta.OwnerRefable = (*Route)(nil) +) + +// TrafficTarget holds a single entry of the routing table for a Route. +type TrafficTarget struct { + // Tag is optionally used to expose a dedicated url for referencing + // this target exclusively. + // +optional + // TODO(mattmoor): Discuss alternative naming options. + Tag string `json:"tag,omitempty"` + + // RevisionName of a specific revision to which to send this portion of + // traffic. This is mutually exclusive with ConfigurationName. + // +optional + RevisionName string `json:"revisionName,omitempty"` + + // ConfigurationName of a configuration to whose latest revision we will send + // this portion of traffic. When the "status.latestReadyRevisionName" of the + // referenced configuration changes, we will automatically migrate traffic + // from the prior "latest ready" revision to the new one. This field is never + // set in Route's status, only its spec. This is mutually exclusive with + // RevisionName. + // +optional + ConfigurationName string `json:"configurationName,omitempty"` + + // LatestRevision may be optionally provided to indicate that the latest + // ready Revision of the Configuration should be used for this traffic + // target. When provided LatestRevision must be true if RevisionName is + // empty; it must be false when RevisionName is non-empty. + // +optional + LatestRevision *bool `json:"latestRevision,omitempty"` + + // Percent specifies percent of the traffic to this Revision or Configuration. + // This defaults to zero if unspecified. + // +optional + Percent int `json:"percent"` + + // URL displays the URL for accessing named traffic targets. URL is displayed in + // status, and is disallowed on spec. URL must contain a scheme (e.g. http://) and + // a hostname, but may not contain anything else (e.g. basic auth, url path, etc.) + // +optional + URL *apis.URL `json:"url,omitempty"` +} + +// RouteSpec holds the desired state of the Route (from the client). +type RouteSpec struct { + // Traffic specifies how to distribute traffic over a collection of + // revisions and configurations. + // +optional + Traffic []TrafficTarget `json:"traffic,omitempty"` +} + +const ( + // RouteConditionReady is set when the service is configured + // and has available backends ready to receive traffic. + RouteConditionReady = apis.ConditionReady +) + +// RouteStatusFields holds the fields of Route's status that +// are not generally shared. This is defined separately and inlined so that +// other types can readily consume these fields via duck typing. +type RouteStatusFields struct { + // URL holds the url that will distribute traffic over the provided traffic targets. + // It generally has the form http[s]://{route-name}.{route-namespace}.{cluster-level-suffix} + // +optional + URL *apis.URL `json:"url,omitempty"` + + // Address holds the information needed for a Route to be the target of an event. + // +optional + Address *duckv1beta1.Addressable `json:"address,omitempty"` + + // Traffic holds the configured traffic distribution. + // These entries will always contain RevisionName references. + // When ConfigurationName appears in the spec, this will hold the + // LatestReadyRevisionName that we last observed. + // +optional + Traffic []TrafficTarget `json:"traffic,omitempty"` +} + +// RouteStatus communicates the observed state of the Route (from the controller). +type RouteStatus struct { + duckv1beta1.Status `json:",inline"` + + RouteStatusFields `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// RouteList is a list of Route resources +type RouteList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Route `json:"items"` +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/route_validation.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/route_validation.go new file mode 100644 index 0000000000..66cd89f521 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/route_validation.go @@ -0,0 +1,171 @@ +/* +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 v1beta1 + +import ( + "context" + "fmt" + + "knative.dev/pkg/apis" + "github.com/knative/serving/pkg/apis/serving" + "k8s.io/apimachinery/pkg/util/validation" +) + +// Validate makes sure that Route is properly configured. +func (r *Route) Validate(ctx context.Context) *apis.FieldError { + errs := serving.ValidateObjectMetadata(r.GetObjectMeta()).ViaField("metadata") + errs = errs.Also(r.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + errs = errs.Also(r.Status.Validate(apis.WithinStatus(ctx)).ViaField("status")) + return errs +} + +func validateTrafficList(ctx context.Context, traffic []TrafficTarget) *apis.FieldError { + var errs *apis.FieldError + + // Track the targets of named TrafficTarget entries (to detect duplicates). + trafficMap := make(map[string]int) + + sum := 0 + for i, tt := range traffic { + errs = errs.Also(tt.Validate(ctx).ViaIndex(i)) + + if idx, ok := trafficMap[tt.Tag]; ok { + // We want only single definition of the route, even if it points + // to the same config or revision. + errs = errs.Also(&apis.FieldError{ + Message: fmt.Sprintf("Multiple definitions for %q", tt.Tag), + Paths: []string{ + fmt.Sprintf("[%d].tag", i), + fmt.Sprintf("[%d].tag", idx), + }, + }) + } else { + trafficMap[tt.Tag] = i + } + sum += tt.Percent + } + + if sum != 100 { + errs = errs.Also(&apis.FieldError{ + Message: fmt.Sprintf("Traffic targets sum to %d, want 100", sum), + Paths: []string{apis.CurrentField}, + }) + } + return errs +} + +// Validate implements apis.Validatable +func (rs *RouteSpec) Validate(ctx context.Context) *apis.FieldError { + return validateTrafficList(ctx, rs.Traffic).ViaField("traffic") +} + +// Validate verifies that TrafficTarget is properly configured. +func (tt *TrafficTarget) Validate(ctx context.Context) *apis.FieldError { + var errs *apis.FieldError + + // We only validate the sense of latestRevision in the context of a Spec, + // and only when it is specified. + if apis.IsInSpec(ctx) && tt.LatestRevision != nil { + lr := *tt.LatestRevision + pinned := tt.RevisionName != "" + if pinned == lr { + // The senses for whether to pin to a particular revision or + // float forward to the latest revision must match. + errs = errs.Also(apis.ErrInvalidValue(lr, "latestRevision")) + } + } + + switch { + // When we have a default configurationName, we don't + // allow one to be specified. + case HasDefaultConfigurationName(ctx) && tt.ConfigurationName != "": + errs = errs.Also(apis.ErrDisallowedFields("configurationName")) + + // Both revisionName and configurationName are never allowed to + // appear concurrently. + case tt.RevisionName != "" && tt.ConfigurationName != "": + errs = errs.Also(apis.ErrMultipleOneOf( + "revisionName", "configurationName")) + + // When a revisionName appears, we must check that the name is valid. + case tt.RevisionName != "": + if el := validation.IsQualifiedName(tt.RevisionName); len(el) > 0 { + errs = errs.Also(apis.ErrInvalidKeyName( + tt.RevisionName, "revisionName", el...)) + } + + // When revisionName is missing in Status report an error. + case apis.IsInStatus(ctx): + errs = errs.Also(apis.ErrMissingField("revisionName")) + + // When configurationName is specified, we must check that the name is valid. + case tt.ConfigurationName != "": + if el := validation.IsQualifiedName(tt.ConfigurationName); len(el) > 0 { + errs = errs.Also(apis.ErrInvalidKeyName( + tt.ConfigurationName, "configurationName", el...)) + } + + // When we are using a default configurationName, it must be a valid name already. + case HasDefaultConfigurationName(ctx): + + // All other cases are missing one of revisionName or configurationName. + default: + errs = errs.Also(apis.ErrMissingOneOf( + "revisionName", "configurationName")) + } + + // Check that the traffic Percentage is within bounds. + if tt.Percent < 0 || tt.Percent > 100 { + errs = errs.Also(apis.ErrOutOfBoundsValue( + tt.Percent, 0, 100, "percent")) + } + + // Check that we set the URL appropriately. + if tt.URL.String() != "" { + // URL is not allowed in traffic under spec. + if apis.IsInSpec(ctx) { + errs = errs.Also(apis.ErrDisallowedFields("url")) + } + + // URL is not allowed in any traffic target without a name. + if tt.Tag == "" { + errs = errs.Also(apis.ErrDisallowedFields("url")) + } + } else if tt.Tag != "" { + // URL must be specified in status when name is specified. + if apis.IsInStatus(ctx) { + errs = errs.Also(apis.ErrMissingField("url")) + } + } + + return errs +} + +// Validate implements apis.Validatable +func (rs *RouteStatus) Validate(ctx context.Context) *apis.FieldError { + return rs.RouteStatusFields.Validate(ctx) +} + +// Validate implements apis.Validatable +func (rsf *RouteStatusFields) Validate(ctx context.Context) *apis.FieldError { + // TODO(mattmoor): Validate other status fields. + + if len(rsf.Traffic) != 0 { + return validateTrafficList(ctx, rsf.Traffic).ViaField("traffic") + } + return nil +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/service_conversion.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/service_conversion.go new file mode 100644 index 0000000000..ca7fdb0818 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/service_conversion.go @@ -0,0 +1,34 @@ +/* +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 v1beta1 + +import ( + "context" + "fmt" + + "knative.dev/pkg/apis" +) + +// ConvertUp implements apis.Convertible +func (source *Service) ConvertUp(ctx context.Context, sink apis.Convertible) error { + return fmt.Errorf("v1beta1 is the highest known version, got: %T", sink) +} + +// ConvertDown implements apis.Convertible +func (sink *Service) ConvertDown(ctx context.Context, source apis.Convertible) error { + return fmt.Errorf("v1beta1 is the highest known version, got: %T", source) +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/service_defaults.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/service_defaults.go new file mode 100644 index 0000000000..5e1a5e583b --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/service_defaults.go @@ -0,0 +1,57 @@ +/* +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 v1beta1 + +import ( + "context" + + "k8s.io/apimachinery/pkg/api/equality" + + "knative.dev/pkg/apis" + "github.com/knative/serving/pkg/apis/serving" +) + +// SetDefaults implements apis.Defaultable +func (s *Service) SetDefaults(ctx context.Context) { + ctx = apis.WithinParent(ctx, s.ObjectMeta) + s.Spec.SetDefaults(apis.WithinSpec(ctx)) + + if ui := apis.GetUserInfo(ctx); ui != nil { + ans := s.GetAnnotations() + if ans == nil { + ans = map[string]string{} + defer s.SetAnnotations(ans) + } + + if apis.IsInUpdate(ctx) { + old := apis.GetBaseline(ctx).(*Service) + if equality.Semantic.DeepEqual(old.Spec, s.Spec) { + return + } + ans[serving.UpdaterAnnotation] = ui.Username + } else { + ans[serving.CreatorAnnotation] = ui.Username + ans[serving.UpdaterAnnotation] = ui.Username + } + } +} + +// SetDefaults implements apis.Defaultable +func (ss *ServiceSpec) SetDefaults(ctx context.Context) { + ss.ConfigurationSpec.SetDefaults(ctx) + ss.RouteSpec.SetDefaults(WithDefaultConfigurationName(ctx)) +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/service_lifecycle.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/service_lifecycle.go new file mode 100644 index 0000000000..5168d91116 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/service_lifecycle.go @@ -0,0 +1,35 @@ +/* +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 v1beta1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + + "knative.dev/pkg/apis" +) + +var serviceCondSet = apis.NewLivingConditionSet() + +// GetGroupVersionKind returns the GroupVersionKind. +func (s *Service) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Service") +} + +// IsReady returns if the service is ready to serve the requested configuration. +func (ss *ServiceStatus) IsReady() bool { + return serviceCondSet.Manage(ss).IsHappy() +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/service_types.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/service_types.go new file mode 100644 index 0000000000..3fc155a7ae --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/service_types.go @@ -0,0 +1,113 @@ +/* +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 v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/kmeta" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Service acts as a top-level container that manages a Route and Configuration +// which implement a network service. Service exists to provide a singular +// abstraction which can be access controlled, reasoned about, and which +// encapsulates software lifecycle decisions such as rollout policy and +// team resource ownership. Service acts only as an orchestrator of the +// underlying Routes and Configurations (much as a kubernetes Deployment +// orchestrates ReplicaSets), and its usage is optional but recommended. +// +// The Service's controller will track the statuses of its owned Configuration +// and Route, reflecting their statuses and conditions as its own. +// +// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#service +type Service struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec ServiceSpec `json:"spec,omitempty"` + + // +optional + Status ServiceStatus `json:"status,omitempty"` +} + +// Verify that Service adheres to the appropriate interfaces. +var ( + // Check that Service may be validated and defaulted. + _ apis.Validatable = (*Service)(nil) + _ apis.Defaultable = (*Service)(nil) + + // Check that Service can be converted to higher versions. + _ apis.Convertible = (*Service)(nil) + + // Check that we can create OwnerReferences to a Service. + _ kmeta.OwnerRefable = (*Service)(nil) +) + +// ServiceSpec represents the configuration for the Service object. +// A Service's specification is the union of the specifications for a Route +// and Configuration. The Service restricts what can be expressed in these +// fields, e.g. the Route must reference the provided Configuration; +// however, these limitations also enable friendlier defaulting, +// e.g. Route never needs a Configuration name, and may be defaulted to +// the appropriate "run latest" spec. +type ServiceSpec struct { + // ServiceSpec inlines an unrestricted ConfigurationSpec. + ConfigurationSpec `json:",inline"` + + // ServiceSpec inlines RouteSpec and restricts/defaults its fields + // via webhook. In particular, this spec can only reference this + // Service's configuration and revisions (which also influences + // defaults). + RouteSpec `json:",inline"` +} + +// ConditionType represents a Service condition value +const ( + // ServiceConditionReady is set when the service is configured + // and has available backends ready to receive traffic. + ServiceConditionReady = apis.ConditionReady +) + +// ServiceStatus represents the Status stanza of the Service resource. +type ServiceStatus struct { + duckv1beta1.Status `json:",inline"` + + // In addition to inlining ConfigurationSpec, we also inline the fields + // specific to ConfigurationStatus. + ConfigurationStatusFields `json:",inline"` + + // In addition to inlining RouteSpec, we also inline the fields + // specific to RouteStatus. + RouteStatusFields `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ServiceList is a list of Service resources +type ServiceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Service `json:"items"` +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/service_validation.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/service_validation.go new file mode 100644 index 0000000000..e4041a52e8 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/service_validation.go @@ -0,0 +1,63 @@ +/* +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 v1beta1 + +import ( + "context" + + "knative.dev/pkg/apis" + "github.com/knative/serving/pkg/apis/serving" +) + +// Validate makes sure that Service is properly configured. +func (s *Service) Validate(ctx context.Context) (errs *apis.FieldError) { + // If we are in a status sub resource update, the metadata and spec cannot change. + // So, to avoid rejecting controller status updates due to validations that may + // have changed (i.e. due to config-defaults changes), we elide the metadata and + // spec validation. + if !apis.IsInStatusUpdate(ctx) { + errs = errs.Also(serving.ValidateObjectMetadata(s.GetObjectMeta()).ViaField("metadata")) + ctx = apis.WithinParent(ctx, s.ObjectMeta) + errs = errs.Also(s.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + } + + errs = errs.Also(s.Status.Validate(apis.WithinStatus(ctx)).ViaField("status")) + + if apis.IsInUpdate(ctx) { + original := apis.GetBaseline(ctx).(*Service) + + err := s.Spec.ConfigurationSpec.Template.VerifyNameChange(ctx, + original.Spec.ConfigurationSpec.Template) + errs = errs.Also(err.ViaField("spec.template")) + } + + return errs +} + +// Validate implements apis.Validatable +func (ss *ServiceSpec) Validate(ctx context.Context) *apis.FieldError { + return ss.ConfigurationSpec.Validate(ctx).Also( + // Within the context of Service, the RouteSpec has a default + // configurationName. + ss.RouteSpec.Validate(WithDefaultConfigurationName(ctx))) +} + +// Validate implements apis.Validatable +func (ss *ServiceStatus) Validate(ctx context.Context) *apis.FieldError { + return ss.ConfigurationStatusFields.Validate(ctx).Also( + ss.RouteStatusFields.Validate(ctx)) +} diff --git a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/zz_generated.deepcopy.go similarity index 50% rename from vendor/github.com/knative/build/pkg/apis/build/v1alpha1/zz_generated.deepcopy.go rename to vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/zz_generated.deepcopy.go index 2201ea706f..c07bd927fb 100644 --- a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/zz_generated.deepcopy.go @@ -1,7 +1,7 @@ // +build !ignore_autogenerated /* -Copyright 2018 The Knative Authors +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. @@ -16,34 +16,18 @@ See the License for the specific language governing permissions and limitations under the License. */ -// This file was autogenerated by deepcopy-gen. Do not edit it manually! +// Code generated by deepcopy-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( - v1 "k8s.io/api/core/v1" - meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" + apis "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ArgumentSpec) DeepCopyInto(out *ArgumentSpec) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArgumentSpec. -func (in *ArgumentSpec) DeepCopy() *ArgumentSpec { - if in == nil { - return nil - } - out := new(ArgumentSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Build) DeepCopyInto(out *Build) { +func (in *Configuration) DeepCopyInto(out *Configuration) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) @@ -52,18 +36,18 @@ func (in *Build) DeepCopyInto(out *Build) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Build. -func (in *Build) DeepCopy() *Build { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Configuration. +func (in *Configuration) DeepCopy() *Configuration { if in == nil { return nil } - out := new(Build) + out := new(Configuration) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Build) DeepCopyObject() runtime.Object { +func (in *Configuration) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -71,13 +55,13 @@ func (in *Build) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BuildList) DeepCopyInto(out *BuildList) { +func (in *ConfigurationList) DeepCopyInto(out *ConfigurationList) { *out = *in out.TypeMeta = in.TypeMeta out.ListMeta = in.ListMeta if in.Items != nil { in, out := &in.Items, &out.Items - *out = make([]Build, len(*in)) + *out = make([]Configuration, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -85,18 +69,18 @@ func (in *BuildList) DeepCopyInto(out *BuildList) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuildList. -func (in *BuildList) DeepCopy() *BuildList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigurationList. +func (in *ConfigurationList) DeepCopy() *ConfigurationList { if in == nil { return nil } - out := new(BuildList) + out := new(ConfigurationList) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *BuildList) DeepCopyObject() runtime.Object { +func (in *ConfigurationList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -104,171 +88,78 @@ func (in *BuildList) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BuildSpec) DeepCopyInto(out *BuildSpec) { +func (in *ConfigurationSpec) DeepCopyInto(out *ConfigurationSpec) { *out = *in - if in.Source != nil { - in, out := &in.Source, &out.Source - if *in == nil { - *out = nil - } else { - *out = new(SourceSpec) - (*in).DeepCopyInto(*out) - } - } - if in.Sources != nil { - in, out := &in.Sources, &out.Sources - *out = make([]SourceSpec, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Steps != nil { - in, out := &in.Steps, &out.Steps - *out = make([]v1.Container, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Volumes != nil { - in, out := &in.Volumes, &out.Volumes - *out = make([]v1.Volume, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Template != nil { - in, out := &in.Template, &out.Template - if *in == nil { - *out = nil - } else { - *out = new(TemplateInstantiationSpec) - (*in).DeepCopyInto(*out) - } - } - if in.NodeSelector != nil { - in, out := &in.NodeSelector, &out.NodeSelector - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.Timeout != nil { - in, out := &in.Timeout, &out.Timeout - if *in == nil { - *out = nil - } else { - *out = new(meta_v1.Duration) - **out = **in - } - } - if in.Affinity != nil { - in, out := &in.Affinity, &out.Affinity - if *in == nil { - *out = nil - } else { - *out = new(v1.Affinity) - (*in).DeepCopyInto(*out) - } - } + in.Template.DeepCopyInto(&out.Template) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuildSpec. -func (in *BuildSpec) DeepCopy() *BuildSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigurationSpec. +func (in *ConfigurationSpec) DeepCopy() *ConfigurationSpec { if in == nil { return nil } - out := new(BuildSpec) + out := new(ConfigurationSpec) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BuildStatus) DeepCopyInto(out *BuildStatus) { +func (in *ConfigurationStatus) DeepCopyInto(out *ConfigurationStatus) { *out = *in in.Status.DeepCopyInto(&out.Status) - if in.Cluster != nil { - in, out := &in.Cluster, &out.Cluster - if *in == nil { - *out = nil - } else { - *out = new(ClusterSpec) - **out = **in - } - } - if in.Google != nil { - in, out := &in.Google, &out.Google - if *in == nil { - *out = nil - } else { - *out = new(GoogleSpec) - **out = **in - } - } - if in.StartTime != nil { - in, out := &in.StartTime, &out.StartTime - if *in == nil { - *out = nil - } else { - *out = new(meta_v1.Time) - (*in).DeepCopyInto(*out) - } - } - if in.CompletionTime != nil { - in, out := &in.CompletionTime, &out.CompletionTime - if *in == nil { - *out = nil - } else { - *out = new(meta_v1.Time) - (*in).DeepCopyInto(*out) - } - } - if in.StepStates != nil { - in, out := &in.StepStates, &out.StepStates - *out = make([]v1.ContainerState, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.StepsCompleted != nil { - in, out := &in.StepsCompleted, &out.StepsCompleted - *out = make([]string, len(*in)) - copy(*out, *in) + out.ConfigurationStatusFields = in.ConfigurationStatusFields + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigurationStatus. +func (in *ConfigurationStatus) DeepCopy() *ConfigurationStatus { + if in == nil { + return nil } + out := new(ConfigurationStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ConfigurationStatusFields) DeepCopyInto(out *ConfigurationStatusFields) { + *out = *in return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuildStatus. -func (in *BuildStatus) DeepCopy() *BuildStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigurationStatusFields. +func (in *ConfigurationStatusFields) DeepCopy() *ConfigurationStatusFields { if in == nil { return nil } - out := new(BuildStatus) + out := new(ConfigurationStatusFields) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BuildTemplate) DeepCopyInto(out *BuildTemplate) { +func (in *Revision) DeepCopyInto(out *Revision) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuildTemplate. -func (in *BuildTemplate) DeepCopy() *BuildTemplate { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Revision. +func (in *Revision) DeepCopy() *Revision { if in == nil { return nil } - out := new(BuildTemplate) + out := new(Revision) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *BuildTemplate) DeepCopyObject() runtime.Object { +func (in *Revision) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -276,13 +167,13 @@ func (in *BuildTemplate) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BuildTemplateList) DeepCopyInto(out *BuildTemplateList) { +func (in *RevisionList) DeepCopyInto(out *RevisionList) { *out = *in out.TypeMeta = in.TypeMeta out.ListMeta = in.ListMeta if in.Items != nil { in, out := &in.Items, &out.Items - *out = make([]BuildTemplate, len(*in)) + *out = make([]Revision, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -290,18 +181,18 @@ func (in *BuildTemplateList) DeepCopyInto(out *BuildTemplateList) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuildTemplateList. -func (in *BuildTemplateList) DeepCopy() *BuildTemplateList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionList. +func (in *RevisionList) DeepCopy() *RevisionList { if in == nil { return nil } - out := new(BuildTemplateList) + out := new(RevisionList) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *BuildTemplateList) DeepCopyObject() runtime.Object { +func (in *RevisionList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -309,63 +200,84 @@ func (in *BuildTemplateList) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BuildTemplateSpec) DeepCopyInto(out *BuildTemplateSpec) { +func (in *RevisionSpec) DeepCopyInto(out *RevisionSpec) { *out = *in - if in.Parameters != nil { - in, out := &in.Parameters, &out.Parameters - *out = make([]ParameterSpec, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } + in.PodSpec.DeepCopyInto(&out.PodSpec) + if in.TimeoutSeconds != nil { + in, out := &in.TimeoutSeconds, &out.TimeoutSeconds + *out = new(int64) + **out = **in } - if in.Steps != nil { - in, out := &in.Steps, &out.Steps - *out = make([]v1.Container, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionSpec. +func (in *RevisionSpec) DeepCopy() *RevisionSpec { + if in == nil { + return nil } - if in.Volumes != nil { - in, out := &in.Volumes, &out.Volumes - *out = make([]v1.Volume, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } + out := new(RevisionSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RevisionStatus) DeepCopyInto(out *RevisionStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionStatus. +func (in *RevisionStatus) DeepCopy() *RevisionStatus { + if in == nil { + return nil } + out := new(RevisionStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RevisionTemplateSpec) DeepCopyInto(out *RevisionTemplateSpec) { + *out = *in + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuildTemplateSpec. -func (in *BuildTemplateSpec) DeepCopy() *BuildTemplateSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionTemplateSpec. +func (in *RevisionTemplateSpec) DeepCopy() *RevisionTemplateSpec { if in == nil { return nil } - out := new(BuildTemplateSpec) + out := new(RevisionTemplateSpec) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterBuildTemplate) DeepCopyInto(out *ClusterBuildTemplate) { +func (in *Route) DeepCopyInto(out *Route) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterBuildTemplate. -func (in *ClusterBuildTemplate) DeepCopy() *ClusterBuildTemplate { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Route. +func (in *Route) DeepCopy() *Route { if in == nil { return nil } - out := new(ClusterBuildTemplate) + out := new(Route) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ClusterBuildTemplate) DeepCopyObject() runtime.Object { +func (in *Route) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -373,13 +285,13 @@ func (in *ClusterBuildTemplate) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterBuildTemplateList) DeepCopyInto(out *ClusterBuildTemplateList) { +func (in *RouteList) DeepCopyInto(out *RouteList) { *out = *in out.TypeMeta = in.TypeMeta out.ListMeta = in.ListMeta if in.Items != nil { in, out := &in.Items, &out.Items - *out = make([]ClusterBuildTemplate, len(*in)) + *out = make([]Route, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -387,18 +299,18 @@ func (in *ClusterBuildTemplateList) DeepCopyInto(out *ClusterBuildTemplateList) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterBuildTemplateList. -func (in *ClusterBuildTemplateList) DeepCopy() *ClusterBuildTemplateList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteList. +func (in *RouteList) DeepCopy() *RouteList { if in == nil { return nil } - out := new(ClusterBuildTemplateList) + out := new(RouteList) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ClusterBuildTemplateList) DeepCopyObject() runtime.Object { +func (in *RouteList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -406,161 +318,199 @@ func (in *ClusterBuildTemplateList) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) { +func (in *RouteSpec) DeepCopyInto(out *RouteSpec) { *out = *in + if in.Traffic != nil { + in, out := &in.Traffic, &out.Traffic + *out = make([]TrafficTarget, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterSpec. -func (in *ClusterSpec) DeepCopy() *ClusterSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteSpec. +func (in *RouteSpec) DeepCopy() *RouteSpec { if in == nil { return nil } - out := new(ClusterSpec) + out := new(RouteSpec) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GCSSourceSpec) DeepCopyInto(out *GCSSourceSpec) { +func (in *RouteStatus) DeepCopyInto(out *RouteStatus) { *out = *in + in.Status.DeepCopyInto(&out.Status) + in.RouteStatusFields.DeepCopyInto(&out.RouteStatusFields) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GCSSourceSpec. -func (in *GCSSourceSpec) DeepCopy() *GCSSourceSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteStatus. +func (in *RouteStatus) DeepCopy() *RouteStatus { if in == nil { return nil } - out := new(GCSSourceSpec) + out := new(RouteStatus) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GitSourceSpec) DeepCopyInto(out *GitSourceSpec) { +func (in *RouteStatusFields) DeepCopyInto(out *RouteStatusFields) { *out = *in + if in.URL != nil { + in, out := &in.URL, &out.URL + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } + if in.Address != nil { + in, out := &in.Address, &out.Address + *out = new(duckv1beta1.Addressable) + (*in).DeepCopyInto(*out) + } + if in.Traffic != nil { + in, out := &in.Traffic, &out.Traffic + *out = make([]TrafficTarget, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitSourceSpec. -func (in *GitSourceSpec) DeepCopy() *GitSourceSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteStatusFields. +func (in *RouteStatusFields) DeepCopy() *RouteStatusFields { if in == nil { return nil } - out := new(GitSourceSpec) + out := new(RouteStatusFields) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GoogleSpec) DeepCopyInto(out *GoogleSpec) { +func (in *Service) DeepCopyInto(out *Service) { *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GoogleSpec. -func (in *GoogleSpec) DeepCopy() *GoogleSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Service. +func (in *Service) DeepCopy() *Service { if in == nil { return nil } - out := new(GoogleSpec) + out := new(Service) in.DeepCopyInto(out) return out } +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Service) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ParameterSpec) DeepCopyInto(out *ParameterSpec) { +func (in *ServiceList) DeepCopyInto(out *ServiceList) { *out = *in - if in.Default != nil { - in, out := &in.Default, &out.Default - if *in == nil { - *out = nil - } else { - *out = new(string) - **out = **in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Service, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) } } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ParameterSpec. -func (in *ParameterSpec) DeepCopy() *ParameterSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceList. +func (in *ServiceList) DeepCopy() *ServiceList { if in == nil { return nil } - out := new(ParameterSpec) + out := new(ServiceList) in.DeepCopyInto(out) return out } +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ServiceList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SourceSpec) DeepCopyInto(out *SourceSpec) { +func (in *ServiceSpec) DeepCopyInto(out *ServiceSpec) { *out = *in - if in.Git != nil { - in, out := &in.Git, &out.Git - if *in == nil { - *out = nil - } else { - *out = new(GitSourceSpec) - **out = **in - } - } - if in.GCS != nil { - in, out := &in.GCS, &out.GCS - if *in == nil { - *out = nil - } else { - *out = new(GCSSourceSpec) - **out = **in - } - } - if in.Custom != nil { - in, out := &in.Custom, &out.Custom - if *in == nil { - *out = nil - } else { - *out = new(v1.Container) - (*in).DeepCopyInto(*out) - } + in.ConfigurationSpec.DeepCopyInto(&out.ConfigurationSpec) + in.RouteSpec.DeepCopyInto(&out.RouteSpec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceSpec. +func (in *ServiceSpec) DeepCopy() *ServiceSpec { + if in == nil { + return nil } + out := new(ServiceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServiceStatus) DeepCopyInto(out *ServiceStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + out.ConfigurationStatusFields = in.ConfigurationStatusFields + in.RouteStatusFields.DeepCopyInto(&out.RouteStatusFields) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SourceSpec. -func (in *SourceSpec) DeepCopy() *SourceSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceStatus. +func (in *ServiceStatus) DeepCopy() *ServiceStatus { if in == nil { return nil } - out := new(SourceSpec) + out := new(ServiceStatus) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TemplateInstantiationSpec) DeepCopyInto(out *TemplateInstantiationSpec) { +func (in *TrafficTarget) DeepCopyInto(out *TrafficTarget) { *out = *in - if in.Arguments != nil { - in, out := &in.Arguments, &out.Arguments - *out = make([]ArgumentSpec, len(*in)) - copy(*out, *in) - } - if in.Env != nil { - in, out := &in.Env, &out.Env - *out = make([]v1.EnvVar, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } + if in.LatestRevision != nil { + in, out := &in.LatestRevision, &out.LatestRevision + *out = new(bool) + **out = **in + } + if in.URL != nil { + in, out := &in.URL, &out.URL + *out = new(apis.URL) + (*in).DeepCopyInto(*out) } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TemplateInstantiationSpec. -func (in *TemplateInstantiationSpec) DeepCopy() *TemplateInstantiationSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrafficTarget. +func (in *TrafficTarget) DeepCopy() *TrafficTarget { if in == nil { return nil } - out := new(TemplateInstantiationSpec) + out := new(TrafficTarget) in.DeepCopyInto(out) return out } diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/clientset.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/clientset.go index 38bc58c848..6707ffd1b9 100644 --- a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/clientset.go +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/clientset.go @@ -13,12 +13,16 @@ 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 client-gen. DO NOT EDIT. + package versioned import ( autoscalingv1alpha1 "github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1" networkingv1alpha1 "github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1" servingv1alpha1 "github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1" + servingv1beta1 "github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -33,8 +37,9 @@ type Interface interface { // Deprecated: please explicitly pick a version if possible. Networking() networkingv1alpha1.NetworkingV1alpha1Interface ServingV1alpha1() servingv1alpha1.ServingV1alpha1Interface + ServingV1beta1() servingv1beta1.ServingV1beta1Interface // Deprecated: please explicitly pick a version if possible. - Serving() servingv1alpha1.ServingV1alpha1Interface + Serving() servingv1beta1.ServingV1beta1Interface } // Clientset contains the clients for groups. Each group has exactly one @@ -44,6 +49,7 @@ type Clientset struct { autoscalingV1alpha1 *autoscalingv1alpha1.AutoscalingV1alpha1Client networkingV1alpha1 *networkingv1alpha1.NetworkingV1alpha1Client servingV1alpha1 *servingv1alpha1.ServingV1alpha1Client + servingV1beta1 *servingv1beta1.ServingV1beta1Client } // AutoscalingV1alpha1 retrieves the AutoscalingV1alpha1Client @@ -73,10 +79,15 @@ func (c *Clientset) ServingV1alpha1() servingv1alpha1.ServingV1alpha1Interface { return c.servingV1alpha1 } +// ServingV1beta1 retrieves the ServingV1beta1Client +func (c *Clientset) ServingV1beta1() servingv1beta1.ServingV1beta1Interface { + return c.servingV1beta1 +} + // Deprecated: Serving retrieves the default version of ServingClient. // Please explicitly pick a version. -func (c *Clientset) Serving() servingv1alpha1.ServingV1alpha1Interface { - return c.servingV1alpha1 +func (c *Clientset) Serving() servingv1beta1.ServingV1beta1Interface { + return c.servingV1beta1 } // Discovery retrieves the DiscoveryClient @@ -107,6 +118,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } + cs.servingV1beta1, err = servingv1beta1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) if err != nil { @@ -122,6 +137,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { cs.autoscalingV1alpha1 = autoscalingv1alpha1.NewForConfigOrDie(c) cs.networkingV1alpha1 = networkingv1alpha1.NewForConfigOrDie(c) cs.servingV1alpha1 = servingv1alpha1.NewForConfigOrDie(c) + cs.servingV1beta1 = servingv1beta1.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &cs @@ -133,6 +149,7 @@ func New(c rest.Interface) *Clientset { cs.autoscalingV1alpha1 = autoscalingv1alpha1.New(c) cs.networkingV1alpha1 = networkingv1alpha1.New(c) cs.servingV1alpha1 = servingv1alpha1.New(c) + cs.servingV1beta1 = servingv1beta1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/doc.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/doc.go index 2470adee79..1122e50bfc 100644 --- a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/doc.go +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/doc.go @@ -13,5 +13,8 @@ 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 client-gen. DO NOT EDIT. + // This package has the automatically generated clientset. package versioned diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/scheme/doc.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/scheme/doc.go index 90a95408c5..7d76538485 100644 --- a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/scheme/doc.go +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/scheme/doc.go @@ -13,5 +13,8 @@ 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 client-gen. DO NOT EDIT. + // This package contains the scheme of the automatically generated clientset. package scheme diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/scheme/register.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/scheme/register.go index 3d70a2c315..b7aed539d6 100644 --- a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/scheme/register.go +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/scheme/register.go @@ -13,17 +13,21 @@ 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 client-gen. DO NOT EDIT. + package scheme import ( autoscalingv1alpha1 "github.com/knative/serving/pkg/apis/autoscaling/v1alpha1" networkingv1alpha1 "github.com/knative/serving/pkg/apis/networking/v1alpha1" servingv1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" + servingv1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" serializer "k8s.io/apimachinery/pkg/runtime/serializer" - util_runtime "k8s.io/apimachinery/pkg/util/runtime" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" ) var Scheme = runtime.NewScheme() @@ -33,6 +37,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ autoscalingv1alpha1.AddToScheme, networkingv1alpha1.AddToScheme, servingv1alpha1.AddToScheme, + servingv1beta1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition @@ -53,5 +58,5 @@ var AddToScheme = localSchemeBuilder.AddToScheme func init() { v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) - util_runtime.Must(AddToScheme(Scheme)) + utilruntime.Must(AddToScheme(Scheme)) } diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/autoscaling_client.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/autoscaling_client.go index c79410c0bb..8d0ce8489e 100644 --- a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/autoscaling_client.go +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/autoscaling_client.go @@ -13,6 +13,9 @@ 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 client-gen. DO NOT EDIT. + package v1alpha1 import ( diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/doc.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/doc.go index 1a38cd7980..a1c6bb9fe8 100644 --- a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/doc.go +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/doc.go @@ -13,5 +13,8 @@ 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 client-gen. DO NOT EDIT. + // This package has the automatically generated typed clients. package v1alpha1 diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/generated_expansion.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/generated_expansion.go index ed2b6b5173..66c99940e1 100644 --- a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/generated_expansion.go +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/generated_expansion.go @@ -13,6 +13,9 @@ 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 client-gen. DO NOT EDIT. + package v1alpha1 type PodAutoscalerExpansion interface{} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/podautoscaler.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/podautoscaler.go index 11fc2bbe45..81411091f2 100644 --- a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/podautoscaler.go +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/podautoscaler.go @@ -13,6 +13,9 @@ 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 client-gen. DO NOT EDIT. + package v1alpha1 import ( diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/certificate.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/certificate.go index 58f8d09389..ee8cc2719b 100644 --- a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/certificate.go +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/certificate.go @@ -13,6 +13,9 @@ 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 client-gen. DO NOT EDIT. + package v1alpha1 import ( diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/clusteringress.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/clusteringress.go index 32971334f0..55777ab244 100644 --- a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/clusteringress.go +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/clusteringress.go @@ -13,6 +13,9 @@ 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 client-gen. DO NOT EDIT. + package v1alpha1 import ( diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/doc.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/doc.go index 1a38cd7980..a1c6bb9fe8 100644 --- a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/doc.go +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/doc.go @@ -13,5 +13,8 @@ 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 client-gen. DO NOT EDIT. + // This package has the automatically generated typed clients. package v1alpha1 diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/generated_expansion.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/generated_expansion.go index 83acdcf74f..808a1cd98c 100644 --- a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/generated_expansion.go +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/generated_expansion.go @@ -13,10 +13,15 @@ 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 client-gen. DO NOT EDIT. + package v1alpha1 type CertificateExpansion interface{} type ClusterIngressExpansion interface{} +type IngressExpansion interface{} + type ServerlessServiceExpansion interface{} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/ingress.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/ingress.go new file mode 100644 index 0000000000..0158983bfb --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/ingress.go @@ -0,0 +1,174 @@ +/* +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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/networking/v1alpha1" + scheme "github.com/knative/serving/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// IngressesGetter has a method to return a IngressInterface. +// A group's client should implement this interface. +type IngressesGetter interface { + Ingresses(namespace string) IngressInterface +} + +// IngressInterface has methods to work with Ingress resources. +type IngressInterface interface { + Create(*v1alpha1.Ingress) (*v1alpha1.Ingress, error) + Update(*v1alpha1.Ingress) (*v1alpha1.Ingress, error) + UpdateStatus(*v1alpha1.Ingress) (*v1alpha1.Ingress, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.Ingress, error) + List(opts v1.ListOptions) (*v1alpha1.IngressList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Ingress, err error) + IngressExpansion +} + +// ingresses implements IngressInterface +type ingresses struct { + client rest.Interface + ns string +} + +// newIngresses returns a Ingresses +func newIngresses(c *NetworkingV1alpha1Client, namespace string) *ingresses { + return &ingresses{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the ingress, and returns the corresponding ingress object, and an error if there is any. +func (c *ingresses) Get(name string, options v1.GetOptions) (result *v1alpha1.Ingress, err error) { + result = &v1alpha1.Ingress{} + err = c.client.Get(). + Namespace(c.ns). + Resource("ingresses"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Ingresses that match those selectors. +func (c *ingresses) List(opts v1.ListOptions) (result *v1alpha1.IngressList, err error) { + result = &v1alpha1.IngressList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("ingresses"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested ingresses. +func (c *ingresses) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("ingresses"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a ingress and creates it. Returns the server's representation of the ingress, and an error, if there is any. +func (c *ingresses) Create(ingress *v1alpha1.Ingress) (result *v1alpha1.Ingress, err error) { + result = &v1alpha1.Ingress{} + err = c.client.Post(). + Namespace(c.ns). + Resource("ingresses"). + Body(ingress). + Do(). + Into(result) + return +} + +// Update takes the representation of a ingress and updates it. Returns the server's representation of the ingress, and an error, if there is any. +func (c *ingresses) Update(ingress *v1alpha1.Ingress) (result *v1alpha1.Ingress, err error) { + result = &v1alpha1.Ingress{} + err = c.client.Put(). + Namespace(c.ns). + Resource("ingresses"). + Name(ingress.Name). + Body(ingress). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *ingresses) UpdateStatus(ingress *v1alpha1.Ingress) (result *v1alpha1.Ingress, err error) { + result = &v1alpha1.Ingress{} + err = c.client.Put(). + Namespace(c.ns). + Resource("ingresses"). + Name(ingress.Name). + SubResource("status"). + Body(ingress). + Do(). + Into(result) + return +} + +// Delete takes name of the ingress and deletes it. Returns an error if one occurs. +func (c *ingresses) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("ingresses"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *ingresses) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("ingresses"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched ingress. +func (c *ingresses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Ingress, err error) { + result = &v1alpha1.Ingress{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("ingresses"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/networking_client.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/networking_client.go index 3d742d400b..31681c7caa 100644 --- a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/networking_client.go +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/networking_client.go @@ -13,6 +13,9 @@ 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 client-gen. DO NOT EDIT. + package v1alpha1 import ( @@ -26,6 +29,7 @@ type NetworkingV1alpha1Interface interface { RESTClient() rest.Interface CertificatesGetter ClusterIngressesGetter + IngressesGetter ServerlessServicesGetter } @@ -42,6 +46,10 @@ func (c *NetworkingV1alpha1Client) ClusterIngresses() ClusterIngressInterface { return newClusterIngresses(c) } +func (c *NetworkingV1alpha1Client) Ingresses(namespace string) IngressInterface { + return newIngresses(c, namespace) +} + func (c *NetworkingV1alpha1Client) ServerlessServices(namespace string) ServerlessServiceInterface { return newServerlessServices(c, namespace) } diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/serverlessservice.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/serverlessservice.go index 8dc57ff841..c728b95a00 100644 --- a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/serverlessservice.go +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/serverlessservice.go @@ -13,6 +13,9 @@ 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 client-gen. DO NOT EDIT. + package v1alpha1 import ( diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/configuration.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/configuration.go index c766b0d281..17c02afdc8 100644 --- a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/configuration.go +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/configuration.go @@ -13,6 +13,9 @@ 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 client-gen. DO NOT EDIT. + package v1alpha1 import ( diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/doc.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/doc.go index 1a38cd7980..a1c6bb9fe8 100644 --- a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/doc.go +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/doc.go @@ -13,5 +13,8 @@ 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 client-gen. DO NOT EDIT. + // This package has the automatically generated typed clients. package v1alpha1 diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/generated_expansion.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/generated_expansion.go index d8186b3195..6ce17decf7 100644 --- a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/generated_expansion.go +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/generated_expansion.go @@ -13,6 +13,9 @@ 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 client-gen. DO NOT EDIT. + package v1alpha1 type ConfigurationExpansion interface{} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/revision.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/revision.go index 1460b686ea..4299306610 100644 --- a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/revision.go +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/revision.go @@ -13,6 +13,9 @@ 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 client-gen. DO NOT EDIT. + package v1alpha1 import ( diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/route.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/route.go index 403e5e7aa5..320477113f 100644 --- a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/route.go +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/route.go @@ -13,6 +13,9 @@ 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 client-gen. DO NOT EDIT. + package v1alpha1 import ( diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/service.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/service.go index 28e6afd012..1309f2fb37 100644 --- a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/service.go +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/service.go @@ -13,6 +13,9 @@ 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 client-gen. DO NOT EDIT. + package v1alpha1 import ( diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/serving_client.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/serving_client.go index 9d820f5511..0a75f4a864 100644 --- a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/serving_client.go +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/serving_client.go @@ -13,6 +13,9 @@ 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 client-gen. DO NOT EDIT. + package v1alpha1 import ( diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/configuration.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/configuration.go new file mode 100644 index 0000000000..d065962d65 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/configuration.go @@ -0,0 +1,174 @@ +/* +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 client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + scheme "github.com/knative/serving/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// ConfigurationsGetter has a method to return a ConfigurationInterface. +// A group's client should implement this interface. +type ConfigurationsGetter interface { + Configurations(namespace string) ConfigurationInterface +} + +// ConfigurationInterface has methods to work with Configuration resources. +type ConfigurationInterface interface { + Create(*v1beta1.Configuration) (*v1beta1.Configuration, error) + Update(*v1beta1.Configuration) (*v1beta1.Configuration, error) + UpdateStatus(*v1beta1.Configuration) (*v1beta1.Configuration, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1beta1.Configuration, error) + List(opts v1.ListOptions) (*v1beta1.ConfigurationList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Configuration, err error) + ConfigurationExpansion +} + +// configurations implements ConfigurationInterface +type configurations struct { + client rest.Interface + ns string +} + +// newConfigurations returns a Configurations +func newConfigurations(c *ServingV1beta1Client, namespace string) *configurations { + return &configurations{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the configuration, and returns the corresponding configuration object, and an error if there is any. +func (c *configurations) Get(name string, options v1.GetOptions) (result *v1beta1.Configuration, err error) { + result = &v1beta1.Configuration{} + err = c.client.Get(). + Namespace(c.ns). + Resource("configurations"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Configurations that match those selectors. +func (c *configurations) List(opts v1.ListOptions) (result *v1beta1.ConfigurationList, err error) { + result = &v1beta1.ConfigurationList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("configurations"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested configurations. +func (c *configurations) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("configurations"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a configuration and creates it. Returns the server's representation of the configuration, and an error, if there is any. +func (c *configurations) Create(configuration *v1beta1.Configuration) (result *v1beta1.Configuration, err error) { + result = &v1beta1.Configuration{} + err = c.client.Post(). + Namespace(c.ns). + Resource("configurations"). + Body(configuration). + Do(). + Into(result) + return +} + +// Update takes the representation of a configuration and updates it. Returns the server's representation of the configuration, and an error, if there is any. +func (c *configurations) Update(configuration *v1beta1.Configuration) (result *v1beta1.Configuration, err error) { + result = &v1beta1.Configuration{} + err = c.client.Put(). + Namespace(c.ns). + Resource("configurations"). + Name(configuration.Name). + Body(configuration). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *configurations) UpdateStatus(configuration *v1beta1.Configuration) (result *v1beta1.Configuration, err error) { + result = &v1beta1.Configuration{} + err = c.client.Put(). + Namespace(c.ns). + Resource("configurations"). + Name(configuration.Name). + SubResource("status"). + Body(configuration). + Do(). + Into(result) + return +} + +// Delete takes name of the configuration and deletes it. Returns an error if one occurs. +func (c *configurations) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("configurations"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *configurations) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("configurations"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched configuration. +func (c *configurations) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Configuration, err error) { + result = &v1beta1.Configuration{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("configurations"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/doc.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/doc.go new file mode 100644 index 0000000000..ede2d4a287 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +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 client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/generated_expansion.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/generated_expansion.go new file mode 100644 index 0000000000..58d005da44 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/generated_expansion.go @@ -0,0 +1,27 @@ +/* +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 client-gen. DO NOT EDIT. + +package v1beta1 + +type ConfigurationExpansion interface{} + +type RevisionExpansion interface{} + +type RouteExpansion interface{} + +type ServiceExpansion interface{} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/revision.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/revision.go new file mode 100644 index 0000000000..b76df83b7c --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/revision.go @@ -0,0 +1,174 @@ +/* +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 client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + scheme "github.com/knative/serving/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// RevisionsGetter has a method to return a RevisionInterface. +// A group's client should implement this interface. +type RevisionsGetter interface { + Revisions(namespace string) RevisionInterface +} + +// RevisionInterface has methods to work with Revision resources. +type RevisionInterface interface { + Create(*v1beta1.Revision) (*v1beta1.Revision, error) + Update(*v1beta1.Revision) (*v1beta1.Revision, error) + UpdateStatus(*v1beta1.Revision) (*v1beta1.Revision, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1beta1.Revision, error) + List(opts v1.ListOptions) (*v1beta1.RevisionList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Revision, err error) + RevisionExpansion +} + +// revisions implements RevisionInterface +type revisions struct { + client rest.Interface + ns string +} + +// newRevisions returns a Revisions +func newRevisions(c *ServingV1beta1Client, namespace string) *revisions { + return &revisions{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the revision, and returns the corresponding revision object, and an error if there is any. +func (c *revisions) Get(name string, options v1.GetOptions) (result *v1beta1.Revision, err error) { + result = &v1beta1.Revision{} + err = c.client.Get(). + Namespace(c.ns). + Resource("revisions"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Revisions that match those selectors. +func (c *revisions) List(opts v1.ListOptions) (result *v1beta1.RevisionList, err error) { + result = &v1beta1.RevisionList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("revisions"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested revisions. +func (c *revisions) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("revisions"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a revision and creates it. Returns the server's representation of the revision, and an error, if there is any. +func (c *revisions) Create(revision *v1beta1.Revision) (result *v1beta1.Revision, err error) { + result = &v1beta1.Revision{} + err = c.client.Post(). + Namespace(c.ns). + Resource("revisions"). + Body(revision). + Do(). + Into(result) + return +} + +// Update takes the representation of a revision and updates it. Returns the server's representation of the revision, and an error, if there is any. +func (c *revisions) Update(revision *v1beta1.Revision) (result *v1beta1.Revision, err error) { + result = &v1beta1.Revision{} + err = c.client.Put(). + Namespace(c.ns). + Resource("revisions"). + Name(revision.Name). + Body(revision). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *revisions) UpdateStatus(revision *v1beta1.Revision) (result *v1beta1.Revision, err error) { + result = &v1beta1.Revision{} + err = c.client.Put(). + Namespace(c.ns). + Resource("revisions"). + Name(revision.Name). + SubResource("status"). + Body(revision). + Do(). + Into(result) + return +} + +// Delete takes name of the revision and deletes it. Returns an error if one occurs. +func (c *revisions) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("revisions"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *revisions) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("revisions"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched revision. +func (c *revisions) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Revision, err error) { + result = &v1beta1.Revision{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("revisions"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/route.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/route.go new file mode 100644 index 0000000000..f278511fab --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/route.go @@ -0,0 +1,174 @@ +/* +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 client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + scheme "github.com/knative/serving/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// RoutesGetter has a method to return a RouteInterface. +// A group's client should implement this interface. +type RoutesGetter interface { + Routes(namespace string) RouteInterface +} + +// RouteInterface has methods to work with Route resources. +type RouteInterface interface { + Create(*v1beta1.Route) (*v1beta1.Route, error) + Update(*v1beta1.Route) (*v1beta1.Route, error) + UpdateStatus(*v1beta1.Route) (*v1beta1.Route, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1beta1.Route, error) + List(opts v1.ListOptions) (*v1beta1.RouteList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Route, err error) + RouteExpansion +} + +// routes implements RouteInterface +type routes struct { + client rest.Interface + ns string +} + +// newRoutes returns a Routes +func newRoutes(c *ServingV1beta1Client, namespace string) *routes { + return &routes{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the route, and returns the corresponding route object, and an error if there is any. +func (c *routes) Get(name string, options v1.GetOptions) (result *v1beta1.Route, err error) { + result = &v1beta1.Route{} + err = c.client.Get(). + Namespace(c.ns). + Resource("routes"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Routes that match those selectors. +func (c *routes) List(opts v1.ListOptions) (result *v1beta1.RouteList, err error) { + result = &v1beta1.RouteList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("routes"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested routes. +func (c *routes) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("routes"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a route and creates it. Returns the server's representation of the route, and an error, if there is any. +func (c *routes) Create(route *v1beta1.Route) (result *v1beta1.Route, err error) { + result = &v1beta1.Route{} + err = c.client.Post(). + Namespace(c.ns). + Resource("routes"). + Body(route). + Do(). + Into(result) + return +} + +// Update takes the representation of a route and updates it. Returns the server's representation of the route, and an error, if there is any. +func (c *routes) Update(route *v1beta1.Route) (result *v1beta1.Route, err error) { + result = &v1beta1.Route{} + err = c.client.Put(). + Namespace(c.ns). + Resource("routes"). + Name(route.Name). + Body(route). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *routes) UpdateStatus(route *v1beta1.Route) (result *v1beta1.Route, err error) { + result = &v1beta1.Route{} + err = c.client.Put(). + Namespace(c.ns). + Resource("routes"). + Name(route.Name). + SubResource("status"). + Body(route). + Do(). + Into(result) + return +} + +// Delete takes name of the route and deletes it. Returns an error if one occurs. +func (c *routes) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("routes"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *routes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("routes"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched route. +func (c *routes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Route, err error) { + result = &v1beta1.Route{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("routes"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/service.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/service.go new file mode 100644 index 0000000000..5fe1555b3d --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/service.go @@ -0,0 +1,174 @@ +/* +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 client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + scheme "github.com/knative/serving/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// ServicesGetter has a method to return a ServiceInterface. +// A group's client should implement this interface. +type ServicesGetter interface { + Services(namespace string) ServiceInterface +} + +// ServiceInterface has methods to work with Service resources. +type ServiceInterface interface { + Create(*v1beta1.Service) (*v1beta1.Service, error) + Update(*v1beta1.Service) (*v1beta1.Service, error) + UpdateStatus(*v1beta1.Service) (*v1beta1.Service, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1beta1.Service, error) + List(opts v1.ListOptions) (*v1beta1.ServiceList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Service, err error) + ServiceExpansion +} + +// services implements ServiceInterface +type services struct { + client rest.Interface + ns string +} + +// newServices returns a Services +func newServices(c *ServingV1beta1Client, namespace string) *services { + return &services{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the service, and returns the corresponding service object, and an error if there is any. +func (c *services) Get(name string, options v1.GetOptions) (result *v1beta1.Service, err error) { + result = &v1beta1.Service{} + err = c.client.Get(). + Namespace(c.ns). + Resource("services"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Services that match those selectors. +func (c *services) List(opts v1.ListOptions) (result *v1beta1.ServiceList, err error) { + result = &v1beta1.ServiceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("services"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested services. +func (c *services) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("services"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a service and creates it. Returns the server's representation of the service, and an error, if there is any. +func (c *services) Create(service *v1beta1.Service) (result *v1beta1.Service, err error) { + result = &v1beta1.Service{} + err = c.client.Post(). + Namespace(c.ns). + Resource("services"). + Body(service). + Do(). + Into(result) + return +} + +// Update takes the representation of a service and updates it. Returns the server's representation of the service, and an error, if there is any. +func (c *services) Update(service *v1beta1.Service) (result *v1beta1.Service, err error) { + result = &v1beta1.Service{} + err = c.client.Put(). + Namespace(c.ns). + Resource("services"). + Name(service.Name). + Body(service). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *services) UpdateStatus(service *v1beta1.Service) (result *v1beta1.Service, err error) { + result = &v1beta1.Service{} + err = c.client.Put(). + Namespace(c.ns). + Resource("services"). + Name(service.Name). + SubResource("status"). + Body(service). + Do(). + Into(result) + return +} + +// Delete takes name of the service and deletes it. Returns an error if one occurs. +func (c *services) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("services"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *services) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("services"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched service. +func (c *services) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Service, err error) { + result = &v1beta1.Service{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("services"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/serving_client.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/serving_client.go new file mode 100644 index 0000000000..20d6cbf084 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/serving_client.go @@ -0,0 +1,105 @@ +/* +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 client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + "github.com/knative/serving/pkg/client/clientset/versioned/scheme" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" +) + +type ServingV1beta1Interface interface { + RESTClient() rest.Interface + ConfigurationsGetter + RevisionsGetter + RoutesGetter + ServicesGetter +} + +// ServingV1beta1Client is used to interact with features provided by the serving.knative.dev group. +type ServingV1beta1Client struct { + restClient rest.Interface +} + +func (c *ServingV1beta1Client) Configurations(namespace string) ConfigurationInterface { + return newConfigurations(c, namespace) +} + +func (c *ServingV1beta1Client) Revisions(namespace string) RevisionInterface { + return newRevisions(c, namespace) +} + +func (c *ServingV1beta1Client) Routes(namespace string) RouteInterface { + return newRoutes(c, namespace) +} + +func (c *ServingV1beta1Client) Services(namespace string) ServiceInterface { + return newServices(c, namespace) +} + +// NewForConfig creates a new ServingV1beta1Client for the given config. +func NewForConfig(c *rest.Config) (*ServingV1beta1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &ServingV1beta1Client{client}, nil +} + +// NewForConfigOrDie creates a new ServingV1beta1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *ServingV1beta1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new ServingV1beta1Client for the given RESTClient. +func New(c rest.Interface) *ServingV1beta1Client { + return &ServingV1beta1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *ServingV1beta1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/github.com/knative/serving/pkg/deployment/testdata/config-deployment.yaml b/vendor/github.com/knative/serving/pkg/deployment/testdata/config-deployment.yaml new file mode 120000 index 0000000000..a1c7629c19 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/deployment/testdata/config-deployment.yaml @@ -0,0 +1 @@ +../../../config/config-deployment.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/metrics/testdata/config-observability.yaml b/vendor/github.com/knative/serving/pkg/metrics/testdata/config-observability.yaml new file mode 120000 index 0000000000..7827630e3a --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/metrics/testdata/config-observability.yaml @@ -0,0 +1 @@ +../../../config/config-observability.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/certificate/config/testdata/config-certmanager.yaml b/vendor/github.com/knative/serving/pkg/reconciler/certificate/config/testdata/config-certmanager.yaml new file mode 120000 index 0000000000..6d8b9bae96 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/reconciler/certificate/config/testdata/config-certmanager.yaml @@ -0,0 +1 @@ +../../../../../config/config-certmanager.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/configuration/config/testdata/config-gc.yaml b/vendor/github.com/knative/serving/pkg/reconciler/configuration/config/testdata/config-gc.yaml new file mode 120000 index 0000000000..929b7c057a --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/reconciler/configuration/config/testdata/config-gc.yaml @@ -0,0 +1 @@ +../../../../../config/config-gc.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/ingress/config/testdata/config-istio.yaml b/vendor/github.com/knative/serving/pkg/reconciler/ingress/config/testdata/config-istio.yaml new file mode 120000 index 0000000000..342ffffed5 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/reconciler/ingress/config/testdata/config-istio.yaml @@ -0,0 +1 @@ +../../../../../config/config-istio.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/ingress/config/testdata/config-network.yaml b/vendor/github.com/knative/serving/pkg/reconciler/ingress/config/testdata/config-network.yaml new file mode 120000 index 0000000000..b774d24cbb --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/reconciler/ingress/config/testdata/config-network.yaml @@ -0,0 +1 @@ +../../../../../config/config-network.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/revision/config/testdata/config-autoscaler.yaml b/vendor/github.com/knative/serving/pkg/reconciler/revision/config/testdata/config-autoscaler.yaml new file mode 120000 index 0000000000..05b9f33bbc --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/reconciler/revision/config/testdata/config-autoscaler.yaml @@ -0,0 +1 @@ +../../../../../config/config-autoscaler.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/revision/config/testdata/config-deployment.yaml b/vendor/github.com/knative/serving/pkg/reconciler/revision/config/testdata/config-deployment.yaml new file mode 120000 index 0000000000..8e4b6d96a0 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/reconciler/revision/config/testdata/config-deployment.yaml @@ -0,0 +1 @@ +../../../../../config/config-deployment.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/revision/config/testdata/config-logging.yaml b/vendor/github.com/knative/serving/pkg/reconciler/revision/config/testdata/config-logging.yaml new file mode 120000 index 0000000000..def106f120 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/reconciler/revision/config/testdata/config-logging.yaml @@ -0,0 +1 @@ +../../../../../config/config-logging.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/revision/config/testdata/config-network.yaml b/vendor/github.com/knative/serving/pkg/reconciler/revision/config/testdata/config-network.yaml new file mode 120000 index 0000000000..b774d24cbb --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/reconciler/revision/config/testdata/config-network.yaml @@ -0,0 +1 @@ +../../../../../config/config-network.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/revision/config/testdata/config-observability.yaml b/vendor/github.com/knative/serving/pkg/reconciler/revision/config/testdata/config-observability.yaml new file mode 120000 index 0000000000..ecbbeaaee7 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/reconciler/revision/config/testdata/config-observability.yaml @@ -0,0 +1 @@ +../../../../../config/config-observability.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/route/config/testdata/config-domain.yaml b/vendor/github.com/knative/serving/pkg/reconciler/route/config/testdata/config-domain.yaml new file mode 120000 index 0000000000..fd6402b7c4 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/reconciler/route/config/testdata/config-domain.yaml @@ -0,0 +1 @@ +../../../../../config/config-domain.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/route/config/testdata/config-gc.yaml b/vendor/github.com/knative/serving/pkg/reconciler/route/config/testdata/config-gc.yaml new file mode 120000 index 0000000000..929b7c057a --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/reconciler/route/config/testdata/config-gc.yaml @@ -0,0 +1 @@ +../../../../../config/config-gc.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/route/config/testdata/config-network.yaml b/vendor/github.com/knative/serving/pkg/reconciler/route/config/testdata/config-network.yaml new file mode 120000 index 0000000000..b774d24cbb --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/reconciler/route/config/testdata/config-network.yaml @@ -0,0 +1 @@ +../../../../../config/config-network.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/clusteringress/config/testdata/config-istio.yaml b/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/clusteringress/config/testdata/config-istio.yaml deleted file mode 120000 index c9ae2a7ee3..0000000000 --- a/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/clusteringress/config/testdata/config-istio.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../../config/config-istio.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/configuration/config/testdata/config-gc.yaml b/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/configuration/config/testdata/config-gc.yaml deleted file mode 120000 index dc98107b5c..0000000000 --- a/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/configuration/config/testdata/config-gc.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../../config/config-gc.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/revision/config/testdata/config-autoscaler.yaml b/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/revision/config/testdata/config-autoscaler.yaml deleted file mode 120000 index 17e4b72c26..0000000000 --- a/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/revision/config/testdata/config-autoscaler.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../../config/config-autoscaler.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/revision/config/testdata/config-controller.yaml b/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/revision/config/testdata/config-controller.yaml deleted file mode 120000 index b8047a772b..0000000000 --- a/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/revision/config/testdata/config-controller.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../../config/config-controller.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/revision/config/testdata/config-logging.yaml b/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/revision/config/testdata/config-logging.yaml deleted file mode 120000 index cd048f0179..0000000000 --- a/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/revision/config/testdata/config-logging.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../../config/config-logging.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/revision/config/testdata/config-network.yaml b/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/revision/config/testdata/config-network.yaml deleted file mode 120000 index f17cdcd38a..0000000000 --- a/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/revision/config/testdata/config-network.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../../config/config-network.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/revision/config/testdata/config-observability.yaml b/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/revision/config/testdata/config-observability.yaml deleted file mode 120000 index a89f2a9531..0000000000 --- a/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/revision/config/testdata/config-observability.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../../config/config-observability.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/route/config/testdata/config-domain.yaml b/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/route/config/testdata/config-domain.yaml deleted file mode 120000 index 4111917256..0000000000 --- a/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/route/config/testdata/config-domain.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../../config/config-domain.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/route/config/testdata/config-gc.yaml b/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/route/config/testdata/config-gc.yaml deleted file mode 120000 index dc98107b5c..0000000000 --- a/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/route/config/testdata/config-gc.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../../config/config-gc.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/route/config/testdata/config-network.yaml b/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/route/config/testdata/config-network.yaml deleted file mode 120000 index f17cdcd38a..0000000000 --- a/vendor/github.com/knative/serving/pkg/reconciler/v1alpha1/route/config/testdata/config-network.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../../config/config-network.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/third_party/config/build/LICENSE b/vendor/github.com/knative/serving/third_party/config/build/LICENSE deleted file mode 100644 index 2c45691e88..0000000000 --- a/vendor/github.com/knative/serving/third_party/config/build/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2016 Istio 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. diff --git a/vendor/github.com/knative/serving/third_party/config/monitoring/metrics/prometheus/istio/LICENSE b/vendor/github.com/knative/serving/third_party/config/monitoring/metrics/prometheus/istio/LICENSE deleted file mode 100644 index 2c45691e88..0000000000 --- a/vendor/github.com/knative/serving/third_party/config/monitoring/metrics/prometheus/istio/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2016 Istio 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. diff --git a/vendor/github.com/knative/serving/third_party/istio-1.0-latest b/vendor/github.com/knative/serving/third_party/istio-1.0-latest new file mode 120000 index 0000000000..28c3c58ea4 --- /dev/null +++ b/vendor/github.com/knative/serving/third_party/istio-1.0-latest @@ -0,0 +1 @@ +istio-1.0.7 \ No newline at end of file diff --git a/vendor/github.com/knative/serving/third_party/istio-1.1-latest b/vendor/github.com/knative/serving/third_party/istio-1.1-latest new file mode 120000 index 0000000000..eeb30440bc --- /dev/null +++ b/vendor/github.com/knative/serving/third_party/istio-1.1-latest @@ -0,0 +1 @@ +istio-1.1.7 \ No newline at end of file diff --git a/vendor/github.com/knative/serving/third_party/istio-1.2-latest b/vendor/github.com/knative/serving/third_party/istio-1.2-latest new file mode 120000 index 0000000000..bc5de0fd09 --- /dev/null +++ b/vendor/github.com/knative/serving/third_party/istio-1.2-latest @@ -0,0 +1 @@ +istio-1.2.0 \ No newline at end of file diff --git a/vendor/github.com/knative/pkg/LICENSE b/vendor/knative.dev/pkg/LICENSE similarity index 100% rename from vendor/github.com/knative/pkg/LICENSE rename to vendor/knative.dev/pkg/LICENSE diff --git a/vendor/github.com/knative/pkg/apis/condition_set.go b/vendor/knative.dev/pkg/apis/condition_set.go similarity index 100% rename from vendor/github.com/knative/pkg/apis/condition_set.go rename to vendor/knative.dev/pkg/apis/condition_set.go diff --git a/vendor/github.com/knative/pkg/apis/condition_types.go b/vendor/knative.dev/pkg/apis/condition_types.go similarity index 100% rename from vendor/github.com/knative/pkg/apis/condition_types.go rename to vendor/knative.dev/pkg/apis/condition_types.go diff --git a/vendor/github.com/knative/pkg/apis/contexts.go b/vendor/knative.dev/pkg/apis/contexts.go similarity index 100% rename from vendor/github.com/knative/pkg/apis/contexts.go rename to vendor/knative.dev/pkg/apis/contexts.go diff --git a/vendor/github.com/knative/pkg/apis/deprecated.go b/vendor/knative.dev/pkg/apis/deprecated.go similarity index 100% rename from vendor/github.com/knative/pkg/apis/deprecated.go rename to vendor/knative.dev/pkg/apis/deprecated.go diff --git a/vendor/github.com/knative/pkg/apis/doc.go b/vendor/knative.dev/pkg/apis/doc.go similarity index 100% rename from vendor/github.com/knative/pkg/apis/doc.go rename to vendor/knative.dev/pkg/apis/doc.go diff --git a/vendor/github.com/knative/pkg/apis/duck/cached.go b/vendor/knative.dev/pkg/apis/duck/cached.go similarity index 100% rename from vendor/github.com/knative/pkg/apis/duck/cached.go rename to vendor/knative.dev/pkg/apis/duck/cached.go diff --git a/vendor/github.com/knative/pkg/apis/duck/doc.go b/vendor/knative.dev/pkg/apis/duck/doc.go similarity index 100% rename from vendor/github.com/knative/pkg/apis/duck/doc.go rename to vendor/knative.dev/pkg/apis/duck/doc.go diff --git a/vendor/github.com/knative/pkg/apis/duck/enqueue.go b/vendor/knative.dev/pkg/apis/duck/enqueue.go similarity index 100% rename from vendor/github.com/knative/pkg/apis/duck/enqueue.go rename to vendor/knative.dev/pkg/apis/duck/enqueue.go diff --git a/vendor/github.com/knative/pkg/apis/duck/interface.go b/vendor/knative.dev/pkg/apis/duck/interface.go similarity index 100% rename from vendor/github.com/knative/pkg/apis/duck/interface.go rename to vendor/knative.dev/pkg/apis/duck/interface.go diff --git a/vendor/github.com/knative/pkg/apis/duck/patch.go b/vendor/knative.dev/pkg/apis/duck/patch.go similarity index 100% rename from vendor/github.com/knative/pkg/apis/duck/patch.go rename to vendor/knative.dev/pkg/apis/duck/patch.go diff --git a/vendor/github.com/knative/pkg/apis/duck/proxy.go b/vendor/knative.dev/pkg/apis/duck/proxy.go similarity index 100% rename from vendor/github.com/knative/pkg/apis/duck/proxy.go rename to vendor/knative.dev/pkg/apis/duck/proxy.go diff --git a/vendor/github.com/knative/pkg/apis/duck/register.go b/vendor/knative.dev/pkg/apis/duck/register.go similarity index 100% rename from vendor/github.com/knative/pkg/apis/duck/register.go rename to vendor/knative.dev/pkg/apis/duck/register.go diff --git a/vendor/github.com/knative/pkg/apis/duck/typed.go b/vendor/knative.dev/pkg/apis/duck/typed.go similarity index 99% rename from vendor/github.com/knative/pkg/apis/duck/typed.go rename to vendor/knative.dev/pkg/apis/duck/typed.go index 397f3a8749..bf992c49f6 100644 --- a/vendor/github.com/knative/pkg/apis/duck/typed.go +++ b/vendor/knative.dev/pkg/apis/duck/typed.go @@ -29,7 +29,7 @@ import ( "k8s.io/client-go/dynamic" "k8s.io/client-go/tools/cache" - "github.com/knative/pkg/apis" + "knative.dev/pkg/apis" ) // TypedInformerFactory implements InformerFactory such that the elements diff --git a/vendor/github.com/knative/pkg/apis/duck/unstructured.go b/vendor/knative.dev/pkg/apis/duck/unstructured.go similarity index 100% rename from vendor/github.com/knative/pkg/apis/duck/unstructured.go rename to vendor/knative.dev/pkg/apis/duck/unstructured.go diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/addressable_types.go b/vendor/knative.dev/pkg/apis/duck/v1alpha1/addressable_types.go similarity index 96% rename from vendor/github.com/knative/pkg/apis/duck/v1alpha1/addressable_types.go rename to vendor/knative.dev/pkg/apis/duck/v1alpha1/addressable_types.go index 75ab2f573e..2b5fcbd9e2 100644 --- a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/addressable_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1alpha1/addressable_types.go @@ -20,9 +20,9 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "github.com/knative/pkg/apis" - "github.com/knative/pkg/apis/duck" - "github.com/knative/pkg/apis/duck/v1beta1" + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" + "knative.dev/pkg/apis/duck/v1beta1" ) // Addressable provides a generic mechanism for a custom resource diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/condition_set.go b/vendor/knative.dev/pkg/apis/duck/v1alpha1/condition_set.go similarity index 99% rename from vendor/github.com/knative/pkg/apis/duck/v1alpha1/condition_set.go rename to vendor/knative.dev/pkg/apis/duck/v1alpha1/condition_set.go index 72d4bf605d..490a5bb8d9 100644 --- a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/condition_set.go +++ b/vendor/knative.dev/pkg/apis/duck/v1alpha1/condition_set.go @@ -23,7 +23,7 @@ import ( "fmt" - "github.com/knative/pkg/apis" + "knative.dev/pkg/apis" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/conditions_types.go b/vendor/knative.dev/pkg/apis/duck/v1alpha1/conditions_types.go similarity index 99% rename from vendor/github.com/knative/pkg/apis/duck/v1alpha1/conditions_types.go rename to vendor/knative.dev/pkg/apis/duck/v1alpha1/conditions_types.go index b82de3c4c2..12003a5863 100644 --- a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/conditions_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1alpha1/conditions_types.go @@ -23,8 +23,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "github.com/knative/pkg/apis" - "github.com/knative/pkg/apis/duck" + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" ) // Conditions is the schema for the conditions portion of the payload diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/doc.go b/vendor/knative.dev/pkg/apis/duck/v1alpha1/doc.go similarity index 100% rename from vendor/github.com/knative/pkg/apis/duck/v1alpha1/doc.go rename to vendor/knative.dev/pkg/apis/duck/v1alpha1/doc.go diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/legacy_targetable_types.go b/vendor/knative.dev/pkg/apis/duck/v1alpha1/legacy_targetable_types.go similarity index 97% rename from vendor/github.com/knative/pkg/apis/duck/v1alpha1/legacy_targetable_types.go rename to vendor/knative.dev/pkg/apis/duck/v1alpha1/legacy_targetable_types.go index 5e4d6f2e38..27e7c3daaa 100644 --- a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/legacy_targetable_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1alpha1/legacy_targetable_types.go @@ -20,8 +20,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "github.com/knative/pkg/apis" - "github.com/knative/pkg/apis/duck" + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" ) // LegacyTargetable left around until we migrate to Addressable in the diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/register.go b/vendor/knative.dev/pkg/apis/duck/v1alpha1/register.go similarity index 98% rename from vendor/github.com/knative/pkg/apis/duck/v1alpha1/register.go rename to vendor/knative.dev/pkg/apis/duck/v1alpha1/register.go index 4bb344f2ac..51e3565cde 100644 --- a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/register.go +++ b/vendor/knative.dev/pkg/apis/duck/v1alpha1/register.go @@ -17,7 +17,7 @@ limitations under the License. package v1alpha1 import ( - "github.com/knative/pkg/apis/duck" + "knative.dev/pkg/apis/duck" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/retired_targetable_types.go b/vendor/knative.dev/pkg/apis/duck/v1alpha1/retired_targetable_types.go similarity index 97% rename from vendor/github.com/knative/pkg/apis/duck/v1alpha1/retired_targetable_types.go rename to vendor/knative.dev/pkg/apis/duck/v1alpha1/retired_targetable_types.go index 0e91aef8ac..9306336d27 100644 --- a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/retired_targetable_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1alpha1/retired_targetable_types.go @@ -20,8 +20,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "github.com/knative/pkg/apis" - "github.com/knative/pkg/apis/duck" + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" ) // Targetable is an earlier version of the Callable interface. diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go b/vendor/knative.dev/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go similarity index 100% rename from vendor/github.com/knative/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go rename to vendor/knative.dev/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go diff --git a/vendor/github.com/knative/pkg/apis/duck/v1beta1/addressable_types.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/addressable_types.go similarity index 97% rename from vendor/github.com/knative/pkg/apis/duck/v1beta1/addressable_types.go rename to vendor/knative.dev/pkg/apis/duck/v1beta1/addressable_types.go index 379098e7f2..817585a3b3 100644 --- a/vendor/github.com/knative/pkg/apis/duck/v1beta1/addressable_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/addressable_types.go @@ -20,8 +20,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "github.com/knative/pkg/apis" - "github.com/knative/pkg/apis/duck" + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" ) // Addressable provides a generic mechanism for a custom resource diff --git a/vendor/github.com/knative/pkg/apis/duck/v1beta1/doc.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/doc.go similarity index 100% rename from vendor/github.com/knative/pkg/apis/duck/v1beta1/doc.go rename to vendor/knative.dev/pkg/apis/duck/v1beta1/doc.go diff --git a/vendor/github.com/knative/pkg/apis/duck/v1beta1/register.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/register.go similarity index 97% rename from vendor/github.com/knative/pkg/apis/duck/v1beta1/register.go rename to vendor/knative.dev/pkg/apis/duck/v1beta1/register.go index c337e4a619..7d5ac1c428 100644 --- a/vendor/github.com/knative/pkg/apis/duck/v1beta1/register.go +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/register.go @@ -17,7 +17,7 @@ limitations under the License. package v1beta1 import ( - "github.com/knative/pkg/apis/duck" + "knative.dev/pkg/apis/duck" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/vendor/github.com/knative/pkg/apis/duck/v1beta1/status_types.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/status_types.go similarity index 98% rename from vendor/github.com/knative/pkg/apis/duck/v1beta1/status_types.go rename to vendor/knative.dev/pkg/apis/duck/v1beta1/status_types.go index b999737ae1..7056b0d095 100644 --- a/vendor/github.com/knative/pkg/apis/duck/v1beta1/status_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/status_types.go @@ -24,8 +24,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "github.com/knative/pkg/apis" - "github.com/knative/pkg/apis/duck" + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" ) // Conditions is a simple wrapper around apis.Conditions to implement duck.Implementable. diff --git a/vendor/github.com/knative/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go similarity index 99% rename from vendor/github.com/knative/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go rename to vendor/knative.dev/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go index 791c06d96a..329aabb64b 100644 --- a/vendor/github.com/knative/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go @@ -21,8 +21,8 @@ limitations under the License. package v1beta1 import ( - apis "github.com/knative/pkg/apis" runtime "k8s.io/apimachinery/pkg/runtime" + apis "knative.dev/pkg/apis" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. diff --git a/vendor/github.com/knative/pkg/apis/duck/verify.go b/vendor/knative.dev/pkg/apis/duck/verify.go similarity index 99% rename from vendor/github.com/knative/pkg/apis/duck/verify.go rename to vendor/knative.dev/pkg/apis/duck/verify.go index eb6bdebf43..236a392c7e 100644 --- a/vendor/github.com/knative/pkg/apis/duck/verify.go +++ b/vendor/knative.dev/pkg/apis/duck/verify.go @@ -20,7 +20,7 @@ import ( "encoding/json" "fmt" - "github.com/knative/pkg/kmp" + "knative.dev/pkg/kmp" ) // Implementable is implemented by the Fooable duck type that consumers diff --git a/vendor/github.com/knative/pkg/apis/field_error.go b/vendor/knative.dev/pkg/apis/field_error.go similarity index 99% rename from vendor/github.com/knative/pkg/apis/field_error.go rename to vendor/knative.dev/pkg/apis/field_error.go index 8b56be976e..59b281d6ee 100644 --- a/vendor/github.com/knative/pkg/apis/field_error.go +++ b/vendor/knative.dev/pkg/apis/field_error.go @@ -21,7 +21,7 @@ import ( "sort" "strings" - "github.com/knative/pkg/kmp" + "knative.dev/pkg/kmp" ) // CurrentField is a constant to supply as a fieldPath for when there is diff --git a/vendor/github.com/knative/pkg/apis/interfaces.go b/vendor/knative.dev/pkg/apis/interfaces.go similarity index 90% rename from vendor/github.com/knative/pkg/apis/interfaces.go rename to vendor/knative.dev/pkg/apis/interfaces.go index 601d083dd6..6b6c772d74 100644 --- a/vendor/github.com/knative/pkg/apis/interfaces.go +++ b/vendor/knative.dev/pkg/apis/interfaces.go @@ -66,3 +66,10 @@ type Listable interface { // The webhook functionality for this has been turned down, which is why this // interface is empty. type Annotatable interface{} + +// HasSpec indicates that a particular type has a specification information +// and that information is retrievable. +type HasSpec interface { + // GetUntypedSpec returns the spec of the resource. + GetUntypedSpec() interface{} +} diff --git a/vendor/github.com/knative/pkg/apis/kind2resource.go b/vendor/knative.dev/pkg/apis/kind2resource.go similarity index 100% rename from vendor/github.com/knative/pkg/apis/kind2resource.go rename to vendor/knative.dev/pkg/apis/kind2resource.go diff --git a/vendor/github.com/knative/pkg/apis/metadata_validation.go b/vendor/knative.dev/pkg/apis/metadata_validation.go similarity index 100% rename from vendor/github.com/knative/pkg/apis/metadata_validation.go rename to vendor/knative.dev/pkg/apis/metadata_validation.go diff --git a/vendor/github.com/knative/pkg/apis/url.go b/vendor/knative.dev/pkg/apis/url.go similarity index 100% rename from vendor/github.com/knative/pkg/apis/url.go rename to vendor/knative.dev/pkg/apis/url.go diff --git a/vendor/github.com/knative/pkg/apis/volatile_time.go b/vendor/knative.dev/pkg/apis/volatile_time.go similarity index 100% rename from vendor/github.com/knative/pkg/apis/volatile_time.go rename to vendor/knative.dev/pkg/apis/volatile_time.go diff --git a/vendor/github.com/knative/pkg/apis/zz_generated.deepcopy.go b/vendor/knative.dev/pkg/apis/zz_generated.deepcopy.go similarity index 100% rename from vendor/github.com/knative/pkg/apis/zz_generated.deepcopy.go rename to vendor/knative.dev/pkg/apis/zz_generated.deepcopy.go diff --git a/vendor/github.com/knative/pkg/changeset/commit.go b/vendor/knative.dev/pkg/changeset/commit.go similarity index 100% rename from vendor/github.com/knative/pkg/changeset/commit.go rename to vendor/knative.dev/pkg/changeset/commit.go diff --git a/vendor/github.com/knative/pkg/changeset/doc.go b/vendor/knative.dev/pkg/changeset/doc.go similarity index 100% rename from vendor/github.com/knative/pkg/changeset/doc.go rename to vendor/knative.dev/pkg/changeset/doc.go diff --git a/vendor/github.com/knative/pkg/configmap/doc.go b/vendor/knative.dev/pkg/configmap/doc.go similarity index 100% rename from vendor/github.com/knative/pkg/configmap/doc.go rename to vendor/knative.dev/pkg/configmap/doc.go diff --git a/vendor/github.com/knative/pkg/configmap/filter.go b/vendor/knative.dev/pkg/configmap/filter.go similarity index 100% rename from vendor/github.com/knative/pkg/configmap/filter.go rename to vendor/knative.dev/pkg/configmap/filter.go diff --git a/vendor/github.com/knative/pkg/configmap/informed_watcher.go b/vendor/knative.dev/pkg/configmap/informed_watcher.go similarity index 100% rename from vendor/github.com/knative/pkg/configmap/informed_watcher.go rename to vendor/knative.dev/pkg/configmap/informed_watcher.go diff --git a/vendor/github.com/knative/pkg/configmap/load.go b/vendor/knative.dev/pkg/configmap/load.go similarity index 100% rename from vendor/github.com/knative/pkg/configmap/load.go rename to vendor/knative.dev/pkg/configmap/load.go diff --git a/vendor/github.com/knative/pkg/configmap/manual_watcher.go b/vendor/knative.dev/pkg/configmap/manual_watcher.go similarity index 100% rename from vendor/github.com/knative/pkg/configmap/manual_watcher.go rename to vendor/knative.dev/pkg/configmap/manual_watcher.go diff --git a/vendor/github.com/knative/pkg/configmap/static_watcher.go b/vendor/knative.dev/pkg/configmap/static_watcher.go similarity index 100% rename from vendor/github.com/knative/pkg/configmap/static_watcher.go rename to vendor/knative.dev/pkg/configmap/static_watcher.go diff --git a/vendor/github.com/knative/pkg/configmap/store.go b/vendor/knative.dev/pkg/configmap/store.go similarity index 100% rename from vendor/github.com/knative/pkg/configmap/store.go rename to vendor/knative.dev/pkg/configmap/store.go diff --git a/vendor/github.com/knative/pkg/configmap/watcher.go b/vendor/knative.dev/pkg/configmap/watcher.go similarity index 100% rename from vendor/github.com/knative/pkg/configmap/watcher.go rename to vendor/knative.dev/pkg/configmap/watcher.go diff --git a/vendor/github.com/knative/pkg/kmeta/accessor.go b/vendor/knative.dev/pkg/kmeta/accessor.go similarity index 100% rename from vendor/github.com/knative/pkg/kmeta/accessor.go rename to vendor/knative.dev/pkg/kmeta/accessor.go diff --git a/vendor/github.com/knative/pkg/kmeta/doc.go b/vendor/knative.dev/pkg/kmeta/doc.go similarity index 100% rename from vendor/github.com/knative/pkg/kmeta/doc.go rename to vendor/knative.dev/pkg/kmeta/doc.go diff --git a/vendor/github.com/knative/pkg/kmeta/labels.go b/vendor/knative.dev/pkg/kmeta/labels.go similarity index 100% rename from vendor/github.com/knative/pkg/kmeta/labels.go rename to vendor/knative.dev/pkg/kmeta/labels.go diff --git a/vendor/github.com/knative/pkg/kmeta/names.go b/vendor/knative.dev/pkg/kmeta/names.go similarity index 100% rename from vendor/github.com/knative/pkg/kmeta/names.go rename to vendor/knative.dev/pkg/kmeta/names.go diff --git a/vendor/github.com/knative/pkg/kmeta/owner_references.go b/vendor/knative.dev/pkg/kmeta/owner_references.go similarity index 100% rename from vendor/github.com/knative/pkg/kmeta/owner_references.go rename to vendor/knative.dev/pkg/kmeta/owner_references.go diff --git a/vendor/github.com/knative/pkg/kmp/diff.go b/vendor/knative.dev/pkg/kmp/diff.go similarity index 100% rename from vendor/github.com/knative/pkg/kmp/diff.go rename to vendor/knative.dev/pkg/kmp/diff.go diff --git a/vendor/github.com/knative/pkg/kmp/doc.go b/vendor/knative.dev/pkg/kmp/doc.go similarity index 100% rename from vendor/github.com/knative/pkg/kmp/doc.go rename to vendor/knative.dev/pkg/kmp/doc.go diff --git a/vendor/github.com/knative/pkg/kmp/reporters.go b/vendor/knative.dev/pkg/kmp/reporters.go similarity index 100% rename from vendor/github.com/knative/pkg/kmp/reporters.go rename to vendor/knative.dev/pkg/kmp/reporters.go diff --git a/vendor/github.com/knative/pkg/logging/config.go b/vendor/knative.dev/pkg/logging/config.go similarity index 98% rename from vendor/github.com/knative/pkg/logging/config.go rename to vendor/knative.dev/pkg/logging/config.go index 236a449864..1a658fdc00 100644 --- a/vendor/github.com/knative/pkg/logging/config.go +++ b/vendor/knative.dev/pkg/logging/config.go @@ -27,8 +27,8 @@ import ( "go.uber.org/zap/zapcore" corev1 "k8s.io/api/core/v1" - "github.com/knative/pkg/changeset" - "github.com/knative/pkg/logging/logkey" + "knative.dev/pkg/changeset" + "knative.dev/pkg/logging/logkey" ) const ConfigMapNameEnv = "CONFIG_LOGGING_NAME" diff --git a/vendor/github.com/knative/pkg/logging/logger.go b/vendor/knative.dev/pkg/logging/logger.go similarity index 100% rename from vendor/github.com/knative/pkg/logging/logger.go rename to vendor/knative.dev/pkg/logging/logger.go diff --git a/vendor/github.com/knative/pkg/logging/logkey/constants.go b/vendor/knative.dev/pkg/logging/logkey/constants.go similarity index 100% rename from vendor/github.com/knative/pkg/logging/logkey/constants.go rename to vendor/knative.dev/pkg/logging/logkey/constants.go diff --git a/vendor/github.com/knative/pkg/logging/zz_generated.deepcopy.go b/vendor/knative.dev/pkg/logging/zz_generated.deepcopy.go similarity index 100% rename from vendor/github.com/knative/pkg/logging/zz_generated.deepcopy.go rename to vendor/knative.dev/pkg/logging/zz_generated.deepcopy.go diff --git a/vendor/knative.dev/pkg/ptr/doc.go b/vendor/knative.dev/pkg/ptr/doc.go new file mode 100644 index 0000000000..1ebcea2845 --- /dev/null +++ b/vendor/knative.dev/pkg/ptr/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. +*/ + +// Package ptr holds utilities for taking pointer references to values. +package ptr diff --git a/vendor/knative.dev/pkg/ptr/ptr.go b/vendor/knative.dev/pkg/ptr/ptr.go new file mode 100644 index 0000000000..3564647338 --- /dev/null +++ b/vendor/knative.dev/pkg/ptr/ptr.go @@ -0,0 +1,41 @@ +/* +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 ptr + +// Int32 is a helper for turning integers into pointers for use in +// API types that want *int32. +func Int32(i int32) *int32 { + return &i +} + +// Int64 is a helper for turning integers into pointers for use in +// API types that want *int64. +func Int64(i int64) *int64 { + return &i +} + +// Bool is a helper for turning bools into pointers for use in +// API types that want *bool. +func Bool(b bool) *bool { + return &b +} + +// String is a helper for turning strings into pointers for use in +// API types that want *string. +func String(s string) *string { + return &s +} diff --git a/vendor/github.com/knative/pkg/signals/signal.go b/vendor/knative.dev/pkg/signals/signal.go similarity index 100% rename from vendor/github.com/knative/pkg/signals/signal.go rename to vendor/knative.dev/pkg/signals/signal.go diff --git a/vendor/github.com/knative/pkg/signals/signal_posix.go b/vendor/knative.dev/pkg/signals/signal_posix.go similarity index 100% rename from vendor/github.com/knative/pkg/signals/signal_posix.go rename to vendor/knative.dev/pkg/signals/signal_posix.go diff --git a/vendor/github.com/knative/pkg/signals/signal_windows.go b/vendor/knative.dev/pkg/signals/signal_windows.go similarity index 100% rename from vendor/github.com/knative/pkg/signals/signal_windows.go rename to vendor/knative.dev/pkg/signals/signal_windows.go diff --git a/vendor/github.com/knative/pkg/test/cleanup.go b/vendor/knative.dev/pkg/test/cleanup.go similarity index 96% rename from vendor/github.com/knative/pkg/test/cleanup.go rename to vendor/knative.dev/pkg/test/cleanup.go index aa2c860fd8..b349172629 100644 --- a/vendor/github.com/knative/pkg/test/cleanup.go +++ b/vendor/knative.dev/pkg/test/cleanup.go @@ -23,7 +23,7 @@ import ( "os" "os/signal" - "github.com/knative/pkg/test/logging" + "knative.dev/pkg/test/logging" ) // CleanupOnInterrupt will execute the function cleanup if an interrupt signal is caught diff --git a/vendor/github.com/knative/pkg/test/clients.go b/vendor/knative.dev/pkg/test/clients.go similarity index 98% rename from vendor/github.com/knative/pkg/test/clients.go rename to vendor/knative.dev/pkg/test/clients.go index fbd9e65836..44f7532f0a 100644 --- a/vendor/github.com/knative/pkg/test/clients.go +++ b/vendor/knative.dev/pkg/test/clients.go @@ -22,8 +22,8 @@ import ( "fmt" "strings" - "github.com/knative/pkg/test/logging" - "github.com/knative/pkg/test/spoof" + "knative.dev/pkg/test/logging" + "knative.dev/pkg/test/spoof" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" diff --git a/vendor/github.com/knative/pkg/test/crd.go b/vendor/knative.dev/pkg/test/crd.go similarity index 100% rename from vendor/github.com/knative/pkg/test/crd.go rename to vendor/knative.dev/pkg/test/crd.go diff --git a/vendor/github.com/knative/pkg/test/e2e_flags.go b/vendor/knative.dev/pkg/test/e2e_flags.go similarity index 100% rename from vendor/github.com/knative/pkg/test/e2e_flags.go rename to vendor/knative.dev/pkg/test/e2e_flags.go diff --git a/vendor/github.com/knative/pkg/test/ingress/ingress.go b/vendor/knative.dev/pkg/test/ingress/ingress.go similarity index 100% rename from vendor/github.com/knative/pkg/test/ingress/ingress.go rename to vendor/knative.dev/pkg/test/ingress/ingress.go diff --git a/vendor/github.com/knative/pkg/test/kube_checks.go b/vendor/knative.dev/pkg/test/kube_checks.go similarity index 99% rename from vendor/github.com/knative/pkg/test/kube_checks.go rename to vendor/knative.dev/pkg/test/kube_checks.go index 1b78914f5e..cf1b6cc406 100644 --- a/vendor/github.com/knative/pkg/test/kube_checks.go +++ b/vendor/knative.dev/pkg/test/kube_checks.go @@ -25,7 +25,7 @@ import ( "strings" "time" - "github.com/knative/pkg/test/logging" + "knative.dev/pkg/test/logging" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/vendor/github.com/knative/pkg/test/logging/logging.go b/vendor/knative.dev/pkg/test/logging/logging.go similarity index 99% rename from vendor/github.com/knative/pkg/test/logging/logging.go rename to vendor/knative.dev/pkg/test/logging/logging.go index 2c641bd7a9..13bd1d72ef 100644 --- a/vendor/github.com/knative/pkg/test/logging/logging.go +++ b/vendor/knative.dev/pkg/test/logging/logging.go @@ -28,7 +28,7 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/golang/glog" - "github.com/knative/pkg/logging" + "knative.dev/pkg/logging" "go.opencensus.io/stats/view" "go.opencensus.io/trace" "go.uber.org/zap" diff --git a/vendor/github.com/knative/pkg/test/monitoring/doc.go b/vendor/knative.dev/pkg/test/monitoring/doc.go similarity index 100% rename from vendor/github.com/knative/pkg/test/monitoring/doc.go rename to vendor/knative.dev/pkg/test/monitoring/doc.go diff --git a/vendor/github.com/knative/pkg/test/monitoring/monitoring.go b/vendor/knative.dev/pkg/test/monitoring/monitoring.go similarity index 98% rename from vendor/github.com/knative/pkg/test/monitoring/monitoring.go rename to vendor/knative.dev/pkg/test/monitoring/monitoring.go index ccbad42b17..ea593d623b 100644 --- a/vendor/github.com/knative/pkg/test/monitoring/monitoring.go +++ b/vendor/knative.dev/pkg/test/monitoring/monitoring.go @@ -23,7 +23,7 @@ import ( "os/exec" "strings" - "github.com/knative/pkg/test/logging" + "knative.dev/pkg/test/logging" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" diff --git a/vendor/github.com/knative/pkg/test/request.go b/vendor/knative.dev/pkg/test/request.go similarity index 98% rename from vendor/github.com/knative/pkg/test/request.go rename to vendor/knative.dev/pkg/test/request.go index 5840d2a448..462c857e2f 100644 --- a/vendor/github.com/knative/pkg/test/request.go +++ b/vendor/knative.dev/pkg/test/request.go @@ -26,8 +26,8 @@ import ( "strings" "time" - "github.com/knative/pkg/test/logging" - "github.com/knative/pkg/test/spoof" + "knative.dev/pkg/test/logging" + "knative.dev/pkg/test/spoof" ) // RequestOption enables configuration of requests diff --git a/vendor/github.com/knative/pkg/test/spoof/error_checks.go b/vendor/knative.dev/pkg/test/spoof/error_checks.go similarity index 100% rename from vendor/github.com/knative/pkg/test/spoof/error_checks.go rename to vendor/knative.dev/pkg/test/spoof/error_checks.go diff --git a/vendor/github.com/knative/pkg/test/spoof/spoof.go b/vendor/knative.dev/pkg/test/spoof/spoof.go similarity index 98% rename from vendor/github.com/knative/pkg/test/spoof/spoof.go rename to vendor/knative.dev/pkg/test/spoof/spoof.go index f23d3049e1..37f83b6c0f 100644 --- a/vendor/github.com/knative/pkg/test/spoof/spoof.go +++ b/vendor/knative.dev/pkg/test/spoof/spoof.go @@ -24,9 +24,9 @@ import ( "net/http" "time" - ingress "github.com/knative/pkg/test/ingress" - "github.com/knative/pkg/test/logging" - "github.com/knative/pkg/test/zipkin" + ingress "knative.dev/pkg/test/ingress" + "knative.dev/pkg/test/logging" + "knative.dev/pkg/test/zipkin" "github.com/pkg/errors" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/kubernetes" diff --git a/vendor/github.com/knative/pkg/test/zipkin/doc.go b/vendor/knative.dev/pkg/test/zipkin/doc.go similarity index 100% rename from vendor/github.com/knative/pkg/test/zipkin/doc.go rename to vendor/knative.dev/pkg/test/zipkin/doc.go diff --git a/vendor/github.com/knative/pkg/test/zipkin/util.go b/vendor/knative.dev/pkg/test/zipkin/util.go similarity index 98% rename from vendor/github.com/knative/pkg/test/zipkin/util.go rename to vendor/knative.dev/pkg/test/zipkin/util.go index add07498f4..cbf3c7eb3d 100644 --- a/vendor/github.com/knative/pkg/test/zipkin/util.go +++ b/vendor/knative.dev/pkg/test/zipkin/util.go @@ -25,8 +25,8 @@ import ( "net/http" "sync" - "github.com/knative/pkg/test/logging" - "github.com/knative/pkg/test/monitoring" + "knative.dev/pkg/test/logging" + "knative.dev/pkg/test/monitoring" "go.opencensus.io/trace" "k8s.io/client-go/kubernetes" ) diff --git a/vendor/github.com/knative/pkg/webhook/certs.go b/vendor/knative.dev/pkg/webhook/certs.go similarity index 99% rename from vendor/github.com/knative/pkg/webhook/certs.go rename to vendor/knative.dev/pkg/webhook/certs.go index ba0ee73937..1a0348394d 100644 --- a/vendor/github.com/knative/pkg/webhook/certs.go +++ b/vendor/knative.dev/pkg/webhook/certs.go @@ -29,7 +29,7 @@ import ( "go.uber.org/zap" - "github.com/knative/pkg/logging" + "knative.dev/pkg/logging" ) const ( diff --git a/vendor/knative.dev/pkg/webhook/user_info.go b/vendor/knative.dev/pkg/webhook/user_info.go new file mode 100644 index 0000000000..24f5bd9ed5 --- /dev/null +++ b/vendor/knative.dev/pkg/webhook/user_info.go @@ -0,0 +1,62 @@ +/* +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 webhook + +import ( + "context" + + "k8s.io/apimachinery/pkg/api/equality" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "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 = "/updater" +) + +// 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 { + objectMetaAccessor, ok := resource.(metav1.ObjectMetaAccessor) + if !ok { + return + } + + annotations := objectMetaAccessor.GetObjectMeta().GetAnnotations() + if annotations == nil { + annotations = map[string]string{} + defer objectMetaAccessor.GetObjectMeta().SetAnnotations(annotations) + } + + if apis.IsInUpdate(ctx) { + old := apis.GetBaseline(ctx).(apis.HasSpec) + if equality.Semantic.DeepEqual(old.GetUntypedSpec(), resource.GetUntypedSpec()) { + return + } + annotations[groupName+UpdaterAnnotationSuffix] = ui.Username + } else { + annotations[groupName+CreatorAnnotationSuffix] = ui.Username + annotations[groupName+UpdaterAnnotationSuffix] = ui.Username + } + } +} diff --git a/vendor/github.com/knative/pkg/webhook/webhook.go b/vendor/knative.dev/pkg/webhook/webhook.go similarity index 95% rename from vendor/github.com/knative/pkg/webhook/webhook.go rename to vendor/knative.dev/pkg/webhook/webhook.go index 8ed6417655..7f23b47edc 100644 --- a/vendor/github.com/knative/pkg/webhook/webhook.go +++ b/vendor/knative.dev/pkg/webhook/webhook.go @@ -31,11 +31,11 @@ import ( "go.uber.org/zap" - "github.com/knative/pkg/apis" - "github.com/knative/pkg/apis/duck" - "github.com/knative/pkg/kmp" - "github.com/knative/pkg/logging" - "github.com/knative/pkg/logging/logkey" + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" + "knative.dev/pkg/kmp" + "knative.dev/pkg/logging" + "knative.dev/pkg/logging/logkey" "github.com/markbates/inflect" "github.com/mattbaird/jsonpatch" @@ -550,6 +550,11 @@ func (ac *AdmissionController) mutate(ctx context.Context, req *admissionv1beta1 oldObj = oldObj.DeepCopyObject().(GenericCRD) oldObj.SetDefaults(ctx) + s, ok := oldObj.(apis.HasSpec) + if ok { + SetUserInfoAnnotations(s, ctx, req.Resource.Group) + } + if req.SubResource == "" { ctx = apis.WithinUpdate(ctx, oldObj) } else { @@ -568,6 +573,11 @@ func (ac *AdmissionController) mutate(ctx context.Context, req *admissionv1beta1 return nil, err } + if patches, err = ac.setUserInfoAnnotations(ctx, patches, newObj, req.Resource.Group); err != nil { + logger.Errorw("Failed the resource user info annotator", zap.Error(err)) + return nil, err + } + // None of the validators will accept a nil value for newObj. if newObj == nil { return nil, errMissingNewObject @@ -582,6 +592,26 @@ func (ac *AdmissionController) mutate(ctx context.Context, req *admissionv1beta1 return json.Marshal(patches) } +func (ac *AdmissionController) setUserInfoAnnotations(ctx context.Context, patches duck.JSONPatch, new GenericCRD, groupName string) (duck.JSONPatch, error) { + if new == nil { + return patches, nil + } + nh, ok := new.(apis.HasSpec) + if !ok { + return patches, nil + } + + b, a := new.DeepCopyObject().(apis.HasSpec), nh + + SetUserInfoAnnotations(nh, ctx, groupName) + + patch, err := duck.CreatePatch(b, a) + if err != nil { + return nil, err + } + return append(patches, patch...), nil +} + // roundTripPatch generates the JSONPatch that corresponds to round tripping the given bytes through // the Golang type (JSON -> Golang type -> JSON). Because it is not always true that // bytes == json.Marshal(json.Unmarshal(bytes)).