diff --git a/Gopkg.lock b/Gopkg.lock index f3884258fe..dfa55c2711 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -208,6 +208,13 @@ pruneopts = "NUT" revision = "6f77996f0c42f7b84e5a2b252227263f93432e9b" +[[projects]] + digest = "1:7915c656a10819b240db94ffd6afc6a621af4687db735341d9919668750485ec" + name = "github.com/google/go-containerregistry" + packages = ["pkg/name"] + pruneopts = "NUT" + revision = "abf9ef06abd9f532944e28e8942644ea4b710a40" + [[projects]] branch = "master" digest = "1:52c5834e2bebac9030c97cc0798ac11c3aa8a39f098aeb419f142533da6cd3cc" @@ -326,6 +333,52 @@ pruneopts = "NUT" revision = "677d3d17e84b7337f006220d6bb465af4f416f81" +[[projects]] + digest = "1:68ecd48e097f4e52b9802781008a5d282a6f350f0efa86f2314d7fd81eefe99e" + name = "github.com/knative/serving" + packages = [ + "pkg/apis/autoscaling", + "pkg/apis/autoscaling/v1alpha1", + "pkg/apis/config", + "pkg/apis/networking", + "pkg/apis/networking/v1alpha1", + "pkg/apis/serving", + "pkg/apis/serving/v1alpha1", + "pkg/apis/serving/v1beta1", + "pkg/client/clientset/versioned", + "pkg/client/clientset/versioned/fake", + "pkg/client/clientset/versioned/scheme", + "pkg/client/clientset/versioned/typed/autoscaling/v1alpha1", + "pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake", + "pkg/client/clientset/versioned/typed/networking/v1alpha1", + "pkg/client/clientset/versioned/typed/networking/v1alpha1/fake", + "pkg/client/clientset/versioned/typed/serving/v1alpha1", + "pkg/client/clientset/versioned/typed/serving/v1alpha1/fake", + "pkg/client/clientset/versioned/typed/serving/v1beta1", + "pkg/client/clientset/versioned/typed/serving/v1beta1/fake", + "pkg/client/informers/externalversions", + "pkg/client/informers/externalversions/autoscaling", + "pkg/client/informers/externalversions/autoscaling/v1alpha1", + "pkg/client/informers/externalversions/internalinterfaces", + "pkg/client/informers/externalversions/networking", + "pkg/client/informers/externalversions/networking/v1alpha1", + "pkg/client/informers/externalversions/serving", + "pkg/client/informers/externalversions/serving/v1alpha1", + "pkg/client/informers/externalversions/serving/v1beta1", + "pkg/client/injection/client", + "pkg/client/injection/client/fake", + "pkg/client/injection/informers/serving/factory", + "pkg/client/injection/informers/serving/factory/fake", + "pkg/client/injection/informers/serving/v1beta1/service", + "pkg/client/injection/informers/serving/v1beta1/service/fake", + "pkg/client/listers/autoscaling/v1alpha1", + "pkg/client/listers/networking/v1alpha1", + "pkg/client/listers/serving/v1alpha1", + "pkg/client/listers/serving/v1beta1", + ] + pruneopts = "NUT" + revision = "50cdf8762deae58ed89763adef26a88e7efecac7" + [[projects]] branch = "master" digest = "1:bba4889bf4bf0a2f132ed8a2bbc4725c2877bc7b7dee37cdc551351b862a3559" @@ -1117,6 +1170,7 @@ "logging/testing", "metrics", "metrics/metricskey", + "ptr", "reconciler/testing", "signals", "system", @@ -1142,13 +1196,21 @@ "github.com/google/go-cmp/cmp/cmpopts", "github.com/kelseyhightower/envconfig", "github.com/knative/eventing/pkg/apis/duck/v1alpha1", + "github.com/knative/serving/pkg/apis/serving/v1beta1", + "github.com/knative/serving/pkg/client/clientset/versioned", + "github.com/knative/serving/pkg/client/clientset/versioned/fake", + "github.com/knative/serving/pkg/client/injection/client", + "github.com/knative/serving/pkg/client/injection/client/fake", + "github.com/knative/serving/pkg/client/injection/informers/serving/v1beta1/service", + "github.com/knative/serving/pkg/client/injection/informers/serving/v1beta1/service/fake", + "github.com/knative/serving/pkg/client/listers/serving/v1beta1", "github.com/knative/test-infra/scripts", "github.com/knative/test-infra/tools/dep-collector", "go.opencensus.io/stats", "go.opencensus.io/stats/view", "go.opencensus.io/tag", "go.uber.org/zap", - "golang.org/x/net/context", + "go.uber.org/zap/zapcore", "google.golang.org/api/option", "k8s.io/api/apps/v1", "k8s.io/api/batch/v1", @@ -1163,6 +1225,7 @@ "k8s.io/apimachinery/pkg/runtime/schema", "k8s.io/apimachinery/pkg/runtime/serializer", "k8s.io/apimachinery/pkg/types", + "k8s.io/apimachinery/pkg/util/intstr", "k8s.io/apimachinery/pkg/util/runtime", "k8s.io/apimachinery/pkg/util/sets", "k8s.io/apimachinery/pkg/util/sets/types", diff --git a/Gopkg.toml b/Gopkg.toml index 685d20fd75..59c0e913fc 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -23,9 +23,14 @@ required = [ [[override]] name = "github.com/knative/eventing" - # HEAD as of 2919-06-26 + # HEAD as of 2019-06-26 revision = "677d3d17e84b7337f006220d6bb465af4f416f81" +[[override]] + name = "github.com/knative/serving" + # HEAD as of 2919-06-26 + revision = "50cdf8762deae58ed89763adef26a88e7efecac7" + [[override]] name = "go.uber.org/zap" revision = "67bc79d13d155c02fd008f721863ff8cc5f30659" diff --git a/cmd/controller/main.go b/cmd/controller/main.go index 15a24fa50a..c3bb14e7c0 100644 --- a/cmd/controller/main.go +++ b/cmd/controller/main.go @@ -21,11 +21,14 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" "github.com/GoogleCloudPlatform/cloud-run-events/pkg/reconciler/pullsubscription" + "github.com/GoogleCloudPlatform/cloud-run-events/pkg/reconciler/topic" + "knative.dev/pkg/injection/sharedmain" ) func main() { sharedmain.Main("controller", pullsubscription.NewController, + topic.NewController, ) } diff --git a/cmd/pubsub/publisher/main.go b/cmd/pubsub/publisher/main.go new file mode 100644 index 0000000000..a3b9f2dcf6 --- /dev/null +++ b/cmd/pubsub/publisher/main.go @@ -0,0 +1,77 @@ +/* +Copyright 2019 Google LLC + +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 main + +import ( + "context" + "flag" + "log" + + "cloud.google.com/go/compute/metadata" + "github.com/kelseyhightower/envconfig" + "go.uber.org/zap" + "go.uber.org/zap/zapcore" + + "github.com/GoogleCloudPlatform/cloud-run-events/pkg/pubsub/publisher" +) + +type envConfig struct { + // Environment variable containing project id. + Project string `envconfig:"PROJECT_ID"` + + // Topic is the environment variable containing the PubSub Topic being + // subscribed to's name. In the form that is unique within the project. + // E.g. 'laconia', not 'projects/my-gcp-project/topics/laconia'. + Topic string `envconfig:"PUBSUB_TOPIC_ID" required:"true"` +} + +func main() { + flag.Parse() + + ctx := context.Background() + logCfg := zap.NewProductionConfig() // TODO: to replace with a dynamically updating logger. + logCfg.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder + logger, err := logCfg.Build() + if err != nil { + log.Fatalf("Unable to create logger: %v", err) + } + + var env envConfig + if err := envconfig.Process("", &env); err != nil { + logger.Fatal("Failed to process env var", zap.Error(err)) + } + + if env.Project == "" { + project, err := metadata.ProjectID() + if err != nil { + logger.Fatal("failed to find project id. ", zap.Error(err)) + } + env.Project = project + } + + logger.Info("using project.", zap.String("project", env.Project)) + + startable := &publisher.Publisher{ + ProjectID: env.Project, + TopicID: env.Topic, + } + + logger.Info("Starting Pub/Sub Publisher.", zap.Any("publisher", startable)) + if err := startable.Start(ctx); err != nil { + logger.Fatal("failed to start publisher: ", zap.Error(err)) + } +} diff --git a/config/201-clusterrole.yaml b/config/201-clusterrole.yaml index 9cb0378151..e124c89b2d 100644 --- a/config/201-clusterrole.yaml +++ b/config/201-clusterrole.yaml @@ -56,6 +56,12 @@ rules: - deployments verbs: *everything +- apiGroups: + - serving.knative.dev + resources: + - services + verbs: *everything + - apiGroups: - batch resources: diff --git a/pkg/apis/pubsub/v1alpha1/topic_lifecycle.go b/pkg/apis/pubsub/v1alpha1/topic_lifecycle.go index bc972c4032..5f5e652ab0 100644 --- a/pkg/apis/pubsub/v1alpha1/topic_lifecycle.go +++ b/pkg/apis/pubsub/v1alpha1/topic_lifecycle.go @@ -17,8 +17,6 @@ package v1alpha1 import ( - appsv1 "k8s.io/api/apps/v1" - "knative.dev/pkg/apis" "knative.dev/pkg/apis/duck/v1alpha1" ) @@ -55,21 +53,17 @@ func (ts *TopicStatus) SetAddress(url *apis.URL) { } } -func (ts *TopicStatus) PropagateDeploymentAvailability(d *appsv1.Deployment) { - for _, cond := range d.Status.Conditions { - if cond.Type == appsv1.DeploymentAvailable { - switch cond.Status { - case "True": - ts.MarkDeployed() - case "False": - ts.MarkNotDeployed(cond.Reason, cond.Message) - default: - ts.MarkDeploying(cond.Reason, cond.Message) - } - return - } +func (ts *TopicStatus) PropagatePublisherStatus(ready *apis.Condition) { + switch { + case ready == nil: + ts.MarkDeploying("PublisherStatus", "Publisher has no Ready type status.") + case ready.IsTrue(): + ts.MarkDeployed() + case ready.IsFalse(): + ts.MarkNotDeployed(ready.Reason, ready.Message) + default: + ts.MarkDeploying(ready.Reason, ready.Message) } - ts.MarkDeploying("DeploymentStatus", "Failed to inspect Deployment status.") } // MarkDeployed sets the condition that the publisher has been deployed. diff --git a/pkg/pubsub/adapter/adapter.go b/pkg/pubsub/adapter/adapter.go index 41a250ebf1..9087920f2a 100644 --- a/pkg/pubsub/adapter/adapter.go +++ b/pkg/pubsub/adapter/adapter.go @@ -17,6 +17,7 @@ limitations under the License. package adapter import ( + "context" "fmt" cloudevents "github.com/cloudevents/sdk-go" @@ -24,7 +25,6 @@ import ( "github.com/cloudevents/sdk-go/pkg/cloudevents/transport/http" cepubsub "github.com/cloudevents/sdk-go/pkg/cloudevents/transport/pubsub" "go.uber.org/zap" - "golang.org/x/net/context" "knative.dev/pkg/logging" "github.com/GoogleCloudPlatform/cloud-run-events/pkg/apis/pubsub/v1alpha1" diff --git a/pkg/pubsub/invoker/invoker.go b/pkg/pubsub/invoker/invoker.go index 130407babb..546148cab3 100644 --- a/pkg/pubsub/invoker/invoker.go +++ b/pkg/pubsub/invoker/invoker.go @@ -17,13 +17,13 @@ limitations under the License. package invoker import ( + "context" "errors" "fmt" cloudevents "github.com/cloudevents/sdk-go" "github.com/cloudevents/sdk-go/pkg/cloudevents/transport" cepubsub "github.com/cloudevents/sdk-go/pkg/cloudevents/transport/pubsub" - "golang.org/x/net/context" "github.com/GoogleCloudPlatform/cloud-run-events/pkg/apis/pubsub/v1alpha1" "github.com/GoogleCloudPlatform/cloud-run-events/pkg/kncloudevents" diff --git a/pkg/pubsub/publisher/publisher.go b/pkg/pubsub/publisher/publisher.go new file mode 100644 index 0000000000..7b287bfac5 --- /dev/null +++ b/pkg/pubsub/publisher/publisher.go @@ -0,0 +1,92 @@ +/* +Copyright 2019 Google LLC + +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 publisher + +import ( + "fmt" + + "context" + + cloudevents "github.com/cloudevents/sdk-go" + cepubsub "github.com/cloudevents/sdk-go/pkg/cloudevents/transport/pubsub" + + "github.com/GoogleCloudPlatform/cloud-run-events/pkg/kncloudevents" +) + +// Publisher implements the Pub/Sub adapter to deliver Pub/Sub messages from a +// pre-existing topic/subscription to a Sink. +type Publisher struct { + // ProjectID is the pre-existing eventing project id to use. + ProjectID string + // TopicID is the pre-existing eventing pub/sub topic id to use. + TopicID string + + // inbound is the cloudevents client to use to receive events. + inbound cloudevents.Client + // outbound is the cloudevents client to use to send events. + outbound cloudevents.Client +} + +func (a *Publisher) Start(ctx context.Context) error { + var err error + + // Receive events on HTTP. + if a.inbound == nil { + if a.inbound, err = kncloudevents.NewDefaultClient(); err != nil { + return fmt.Errorf("failed to create inbound cloudevent client: %s", err.Error()) + } + } + + // Send Events on Pub/Sub. + if a.outbound == nil { + if a.outbound, err = a.newPubSubClient(ctx); err != nil { + return fmt.Errorf("failed to create outbound cloudevent client: %s", err.Error()) + } + } + + return a.inbound.StartReceiver(ctx, a.receive) +} + +func (a *Publisher) receive(ctx context.Context, event cloudevents.Event, resp *cloudevents.EventResponse) error { + if r, err := a.outbound.Send(ctx, event); err != nil { + return err + } else if r != nil { + resp.RespondWith(200, r) + } + + return nil +} + +func (a *Publisher) newPubSubClient(ctx context.Context) (cloudevents.Client, error) { + tOpts := []cepubsub.Option{ + cepubsub.WithBinaryEncoding(), + cepubsub.WithProjectID(a.ProjectID), + cepubsub.WithTopicID(a.TopicID), + } + + // Make a pubsub transport for the CloudEvents client. + t, err := cepubsub.New(ctx, tOpts...) + if err != nil { + return nil, err + } + + // Use the transport to make a new CloudEvents client. + return cloudevents.NewClient(t, + cloudevents.WithUUIDs(), + cloudevents.WithTimeNow(), + ) +} diff --git a/pkg/reconciler/reconciler.go b/pkg/reconciler/reconciler.go index 9e26a6ae4a..a49390193e 100644 --- a/pkg/reconciler/reconciler.go +++ b/pkg/reconciler/reconciler.go @@ -20,17 +20,6 @@ import ( "context" "time" - "knative.dev/pkg/logging" - - "knative.dev/pkg/controller" - "knative.dev/pkg/injection/clients/dynamicclient" - "knative.dev/pkg/injection/clients/kubeclient" - - runclient "github.com/GoogleCloudPlatform/cloud-run-events/pkg/client/injection/client" - - clientset "github.com/GoogleCloudPlatform/cloud-run-events/pkg/client/clientset/versioned" - runScheme "github.com/GoogleCloudPlatform/cloud-run-events/pkg/client/clientset/versioned/scheme" - "go.uber.org/zap" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/dynamic" @@ -39,7 +28,18 @@ import ( typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" "k8s.io/client-go/rest" "k8s.io/client-go/tools/record" + + clientset "github.com/GoogleCloudPlatform/cloud-run-events/pkg/client/clientset/versioned" + runScheme "github.com/GoogleCloudPlatform/cloud-run-events/pkg/client/clientset/versioned/scheme" + runclient "github.com/GoogleCloudPlatform/cloud-run-events/pkg/client/injection/client" + servingclientset "github.com/knative/serving/pkg/client/clientset/versioned" + servingclient "github.com/knative/serving/pkg/client/injection/client" + "go.uber.org/zap" "knative.dev/pkg/configmap" + "knative.dev/pkg/controller" + "knative.dev/pkg/injection/clients/dynamicclient" + "knative.dev/pkg/injection/clients/kubeclient" + "knative.dev/pkg/logging" "knative.dev/pkg/system" ) @@ -100,8 +100,12 @@ type Base struct { // DynamicClientSet allows us to configure pluggable Build objects DynamicClientSet dynamic.Interface + // RunClientSet is the client for cloud run events. RunClientSet clientset.Interface + // ServingClientSet is the client for Knative Serving + ServingClientSet servingclientset.Interface + // ConfigMapWatcher allows us to watch for ConfigMap changes. ConfigMapWatcher configmap.Watcher @@ -167,6 +171,7 @@ func NewBase(ctx context.Context, controllerAgentName string, cmw configmap.Watc base := &Base{ KubeClientSet: kubeClient, RunClientSet: runclient.Get(ctx), + ServingClientSet: servingclient.Get(ctx), DynamicClientSet: dynamicclient.Get(ctx), ConfigMapWatcher: cmw, Recorder: recorder, diff --git a/pkg/reconciler/testing/factory.go b/pkg/reconciler/testing/factory.go index 937ef8a750..997fc3ab0d 100644 --- a/pkg/reconciler/testing/factory.go +++ b/pkg/reconciler/testing/factory.go @@ -20,18 +20,17 @@ import ( "context" "testing" - "knative.dev/pkg/configmap" - "knative.dev/pkg/logging" - "k8s.io/apimachinery/pkg/runtime" - ktesting "k8s.io/client-go/testing" "k8s.io/client-go/tools/record" + "knative.dev/pkg/configmap" "knative.dev/pkg/controller" + "knative.dev/pkg/logging" logtesting "knative.dev/pkg/logging/testing" fakerunclient "github.com/GoogleCloudPlatform/cloud-run-events/pkg/client/injection/client/fake" + fakeservingclient "github.com/knative/serving/pkg/client/injection/client/fake" fakedynamicclient "knative.dev/pkg/injection/clients/dynamicclient/fake" fakekubeclient "knative.dev/pkg/injection/clients/kubeclient/fake" @@ -58,6 +57,7 @@ func MakeFactory(ctor Ctor) Factory { ctx, kubeClient := fakekubeclient.With(ctx, ls.GetKubeObjects()...) ctx, client := fakerunclient.With(ctx, ls.GetEventsObjects()...) + ctx, servingclient := fakeservingclient.With(ctx, ls.GetServingObjects()...) dynamicScheme := runtime.NewScheme() for _, addTo := range clientSetSchemes { @@ -88,6 +88,7 @@ func MakeFactory(ctor Ctor) Factory { kubeClient.PrependReactor("*", "*", reactor) client.PrependReactor("*", "*", reactor) dynamicClient.PrependReactor("*", "*", reactor) + servingclient.PrependReactor("*", "*", reactor) } // Validate all Create operations through the serving client. @@ -100,7 +101,7 @@ func MakeFactory(ctor Ctor) Factory { return ValidateUpdates(context.Background(), action) }) - actionRecorderList := ActionRecorderList{dynamicClient, client, kubeClient} + actionRecorderList := ActionRecorderList{dynamicClient, client, kubeClient, servingclient} eventList := EventList{Recorder: eventRecorder} return c, actionRecorderList, eventList, statsReporter diff --git a/pkg/reconciler/testing/listers.go b/pkg/reconciler/testing/listers.go index d1e8dfa7ea..70d0461509 100644 --- a/pkg/reconciler/testing/listers.go +++ b/pkg/reconciler/testing/listers.go @@ -23,14 +23,19 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - fakekubeclientset "k8s.io/client-go/kubernetes/fake" appsv1listers "k8s.io/client-go/listers/apps/v1" corev1listers "k8s.io/client-go/listers/core/v1" rbacv1listers "k8s.io/client-go/listers/rbac/v1" "k8s.io/client-go/tools/cache" - fakesharedclientset "knative.dev/pkg/client/clientset/versioned/fake" + + servingv1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + servinglisters "github.com/knative/serving/pkg/client/listers/serving/v1beta1" "knative.dev/pkg/reconciler/testing" + fakeservingclientset "github.com/knative/serving/pkg/client/clientset/versioned/fake" + fakekubeclientset "k8s.io/client-go/kubernetes/fake" + fakesharedclientset "knative.dev/pkg/client/clientset/versioned/fake" + pubsubv1alpha1 "github.com/GoogleCloudPlatform/cloud-run-events/pkg/apis/pubsub/v1alpha1" fakeeventsclientset "github.com/GoogleCloudPlatform/cloud-run-events/pkg/client/clientset/versioned/fake" pubsublisters "github.com/GoogleCloudPlatform/cloud-run-events/pkg/client/listers/pubsub/v1alpha1" @@ -45,11 +50,13 @@ var clientSetSchemes = []func(*runtime.Scheme) error{ fakekubeclientset.AddToScheme, fakesharedclientset.AddToScheme, fakeeventsclientset.AddToScheme, + fakeservingclientset.AddToScheme, sinkAddToScheme, } type Listers struct { sorter testing.ObjectSorter + servinglisters.ConfigurationLister } func NewListers(objs []runtime.Object) Listers { @@ -91,6 +98,10 @@ func (l *Listers) GetAllObjects() []runtime.Object { return all } +func (l *Listers) GetServingObjects() []runtime.Object { + return l.sorter.ObjectsForSchemeFunc(fakeservingclientset.AddToScheme) +} + func (l *Listers) GetSharedObjects() []runtime.Object { return l.sorter.ObjectsForSchemeFunc(fakesharedclientset.AddToScheme) } @@ -99,6 +110,10 @@ func (l *Listers) GetPullSubscriptionLister() pubsublisters.PullSubscriptionList return pubsublisters.NewPullSubscriptionLister(l.indexerFor(&pubsubv1alpha1.PullSubscription{})) } +func (l *Listers) GetTopicLister() pubsublisters.TopicLister { + return pubsublisters.NewTopicLister(l.indexerFor(&pubsubv1alpha1.Topic{})) +} + func (l *Listers) GetChannelLister() pubsublisters.ChannelLister { return pubsublisters.NewChannelLister(l.indexerFor(&pubsubv1alpha1.Channel{})) } @@ -111,6 +126,10 @@ func (l *Listers) GetK8sServiceLister() corev1listers.ServiceLister { return corev1listers.NewServiceLister(l.indexerFor(&corev1.Service{})) } +func (l *Listers) GetServiceLister() servinglisters.ServiceLister { + return servinglisters.NewServiceLister(l.indexerFor(&servingv1beta1.Service{})) +} + func (l *Listers) GetNamespaceLister() corev1listers.NamespaceLister { return corev1listers.NewNamespaceLister(l.indexerFor(&corev1.Namespace{})) } diff --git a/pkg/reconciler/testing/topic.go b/pkg/reconciler/testing/topic.go new file mode 100644 index 0000000000..fadf6901c3 --- /dev/null +++ b/pkg/reconciler/testing/topic.go @@ -0,0 +1,152 @@ +/* +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 testing + +import ( + "context" + "time" + + "knative.dev/pkg/apis" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + + "github.com/GoogleCloudPlatform/cloud-run-events/pkg/apis/pubsub/v1alpha1" +) + +// TopicOption enables further configuration of a Topic. +type TopicOption func(*v1alpha1.Topic) + +// NewTopic creates a Topic with TopicOptions +func NewTopic(name, namespace string, so ...TopicOption) *v1alpha1.Topic { + s := &v1alpha1.Topic{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: namespace, + }, + } + for _, opt := range so { + opt(s) + } + s.SetDefaults(context.Background()) + return s +} + +func WithTopicUID(uid types.UID) TopicOption { + return func(s *v1alpha1.Topic) { + s.UID = uid + } +} + +// WithInitTopicConditions initializes the Topics's conditions. +func WithInitTopicConditions(s *v1alpha1.Topic) { + s.Status.InitializeConditions() +} + +func WithTopicTopicID(topicID string) TopicOption { + return func(s *v1alpha1.Topic) { + s.Status.MarkTopicReady() + s.Status.TopicID = topicID + } +} + +func WithTopicPropagationPolicy(policy string) TopicOption { + return func(s *v1alpha1.Topic) { + s.Spec.PropagationPolicy = v1alpha1.PropagationPolicyType(policy) + } +} + +func WithTopicMarkTopicCreating(topicID string) TopicOption { + return func(s *v1alpha1.Topic) { + s.Status.MarkTopicOperating("Creating", "Created Job to create topic %q.", topicID) + s.Status.TopicID = topicID + } +} + +func WithTopicMarkTopicVerifying(topicID string) TopicOption { + return func(s *v1alpha1.Topic) { + s.Status.MarkTopicOperating("Verifying", "Created Job to verify topic %q.", topicID) + s.Status.TopicID = topicID + } +} + +func WithTopicTopicDeleting(topicID string) TopicOption { + return func(s *v1alpha1.Topic) { + s.Status.MarkTopicOperating("Deleting", "Created Job to delete topic %q.", topicID) + s.Status.TopicID = topicID + } +} + +func WithTopicTopicDeleted(topicID string) TopicOption { + return func(s *v1alpha1.Topic) { + s.Status.MarkNoTopic("Deleted", "Successfully deleted topic %q.", topicID) + s.Status.TopicID = "" + } +} + +func WithTopicAddress(uri string) TopicOption { + return func(s *v1alpha1.Topic) { + if uri != "" { + u, _ := apis.ParseURL(uri) + s.Status.SetAddress(u) + } else { + s.Status.SetAddress(nil) + } + } +} + +func WithTopicSpec(spec v1alpha1.TopicSpec) TopicOption { + return func(s *v1alpha1.Topic) { + s.Spec = spec + } +} + +func WithTopicDeployed(s *v1alpha1.Topic) { + s.Status.MarkDeployed() +} + +func WithTopicReady(topicID string) TopicOption { + return func(s *v1alpha1.Topic) { + s.Status.InitializeConditions() + s.Status.MarkDeployed() + s.Status.MarkTopicReady() + s.Status.TopicID = topicID + } +} + +func WithTopicDeleted(s *v1alpha1.Topic) { + t := metav1.NewTime(time.Unix(1e9, 0)) + s.ObjectMeta.SetDeletionTimestamp(&t) +} + +func WithTopicOwnerReferences(ownerReferences []metav1.OwnerReference) TopicOption { + return func(c *v1alpha1.Topic) { + c.ObjectMeta.OwnerReferences = ownerReferences + } +} + +func WithTopicLabels(labels map[string]string) TopicOption { + return func(c *v1alpha1.Topic) { + c.ObjectMeta.Labels = labels + } +} + +func WithTopicFinalizers(finalizers ...string) TopicOption { + return func(s *v1alpha1.Topic) { + s.Finalizers = finalizers + } +} diff --git a/pkg/reconciler/topic/controller.go b/pkg/reconciler/topic/controller.go new file mode 100644 index 0000000000..5183d1a2b0 --- /dev/null +++ b/pkg/reconciler/topic/controller.go @@ -0,0 +1,96 @@ +/* +Copyright 2019 Google LLC + +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 topic + +import ( + "context" + + "github.com/kelseyhightower/envconfig" + "go.uber.org/zap" + "k8s.io/client-go/tools/cache" + "knative.dev/pkg/configmap" + "knative.dev/pkg/controller" + "knative.dev/pkg/logging" + + "github.com/GoogleCloudPlatform/cloud-run-events/pkg/apis/pubsub/v1alpha1" + "github.com/GoogleCloudPlatform/cloud-run-events/pkg/reconciler" + "github.com/GoogleCloudPlatform/cloud-run-events/pkg/reconciler/pubsub" + + topicinformer "github.com/GoogleCloudPlatform/cloud-run-events/pkg/client/injection/informers/pubsub/v1alpha1/topic" + serviceinformer "github.com/knative/serving/pkg/client/injection/informers/serving/v1beta1/service" + jobinformer "knative.dev/pkg/injection/informers/kubeinformers/batchv1/job" +) + +const ( + // controllerAgentName is the string used by this controller to identify + // itself when creating events. + controllerAgentName = "cloud-run-events-pubsub-topic-controller" +) + +type envConfig struct { + // Publisher is the image used to publish to Pub/Sub. Required. + Publisher string `envconfig:"PUBSUB_PUBLISHER_IMAGE" required:"true"` + + // TopicOps is the image for operating on topics. Required. + TopicOps string `envconfig:"PUBSUB_TOPIC_IMAGE" required:"true"` +} + +// NewController initializes the controller and is called by the generated code +// Registers event handlers to enqueue events +func NewController( + ctx context.Context, + cmw configmap.Watcher, +) *controller.Impl { + topicInformer := topicinformer.Get(ctx) + jobInformer := jobinformer.Get(ctx) + serviceInformer := serviceinformer.Get(ctx) + + logger := logging.FromContext(ctx).Named(controllerAgentName) + + var env envConfig + if err := envconfig.Process("", &env); err != nil { + logger.Fatal("Failed to process env var", zap.Error(err)) + } + + pubsubBase := &pubsub.PubSubBase{ + Base: reconciler.NewBase(ctx, controllerAgentName, cmw), + TopicOpsImage: env.TopicOps, + } + + c := &Reconciler{ + PubSubBase: pubsubBase, + topicLister: topicInformer.Lister(), + serviceLister: serviceInformer.Lister(), + publisherImage: env.Publisher, + } + impl := controller.NewImpl(c, c.Logger, ReconcilerName) + + c.Logger.Info("Setting up event handlers") + topicInformer.Informer().AddEventHandler(controller.HandleAll(impl.Enqueue)) + + serviceInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{ + FilterFunc: controller.Filter(v1alpha1.SchemeGroupVersion.WithKind("Topic")), + Handler: controller.HandleAll(impl.EnqueueControllerOf), + }) + + jobInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{ + FilterFunc: controller.Filter(v1alpha1.SchemeGroupVersion.WithKind("Topic")), + Handler: controller.HandleAll(impl.EnqueueControllerOf), + }) + + return impl +} diff --git a/pkg/reconciler/topic/controller_test.go b/pkg/reconciler/topic/controller_test.go new file mode 100644 index 0000000000..0e9c573eea --- /dev/null +++ b/pkg/reconciler/topic/controller_test.go @@ -0,0 +1,47 @@ +/* +Copyright 2019 Google LLC + +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 topic + +import ( + "os" + "testing" + + "knative.dev/pkg/configmap" + logtesting "knative.dev/pkg/logging/testing" + . "knative.dev/pkg/reconciler/testing" + + // Fake injection informers + + _ "github.com/knative/serving/pkg/client/injection/informers/serving/v1beta1/service/fake" + _ "knative.dev/pkg/injection/informers/kubeinformers/batchv1/job/fake" + + _ "github.com/GoogleCloudPlatform/cloud-run-events/pkg/client/injection/informers/pubsub/v1alpha1/topic/fake" +) + +func TestNew(t *testing.T) { + defer logtesting.ClearAll() + ctx, _ := SetupFakeContext(t) + + _ = os.Setenv("PUBSUB_PUBLISHER_IMAGE", "PUBSUB_PUBLISHER_IMAGE") + _ = os.Setenv("PUBSUB_TOPIC_IMAGE", "PUBSUB_TOPIC_IMAGE") + + c := NewController(ctx, configmap.NewFixedWatcher()) + + if c == nil { + t.Fatal("Expected NewController to return a non-nil value") + } +} diff --git a/pkg/reconciler/topic/doc.go b/pkg/reconciler/topic/doc.go new file mode 100644 index 0000000000..f6a3e0a97d --- /dev/null +++ b/pkg/reconciler/topic/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2019 Google LLC + +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 topic implements the Cloud Pub/Sub Topic controller. +package topic diff --git a/pkg/reconciler/topic/resources/labels.go b/pkg/reconciler/topic/resources/labels.go new file mode 100644 index 0000000000..3f14af340d --- /dev/null +++ b/pkg/reconciler/topic/resources/labels.go @@ -0,0 +1,32 @@ +/* +Copyright 2019 Google LLC + +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 resources + +import ( + "k8s.io/apimachinery/pkg/labels" +) + +func GetLabelSelector(controller, source string) labels.Selector { + return labels.SelectorFromSet(GetLabels(controller, source)) +} + +func GetLabels(controller, topic string) map[string]string { + return map[string]string{ + "pubsub.cloud.run/controller": controller, + "pubsub.cloud.run/topic": topic, + } +} diff --git a/pkg/reconciler/topic/resources/publisher.go b/pkg/reconciler/topic/resources/publisher.go new file mode 100644 index 0000000000..1c00ab256e --- /dev/null +++ b/pkg/reconciler/topic/resources/publisher.go @@ -0,0 +1,116 @@ +/* +Copyright 2019 Google LLC + +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 resources + +import ( + "fmt" + + servingv1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/pkg/kmeta" + + "github.com/GoogleCloudPlatform/cloud-run-events/pkg/apis/pubsub/v1alpha1" +) + +// PublisherArgs are the arguments needed to create a Topic publisher. +// Every field is required. +type PublisherArgs struct { + Image string + Topic *v1alpha1.Topic + Labels map[string]string +} + +const ( + credsVolume = "google-cloud-key" + credsMountPath = "/var/secrets/google" +) + +// DefaultSecretSelector is the default secret selector used to load the creds +// for the publisher to auth with Google Cloud. +func DefaultSecretSelector() *corev1.SecretKeySelector { + return &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "google-cloud-key", + }, + Key: "key.json", + } +} + +// MakePublisher generates (but does not insert into K8s) the Invoker Deployment for +// Channels. +func MakePublisher(args *PublisherArgs) *servingv1beta1.Service { + secret := args.Topic.Spec.Secret + if secret == nil { + secret = DefaultSecretSelector() + } + + credsFile := fmt.Sprintf("%s/%s", credsMountPath, secret.Key) + + podSpec := corev1.PodSpec{ + ServiceAccountName: args.Topic.Spec.ServiceAccountName, + Containers: []corev1.Container{{ + Name: "publisher", + Image: args.Image, + Env: []corev1.EnvVar{{ + Name: "GOOGLE_APPLICATION_CREDENTIALS", + Value: credsFile, + }, { + Name: "PROJECT_ID", + Value: args.Topic.Spec.Project, + }, { + Name: "PUBSUB_TOPIC_ID", + Value: args.Topic.Spec.Topic, + }}, + VolumeMounts: []corev1.VolumeMount{{ + Name: credsVolume, + MountPath: credsMountPath, + }}}, + }, + Volumes: []corev1.Volume{{ + Name: credsVolume, + VolumeSource: corev1.VolumeSource{ + Secret: &corev1.SecretVolumeSource{ + SecretName: secret.Name, + }, + }, + }}, + } + + return &servingv1beta1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: args.Topic.Namespace, + GenerateName: fmt.Sprintf("pubsub-publisher-%s-", args.Topic.Name), + // TODO: not sure we should use labels like this. It depends on the + // upstream caller to use the correct label creation method. + Labels: args.Labels, + OwnerReferences: []metav1.OwnerReference{*kmeta.NewControllerRef(args.Topic)}, + }, + Spec: servingv1beta1.ServiceSpec{ + ConfigurationSpec: servingv1beta1.ConfigurationSpec{ + Template: servingv1beta1.RevisionTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: args.Labels, + }, + Spec: servingv1beta1.RevisionSpec{ + PodSpec: podSpec, + }, + }, + }, + }, + } +} diff --git a/pkg/reconciler/topic/resources/publisher_test.go b/pkg/reconciler/topic/resources/publisher_test.go new file mode 100644 index 0000000000..b646a68be1 --- /dev/null +++ b/pkg/reconciler/topic/resources/publisher_test.go @@ -0,0 +1,145 @@ +/* +Copyright 2019 Google LLC + +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 resources + +import ( + "encoding/json" + "testing" + + "github.com/google/go-cmp/cmp" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/GoogleCloudPlatform/cloud-run-events/pkg/apis/pubsub/v1alpha1" +) + +func TestMakePublisher(t *testing.T) { + topic := &v1alpha1.Topic{ + ObjectMeta: metav1.ObjectMeta{ + Name: "topic-name", + Namespace: "topic-namespace", + }, + Spec: v1alpha1.TopicSpec{ + ServiceAccountName: "topic-svc-acct", + Project: "eventing-name", + Topic: "topic-name", + Secret: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "eventing-secret-name", + }, + Key: "eventing-secret-key", + }, + }, + } + + pub := MakePublisher(&PublisherArgs{ + Image: "test-image", + Topic: topic, + Labels: GetLabels("controller-name", "topic-name"), + }) + + gotb, _ := json.MarshalIndent(pub, "", " ") + got := string(gotb) + + want := `{ + "metadata": { + "generateName": "pubsub-publisher-topic-name-", + "namespace": "topic-namespace", + "creationTimestamp": null, + "labels": { + "pubsub.cloud.run/controller": "controller-name", + "pubsub.cloud.run/topic": "topic-name" + }, + "ownerReferences": [ + { + "apiVersion": "pubsub.cloud.run/v1alpha1", + "kind": "Topic", + "name": "topic-name", + "uid": "", + "controller": true, + "blockOwnerDeletion": true + } + ] + }, + "spec": { + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "pubsub.cloud.run/controller": "controller-name", + "pubsub.cloud.run/topic": "topic-name" + } + }, + "spec": { + "volumes": [ + { + "name": "google-cloud-key", + "secret": { + "secretName": "eventing-secret-name" + } + } + ], + "containers": [ + { + "name": "publisher", + "image": "test-image", + "env": [ + { + "name": "GOOGLE_APPLICATION_CREDENTIALS", + "value": "/var/secrets/google/eventing-secret-key" + }, + { + "name": "PROJECT_ID", + "value": "eventing-name" + }, + { + "name": "PUBSUB_TOPIC_ID", + "value": "topic-name" + } + ], + "resources": {}, + "volumeMounts": [ + { + "name": "google-cloud-key", + "mountPath": "/var/secrets/google" + } + ] + } + ], + "serviceAccountName": "topic-svc-acct" + } + } + }, + "status": {} +}` + + if diff := cmp.Diff(want, got); diff != "" { + t.Errorf("unexpected deploy (-want, +got) = %v", diff) + } +} + +func TestMakePublisherSelector(t *testing.T) { + selector := GetLabelSelector("controller-name", "topic-name") + + want := "pubsub.cloud.run/controller=controller-name,pubsub.cloud.run/topic=topic-name" + + got := selector.String() + + if diff := cmp.Diff(want, got); diff != "" { + t.Errorf("unexpected selector (-want, +got) = %v", diff) + } +} diff --git a/pkg/reconciler/topic/topic.go b/pkg/reconciler/topic/topic.go new file mode 100644 index 0000000000..855833fff9 --- /dev/null +++ b/pkg/reconciler/topic/topic.go @@ -0,0 +1,418 @@ +/* +Copyright 2019 Google LLC + +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 topic + +import ( + "context" + "encoding/json" + "reflect" + "time" + + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/equality" + apierrors "k8s.io/apimachinery/pkg/api/errors" + apierrs "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/sets" + "k8s.io/client-go/tools/cache" + + "github.com/google/go-cmp/cmp" + servingv1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + servinglisters "github.com/knative/serving/pkg/client/listers/serving/v1beta1" + "go.uber.org/zap" + "knative.dev/pkg/apis" + "knative.dev/pkg/controller" + "knative.dev/pkg/logging" + + "github.com/GoogleCloudPlatform/cloud-run-events/pkg/apis/pubsub/v1alpha1" + listers "github.com/GoogleCloudPlatform/cloud-run-events/pkg/client/listers/pubsub/v1alpha1" + "github.com/GoogleCloudPlatform/cloud-run-events/pkg/reconciler/pubsub" + "github.com/GoogleCloudPlatform/cloud-run-events/pkg/reconciler/topic/resources" +) + +const ( + // ReconcilerName is the name of the reconciler + ReconcilerName = "Topics" + + finalizerName = controllerAgentName +) + +// Reconciler implements controller.Reconciler for Topic resources. +type Reconciler struct { + *pubsub.PubSubBase + + // listers index properties about resources + topicLister listers.TopicLister + serviceLister servinglisters.ServiceLister + + publisherImage string +} + +// Check that our Reconciler implements controller.Reconciler +var _ controller.Reconciler = (*Reconciler)(nil) + +// Reconcile compares the actual state with the desired, and attempts to +// converge the two. It then updates the Status block of the Service resource +// with the current status of the resource. +func (c *Reconciler) Reconcile(ctx context.Context, key string) error { + // Convert the namespace/name string into a distinct namespace and name + namespace, name, err := cache.SplitMetaNamespaceKey(key) + if err != nil { + c.Logger.Errorf("invalid resource key: %s", key) + return nil + } + logger := logging.FromContext(ctx) + + // Get the Topic resource with this namespace/name + original, err := c.topicLister.Topics(namespace).Get(name) + if apierrs.IsNotFound(err) { + // The resource may no longer exist, in which case we stop processing. + logger.Errorf("service %q in work queue no longer exists", key) + return nil + } else if err != nil { + return err + } + + // Don't modify the informers copy + Topic := original.DeepCopy() + + // Reconcile this copy of the Topic and then write back any status + // updates regardless of whether the reconciliation errored out. + var reconcileErr = c.reconcile(ctx, Topic) + + // If no error is returned, mark the observed generation. + if reconcileErr == nil { + Topic.Status.ObservedGeneration = Topic.Generation + } + + if equality.Semantic.DeepEqual(original.Finalizers, Topic.Finalizers) { + // If we didn't change finalizers then don't call updateFinalizers. + + } else if _, updated, fErr := c.updateFinalizers(ctx, Topic); fErr != nil { + logger.Warnw("Failed to update Topic finalizers", zap.Error(fErr)) + c.Recorder.Eventf(Topic, corev1.EventTypeWarning, "UpdateFailed", + "Failed to update finalizers for Topic %q: %v", Topic.Name, fErr) + return fErr + } else if updated { + // There was a difference and updateFinalizers said it updated and did not return an error. + c.Recorder.Eventf(Topic, corev1.EventTypeNormal, "Updated", "Updated Topic %q finalizers", Topic.GetName()) + } + + if equality.Semantic.DeepEqual(original.Status, Topic.Status) { + // If we didn't change anything then don't call updateStatus. + // This is important because the copy we loaded from the informer's + // cache may be stale and we don't want to overwrite a prior update + // to status with this stale state. + + } else if _, uErr := c.updateStatus(ctx, Topic); uErr != nil { + logger.Warnw("Failed to update Topic status", zap.Error(uErr)) + c.Recorder.Eventf(Topic, corev1.EventTypeWarning, "UpdateFailed", + "Failed to update status for Topic %q: %v", Topic.Name, uErr) + return uErr + } else if reconcileErr == nil { + // There was a difference and updateStatus did not return an error. + c.Recorder.Eventf(Topic, corev1.EventTypeNormal, "Updated", "Updated Topic %q", Topic.GetName()) + } + if reconcileErr != nil { + c.Recorder.Event(Topic, corev1.EventTypeWarning, "InternalError", reconcileErr.Error()) + } + return reconcileErr +} + +func (c *Reconciler) reconcile(ctx context.Context, topic *v1alpha1.Topic) error { + logger := logging.FromContext(ctx) + + topic.Status.InitializeConditions() + + if topic.GetDeletionTimestamp() != nil { + logger.Debug("Topic Deleting.", zap.Any("propagationPolicy", topic.Spec.PropagationPolicy)) + + if topic.Spec.PropagationPolicy == v1alpha1.TopicPolicyCreateDelete { + // Ensure the Topic is deleted. + state, err := c.EnsureTopicDeleted(ctx, topic, topic.Spec.Project, topic.Status.TopicID) + switch state { + case pubsub.OpsJobGetFailed: + logger.Error("Failed to get Topic ops job.", zap.Any("state", state), zap.Error(err)) + return err + + case pubsub.OpsJobCreated: + // If we created a job to make a topic, then add the finalizer and update the status. + topic.Status.MarkTopicOperating( + "Deleting", + "Created Job to delete topic %q.", + topic.Status.TopicID) + return nil + + case pubsub.OpsJobCompleteSuccessful: + topic.Status.MarkNoTopic("Deleted", "Successfully deleted topic %q.", topic.Status.TopicID) + topic.Status.TopicID = "" + removeFinalizer(topic) + + case pubsub.OpsJobCreateFailed, pubsub.OpsJobCompleteFailed: + logger.Error("Failed to delete topic.", zap.Any("state", state), zap.Error(err)) + + msg := "unknown" + if err != nil { + msg = err.Error() + } + topic.Status.MarkNoTopic( + "DeleteFailed", + "Failed to delete topic: %q.", + msg) + return err + } + } else { + removeFinalizer(topic) + } + + return nil + } + + // Set the topic being used. + topic.Status.TopicID = topic.Spec.Topic + + switch topic.Spec.PropagationPolicy { + case v1alpha1.TopicPolicyCreateDelete, v1alpha1.TopicPolicyCreateNoDelete: + state, err := c.EnsureTopicCreated(ctx, topic, topic.Spec.Project, topic.Status.TopicID) + // Check state. + switch state { + case pubsub.OpsJobGetFailed: + logger.Error("Failed to get topic ops job.", + zap.Any("propagationPolicy", topic.Spec.PropagationPolicy), + zap.Any("state", state), + zap.Error(err)) + return err + + case pubsub.OpsJobCreated: + // If we created a job to make a topic, then add the finalizer and update the status. + addFinalizer(topic) + topic.Status.MarkTopicOperating("Creating", + "Created Job to create topic %q.", + topic.Status.TopicID) + return nil + + case pubsub.OpsJobCompleteSuccessful: + topic.Status.MarkTopicReady() + + case pubsub.OpsJobCreateFailed, pubsub.OpsJobCompleteFailed: + logger.Error("Failed to create topic.", + zap.Any("propagationPolicy", topic.Spec.PropagationPolicy), + zap.Any("state", state), + zap.Error(err)) + + msg := "unknown" + if err != nil { + msg = err.Error() + } + topic.Status.MarkNoTopic( + "CreateFailed", + "Failed to create Topic: %q", + msg) + return err + } + + case v1alpha1.TopicPolicyNoCreateNoDelete: + state, err := c.EnsureTopicExists(ctx, topic, topic.Spec.Project, topic.Status.TopicID) + // Check state. + switch state { + case pubsub.OpsJobGetFailed: + logger.Error("Failed to get topic ops job.", + zap.Any("propagationPolicy", topic.Spec.PropagationPolicy), + zap.Any("state", state), + zap.Error(err)) + return err + + case pubsub.OpsJobCreated: + // If we created a job to verify a topic, then update the status. + topic.Status.MarkTopicOperating("Verifying", + "Created Job to verify topic %q.", + topic.Status.TopicID) + return nil + + case pubsub.OpsJobCompleteSuccessful: + topic.Status.MarkTopicReady() + + case pubsub.OpsJobCreateFailed, pubsub.OpsJobCompleteFailed: + logger.Error("Failed to verify topic.", + zap.Any("propagationPolicy", topic.Spec.PropagationPolicy), + zap.Any("state", state), + zap.Error(err)) + + msg := "unknown" + if err != nil { + msg = err.Error() + } + topic.Status.MarkNoTopic( + "VerifyFailed", + "Failed to verify Topic: %q", + msg) + return err + } + default: + logger.Error("Unknown propagation policy.", zap.Any("propagationPolicy", topic.Spec.PropagationPolicy)) + return nil + } + + publisher, err := c.createOrUpdatePublisher(ctx, topic) + if err != nil { + logger.Error("Unable to create the publisher", zap.Error(err)) + return err + } + topic.Status.PropagatePublisherStatus(publisher.Status.GetCondition(apis.ConditionReady)) + + if publisher.Status.IsReady() { + topic.Status.SetAddress(publisher.Status.Address.URL) + } + return nil +} + +func (c *Reconciler) updateStatus(ctx context.Context, desired *v1alpha1.Topic) (*v1alpha1.Topic, error) { + topic, err := c.topicLister.Topics(desired.Namespace).Get(desired.Name) + if err != nil { + return nil, err + } + // If there's nothing to update, just return. + if reflect.DeepEqual(topic.Status, desired.Status) { + return topic, nil + } + becomesReady := desired.Status.IsReady() && !topic.Status.IsReady() + // Don't modify the informers copy. + existing := topic.DeepCopy() + existing.Status = desired.Status + + ch, err := c.RunClientSet.PubsubV1alpha1().Topics(desired.Namespace).UpdateStatus(existing) + if err == nil && becomesReady { + duration := time.Since(ch.ObjectMeta.CreationTimestamp.Time) + c.Logger.Infof("Topic %q became ready after %v", topic.Name, duration) + + if err := c.StatsReporter.ReportReady("Topic", topic.Namespace, topic.Name, duration); err != nil { + logging.FromContext(ctx).Infof("failed to record ready for Topic, %v", err) + } + } + + return ch, err +} + +func (c *Reconciler) updateFinalizers(ctx context.Context, desired *v1alpha1.Topic) (*v1alpha1.Topic, bool, error) { + source, err := c.topicLister.Topics(desired.Namespace).Get(desired.Name) + if err != nil { + return nil, false, err + } + + // Don't modify the informers copy. + existing := source.DeepCopy() + + var finalizers []string + + // If there's nothing to update, just return. + exisitingFinalizers := sets.NewString(existing.Finalizers...) + desiredFinalizers := sets.NewString(desired.Finalizers...) + + if desiredFinalizers.Has(finalizerName) { + if exisitingFinalizers.Has(finalizerName) { + // Nothing to do. + return desired, false, nil + } + // Add the finalizer. + finalizers = append(existing.Finalizers, finalizerName) + } else { + if !exisitingFinalizers.Has(finalizerName) { + // Nothing to do. + return desired, false, nil + } + // Remove the finalizer. + exisitingFinalizers.Delete(finalizerName) + finalizers = exisitingFinalizers.List() + } + + mergePatch := map[string]interface{}{ + "metadata": map[string]interface{}{ + "finalizers": finalizers, + "resourceVersion": existing.ResourceVersion, + }, + } + + patch, err := json.Marshal(mergePatch) + if err != nil { + return desired, false, err + } + + update, err := c.RunClientSet.PubsubV1alpha1().Topics(existing.Namespace).Patch(existing.Name, types.MergePatchType, patch) + return update, true, err +} + +func addFinalizer(s *v1alpha1.Topic) { + finalizers := sets.NewString(s.Finalizers...) + finalizers.Insert(finalizerName) + s.Finalizers = finalizers.List() +} + +func removeFinalizer(s *v1alpha1.Topic) { + finalizers := sets.NewString(s.Finalizers...) + finalizers.Delete(finalizerName) + s.Finalizers = finalizers.List() +} + +func (r *Reconciler) createOrUpdatePublisher(ctx context.Context, topic *v1alpha1.Topic) (*servingv1beta1.Service, error) { + existing, err := r.getPublisher(ctx, topic) + if err != nil && !apierrors.IsNotFound(err) { + logging.FromContext(ctx).Error("Unable to get an existing publisher", zap.Error(err)) + return nil, err + } + + desired := resources.MakePublisher(&resources.PublisherArgs{ + Image: r.publisherImage, + Topic: topic, + Labels: resources.GetLabels(controllerAgentName, topic.Name), + }) + + if existing == nil { + svc, err := r.ServingClientSet.ServingV1beta1().Services(topic.Namespace).Create(desired) + logging.FromContext(ctx).Desugar().Info("Publisher created.", zap.Error(err), zap.Any("publisher", svc)) + return svc, err + } + + if diff := cmp.Diff(desired.Spec, existing.Spec); diff != "" { + existing.Spec = desired.Spec + svc, err := r.ServingClientSet.ServingV1beta1().Services(topic.Namespace).Update(existing) + logging.FromContext(ctx).Desugar().Info("Publisher updated.", + zap.Error(err), zap.Any("publisher", svc), zap.String("diff", diff)) + return svc, err + } + + logging.FromContext(ctx).Desugar().Info("Reusing existing publisher", zap.Any("publisher", existing)) + return existing, nil +} + +func (r *Reconciler) getPublisher(ctx context.Context, topic *v1alpha1.Topic) (*servingv1beta1.Service, error) { + pl, err := r.ServingClientSet.ServingV1beta1().Services(topic.Namespace).List(metav1.ListOptions{ + LabelSelector: resources.GetLabelSelector(controllerAgentName, topic.Name).String(), + }) + + if err != nil { + logging.FromContext(ctx).Desugar().Error("Unable to list services: %v", zap.Error(err)) + return nil, err + } + for _, pub := range pl.Items { + if metav1.IsControlledBy(&pub, topic) { + return &pub, nil + } + } + return nil, apierrors.NewNotFound(schema.GroupResource{}, "") +} diff --git a/pkg/reconciler/topic/topic_test.go b/pkg/reconciler/topic/topic_test.go new file mode 100644 index 0000000000..2671681142 --- /dev/null +++ b/pkg/reconciler/topic/topic_test.go @@ -0,0 +1,560 @@ +/* +Copyright 2019 Google LLC + +Licensed under the Apache License, Veroute.on 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 topic + +import ( + "context" + "fmt" + "testing" + + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/intstr" + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/kmeta" + + batchv1 "k8s.io/api/batch/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/util/sets" + "k8s.io/client-go/kubernetes/scheme" + clientgotesting "k8s.io/client-go/testing" + + "knative.dev/pkg/configmap" + "knative.dev/pkg/controller" + logtesting "knative.dev/pkg/logging/testing" + + pubsubv1alpha1 "github.com/GoogleCloudPlatform/cloud-run-events/pkg/apis/pubsub/v1alpha1" + "github.com/GoogleCloudPlatform/cloud-run-events/pkg/pubsub/operations" + "github.com/GoogleCloudPlatform/cloud-run-events/pkg/reconciler" + "github.com/GoogleCloudPlatform/cloud-run-events/pkg/reconciler/pubsub" + "github.com/GoogleCloudPlatform/cloud-run-events/pkg/reconciler/topic/resources" + + . "knative.dev/pkg/reconciler/testing" + + . "github.com/GoogleCloudPlatform/cloud-run-events/pkg/reconciler/testing" +) + +const ( + topicName = "hubbub" + sinkName = "sink" + + testNS = "testnamespace" + testImage = "test_image" + topicUID = topicName + "-abc-123" + testProject = "test-project-id" + testTopicID = "cloud-run-topic-" + testNS + "-" + topicName + "-" + topicUID + testServiceAccount = "test-project-id" + testTopicURI = "http://" + topicName + "-topic." + testNS + ".svc.cluster.local" +) + +var ( + trueVal = true + + sinkDNS = sinkName + ".mynamespace.svc.cluster.local" + sinkURI = "http://" + sinkDNS + "/" + + sinkGVK = metav1.GroupVersionKind{ + Group: "testing.cloud.run", + Version: "v1alpha1", + Kind: "Sink", + } +) + +func init() { + // Add types to scheme + _ = pubsubv1alpha1.AddToScheme(scheme.Scheme) +} + +func newSink() *unstructured.Unstructured { + return &unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "testing.cloud.run/v1alpha1", + "kind": "Sink", + "metadata": map[string]interface{}{ + "namespace": testNS, + "name": sinkName, + }, + "status": map[string]interface{}{ + "address": map[string]interface{}{ + "hostname": sinkDNS, + }, + }, + }, + } +} + +func TestAllCases(t *testing.T) { + table := TableTest{{ + Name: "bad workqueue key", + // Make sure Reconcile handles bad keys. + Key: "too/many/parts", + }, { + Name: "key not found", + // Make sure Reconcile handles good keys that don't exist. + Key: "foo/not-found", + }, { + Name: "verify topic", + Objects: []runtime.Object{ + NewTopic(topicName, testNS, + WithTopicUID(topicUID), + WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Project: testProject, + Topic: testTopicID, + ServiceAccountName: testServiceAccount, + }), + WithTopicPropagationPolicy("NoCreateNoDelete"), + ), + newSink(), + }, + Key: testNS + "/" + topicName, + WantEvents: []string{ + Eventf(corev1.EventTypeNormal, "Updated", "Updated Topic %q", topicName), + }, + WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ + Object: NewTopic(topicName, testNS, + WithTopicUID(topicUID), + WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Project: testProject, + Topic: testTopicID, + ServiceAccountName: testServiceAccount, + }), + WithTopicPropagationPolicy("NoCreateNoDelete"), + // Updates + WithInitTopicConditions, + WithTopicMarkTopicVerifying(testTopicID), + ), + }}, + WantCreates: []runtime.Object{ + newTopicJob(NewTopic(topicName, testNS, WithTopicUID(topicUID)), operations.ActionExists), + }, + }, { + Name: "create topic", + Objects: []runtime.Object{ + NewTopic(topicName, testNS, + WithTopicUID(topicUID), + WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Project: testProject, + Topic: testTopicID, + ServiceAccountName: testServiceAccount, + }), + ), + newSink(), + }, + Key: testNS + "/" + topicName, + WantEvents: []string{ + Eventf(corev1.EventTypeNormal, "Updated", "Updated Topic %q finalizers", topicName), + Eventf(corev1.EventTypeNormal, "Updated", "Updated Topic %q", topicName), + }, + WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ + Object: NewTopic(topicName, testNS, + WithTopicUID(topicUID), + WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Project: testProject, + Topic: testTopicID, + ServiceAccountName: testServiceAccount, + }), + // Updates + WithInitTopicConditions, + WithTopicMarkTopicCreating(testTopicID), + ), + }}, + WantCreates: []runtime.Object{ + newTopicJob(NewTopic(topicName, testNS, WithTopicUID(topicUID)), operations.ActionCreate), + }, + WantPatches: []clientgotesting.PatchActionImpl{ + patchFinalizers(testNS, topicName, true), + }, + }, { + Name: "successful create", + Objects: []runtime.Object{ + NewTopic(topicName, testNS, + WithTopicUID(topicUID), + WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Project: testProject, + Topic: testTopicID, + ServiceAccountName: testServiceAccount, + }), + WithInitTopicConditions, + WithTopicTopicID(testTopicID), + ), + newTopicJob(NewTopic(topicName, testNS, WithTopicUID(topicUID)), operations.ActionCreate), + }, + Key: testNS + "/" + topicName, + WithReactors: []clientgotesting.ReactionFunc{ + ProvideResource("create", "services", newPublisher(true, true)), + }, + WantEvents: []string{ + Eventf(corev1.EventTypeNormal, "Updated", "Updated Topic %q", topicName), + }, + WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ + Object: NewTopic(topicName, testNS, + WithTopicUID(topicUID), + WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Project: testProject, + Topic: testTopicID, + ServiceAccountName: testServiceAccount, + }), + WithInitTopicConditions, + WithTopicTopicID(testTopicID), + // Updates + WithTopicDeployed, + WithTopicAddress(testTopicURI), + ), + }}, + WantCreates: []runtime.Object{ + newPublisher(false, false), + }, + }, { + Name: "successful create - reuse existing publisher", + Objects: []runtime.Object{ + NewTopic(topicName, testNS, + WithTopicUID(topicUID), + WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Project: testProject, + Topic: testTopicID, + ServiceAccountName: testServiceAccount, + }), + WithInitTopicConditions, + WithTopicTopicID(testTopicID), + ), + newTopicJob(NewTopic(topicName, testNS, WithTopicUID(topicUID)), operations.ActionCreate), + newPublisher(true, true), + NewService(topicName+"-topic", testNS, + WithServiceOwnerReferences(ownerReferences()), + WithServiceLabels(resources.GetLabels(controllerAgentName, topicName)), + WithServicePorts(servicePorts())), + }, + Key: testNS + "/" + topicName, + WantEvents: []string{ + Eventf(corev1.EventTypeNormal, "Updated", "Updated Topic %q", topicName), + }, + WithReactors: []clientgotesting.ReactionFunc{}, + WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ + Object: NewTopic(topicName, testNS, + WithTopicUID(topicUID), + WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Project: testProject, + Topic: testTopicID, + ServiceAccountName: testServiceAccount, + }), + WithInitTopicConditions, + // Updates + WithTopicReady(testTopicID), + WithTopicAddress(testTopicURI), + ), + }}, + }, { + Name: "deleting - delete topic - policy CreateNoDelete", + Objects: []runtime.Object{ + NewTopic(topicName, testNS, + WithTopicUID(topicUID), + WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Project: testProject, + Topic: testTopicID, + ServiceAccountName: testServiceAccount, + }), + WithTopicReady(testTopicID), + WithTopicFinalizers(finalizerName), + WithTopicDeleted, + ), + }, + Key: testNS + "/" + topicName, + WantEvents: []string{ + Eventf(corev1.EventTypeNormal, "Updated", "Updated Topic %q finalizers", topicName), + }, + WantPatches: []clientgotesting.PatchActionImpl{ + patchFinalizers(testNS, topicName, false), + }, + }, { + Name: "deleting - delete topic - policy CreateDelete", + Objects: []runtime.Object{ + NewTopic(topicName, testNS, + WithTopicUID(topicUID), + WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Project: testProject, + Topic: testTopicID, + ServiceAccountName: testServiceAccount, + }), + WithTopicPropagationPolicy("CreateDelete"), + WithTopicReady(testTopicID), + WithTopicFinalizers(finalizerName), + WithTopicDeleted, + ), + }, + Key: testNS + "/" + topicName, + WantEvents: []string{ + Eventf(corev1.EventTypeNormal, "Updated", "Updated Topic %q", topicName), + }, + WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ + Object: NewTopic(topicName, testNS, + WithTopicUID(topicUID), + WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Project: testProject, + Topic: testTopicID, + ServiceAccountName: testServiceAccount, + }), + WithTopicPropagationPolicy("CreateDelete"), + WithTopicReady(testTopicID), + WithTopicFinalizers(finalizerName), + WithTopicDeleted, + // Updates + WithTopicTopicDeleting(testTopicID), + ), + }}, + WantCreates: []runtime.Object{ + newTopicJob(NewTopic(topicName, testNS, WithTopicUID(topicUID)), operations.ActionDelete), + }, + }, { + Name: "deleting final stage - policy CreateDelete", + Objects: []runtime.Object{ + NewTopic(topicName, testNS, + WithTopicUID(topicUID), + WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Project: testProject, + Topic: testTopicID, + ServiceAccountName: testServiceAccount, + }), + WithTopicPropagationPolicy("CreateDelete"), + WithTopicReady(testTopicID), + WithTopicFinalizers(finalizerName), + WithTopicDeleted, + WithTopicTopicDeleting(testTopicID), + ), + newTopicJobFinished(NewTopic(topicName, testNS, WithTopicUID(topicUID)), operations.ActionDelete, true), + }, + Key: testNS + "/" + topicName, + WantEvents: []string{ + Eventf(corev1.EventTypeNormal, "Updated", "Updated Topic %q finalizers", topicName), + Eventf(corev1.EventTypeNormal, "Updated", "Updated Topic %q", topicName), + }, + WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ + Object: NewTopic(topicName, testNS, + WithTopicUID(topicUID), + WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Project: testProject, + Topic: testTopicID, + ServiceAccountName: testServiceAccount, + }), + WithTopicPropagationPolicy("CreateDelete"), + WithTopicReady(testTopicID), + WithTopicFinalizers(finalizerName), + WithTopicDeleted, + // Updates + WithTopicTopicDeleted(testTopicID), + ), + }}, + WantPatches: []clientgotesting.PatchActionImpl{ + patchFinalizers(testNS, topicName, false), + }, + }} + + defer logtesting.ClearAll() + table.Test(t, MakeFactory(func(ctx context.Context, listers *Listers, cmw configmap.Watcher) controller.Reconciler { + pubsubBase := &pubsub.PubSubBase{ + Base: reconciler.NewBase(ctx, controllerAgentName, cmw), + TopicOpsImage: testImage + "pub", + } + return &Reconciler{ + PubSubBase: pubsubBase, + topicLister: listers.GetTopicLister(), + serviceLister: listers.GetServiceLister(), + publisherImage: testImage, + } + })) + +} + +func TestFinalizers(t *testing.T) { + testCases := []struct { + name string + original sets.String + add bool + want sets.String + }{ + { + name: "empty, add", + original: sets.NewString(), + add: true, + want: sets.NewString(finalizerName), + }, { + name: "empty, delete", + original: sets.NewString(), + add: false, + want: sets.NewString(), + }, { + name: "existing, delete", + original: sets.NewString(finalizerName), + add: false, + want: sets.NewString(), + }, { + name: "existing, add", + original: sets.NewString(finalizerName), + add: true, + want: sets.NewString(finalizerName), + }, { + name: "existing two, delete", + original: sets.NewString(finalizerName, "someother"), + add: false, + want: sets.NewString("someother"), + }, { + name: "existing two, no change", + original: sets.NewString(finalizerName, "someother"), + add: true, + want: sets.NewString(finalizerName, "someother"), + }, + } + + for _, tc := range testCases { + original := &pubsubv1alpha1.Topic{} + original.Finalizers = tc.original.List() + if tc.add { + addFinalizer(original) + } else { + removeFinalizer(original) + } + has := sets.NewString(original.Finalizers...) + diff := has.Difference(tc.want) + if diff.Len() > 0 { + t.Errorf("%q failed, diff: %+v", tc.name, diff) + } + } +} + +func ProvideResource(verb, resource string, obj runtime.Object) clientgotesting.ReactionFunc { + return func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { + if !action.Matches(verb, resource) { + return false, nil, nil + } + return true, obj, nil + } +} + +func patchFinalizers(namespace, name string, add bool) clientgotesting.PatchActionImpl { + action := clientgotesting.PatchActionImpl{} + action.Name = name + action.Namespace = namespace + var fname string + if add { + fname = fmt.Sprintf("%q", finalizerName) + } + patch := `{"metadata":{"finalizers":[` + fname + `],"resourceVersion":""}}` + action.Patch = []byte(patch) + return action +} + +func ownerReferences() []metav1.OwnerReference { + return []metav1.OwnerReference{{ + APIVersion: "pubsub.cloud.run/v1alpha1", + Kind: "Topic", + Name: topicName, + UID: topicUID, + Controller: &trueVal, + BlockOwnerDeletion: &trueVal, + }} +} + +func servicePorts() []corev1.ServicePort { + svcPorts := []corev1.ServicePort{ + { + Name: "http", + Port: 80, + TargetPort: intstr.FromInt(8080), + }, { + Name: "metrics", + Port: 9090, + }, + } + return svcPorts +} + +func newPublisher(get, done bool) runtime.Object { + topic := NewTopic(topicName, testNS, + WithTopicUID(topicUID), + WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Project: testProject, + Topic: testTopicID, + ServiceAccountName: testServiceAccount, + })) + args := &resources.PublisherArgs{ + Image: testImage, + Topic: topic, + Labels: resources.GetLabels(controllerAgentName, topicName), + } + pub := resources.MakePublisher(args) + if get { + if done { + pub.Status.Conditions = []apis.Condition{{ + Type: apis.ConditionReady, + Status: "True", + }} + uri, _ := apis.ParseURL(testTopicURI) + pub.Status.Address = &v1beta1.Addressable{URL: uri} + } else { + pub.Status.Conditions = []apis.Condition{{ + Type: apis.ConditionReady, + Status: "Unknown", + }} + } + } + return pub +} + +func newTopicJob(owner kmeta.OwnerRefable, action string) runtime.Object { + return operations.NewTopicOps(operations.TopicArgs{ + Image: testImage + "pub", + Action: action, + ProjectID: testProject, + TopicID: testTopicID, + Owner: owner, + }) +} + +func newTopicJobFinished(owner kmeta.OwnerRefable, action string, success bool) runtime.Object { + job := operations.NewTopicOps(operations.TopicArgs{ + Image: testImage + "pub", + Action: action, + ProjectID: testProject, + TopicID: testTopicID, + Owner: owner, + }) + + if success { + job.Status.Active = 0 + job.Status.Succeeded = 1 + job.Status.Conditions = []batchv1.JobCondition{{ + Type: batchv1.JobComplete, + Status: corev1.ConditionTrue, + }, { + Type: batchv1.JobFailed, + Status: corev1.ConditionFalse, + }} + } else { + job.Status.Active = 0 + job.Status.Succeeded = 0 + job.Status.Conditions = []batchv1.JobCondition{{ + Type: batchv1.JobComplete, + Status: corev1.ConditionTrue, + }, { + Type: batchv1.JobFailed, + Status: corev1.ConditionTrue, + }} + } + + return job +} diff --git a/third_party/VENDOR-LICENSE b/third_party/VENDOR-LICENSE index 949995be04..70a4b61a46 100644 --- a/third_party/VENDOR-LICENSE +++ b/third_party/VENDOR-LICENSE @@ -1897,6 +1897,213 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +=========================================================== +Import: github.com/GoogleCloudPlatform/cloud-run-events/vendor/github.com/google/go-containerregistry + + + 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/GoogleCloudPlatform/cloud-run-events/vendor/github.com/google/gofuzz @@ -3101,6 +3308,214 @@ Import: github.com/GoogleCloudPlatform/cloud-run-events/vendor/github.com/knativ +=========================================================== +Import: github.com/GoogleCloudPlatform/cloud-run-events/vendor/github.com/knative/serving + + + 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/GoogleCloudPlatform/cloud-run-events/vendor/github.com/markbates/inflect diff --git a/vendor/github.com/google/go-containerregistry/LICENSE b/vendor/github.com/google/go-containerregistry/LICENSE new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/LICENSE @@ -0,0 +1,202 @@ + + 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. \ 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 new file mode 100644 index 0000000000..01b03e5626 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/name/check.go @@ -0,0 +1,43 @@ +// 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 + +import ( + "strings" + "unicode/utf8" +) + +// 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 { + return func(r rune) rune { + if strings.ContainsRune(runes, r) { + return -1 + } + return r + } +} + +// checkElement checks a given named element matches character and length restrictions. +// Returns true if the given element adheres to the given restrictions, false otherwise. +func checkElement(name, element, allowedRunes string, minRunes, maxRunes int) error { + numRunes := utf8.RuneCountInString(element) + if (numRunes < minRunes) || (maxRunes < numRunes) { + return NewErrBadName("%s must be between %d and %d runes in length: %s", name, minRunes, maxRunes, element) + } else if len(strings.Map(stripRunesFn(allowedRunes), element)) != 0 { + return NewErrBadName("%s can only contain the runes `%s`: %s", name, allowedRunes, element) + } + return nil +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/digest.go b/vendor/github.com/google/go-containerregistry/pkg/name/digest.go new file mode 100644 index 0000000000..2dc0f7f371 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/name/digest.go @@ -0,0 +1,90 @@ +// 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 + +import ( + "strings" +) + +const ( + // These have the form: sha256: + // TODO(dekkagaijin): replace with opencontainers/go-digest or docker/distribution's validation. + digestChars = "sh:0123456789abcdef" + digestDelim = "@" +) + +// Digest stores a digest name in a structured form. +type Digest struct { + Repository + digest string +} + +// Ensure Digest implements Reference +var _ Reference = (*Digest)(nil) + +// Context implements Reference. +func (d Digest) Context() Repository { + return d.Repository +} + +// Identifier implements Reference. +func (d Digest) Identifier() string { + return d.DigestStr() +} + +// DigestStr returns the digest component of the Digest. +func (d Digest) DigestStr() string { + return d.digest +} + +// Name returns the name from which the Digest was derived. +func (d Digest) Name() string { + return d.Repository.Name() + digestDelim + d.DigestStr() +} + +func (d Digest) String() string { + return d.Name() +} + +func checkDigest(name string) error { + return checkElement("digest", name, digestChars, 7+64, 7+64) +} + +// 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 { + return Digest{}, NewErrBadName("a digest must contain exactly one '@' separator (e.g. registry/repository@digest) saw: %s", name) + } + base := parts[0] + digest := parts[1] + + // 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, opts...) + if err != nil { + return Digest{}, err + } + return Digest{repo, digest}, nil +} 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/errors.go b/vendor/github.com/google/go-containerregistry/pkg/name/errors.go new file mode 100644 index 0000000000..7847cc5d1e --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/name/errors.go @@ -0,0 +1,37 @@ +// 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 + +import "fmt" + +// ErrBadName is an error for when a bad docker name is supplied. +type ErrBadName struct { + info string +} + +func (e *ErrBadName) Error() string { + return e.info +} + +// NewErrBadName returns a ErrBadName which returns the given formatted string from Error(). +func NewErrBadName(fmtStr string, args ...interface{}) *ErrBadName { + return &ErrBadName{fmt.Sprintf(fmtStr, args...)} +} + +// IsErrBadName returns true if the given error is an ErrBadName. +func IsErrBadName(err error) bool { + _, ok := err.(*ErrBadName) + return ok +} 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 new file mode 100644 index 0000000000..cca3034053 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/name/ref.go @@ -0,0 +1,50 @@ +// 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 + +import ( + "errors" + "fmt" +) + +// Reference defines the interface that consumers use when they can +// take either a tag or a digest. +type Reference interface { + fmt.Stringer + + // Context accesses the Repository context of the reference. + Context() Repository + + // Identifier accesses the type-specific portion of the reference. + Identifier() string + + // Name is the fully-qualified reference name. + Name() string + + // Scope is the scope needed to access this reference. + Scope(string) string +} + +// ParseReference parses the string as a reference, either by tag or digest. +func ParseReference(s string, opts ...Option) (Reference, error) { + if t, err := NewTag(s, opts...); err == nil { + return t, nil + } + if d, err := NewDigest(s, opts...); err == nil { + return d, nil + } + // TODO: Combine above errors into something more useful? + return nil, errors.New("could not parse reference") +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/registry.go b/vendor/github.com/google/go-containerregistry/pkg/name/registry.go new file mode 100644 index 0000000000..c12dd46c2c --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/name/registry.go @@ -0,0 +1,142 @@ +// 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 + +import ( + "net" + "net/url" + "regexp" + "strings" +) + +const ( + // DefaultRegistry is Docker Hub, assumed when a hostname is omitted. + DefaultRegistry = "index.docker.io" + defaultRegistryAlias = "docker.io" +) + +// Detect more complex forms of local references. +var reLocal = regexp.MustCompile(`.*\.local(?:host)?(?::\d{1,5})?$`) + +// Detect the loopback IP (127.0.0.1) +var reLoopback = regexp.MustCompile(regexp.QuoteMeta("127.0.0.1")) + +// Detect the loopback IPV6 (::1) +var reipv6Loopback = regexp.MustCompile(regexp.QuoteMeta("::1")) + +// Registry stores a docker registry name in a structured form. +type Registry struct { + insecure bool + registry string +} + +// RegistryStr returns the registry component of the Registry. +func (r Registry) RegistryStr() string { + if r.registry != "" { + return r.registry + } + return DefaultRegistry +} + +// Name returns the name from which the Registry was derived. +func (r Registry) Name() string { + return r.RegistryStr() +} + +func (r Registry) String() string { + return r.Name() +} + +// Scope returns the scope required to access the registry. +func (r Registry) Scope(string) string { + // The only resource under 'registry' is 'catalog'. http://goo.gl/N9cN9Z + return "registry:catalog:*" +} + +func (r Registry) isRFC1918() bool { + ipStr := strings.Split(r.Name(), ":")[0] + ip := net.ParseIP(ipStr) + if ip == nil { + return false + } + for _, cidr := range []string{"10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"} { + _, block, _ := net.ParseCIDR(cidr) + if block.Contains(ip) { + return true + } + } + return false +} + +// Scheme returns https scheme for all the endpoints except localhost or when explicitly defined. +func (r Registry) Scheme() string { + if r.insecure { + return "http" + } + if r.isRFC1918() { + return "http" + } + if strings.HasPrefix(r.Name(), "localhost:") { + return "http" + } + if reLocal.MatchString(r.Name()) { + return "http" + } + if reLoopback.MatchString(r.Name()) { + return "http" + } + if reipv6Loopback.MatchString(r.Name()) { + return "http" + } + return "https" +} + +func checkRegistry(name string) error { + // Per RFC 3986, registries (authorities) are required to be prefixed with "//" + // url.Host == hostname[:port] == authority + if url, err := url.Parse("//" + name); err != nil || url.Host != name { + return NewErrBadName("registries must be valid RFC 3986 URI authorities: %s", name) + } + return nil +} + +// 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, 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") + } + + if err := checkRegistry(name); err != nil { + return Registry{}, err + } + + // Rewrite "docker.io" to "index.docker.io". + // See: https://github.com/google/go-containerregistry/issues/68 + if name == defaultRegistryAlias { + name = DefaultRegistry + } + + return Registry{registry: name, insecure: opt.insecure}, nil +} + +// NewInsecureRegistry returns an Insecure Registry based on the given name. +// +// 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 new file mode 100644 index 0000000000..f333779884 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/name/repository.go @@ -0,0 +1,100 @@ +// 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 + +import ( + "fmt" + "strings" +) + +const ( + defaultNamespace = "library" + repositoryChars = "abcdefghijklmnopqrstuvwxyz0123456789_-./" + regRepoDelimiter = "/" +) + +// Repository stores a docker repository name in a structured form. +type Repository struct { + Registry + repository string +} + +// See https://docs.docker.com/docker-hub/official_repos +func hasImplicitNamespace(repo string, reg Registry) bool { + return !strings.ContainsRune(repo, '/') && reg.RegistryStr() == DefaultRegistry +} + +// RepositoryStr returns the repository component of the Repository. +func (r Repository) RepositoryStr() string { + if hasImplicitNamespace(r.repository, r.Registry) { + return fmt.Sprintf("%s/%s", defaultNamespace, r.repository) + } + return r.repository +} + +// Name returns the name from which the Repository was derived. +func (r Repository) Name() string { + regName := r.Registry.Name() + if regName != "" { + return regName + regRepoDelimiter + r.RepositoryStr() + } + return r.RepositoryStr() +} + +func (r Repository) String() string { + return r.Name() +} + +// Scope returns the scope required to perform the given action on the registry. +// TODO(jonjohnsonjr): consider moving scopes to a separate package. +func (r Repository) Scope(action string) string { + return fmt.Sprintf("repository:%s:%s", r.RepositoryStr(), action) +} + +func checkRepository(repository string) error { + return checkElement("repository", repository, repositoryChars, 2, 255) +} + +// NewRepository returns a new Repository representing the given name, according to the given strictness. +func NewRepository(name string, opts ...Option) (Repository, error) { + opt := makeOptions(opts...) + if len(name) == 0 { + return Repository{}, NewErrBadName("a repository name must be specified") + } + + var registry string + repo := name + parts := strings.SplitN(name, regRepoDelimiter, 2) + if len(parts) == 2 && (strings.ContainsRune(parts[0], '.') || strings.ContainsRune(parts[0], ':')) { + // The first part of the repository is treated as the registry domain + // iff it contains a '.' or ':' character, otherwise it is all repository + // and the domain defaults to Docker Hub. + registry = parts[0] + repo = parts[1] + } + + if err := checkRepository(repo); err != nil { + return Repository{}, err + } + + reg, err := NewRegistry(registry, opts...) + if err != nil { + return Repository{}, err + } + 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 new file mode 100644 index 0000000000..e6cce34dbd --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/name/tag.go @@ -0,0 +1,102 @@ +// 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 + +import ( + "strings" +) + +const ( + defaultTag = "latest" + // TODO(dekkagaijin): use the docker/distribution regexes for validation. + tagChars = "abcdefghijklmnopqrstuvwxyz0123456789_-.ABCDEFGHIJKLMNOPQRSTUVWXYZ" + tagDelim = ":" +) + +// Tag stores a docker tag name in a structured form. +type Tag struct { + Repository + tag string +} + +// Ensure Tag implements Reference +var _ Reference = (*Tag)(nil) + +// Context implements Reference. +func (t Tag) Context() Repository { + return t.Repository +} + +// Identifier implements Reference. +func (t Tag) Identifier() string { + return t.TagStr() +} + +// TagStr returns the tag component of the Tag. +func (t Tag) TagStr() string { + if t.tag != "" { + return t.tag + } + return defaultTag +} + +// Name returns the name from which the Tag was derived. +func (t Tag) Name() string { + return t.Repository.Name() + tagDelim + t.TagStr() +} + +func (t Tag) String() string { + return t.Name() +} + +// Scope returns the scope required to perform the given action on the tag. +func (t Tag) Scope(action string) string { + return t.Repository.Scope(action) +} + +func checkTag(name string) error { + return checkElement("tag", name, tagChars, 1, 127) +} + +// NewTag returns a new Tag representing the given name, according to the given strictness. +func NewTag(name string, opts ...Option) (Tag, error) { + opt := makeOptions(opts...) + base := name + tag := "" + + // Split on ":" + parts := strings.Split(name, tagDelim) + // Verify that we aren't confusing a tag for a hostname w/ port for the purposes of weak validation. + if len(parts) > 1 && !strings.Contains(parts[len(parts)-1], regRepoDelimiter) { + base = strings.Join(parts[:len(parts)-1], tagDelim) + tag = parts[len(parts)-1] + } + + // We don't require a tag, but if we get one check it's valid, + // even when not being strict. + // If we are being strict, we want to validate the tag regardless in case + // it's empty. + if tag != "" || opt.strict { + if err := checkTag(tag); err != nil { + return Tag{}, err + } + } + + repo, err := NewRepository(base, opts...) + if err != nil { + return Tag{}, err + } + return Tag{repo, tag}, nil +} diff --git a/vendor/github.com/knative/serving/AUTHORS b/vendor/github.com/knative/serving/AUTHORS new file mode 100644 index 0000000000..5ab90824ca --- /dev/null +++ b/vendor/github.com/knative/serving/AUTHORS @@ -0,0 +1,10 @@ +# 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. +IBM Corp +Red Hat, Inc. +Cisco Systems, Inc. diff --git a/vendor/github.com/knative/serving/LICENSE b/vendor/github.com/knative/serving/LICENSE new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/vendor/github.com/knative/serving/LICENSE @@ -0,0 +1,202 @@ + + 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/serving/cmd/activator/kodata/HEAD b/vendor/github.com/knative/serving/cmd/activator/kodata/HEAD new file mode 120000 index 0000000000..8f63681d36 --- /dev/null +++ b/vendor/github.com/knative/serving/cmd/activator/kodata/HEAD @@ -0,0 +1 @@ +../../../.git/HEAD \ No newline at end of file diff --git a/vendor/github.com/knative/serving/cmd/activator/kodata/LICENSE b/vendor/github.com/knative/serving/cmd/activator/kodata/LICENSE new file mode 120000 index 0000000000..5853aaea53 --- /dev/null +++ b/vendor/github.com/knative/serving/cmd/activator/kodata/LICENSE @@ -0,0 +1 @@ +../../../LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/serving/cmd/activator/kodata/VENDOR-LICENSE b/vendor/github.com/knative/serving/cmd/activator/kodata/VENDOR-LICENSE new file mode 120000 index 0000000000..3cc8976451 --- /dev/null +++ b/vendor/github.com/knative/serving/cmd/activator/kodata/VENDOR-LICENSE @@ -0,0 +1 @@ +../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/serving/cmd/autoscaler/kodata/HEAD b/vendor/github.com/knative/serving/cmd/autoscaler/kodata/HEAD new file mode 120000 index 0000000000..8f63681d36 --- /dev/null +++ b/vendor/github.com/knative/serving/cmd/autoscaler/kodata/HEAD @@ -0,0 +1 @@ +../../../.git/HEAD \ No newline at end of file diff --git a/vendor/github.com/knative/serving/cmd/autoscaler/kodata/LICENSE b/vendor/github.com/knative/serving/cmd/autoscaler/kodata/LICENSE new file mode 120000 index 0000000000..5853aaea53 --- /dev/null +++ b/vendor/github.com/knative/serving/cmd/autoscaler/kodata/LICENSE @@ -0,0 +1 @@ +../../../LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/serving/cmd/autoscaler/kodata/VENDOR-LICENSE b/vendor/github.com/knative/serving/cmd/autoscaler/kodata/VENDOR-LICENSE new file mode 120000 index 0000000000..3cc8976451 --- /dev/null +++ b/vendor/github.com/knative/serving/cmd/autoscaler/kodata/VENDOR-LICENSE @@ -0,0 +1 @@ +../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/serving/cmd/controller/kodata/HEAD b/vendor/github.com/knative/serving/cmd/controller/kodata/HEAD new file mode 120000 index 0000000000..8f63681d36 --- /dev/null +++ b/vendor/github.com/knative/serving/cmd/controller/kodata/HEAD @@ -0,0 +1 @@ +../../../.git/HEAD \ No newline at end of file diff --git a/vendor/github.com/knative/serving/cmd/controller/kodata/LICENSE b/vendor/github.com/knative/serving/cmd/controller/kodata/LICENSE new file mode 120000 index 0000000000..5853aaea53 --- /dev/null +++ b/vendor/github.com/knative/serving/cmd/controller/kodata/LICENSE @@ -0,0 +1 @@ +../../../LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/serving/cmd/controller/kodata/VENDOR-LICENSE b/vendor/github.com/knative/serving/cmd/controller/kodata/VENDOR-LICENSE new file mode 120000 index 0000000000..3cc8976451 --- /dev/null +++ b/vendor/github.com/knative/serving/cmd/controller/kodata/VENDOR-LICENSE @@ -0,0 +1 @@ +../../../third_party/VENDOR-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/serving/cmd/networking/certmanager/kodata/VENDOR-LICENSE b/vendor/github.com/knative/serving/cmd/networking/certmanager/kodata/VENDOR-LICENSE new file mode 120000 index 0000000000..7322c09d95 --- /dev/null +++ b/vendor/github.com/knative/serving/cmd/networking/certmanager/kodata/VENDOR-LICENSE @@ -0,0 +1 @@ +../../../../third_party/VENDOR-LICENSE \ No newline at end of file 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/cmd/queue/kodata/HEAD b/vendor/github.com/knative/serving/cmd/queue/kodata/HEAD new file mode 120000 index 0000000000..8f63681d36 --- /dev/null +++ b/vendor/github.com/knative/serving/cmd/queue/kodata/HEAD @@ -0,0 +1 @@ +../../../.git/HEAD \ No newline at end of file diff --git a/vendor/github.com/knative/serving/cmd/queue/kodata/LICENSE b/vendor/github.com/knative/serving/cmd/queue/kodata/LICENSE new file mode 120000 index 0000000000..5853aaea53 --- /dev/null +++ b/vendor/github.com/knative/serving/cmd/queue/kodata/LICENSE @@ -0,0 +1 @@ +../../../LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/serving/cmd/queue/kodata/VENDOR-LICENSE b/vendor/github.com/knative/serving/cmd/queue/kodata/VENDOR-LICENSE new file mode 120000 index 0000000000..3cc8976451 --- /dev/null +++ b/vendor/github.com/knative/serving/cmd/queue/kodata/VENDOR-LICENSE @@ -0,0 +1 @@ +../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/serving/cmd/webhook/kodata/HEAD b/vendor/github.com/knative/serving/cmd/webhook/kodata/HEAD new file mode 120000 index 0000000000..8f63681d36 --- /dev/null +++ b/vendor/github.com/knative/serving/cmd/webhook/kodata/HEAD @@ -0,0 +1 @@ +../../../.git/HEAD \ No newline at end of file diff --git a/vendor/github.com/knative/serving/cmd/webhook/kodata/LICENSE b/vendor/github.com/knative/serving/cmd/webhook/kodata/LICENSE new file mode 120000 index 0000000000..5853aaea53 --- /dev/null +++ b/vendor/github.com/knative/serving/cmd/webhook/kodata/LICENSE @@ -0,0 +1 @@ +../../../LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/serving/cmd/webhook/kodata/VENDOR-LICENSE b/vendor/github.com/knative/serving/cmd/webhook/kodata/VENDOR-LICENSE new file mode 120000 index 0000000000..3cc8976451 --- /dev/null +++ b/vendor/github.com/knative/serving/cmd/webhook/kodata/VENDOR-LICENSE @@ -0,0 +1 @@ +../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/github.com/knative/serving/config/300-imagecache.yaml b/vendor/github.com/knative/serving/config/300-imagecache.yaml new file mode 120000 index 0000000000..f10d6dacf6 --- /dev/null +++ b/vendor/github.com/knative/serving/config/300-imagecache.yaml @@ -0,0 +1 @@ +../vendor/github.com/knative/caching/config/image.yaml \ 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 new file mode 100644 index 0000000000..6807e7194a --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/autoscaling/register.go @@ -0,0 +1,135 @@ +/* +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 autoscaling + +import "time" + +const ( + InternalGroupName = "autoscaling.internal.knative.dev" + + GroupName = "autoscaling.knative.dev" + + // ClassAnnotationKey is the annotation for the explicit class of autoscaler + // that a particular resource has opted into. For example, + // autoscaling.knative.dev/class: foo + // This uses a different domain because unlike the resource, it is user-facing. + ClassAnnotationKey = GroupName + "/class" + // KPA is Knative Horizontal Pod Autoscaler + KPA = "kpa.autoscaling.knative.dev" + // HPA is Kubernetes Horizontal Pod Autoscaler + HPA = "hpa.autoscaling.knative.dev" + + // MinScaleAnnotationKey is the annotation to specify the minimum number of Pods + // the PodAutoscaler should provision. For example, + // autoscaling.knative.dev/minScale: "1" + MinScaleAnnotationKey = GroupName + "/minScale" + // MaxScaleAnnotationKey is the annotation to specify the maximum number of Pods + // the PodAutoscaler should provision. For example, + // autoscaling.knative.dev/maxScale: "10" + MaxScaleAnnotationKey = GroupName + "/maxScale" + + // MetricAnnotationKey is the annotation to specify what metric the PodAutoscaler + // should be scaled on. For example, + // autoscaling.knative.dev/metric: cpu + MetricAnnotationKey = GroupName + "/metric" + // Concurrency is the number of requests in-flight at any given time. + Concurrency = "concurrency" + // CPU is the amount of the requested cpu actually being consumed by the Pod. + CPU = "cpu" + + // 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 + 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. + KPALabelKey = GroupName + "/kpa" +) diff --git a/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/doc.go b/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/doc.go new file mode 100644 index 0000000000..bcdf80570a --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/doc.go @@ -0,0 +1,19 @@ +/* +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. +*/ + +// +k8s:deepcopy-gen=package +// +groupName=autoscaling.internal.knative.dev +package v1alpha1 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 new file mode 100644 index 0000000000..a08ae95e55 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/pa_defaults.go @@ -0,0 +1,52 @@ +/* +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" + + "knative.dev/pkg/apis" + "github.com/knative/serving/pkg/apis/autoscaling" +) + +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(apis.WithinSpec(ctx)) + if r.Annotations == nil { + r.Annotations = make(map[string]string) + } + if _, ok := r.Annotations[autoscaling.ClassAnnotationKey]; !ok { + // Default class to KPA. + r.Annotations[autoscaling.ClassAnnotationKey] = autoscaling.KPA + } + // Default metric per class + if _, ok := r.Annotations[autoscaling.MetricAnnotationKey]; !ok { + r.Annotations[autoscaling.MetricAnnotationKey] = defaultMetric(r.Class()) + } +} + +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 new file mode 100644 index 0000000000..03e7c36a28 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/pa_lifecycle.go @@ -0,0 +1,215 @@ +/* +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" + "math" + "strconv" + "time" + + "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 = apis.NewLivingConditionSet( + PodAutoscalerConditionActive, +) + +func (pa *PodAutoscaler) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("PodAutoscaler") +} + +func (pa *PodAutoscaler) Class() string { + if c, ok := pa.Annotations[autoscaling.ClassAnnotationKey]; ok { + return c + } + // Default to "kpa" class for backward compatibility. + 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 + i, _ := strconv.ParseInt(s, 10, 32) + if i < 0 { + return 0 + } + return int32(i) + } + 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 +func (pa *PodAutoscaler) ScaleBounds() (min, max int32) { + min = pa.annotationInt32(autoscaling.MinScaleAnnotationKey) + max = pa.annotationInt32(autoscaling.MaxScaleAnnotationKey) + return +} + +// 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 ta, err := strconv.ParseFloat(s, 64 /*width*/); err == nil { + // Max check for backwards compatibility. + if ta < 1 || ta > math.MaxInt32 { + return 0, false + } + 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 (pas *PodAutoscalerStatus) IsReady() bool { + return podCondSet.Manage(pas.duck()).IsHappy() +} + +// IsActivating returns true if the pod autoscaler is Activating if it is neither +// Active nor Inactive +func (pas *PodAutoscalerStatus) IsActivating() bool { + cond := pas.GetCondition(PodAutoscalerConditionActive) + return cond != nil && cond.Status == corev1.ConditionUnknown +} + +// 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) +} + +// InitializeConditions initializes the conditionhs of the PA. +func (pas *PodAutoscalerStatus) InitializeConditions() { + podCondSet.Manage(pas.duck()).InitializeConditions() +} + +// MarkActive marks the PA active. +func (pas *PodAutoscalerStatus) MarkActive() { + podCondSet.Manage(pas.duck()).MarkTrue(PodAutoscalerConditionActive) +} + +// MarkActivating marks the PA as activating. +func (pas *PodAutoscalerStatus) MarkActivating(reason, message string) { + podCondSet.Manage(pas.duck()).MarkUnknown(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 (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 (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 (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 (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 new file mode 100644 index 0000000000..18229f71f6 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/pa_types.go @@ -0,0 +1,127 @@ +/* +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 ( + "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" + servingv1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + 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 + +// PodAutoscaler is a Knative abstraction that encapsulates the interface by which Knative +// components instantiate autoscalers. This definition is an abstraction that may be backed +// by multiple definitions. For more information, see the Knative Pluggability presentation: +// https://docs.google.com/presentation/d/10KWynvAJYuOEWy69VBa6bHJVCqIsz1TNdEKosNvcpPY/edit +type PodAutoscaler struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec holds the desired state of the PodAutoscaler (from the client). + // +optional + Spec PodAutoscalerSpec `json:"spec,omitempty"` + + // Status communicates the observed state of the PodAutoscaler (from the controller). + // +optional + Status PodAutoscalerStatus `json:"status,omitempty"` +} + +// Verify that PodAutoscaler adheres to the appropriate interfaces. +var ( + // Check that PodAutoscaler can be validated and can be defaulted. + _ apis.Validatable = (*PodAutoscaler)(nil) + _ apis.Defaultable = (*PodAutoscaler)(nil) + + // Check that we can create OwnerReferences to a PodAutoscaler. + _ kmeta.OwnerRefable = (*PodAutoscaler)(nil) +) + +// PodAutoscalerSpec holds the desired state of the PodAutoscaler (from the client). +type PodAutoscalerSpec 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"` + + // DeprecatedConcurrencyModel no longer does anything, use ContainerConcurrency. + // +optional + DeprecatedConcurrencyModel servingv1alpha1.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 servingv1beta1.RevisionContainerConcurrencyType `json:"containerConcurrency,omitempty"` + + // ScaleTargetRef defines the /scale-able resource that this PodAutoscaler + // is responsible for quickly right-sizing. + ScaleTargetRef corev1.ObjectReference `json:"scaleTargetRef"` + + // DeprecatedServiceName holds the name of a core Kubernetes Service resource that + // load balances over the pods referenced by the ScaleTargetRef. + DeprecatedServiceName string `json:"serviceName"` + + // The application-layer protocol. Matches `ProtocolType` inferred from the revision spec. + ProtocolType net.ProtocolType +} + +const ( + // PodAutoscalerConditionReady is set when the revision is starting to materialize + // runtime resources, and becomes true when those resources are ready. + PodAutoscalerConditionReady = apis.ConditionReady + // PodAutoscalerConditionActive is set when the PodAutoscaler's ScaleTargetRef is receiving traffic. + PodAutoscalerConditionActive apis.ConditionType = "Active" +) + +// PodAutoscalerStatus communicates the observed state of the PodAutoscaler (from the controller). +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 + +// PodAutoscalerList is a list of PodAutoscaler resources +type PodAutoscalerList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []PodAutoscaler `json:"items"` +} 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 new file mode 100644 index 0000000000..7355f474d0 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/pa_validation.go @@ -0,0 +1,80 @@ +/* +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" + "fmt" + + "knative.dev/pkg/apis" + "github.com/knative/serving/pkg/apis/autoscaling" + "github.com/knative/serving/pkg/apis/serving" + "k8s.io/apimachinery/pkg/api/equality" +) + +func (pa *PodAutoscaler) Validate(ctx context.Context) *apis.FieldError { + 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. +func (rs *PodAutoscalerSpec) Validate(ctx context.Context) *apis.FieldError { + if equality.Semantic.DeepEqual(rs, &PodAutoscalerSpec{}) { + return apis.ErrMissingField(apis.CurrentField) + } + errs := serving.ValidateNamespacedObjectReference(&rs.ScaleTargetRef).ViaField("scaleTargetRef") + errs = errs.Also(rs.ContainerConcurrency.Validate(ctx). + ViaField("containerConcurrency")) + return errs.Also(validateSKSFields(ctx, rs)) +} + +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(ctx)).ViaField("protocolType") + } + return all +} + +func (pa *PodAutoscaler) validateMetric() *apis.FieldError { + if metric, ok := pa.Annotations[autoscaling.MetricAnnotationKey]; ok { + switch pa.Class() { + case autoscaling.KPA: + switch metric { + case autoscaling.Concurrency: + return nil + } + case autoscaling.HPA: + switch metric { + case autoscaling.CPU, autoscaling.Concurrency: + return nil + } + // TODO: implement OPS autoscaling. + default: + // Leave other classes of PodAutoscaler alone. + return nil + } + return &apis.FieldError{ + Message: fmt.Sprintf("Unsupported metric %q for PodAutoscaler class %q", + metric, pa.Class()), + Paths: []string{"annotations[autoscaling.knative.dev/metric]"}, + } + } + 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/register.go b/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/register.go new file mode 100644 index 0000000000..92d4fee7f3 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/register.go @@ -0,0 +1,53 @@ +/* +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 ( + "github.com/knative/serving/pkg/apis/autoscaling" + + 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: autoscaling.InternalGroupName, Version: "v1alpha1"} + +// 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, + &PodAutoscaler{}, + &PodAutoscalerList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} 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 new file mode 100644 index 0000000000..2c4a511221 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,225 @@ +// +build !ignore_autogenerated + +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/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 *PodAutoscaler) DeepCopyInto(out *PodAutoscaler) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodAutoscaler. +func (in *PodAutoscaler) DeepCopy() *PodAutoscaler { + if in == nil { + return nil + } + out := new(PodAutoscaler) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PodAutoscaler) 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 *PodAutoscalerList) DeepCopyInto(out *PodAutoscalerList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]PodAutoscaler, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodAutoscalerList. +func (in *PodAutoscalerList) DeepCopy() *PodAutoscalerList { + if in == nil { + return nil + } + out := new(PodAutoscalerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PodAutoscalerList) 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 *PodAutoscalerSpec) DeepCopyInto(out *PodAutoscalerSpec) { + *out = *in + out.ScaleTargetRef = in.ScaleTargetRef + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodAutoscalerSpec. +func (in *PodAutoscalerSpec) DeepCopy() *PodAutoscalerSpec { + if in == nil { + return nil + } + out := new(PodAutoscalerSpec) + in.DeepCopyInto(out) + return out +} + +// 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 + 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]) + } + } + return +} + +// 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(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 new file mode 100644 index 0000000000..5799eb62e4 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/config/defaults.go @@ -0,0 +1,155 @@ +/* +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 + + https://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 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 +func NewDefaultsConfigFromMap(data map[string]string) (*Defaults, error) { + nc := &Defaults{} + + // Process int64 fields + for _, i64 := range []struct { + key string + field *int64 + // specified exactly when optional + defaultValue int64 + }{{ + 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 + } else if val, err := strconv.ParseInt(raw, 10, 64); err != nil { + return nil, err + } else { + *i64.field = val + } + } + + 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 + }{{ + 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 = nil + } else if val, err := resource.ParseQuantity(raw); err != nil { + return nil, err + } else { + *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 +} + +// NewDefaultsConfigFromConfigMap creates a Defaults from the supplied configMap +func NewDefaultsConfigFromConfigMap(config *corev1.ConfigMap) (*Defaults, error) { + return NewDefaultsConfigFromMap(config.Data) +} + +// 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 + 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/doc.go b/vendor/github.com/knative/serving/pkg/apis/config/doc.go new file mode 100644 index 0000000000..8a8d1a7580 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/config/doc.go @@ -0,0 +1,21 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +k8s:deepcopy-gen=package + +// Package config holds the typed objects that define the schemas for +// ConfigMap objects that pertain to our API objects. +package config diff --git a/vendor/github.com/knative/serving/pkg/apis/config/store.go b/vendor/github.com/knative/serving/pkg/apis/config/store.go new file mode 100644 index 0000000000..38f21bc66d --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/config/store.go @@ -0,0 +1,92 @@ +/* +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 config + +import ( + "context" + + "knative.dev/pkg/configmap" +) + +type cfgKey struct{} + +// Config holds the collection of configurations that we attach to contexts. +// +k8s:deepcopy-gen=false +type Config struct { + Defaults *Defaults +} + +// FromContext extracts a Config from the provided context. +func FromContext(ctx context.Context) *Config { + x, ok := ctx.Value(cfgKey{}).(*Config) + if ok { + return x + } + return nil +} + +// FromContextOrDefaults is like FromContext, but when no Config is attached it +// returns a Config populated with the defaults for each of the Config fields. +func FromContextOrDefaults(ctx context.Context) *Config { + if cfg := FromContext(ctx); cfg != nil { + return cfg + } + defaults, _ := NewDefaultsConfigFromMap(map[string]string{}) + return &Config{ + Defaults: defaults, + } +} + +// ToContext attaches the provided Config to the provided context, returning the +// new context with the Config attached. +func ToContext(ctx context.Context, c *Config) context.Context { + return context.WithValue(ctx, cfgKey{}, c) +} + +// Store is a typed wrapper around configmap.Untyped store to handle our configmaps. +// +k8s:deepcopy-gen=false +type Store struct { + *configmap.UntypedStore +} + +// NewStore creates a new store of Configs and optionally calls functions when ConfigMaps are updated. +func NewStore(logger configmap.Logger, onAfterStore ...func(name string, value interface{})) *Store { + store := &Store{ + UntypedStore: configmap.NewUntypedStore( + "defaults", + logger, + configmap.Constructors{ + DefaultsConfigName: NewDefaultsConfigFromConfigMap, + }, + onAfterStore..., + ), + } + + return store +} + +// ToContext attaches the current Config state to the provided context. +func (s *Store) ToContext(ctx context.Context) context.Context { + return ToContext(ctx, s.Load()) +} + +// Load creates a Config from the current config state of the Store. +func (s *Store) Load() *Config { + return &Config{ + Defaults: s.UntypedLoad(DefaultsConfigName).(*Defaults).DeepCopy(), + } +} diff --git a/vendor/github.com/knative/serving/pkg/apis/config/testdata/config-defaults.yaml b/vendor/github.com/knative/serving/pkg/apis/config/testdata/config-defaults.yaml new file mode 120000 index 0000000000..4f00ffb571 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/config/testdata/config-defaults.yaml @@ -0,0 +1 @@ +../../../../config/config-defaults.yaml \ No newline at end of file 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 new file mode 100644 index 0000000000..d0e78d8c0d --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/config/zz_generated.deepcopy.go @@ -0,0 +1,57 @@ +// +build !ignore_autogenerated + +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package 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 + 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 +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Defaults. +func (in *Defaults) DeepCopy() *Defaults { + if in == nil { + return nil + } + out := new(Defaults) + in.DeepCopyInto(out) + return out +} 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 new file mode 100644 index 0000000000..59adf41001 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/generic_types.go @@ -0,0 +1,46 @@ +/* +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 + +import ( + "context" + + "knative.dev/pkg/apis" +) + +// This files contains the versionless types and enums that are strongly +// unlikely to change from version to version. + +// ProtocolType is an enumeration of the supported application-layer protocols +// See also: https://github.com/knative/serving/blob/master/docs/runtime-contract.md#protocols-and-ports +type ProtocolType string + +const ( + // ProtocolHTTP1 maps to HTTP/1.1. + ProtocolHTTP1 ProtocolType = "http1" + // ProtocolH2C maps to HTTP/2 with Prior Knowledge. + ProtocolH2C ProtocolType = "h2c" +) + +// Validate validates that ProtocolType has a correct enum value. +func (p ProtocolType) Validate(context.Context) *apis.FieldError { + switch p { + case ProtocolH2C, ProtocolHTTP1: + return nil + } + 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 new file mode 100644 index 0000000000..83f80b42f1 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/register.go @@ -0,0 +1,79 @@ +/* +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 networking + +const ( + // GroupName is the name for the networking API group. + GroupName = "networking.internal.knative.dev" + + // IngressClassAnnotationKey is the annotation for the + // explicit class of ClusterIngress that a particular resource has + // opted into. For example, + // + // networking.knative.dev/ingress.class: some-network-impl + // + // This uses a different domain because unlike the resource, it is + // user-facing. + // + // The parent resource may use its own annotations to choose the + // annotation value for the ClusterIngress it uses. Based on such + // value a different reconciliation logic may be used (for examples, + // Istio-based ClusterIngress will reconcile into a VirtualService). + IngressClassAnnotationKey = "networking.knative.dev/ingress.class" + + // ClusterIngressLabelKey is the label key attached to underlying network programming + // resources to indicate which ClusterIngress triggered their creation. + 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_defaults.go b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/certificate_defaults.go new file mode 100644 index 0000000000..c270d81887 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/certificate_defaults.go @@ -0,0 +1,24 @@ +/* +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" + +// SetDefaults sets the default values for Certificate. +// Currently it is required that all of the fields of Certificate are +// provisioned by the client. Therefore, SetDefaults does nothing right now. +func (c *Certificate) SetDefaults(context.Context) {} 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 new file mode 100644 index 0000000000..2fd73f017d --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/certificate_lifecycle.go @@ -0,0 +1,80 @@ +/* +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" +) + +// InitializeConditions initializes the certificate conditions. +func (cs *CertificateStatus) InitializeConditions() { + certificateCondSet.Manage(cs).InitializeConditions() +} + +// MarkReady marks the certificate as ready to use. +func (cs *CertificateStatus) MarkReady() { + 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. +func (cs *CertificateStatus) IsReady() bool { + return certificateCondSet.Manage(cs).IsHappy() +} + +// GetCondition gets a speicifc condition of the Certificate status. +func (cs *CertificateStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return certificateCondSet.Manage(cs).GetCondition(t) +} + +// ConditionType represents a Certificate condition value +const ( + // CertificateConditionReady is set when the requested certificate + // is provioned and valid. + CertificateConditionReady = apis.ConditionReady +) + +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 new file mode 100644 index 0000000000..6e817a8b08 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/certificate_types.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 ( + "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 + +// Certificate is responsible for provisioning a SSL certificate for the +// given hosts. It is a Knative abstraction for various SSL certificate +// provisioning solutions (such as cert-manager or self-signed SSL certificate). +type Certificate struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec is the desired state of the Certificate. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status + // +optional + Spec CertificateSpec `json:"spec,omitempty"` + + // Status is the current state of the Certificate. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status + // +optional + Status CertificateStatus `json:"status,omitempty"` +} + +// Verify that Certificate adheres to the appropriate interfaces. +var ( + // Check that Certificate may be validated and defaulted. + _ apis.Validatable = (*Certificate)(nil) + _ apis.Defaultable = (*Certificate)(nil) + + // Check that we can create OwnerReferences to a Certificate.. + _ kmeta.OwnerRefable = (*Certificate)(nil) +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// CertificateList is a collection of `Certificate`. +type CertificateList struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + // Items is the list of `Certificate`. + Items []Certificate `json:"items"` +} + +// CertificateSpec defines the desired state of a `Certificate`. +type CertificateSpec struct { + // DNSNames is a list of DNS names the Certificate could support. + // The wildcard format of DNSNames (e.g. *.default.example.com) is supported. + DNSNames []string `json:"dnsNames"` + + // SecretName is the name of the secret resource to store the SSL certificate in. + SecretName string `json:"secretName"` +} + +// CertificateStatus defines the observed state of a `Certificate`. +type CertificateStatus struct { + // 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 new file mode 100644 index 0000000000..e529bc169a --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/certificate_validation.go @@ -0,0 +1,49 @@ +/* +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" + + "knative.dev/pkg/apis" +) + +// Validate inspects and validates Certificate object. +func (c *Certificate) Validate(ctx context.Context) *apis.FieldError { + return c.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec") +} + +// Validate inspects and validates CertificateSpec object. +func (spec *CertificateSpec) Validate(ctx context.Context) *apis.FieldError { + var all *apis.FieldError + // Spec must have at least one DNS Name. + if len(spec.DNSNames) == 0 { + all = all.Also(apis.ErrMissingField("dnsNames")) + } else { + for index, dnsName := range spec.DNSNames { + if len(dnsName) == 0 { + all = all.Also(apis.ErrInvalidArrayValue("", "dnsNames", index)) + } + } + } + + // Spec must have secretName. + if len(spec.SecretName) == 0 { + all = all.Also(apis.ErrMissingField("secretName")) + } + return all +} 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 new file mode 100644 index 0000000000..46ba152550 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/clusteringress_defaults.go @@ -0,0 +1,27 @@ +/* +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" + + "knative.dev/pkg/apis" +) + +func (c *ClusterIngress) SetDefaults(ctx context.Context) { + 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 new file mode 100644 index 0000000000..92fefe85d9 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/clusteringress_lifecycle.go @@ -0,0 +1,30 @@ +/* +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 ( + "k8s.io/apimachinery/pkg/runtime/schema" +) + +func (ci *ClusterIngress) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("ClusterIngress") +} + +// IsPublic returns whether the ClusterIngress should be exposed publicly. +func (ci *ClusterIngress) IsPublic() bool { + return ci.Spec.Visibility == "" || ci.Spec.Visibility == IngressVisibilityExternalIP +} 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 new file mode 100644 index 0000000000..e9fc07bab9 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/clusteringress_types.go @@ -0,0 +1,75 @@ +/* +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 ( + "knative.dev/pkg/apis" + "knative.dev/pkg/kmeta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient:nonNamespaced + +// ClusterIngress is a collection of rules that allow inbound connections to reach the +// endpoints defined by a backend. A ClusterIngress 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 ClusterIngress 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 ClusterIngress. + // 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 ClusterIngress adheres to the appropriate interfaces. +var ( + // Check that ClusterIngress may be validated and defaulted. + _ apis.Validatable = (*ClusterIngress)(nil) + _ apis.Defaultable = (*ClusterIngress)(nil) + + // Check that we can create OwnerReferences to a ClusterIngress. + _ kmeta.OwnerRefable = (*ClusterIngress)(nil) +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ClusterIngressList is a collection of ClusterIngress objects. +type ClusterIngressList 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 ClusterIngress objects. + Items []ClusterIngress `json:"items"` +} 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 new file mode 100644 index 0000000000..6a59bc15b3 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/clusteringress_validation.go @@ -0,0 +1,28 @@ +/* +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" + + "knative.dev/pkg/apis" +) + +// Validate inspects and validates ClusterIngress object. +func (ci *ClusterIngress) Validate(ctx context.Context) *apis.FieldError { + return ci.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec") +} diff --git a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/doc.go b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/doc.go new file mode 100644 index 0000000000..f3f12f28aa --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/doc.go @@ -0,0 +1,24 @@ +/* +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. +*/ + +// +k8s:deepcopy-gen=package +// +groupName=networking.internal.knative.dev +package v1alpha1 + +// ClusterIngress is heavily based on K8s Ingress +// https://godoc.org/k8s.io/api/extensions/v1beta1#Ingress with some +// highlighted modifications. See clusteringress_types.go for more +// information about the modifications that we made. 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 new file mode 100644 index 0000000000..4c4b7302c0 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/register.go @@ -0,0 +1,58 @@ +/* +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 ( + "github.com/knative/serving/pkg/apis/networking" + 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: networking.GroupName, Version: "v1alpha1"} + +// 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, + &ClusterIngress{}, + &ClusterIngressList{}, + &Ingress{}, + &IngressList{}, + &ServerlessService{}, + &ServerlessServiceList{}, + &Certificate{}, + &CertificateList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/serverlessservice_defaults.go b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/serverlessservice_defaults.go new file mode 100644 index 0000000000..a92f091ed2 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/serverlessservice_defaults.go @@ -0,0 +1,29 @@ +/* +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" + +// SetDefaults sets default values on the ServerlessServiceSpec. +func (c *ServerlessService) SetDefaults(ctx context.Context) { + c.Spec.SetDefaults(ctx) +} + +// SetDefaults sets default values on the ServerlessServiceSpec. +func (c *ServerlessServiceSpec) SetDefaults(ctx context.Context) { + // Nothing is defaultable so far. +} 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 new file mode 100644 index 0000000000..47441aa680 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/serverlessservice_lifecycle.go @@ -0,0 +1,70 @@ +/* +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" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var serverlessServiceCondSet = apis.NewLivingConditionSet( + ServerlessServiceConditionEndspointsPopulated, +) + +// GetGroupVersionKind returns the GVK for the ServerlessService. +func (ss *ServerlessService) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("ServerlessService") +} + +// GetCondition returns the value of the condition `t`. +func (sss *ServerlessServiceStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return serverlessServiceCondSet.Manage(sss).GetCondition(t) +} + +// InitializeConditions initializes the conditions. +func (sss *ServerlessServiceStatus) InitializeConditions() { + serverlessServiceCondSet.Manage(sss).InitializeConditions() +} + +// 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 new file mode 100644 index 0000000000..494b31a5ce --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/serverlessservice_types.go @@ -0,0 +1,129 @@ +/* +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" + networking "github.com/knative/serving/pkg/apis/networking" + 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 + +// ServerlessService is a proxy for the K8s service objects containing the +// endpoints for the revision, whether those are endpoints of the activator or +// revision pods. +// See: https://knative.page.link/naxz for details. +type ServerlessService 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 ServerlessService. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status + // +optional + Spec ServerlessServiceSpec `json:"spec,omitempty"` + + // Status is the current state of the ServerlessService. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status + // +optional + Status ServerlessServiceStatus `json:"status,omitempty"` +} + +// Verify that ServerlessService adheres to the appropriate interfaces. +var ( + // Check that ServerlessService may be validated and defaulted. + _ apis.Validatable = (*ServerlessService)(nil) + _ apis.Defaultable = (*ServerlessService)(nil) + + // Check that we can create OwnerReferences to a ServerlessService. + _ kmeta.OwnerRefable = (*ServerlessService)(nil) +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ServerlessServiceList is a collection of ServerlessService. +type ServerlessServiceList struct { + metav1.TypeMeta `json:",inline"` + // Standard object's 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 ServerlessService. + Items []ServerlessService `json:"items"` +} + +// ServerlessServiceOperationMode is an enumeration of the modes of operation +// for the ServerlessService. +type ServerlessServiceOperationMode string + +const ( + // SKSOperationModeServe is reserved for the state when revision + // pods are serving using traffic. + SKSOperationModeServe ServerlessServiceOperationMode = "Serve" + + // SKSOperationModeProxy is reserved for the state when activator + // pods are serving using traffic. + SKSOperationModeProxy ServerlessServiceOperationMode = "Proxy" +) + +// ServerlessServiceSpec describes the ServerlessService. +type ServerlessServiceSpec struct { + // Mode describes the mode of operation of the ServerlessService. + Mode ServerlessServiceOperationMode `json:"mode,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. + ProtocolType networking.ProtocolType +} + +// ServerlessServiceStatus describes the current state of the ServerlessService. +type ServerlessServiceStatus struct { + 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 = apis.ConditionReady + + // ServerlessServiceConditionEndspointsPopulated is set when the ServerlessService's underlying + // Revision K8s Service has been populated with endpoints. + 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 new file mode 100644 index 0000000000..1b1ed19bf9 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/serverlessservice_validation.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 v1alpha1 + +import ( + "context" + + "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(apis.WithinSpec(ctx)).ViaField("spec") +} + +// Validate inspects and validates ServerlessServiceSpec object. +func (spec *ServerlessServiceSpec) Validate(ctx context.Context) *apis.FieldError { + // Spec must not be empty. + if equality.Semantic.DeepEqual(spec, &ServerlessServiceSpec{}) { + return apis.ErrMissingField(apis.CurrentField) + } + var all *apis.FieldError + // Spec mode must be from the enum and + switch spec.Mode { + case SKSOperationModeProxy, SKSOperationModeServe: + break + case "": + all = all.Also(apis.ErrMissingField("mode")) + default: + all = all.Also(apis.ErrInvalidValue(spec.Mode, "mode")) + } + + 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 new file mode 100644 index 0000000000..e8bc6efe82 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,637 @@ +// +build !ignore_autogenerated + +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/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. +func (in *Certificate) DeepCopyInto(out *Certificate) { + *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 Certificate. +func (in *Certificate) DeepCopy() *Certificate { + if in == nil { + return nil + } + out := new(Certificate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Certificate) 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 *CertificateList) DeepCopyInto(out *CertificateList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Certificate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CertificateList. +func (in *CertificateList) DeepCopy() *CertificateList { + if in == nil { + return nil + } + out := new(CertificateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CertificateList) 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 *CertificateSpec) DeepCopyInto(out *CertificateSpec) { + *out = *in + if in.DNSNames != nil { + in, out := &in.DNSNames, &out.DNSNames + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CertificateSpec. +func (in *CertificateSpec) DeepCopy() *CertificateSpec { + if in == nil { + return nil + } + out := new(CertificateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CertificateStatus) DeepCopyInto(out *CertificateStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + if in.NotAfter != nil { + in, out := &in.NotAfter, &out.NotAfter + *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 +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CertificateStatus. +func (in *CertificateStatus) DeepCopy() *CertificateStatus { + if in == nil { + return nil + } + out := new(CertificateStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterIngress) DeepCopyInto(out *ClusterIngress) { + *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 ClusterIngress. +func (in *ClusterIngress) DeepCopy() *ClusterIngress { + if in == nil { + return nil + } + out := new(ClusterIngress) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterIngress) 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 *ClusterIngressList) DeepCopyInto(out *ClusterIngressList) { + *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)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// 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(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 *HTTP01Challenge) DeepCopyInto(out *HTTP01Challenge) { + *out = *in + 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 HTTP01Challenge. +func (in *HTTP01Challenge) DeepCopy() *HTTP01Challenge { + if in == nil { + return nil + } + 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 *HTTPIngressPath) DeepCopyInto(out *HTTPIngressPath) { + *out = *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 HTTPIngressPath. +func (in *HTTPIngressPath) DeepCopy() *HTTPIngressPath { + if in == nil { + return nil + } + out := new(HTTPIngressPath) + in.DeepCopyInto(out) + return out +} + +// 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 *HTTPRetry) DeepCopyInto(out *HTTPRetry) { + *out = *in + 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 HTTPRetry. +func (in *HTTPRetry) DeepCopy() *HTTPRetry { + if in == nil { + return nil + } + 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 *Ingress) DeepCopyInto(out *Ingress) { + *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 Ingress. +func (in *Ingress) DeepCopy() *Ingress { + if in == nil { + return nil + } + 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 *IngressBackend) DeepCopyInto(out *IngressBackend) { + *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)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// 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(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 *IngressList) DeepCopyInto(out *IngressList) { + *out = *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]) + } + } + return +} + +// 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(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 *IngressRule) DeepCopyInto(out *IngressRule) { + *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 IngressRule. +func (in *IngressRule) DeepCopy() *IngressRule { + if in == nil { + return nil + } + out := new(IngressRule) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IngressSpec) DeepCopyInto(out *IngressSpec) { + *out = *in + if in.TLS != nil { + in, out := &in.TLS, &out.TLS + *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([]IngressRule, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressSpec. +func (in *IngressSpec) DeepCopy() *IngressSpec { + if in == nil { + return nil + } + out := new(IngressSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IngressStatus) DeepCopyInto(out *IngressStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + if in.LoadBalancer != nil { + in, out := &in.LoadBalancer, &out.LoadBalancer + *out = new(LoadBalancerStatus) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressStatus. +func (in *IngressStatus) DeepCopy() *IngressStatus { + if in == nil { + return nil + } + out := new(IngressStatus) + in.DeepCopyInto(out) + 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 + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerIngressStatus. +func (in *LoadBalancerIngressStatus) DeepCopy() *LoadBalancerIngressStatus { + if in == nil { + return nil + } + out := new(LoadBalancerIngressStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LoadBalancerStatus) DeepCopyInto(out *LoadBalancerStatus) { + *out = *in + if in.Ingress != nil { + in, out := &in.Ingress, &out.Ingress + *out = make([]LoadBalancerIngressStatus, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerStatus. +func (in *LoadBalancerStatus) DeepCopy() *LoadBalancerStatus { + if in == nil { + return nil + } + out := new(LoadBalancerStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServerlessService) DeepCopyInto(out *ServerlessService) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServerlessService. +func (in *ServerlessService) DeepCopy() *ServerlessService { + if in == nil { + return nil + } + out := new(ServerlessService) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ServerlessService) 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 *ServerlessServiceList) DeepCopyInto(out *ServerlessServiceList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ServerlessService, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServerlessServiceList. +func (in *ServerlessServiceList) DeepCopy() *ServerlessServiceList { + if in == nil { + return nil + } + out := new(ServerlessServiceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ServerlessServiceList) 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 *ServerlessServiceSpec) DeepCopyInto(out *ServerlessServiceSpec) { + *out = *in + out.ObjectRef = in.ObjectRef + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServerlessServiceSpec. +func (in *ServerlessServiceSpec) DeepCopy() *ServerlessServiceSpec { + if in == nil { + return nil + } + out := new(ServerlessServiceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServerlessServiceStatus) DeepCopyInto(out *ServerlessServiceStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServerlessServiceStatus. +func (in *ServerlessServiceStatus) DeepCopy() *ServerlessServiceStatus { + if in == nil { + return nil + } + out := new(ServerlessServiceStatus) + in.DeepCopyInto(out) + return out +} 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/serving/pkg/apis/serving/metadata_validation.go b/vendor/github.com/knative/serving/pkg/apis/serving/metadata_validation.go new file mode 100644 index 0000000000..1625c5a428 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/metadata_validation.go @@ -0,0 +1,30 @@ +/* +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 ( + "knative.dev/pkg/apis" + "github.com/knative/serving/pkg/apis/autoscaling" + 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 { + 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 new file mode 100644 index 0000000000..c11e02f890 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/register.go @@ -0,0 +1,66 @@ +/* +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 serving + +const ( + GroupName = "serving.knative.dev" + + // ConfigurationLabelKey is the label key attached to a Revision indicating by + // which Configuration it is created. + ConfigurationLabelKey = GroupName + "/configuration" + + // RevisionLastPinnedAnnotationKey is the annotation key used for determining when a route has + // pinned a revision + RevisionLastPinnedAnnotationKey = GroupName + "/lastPinned" + + // RouteLabelKey is the label key attached to a Configuration indicating by + // which Route it is configured as traffic target. + // The key can also be attached to ClusterIngress resources to indicate + // which Route triggered their creation. + RouteLabelKey = GroupName + "/route" + + // RouteNamespaceLabelKey is the label key attached to a ClusterIngress + // by a Route to indicate which namespace the Route was created in. + RouteNamespaceLabelKey = GroupName + "/routeNamespace" + + // RevisionLabelKey is the label key attached to k8s resources to indicate + // which Revision triggered their creation. + RevisionLabelKey = GroupName + "/revision" + + // RevisionUID is the label key attached to a revision to indicate + // its unique identifier + RevisionUID = GroupName + "/revisionUID" + + // ServiceLabelKey is the label key attached to a Route and Configuration indicating by + // which Service they are created. + ServiceLabelKey = GroupName + "/service" + + // ConfigurationGenerationLabelKey is the label key attached to a Revision indicating the + // metadata generation of the Configuration that created this revision + ConfigurationGenerationLabelKey = GroupName + "/configurationGeneration" + + // 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" + + // 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/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 new file mode 100644 index 0000000000..2164605e37 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_defaults.go @@ -0,0 +1,44 @@ +/* +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" + + "knative.dev/pkg/apis" + + "github.com/knative/serving/pkg/apis/serving/v1beta1" +) + +func (c *Configuration) SetDefaults(ctx context.Context) { + ctx = apis.WithinParent(ctx, c.ObjectMeta) + c.Spec.SetDefaults(apis.WithinSpec(ctx)) +} + +func (cs *ConfigurationSpec) SetDefaults(ctx context.Context) { + 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 new file mode 100644 index 0000000000..532cbc3f6b --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_lifecycle.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 ( + "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 = 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() +} + +// IsLatestReadyRevisionNameUpToDate returns true if the Configuration is ready +// and LatestCreateRevisionName is equal to LatestReadyRevisionName. Otherwise +// it returns false. +func (cs *ConfigurationStatus) IsLatestReadyRevisionNameUpToDate() bool { + return cs.IsReady() && + cs.LatestCreatedRevisionName == cs.LatestReadyRevisionName +} + +func (cs *ConfigurationStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return confCondSet.Manage(cs).GetCondition(t) +} + +func (cs *ConfigurationStatus) InitializeConditions() { + confCondSet.Manage(cs).InitializeConditions() +} + +func (cs *ConfigurationStatus) SetLatestCreatedRevisionName(name string) { + cs.LatestCreatedRevisionName = name + if cs.LatestReadyRevisionName != name { + confCondSet.Manage(cs).MarkUnknown( + ConfigurationConditionReady, + "", + "") + } +} + +func (cs *ConfigurationStatus) SetLatestReadyRevisionName(name string) { + cs.LatestReadyRevisionName = name + confCondSet.Manage(cs).MarkTrue(ConfigurationConditionReady) +} + +func (cs *ConfigurationStatus) MarkLatestCreatedFailed(name, message string) { + confCondSet.Manage(cs).MarkFalse( + ConfigurationConditionReady, + "RevisionFailed", + "Revision %q failed with message: %s.", name, message) +} + +func (cs *ConfigurationStatus) MarkRevisionCreationFailed(message string) { + confCondSet.Manage(cs).MarkFalse( + ConfigurationConditionReady, + "RevisionFailed", + "Revision creation failed with message: %s.", message) +} + +func (cs *ConfigurationStatus) MarkLatestReadyDeleted() { + confCondSet.Manage(cs).MarkFalse( + ConfigurationConditionReady, + "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 new file mode 100644 index 0000000000..84922ded3b --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_types.go @@ -0,0 +1,131 @@ +/* +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 ( + "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 +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Configuration represents the "floating HEAD" of a linear history of Revisions, +// and optionally how the containers those revisions reference are built. +// 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"` + + // Spec holds the desired state of the Configuration (from the client). + // +optional + Spec ConfigurationSpec `json:"spec,omitempty"` + + // Status communicates the observed state of the Configuration (from the controller). + // +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 { + // 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"` + + // Build optionally holds the specification for the build to + // perform to produce the Revision's container image. + // +optional + DeprecatedBuild *runtime.RawExtension `json:"build,omitempty"` + + // DeprecatedRevisionTemplate holds the latest specification for the Revision to + // be stamped out. If a Build specification is provided, then the + // 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 + Template *RevisionTemplateSpec `json:"template,omitempty"` +} + +const ( + // ConfigurationConditionReady is set when the configuration's latest + // underlying revision has reported readiness. + ConfigurationConditionReady = apis.ConditionReady +) + +// 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 { + // 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/v1alpha1/configuration_validation.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_validation.go new file mode 100644 index 0000000000..d06a9290af --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_validation.go @@ -0,0 +1,79 @@ +/* +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" + + "k8s.io/apimachinery/pkg/api/equality" + + "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")) + } + + 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. +func (cs *ConfigurationSpec) Validate(ctx context.Context) *apis.FieldError { + if equality.Semantic.DeepEqual(cs, &ConfigurationSpec{}) { + return apis.ErrMissingField(apis.CurrentField) + } + + 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.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/doc.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/doc.go new file mode 100644 index 0000000000..b0c5ebaf7c --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/doc.go @@ -0,0 +1,23 @@ +/* +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. +*/ + +// 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 v1alpha1 diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/register.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/register.go new file mode 100644 index 0000000000..0bad032a10 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/register.go @@ -0,0 +1,59 @@ +/* +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 ( + "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: "v1alpha1"} + +// 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/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 new file mode 100644 index 0000000000..72169b001f --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_defaults.go @@ -0,0 +1,63 @@ +/* +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" + + "knative.dev/pkg/apis" + corev1 "k8s.io/api/core/v1" + + "github.com/knative/serving/pkg/apis/serving/v1beta1" +) + +func (r *Revision) SetDefaults(ctx context.Context) { + r.Spec.SetDefaults(apis.WithinSpec(ctx)) +} + +func (rs *RevisionSpec) SetDefaults(ctx context.Context) { + 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. + if rs.DeprecatedConcurrencyModel == RevisionRequestConcurrencyModelSingle && rs.ContainerConcurrency == 0 { + rs.ContainerConcurrency = 1 + } + + // 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 new file mode 100644 index 0000000000..4e81022625 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_lifecycle.go @@ -0,0 +1,272 @@ +/* +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" + "strconv" + "time" + + "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" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +const ( + // UserPortName is the name that will be used for the Port on the + // Deployment and Pod created by a Revision. This name will be set regardless of if + // a user specifies a port or the default value is chosen. + UserPortName = "user-port" + + // DefaultUserPort is the default port value the QueueProxy will + // use for connecting to the user container. + DefaultUserPort = 8080 + + // QueueAdminPortName specifies the port name for + // health check and lifecycle hooks for queue-proxy. + QueueAdminPortName string = "queueadm-port" + + // AutoscalingQueueMetricsPortName specifies the port name to use for metrics + // emitted by queue-proxy for autoscaler. + AutoscalingQueueMetricsPortName = "queue-metrics" + + // UserQueueMetricsPortName specifies the port name to use for metrics + // emitted by queue-proxy for end user. + UserQueueMetricsPortName = "user-metrics" + + // ServiceQueueMetricsPortName is the name of the port that serves metrics + // on the Kubernetes service. + ServiceQueueMetricsPortName = "metrics" +) + +var revCondSet = apis.NewLivingConditionSet( + RevisionConditionResourcesAvailable, + RevisionConditionContainerHealthy, +) + +func (r *Revision) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Revision") +} + +// 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 + } + return buildRef + } + + if r.Spec.DeprecatedBuildName != "" { + return &corev1.ObjectReference{ + APIVersion: "build.knative.dev/v1alpha1", + Kind: "Build", + Namespace: r.Namespace, + Name: r.Spec.DeprecatedBuildName, + } + } + + return nil +} + +// GetProtocol returns the app level network protocol. +func (r *Revision) GetProtocol() net.ProtocolType { + ports := r.Spec.GetContainer().Ports + if len(ports) > 0 && ports[0].Name == string(net.ProtocolH2C) { + return net.ProtocolH2C + } + + return net.ProtocolHTTP1 +} + +// IsReady looks at the conditions and if the Status has a condition +// RevisionConditionReady returns true if ConditionStatus is True +func (rs *RevisionStatus) IsReady() bool { + return revCondSet.Manage(rs).IsHappy() +} + +// IsActivationRequired returns true if activation is required. +func (rs *RevisionStatus) IsActivationRequired() bool { + if c := revCondSet.Manage(rs).GetCondition(RevisionConditionActive); c != nil { + return c.Status != corev1.ConditionTrue + } + return false +} + +func (rs *RevisionStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return revCondSet.Manage(rs).GetCondition(t) +} + +func (rs *RevisionStatus) InitializeConditions() { + revCondSet.Manage(rs).InitializeConditions() +} + +// 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 +// resource of the given kind and name has already been created, and we do not own it. +func (rs *RevisionStatus) MarkResourceNotOwned(kind, name string) { + revCondSet.Manage(rs).MarkFalse(RevisionConditionResourcesAvailable, "NotOwned", + fmt.Sprintf("There is an existing %s %q that we do not own.", kind, name)) +} + +func (rs *RevisionStatus) MarkDeploying(reason string) { + revCondSet.Manage(rs).MarkUnknown(RevisionConditionResourcesAvailable, reason, "") + revCondSet.Manage(rs).MarkUnknown(RevisionConditionContainerHealthy, reason, "") +} + +func (rs *RevisionStatus) MarkProgressDeadlineExceeded(message string) { + revCondSet.Manage(rs).MarkFalse(RevisionConditionResourcesAvailable, "ProgressDeadlineExceeded", message) +} + +func (rs *RevisionStatus) MarkContainerHealthy() { + revCondSet.Manage(rs).MarkTrue(RevisionConditionContainerHealthy) +} + +func (rs *RevisionStatus) MarkContainerExiting(exitCode int32, message string) { + exitCodeString := fmt.Sprintf("ExitCode%d", exitCode) + revCondSet.Manage(rs).MarkFalse(RevisionConditionContainerHealthy, exitCodeString, RevisionContainerExitingMessage(message)) +} + +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) +} + +func (rs *RevisionStatus) MarkActivating(reason, message string) { + revCondSet.Manage(rs).MarkUnknown(RevisionConditionActive, reason, message) +} + +func (rs *RevisionStatus) MarkInactive(reason, message string) { + revCondSet.Manage(rs).MarkFalse(RevisionConditionActive, reason, message) +} + +func (rs *RevisionStatus) MarkContainerMissing(message string) { + revCondSet.Manage(rs).MarkFalse(RevisionConditionContainerHealthy, "ContainerMissing", message) +} + +// RevisionContainerMissingMessage constructs the status message if a given image +// cannot be pulled correctly. +func RevisionContainerMissingMessage(image string, message string) string { + return fmt.Sprintf("Unable to fetch image %q: %s", image, message) +} + +// RevisionContainerExitingMessage constructs the status message if a container +// fails to come up. +func RevisionContainerExitingMessage(message string) string { + return fmt.Sprintf("Container failed with: %s", message) +} + +const ( + AnnotationParseErrorTypeMissing = "Missing" + AnnotationParseErrorTypeInvalid = "Invalid" + LabelParserErrorTypeMissing = "Missing" + LabelParserErrorTypeInvalid = "Invalid" +) + +// +k8s:deepcopy-gen=false +type AnnotationParseError struct { + Type string + Value string + Err error +} + +// +k8s:deepcopy-gen=false +type LastPinnedParseError AnnotationParseError + +func (e LastPinnedParseError) Error() string { + return fmt.Sprintf("%v lastPinned value: %q", e.Type, e.Value) +} + +func RevisionLastPinnedString(t time.Time) string { + return fmt.Sprintf("%d", t.Unix()) +} + +func (r *Revision) SetLastPinned(t time.Time) { + if r.ObjectMeta.Annotations == nil { + r.ObjectMeta.Annotations = make(map[string]string) + } + + r.ObjectMeta.Annotations[serving.RevisionLastPinnedAnnotationKey] = RevisionLastPinnedString(t) +} + +func (r *Revision) GetLastPinned() (time.Time, error) { + if r.Annotations == nil { + return time.Time{}, LastPinnedParseError{ + Type: AnnotationParseErrorTypeMissing, + } + } + + str, ok := r.ObjectMeta.Annotations[serving.RevisionLastPinnedAnnotationKey] + if !ok { + // If a revision is past the create delay without an annotation it is stale + return time.Time{}, LastPinnedParseError{ + Type: AnnotationParseErrorTypeMissing, + } + } + + secs, err := strconv.ParseInt(str, 10, 64) + if err != nil { + return time.Time{}, LastPinnedParseError{ + Type: AnnotationParseErrorTypeInvalid, + Value: str, + Err: err, + } + } + + 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 new file mode 100644 index 0000000000..69d06faf80 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_types.go @@ -0,0 +1,204 @@ +/* +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 ( + "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 +// +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, and optionally a build that is responsible for +// materializing that container image from source. 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"` + + // Spec holds the desired state of the Revision (from the client). + // +optional + Spec RevisionSpec `json:"spec,omitempty"` + + // Status communicates the observed state of the Revision (from the controller). + // +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"` +} + +// DeprecatedRevisionServingStateType is an enumeration of the levels of serving readiness of the Revision. +// See also: https://github.com/knative/serving/blob/master/docs/spec/errors.md#error-conditions-and-reporting +type DeprecatedRevisionServingStateType string + +const ( + // The revision is ready to serve traffic. It should have Kubernetes + // resources, and the Istio route should be pointed to the given resources. + DeprecatedRevisionServingStateActive DeprecatedRevisionServingStateType = "Active" + // The revision is not currently serving traffic, but could be made to serve + // traffic quickly. It should have Kubernetes resources, but the Istio route + // should be pointed to the activator. + DeprecatedRevisionServingStateReserve DeprecatedRevisionServingStateType = "Reserve" + // The revision has been decommissioned and is not needed to serve traffic + // anymore. It should not have any Istio routes or Kubernetes resources. + // A Revision may be brought out of retirement, but it may take longer than + // it would from a "Reserve" state. + // Note: currently not set anywhere. See https://github.com/knative/serving/issues/1203 + DeprecatedRevisionServingStateRetired DeprecatedRevisionServingStateType = "Retired" +) + +// RevisionRequestConcurrencyModelType is an enumeration of the +// concurrency models supported by a Revision. +// DEPRECATED in favor of RevisionContainerConcurrencyType. +type RevisionRequestConcurrencyModelType string + +const ( + // RevisionRequestConcurrencyModelSingle guarantees that only one + // request will be handled at a time (concurrently) per instance + // of Revision Container. + RevisionRequestConcurrencyModelSingle RevisionRequestConcurrencyModelType = "Single" + // RevisionRequestConcurencyModelMulti allows more than one request to + // be handled at a time (concurrently) per instance of Revision + // Container. + RevisionRequestConcurrencyModelMulti RevisionRequestConcurrencyModelType = "Multi" +) + +// 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 + // + // 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"` + + // DeprecatedServingState holds a value describing the desired state the Kubernetes + // resources should be in for this Revision. + // Users must not specify this when creating a revision. These values are no longer + // updated by the system. + // +optional + DeprecatedServingState DeprecatedRevisionServingStateType `json:"servingState,omitempty"` + + // DeprecatedConcurrencyModel specifies the desired concurrency model + // (Single or Multi) for the + // Revision. Defaults to Multi. + // Deprecated in favor of ContainerConcurrency. + // +optional + DeprecatedConcurrencyModel RevisionRequestConcurrencyModelType `json:"concurrencyModel,omitempty"` + + // DeprecatedBuildName optionally holds the name of the Build responsible for + // producing the container image for its Revision. + // DEPRECATED: Use DeprecatedBuildRef instead. + // +optional + DeprecatedBuildName string `json:"buildName,omitempty"` + + // DeprecatedBuildRef holds the reference to the build (if there is one) responsible + // for producing the container image for this Revision. Otherwise, nil + // +optional + 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 + // this Container, including: name and lifecycle. + // See also the runtime contract for more information about the execution + // environment: + // https://github.com/knative/serving/blob/master/docs/runtime-contract.md + // +optional + 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 = apis.ConditionReady + // RevisionConditionResourcesAvailable is set when underlying + // Kubernetes resources have been provisioned. + RevisionConditionResourcesAvailable apis.ConditionType = "ResourcesAvailable" + // RevisionConditionContainerHealthy is set when the revision readiness check completes. + RevisionConditionContainerHealthy apis.ConditionType = "ContainerHealthy" + // RevisionConditionActive is set when the revision is receiving traffic. + RevisionConditionActive apis.ConditionType = "Active" +) + +// 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/v1alpha1/revision_validation.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_validation.go new file mode 100644 index 0000000000..169ad87745 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_validation.go @@ -0,0 +1,219 @@ +/* +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" + "fmt" + "strconv" + "strings" + + "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" +) + +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 (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 { + 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") + } + + if !strings.HasPrefix(rt.Name, prefix) { + errs = errs.Also(apis.ErrInvalidValue( + fmt.Sprintf("%q must have prefix %q", rt.Name, prefix), + "metadata.name")) + } + } + + errs = errs.Also(validateAnnotations(rt.Annotations)) + 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 DeprecatedRevisionTemplate 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 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 +} + +// 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) + } + + errs := apis.CheckDeprecated(ctx, rs) + + 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 rs.DeprecatedBuildRef != nil { + errs = errs.Also(apis.ErrDisallowedFields("buildRef")) + } + + 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 rs.TimeoutSeconds != nil { + errs = errs.Also(validateTimeoutSeconds(ctx, *rs.TimeoutSeconds)) + } + return errs +} + +func validateAnnotations(annotations map[string]string) *apis.FieldError { + return validatePercentageAnnotationKey(annotations, serving.QueueSideCarResourcePercentageAnnotation) +} + +func validatePercentageAnnotationKey(annotations map[string]string, resourcePercentageAnnotationKey string) *apis.FieldError { + if len(annotations) == 0 { + return nil + } + + v, ok := annotations[resourcePercentageAnnotationKey] + if !ok { + return nil + } + value, err := strconv.ParseFloat(v, 32) + if err != nil { + return apis.ErrInvalidValue(v, apis.CurrentField).ViaKey(resourcePercentageAnnotationKey) + } + + if value <= float64(0.1) || value > float64(100) { + return apis.ErrOutOfBoundsValue(value, 0.1, 100.0, resourcePercentageAnnotationKey) + } + + return nil +} + +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 +} + +// 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) + } +} + +// 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) + } +} 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 new file mode 100644 index 0000000000..3e1e024a32 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_defaults.go @@ -0,0 +1,53 @@ +/* +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" + + "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(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 new file mode 100644 index 0000000000..b8a846e217 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_lifecycle.go @@ -0,0 +1,175 @@ +/* +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" + + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "github.com/knative/serving/pkg/apis/networking/v1alpha1" +) + +var routeCondSet = apis.NewLivingConditionSet( + RouteConditionAllTrafficAssigned, + RouteConditionIngressReady, +) + +func (r *Route) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Route") +} + +func (rs *RouteStatus) IsReady() bool { + return routeCondSet.Manage(rs).IsHappy() +} + +func (rs *RouteStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return routeCondSet.Manage(rs).GetCondition(t) +} + +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) { + routeCondSet.Manage(rs).MarkFalse(RouteConditionIngressReady, "NotOwned", + 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) +} + +func (rs *RouteStatus) MarkUnknownTrafficError(msg string) { + routeCondSet.Manage(rs).MarkUnknown(RouteConditionAllTrafficAssigned, "Unknown", msg) +} + +func (rs *RouteStatus) MarkConfigurationNotReady(name string) { + routeCondSet.Manage(rs).MarkUnknown(RouteConditionAllTrafficAssigned, + "RevisionMissing", + "Configuration %q is waiting for a Revision to become ready.", name) +} + +func (rs *RouteStatus) MarkConfigurationFailed(name string) { + routeCondSet.Manage(rs).MarkFalse(RouteConditionAllTrafficAssigned, + "RevisionMissing", + "Configuration %q does not have any ready Revision.", name) +} + +func (rs *RouteStatus) MarkRevisionNotReady(name string) { + routeCondSet.Manage(rs).MarkUnknown(RouteConditionAllTrafficAssigned, + "RevisionMissing", + "Revision %q is not yet ready.", name) +} + +func (rs *RouteStatus) MarkRevisionFailed(name string) { + routeCondSet.Manage(rs).MarkFalse(RouteConditionAllTrafficAssigned, + "RevisionMissing", + "Revision %q failed to become ready.", name) +} + +func (rs *RouteStatus) MarkMissingTrafficTarget(kind, name string) { + routeCondSet.Manage(rs).MarkFalse(RouteConditionAllTrafficAssigned, + kind+"Missing", + "%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.IngressConditionReady) + if cc == nil { + rs.MarkIngressNotConfigured() + return + } + switch { + case cc.Status == corev1.ConditionUnknown: + routeCondSet.Manage(rs).MarkUnknown(RouteConditionIngressReady, cc.Reason, cc.Message) + case cc.Status == corev1.ConditionTrue: + routeCondSet.Manage(rs).MarkTrue(RouteConditionIngressReady) + case cc.Status == corev1.ConditionFalse: + 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 new file mode 100644 index 0000000000..0d86035d4b --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_types.go @@ -0,0 +1,163 @@ +/* +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 ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "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 +// +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 { + // Name is optionally used to expose a dedicated hostname for referencing this + // target exclusively. It has the form: {name}.${route.status.domain} + // +optional + DeprecatedName string `json:"name,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). +type RouteSpec 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"` + + // Traffic specifies how to distribute traffic over a collection of Knative Serving 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 + + // RouteConditionAllTrafficAssigned is set to False when the + // service is not configured properly or has no available + // backends ready to receive traffic. + RouteConditionAllTrafficAssigned apis.ConditionType = "AllTrafficAssigned" + + // RouteConditionIngressReady is set to False when the + // ClusterIngress fails to become Ready. + 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-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 { + // 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 + 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 + // {route-name}.{route-namespace}.svc.{cluster-domain-name} + // DEPRECATED: Use Address instead. + // +optional + DeprecatedDomainInternal string `json:"domainInternal,omitempty"` + + // Address holds the information needed for a Route to be the target of an event. + // +optional + Address *duckv1alpha1.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/v1alpha1/route_validation.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_validation.go new file mode 100644 index 0000000000..d1ce8193ee --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_validation.go @@ -0,0 +1,95 @@ +/* +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" + "fmt" + + "knative.dev/pkg/apis" + "github.com/knative/serving/pkg/apis/serving" + "k8s.io/apimachinery/pkg/api/equality" +) + +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")) + return errs +} + +func (rs *RouteSpec) Validate(ctx context.Context) *apis.FieldError { + if equality.Semantic.DeepEqual(rs, &RouteSpec{}) { + return apis.ErrMissingField(apis.CurrentField) + } + + 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]diagnostic) + + percentSum := 0 + for i, tt := range rs.Traffic { + // Delegate to the v1beta1 validation. + errs = errs.Also(tt.TrafficTarget.Validate(ctx).ViaFieldIndex("traffic", i)) + + percentSum += tt.Percent + + 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 + } + + errs = errs.Also(apis.CheckDeprecated(ctx, tt).ViaFieldIndex("traffic", i)) + + name := tt.DeprecatedName + field := "name" + if name == "" { + name = tt.Tag + field = "tag" + } + + if d, ok := trafficMap[name]; !ok { + // No entry exists, so add ours + 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", name), + Paths: []string{ + fmt.Sprintf("traffic[%d].%s", d.index, d.field), + fmt.Sprintf("traffic[%d].%s", i, field), + }, + }) + } + } + + if percentSum != 100 { + errs = errs.Also(&apis.FieldError{ + Message: fmt.Sprintf("Traffic targets sum to %d, want 100", percentSum), + Paths: []string{"traffic"}, + }) + } + 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 new file mode 100644 index 0000000000..8dee71bc8a --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_defaults.go @@ -0,0 +1,75 @@ +/* +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" + + "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) { + 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 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.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 new file mode 100644 index 0000000000..76402e6d93 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_lifecycle.go @@ -0,0 +1,161 @@ +/* +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" + + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + + "knative.dev/pkg/apis" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" +) + +var serviceCondSet = apis.NewLivingConditionSet( + ServiceConditionConfigurationsReady, + ServiceConditionRoutesReady, +) + +// GetGroupVersionKind returns the GetGroupVersionKind. +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() +} + +// GetCondition returns the condition by name. +func (ss *ServiceStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return serviceCondSet.Manage(ss).GetCondition(t) +} + +// InitializeConditions sets the initial values to the conditions. +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. +func (ss *ServiceStatus) MarkConfigurationNotOwned(name string) { + serviceCondSet.Manage(ss).MarkFalse(ServiceConditionConfigurationsReady, "NotOwned", + fmt.Sprintf("There is an existing Configuration %q that we do not own.", name)) +} + +// MarkRouteNotOwned surfaces a failure via the RoutesReady status noting that the Route +// with the name we want has already been created and we do not own it. +func (ss *ServiceStatus) MarkRouteNotOwned(name string) { + serviceCondSet.Manage(ss).MarkFalse(ServiceConditionRoutesReady, "NotOwned", + 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) { + ss.ConfigurationStatusFields = cs.ConfigurationStatusFields + + cc := cs.GetCondition(ConfigurationConditionReady) + if cc == nil { + return + } + switch { + case cc.Status == corev1.ConditionUnknown: + serviceCondSet.Manage(ss).MarkUnknown(ServiceConditionConfigurationsReady, cc.Reason, cc.Message) + case cc.Status == corev1.ConditionTrue: + serviceCondSet.Manage(ss).MarkTrue(ServiceConditionConfigurationsReady) + case cc.Status == corev1.ConditionFalse: + serviceCondSet.Manage(ss).MarkFalse(ServiceConditionConfigurationsReady, cc.Reason, cc.Message) + } +} + +// 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." + + // LatestTrafficTarget is the named constant of the `latest` traffic target. + LatestTrafficTarget = "latest" + + // CurrentTrafficTarget is the named constnat of the `current` traffic target. + CurrentTrafficTarget = "current" + + // CandidateTrafficTarget is the named constnat of the `candidate` traffic target. + CandidateTrafficTarget = "candidate" +) + +// MarkRouteNotYetReady marks the service `RouteReady` condition to the `Unknown` state. +// See: #2430, for details. +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 + + rc := rs.GetCondition(RouteConditionReady) + if rc == nil { + return + } + switch { + case rc.Status == corev1.ConditionUnknown: + serviceCondSet.Manage(ss).MarkUnknown(ServiceConditionRoutesReady, rc.Reason, rc.Message) + case rc.Status == corev1.ConditionTrue: + serviceCondSet.Manage(ss).MarkTrue(ServiceConditionRoutesReady) + case rc.Status == corev1.ConditionFalse: + serviceCondSet.Manage(ss).MarkFalse(ServiceConditionRoutesReady, rc.Reason, rc.Message) + } +} + +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 new file mode 100644 index 0000000000..af6d63f61e --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_types.go @@ -0,0 +1,194 @@ +/* +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 ( + 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 set of Routes and +// Configurations 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 Route 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. Exactly one +// of its members (other than Generation) must be specified. Services can either +// track the latest ready revision of a configuration or be pinned to a specific +// revision. +type ServiceSpec 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"` + + // DeprecatedRunLatest defines a simple Service. It will automatically + // configure a route that keeps the latest ready revision + // from the supplied configuration running. + // +optional + DeprecatedRunLatest *RunLatestType `json:"runLatest,omitempty"` + + // DeprecatedPinned is DEPRECATED in favor of ReleaseType + // +optional + DeprecatedPinned *PinnedType `json:"pinned,omitempty"` + + // 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 + 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 + 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 { + // DeprecatedManual type does not contain a configuration as this type provides the + // user complete control over the configuration and route. +} + +// ReleaseType contains the options for slowly releasing revisions. See ServiceSpec for +// more details. +type ReleaseType struct { + // Revisions is an ordered list of 1 or 2 revisions. The first will + // have a TrafficTarget with a name of "current" and the second will have + // a name of "candidate". + // +optional + Revisions []string `json:"revisions,omitempty"` + + // RolloutPercent is the percent of traffic that should be sent to the "candidate" + // revision. Valid values are between 0 and 99 inclusive. + // +optional + RolloutPercent int `json:"rolloutPercent,omitempty"` + + // The configuration for this service. All revisions from this service must + // come from a single configuration. + // +optional + Configuration ConfigurationSpec `json:"configuration,omitempty"` +} + +// ReleaseLatestRevisionKeyword is a shortcut for usage in the `release` mode +// to refer to the latest created revision. +// See #2819 for details. +const ReleaseLatestRevisionKeyword = "@latest" + +// RunLatestType contains the options for always having a route to the latest configuration. See +// ServiceSpec for more details. +type RunLatestType struct { + // The configuration for this service. + // +optional + Configuration ConfigurationSpec `json:"configuration,omitempty"` +} + +// PinnedType is DEPRECATED. ReleaseType should be used instead. To get the behavior of PinnedType set +// ReleaseType.Revisions to []string{PinnedType.RevisionName} and ReleaseType.RolloutPercent to 0. +type PinnedType struct { + // The revision name to pin this service to until changed + // to a different service type. + // +optional + RevisionName string `json:"revisionName,omitempty"` + + // The configuration for this service. + // +optional + Configuration ConfigurationSpec `json:"configuration,omitempty"` +} + +// 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 + // ServiceConditionRoutesReady is set when the service's underlying + // routes have reported readiness. + ServiceConditionRoutesReady apis.ConditionType = "RoutesReady" + // ServiceConditionConfigurationsReady is set when the service's underlying + // configurations have reported readiness. + ServiceConditionConfigurationsReady apis.ConditionType = "ConfigurationsReady" +) + +// ServiceStatus represents the Status stanza of the Service resource. +type ServiceStatus struct { + duckv1beta1.Status `json:",inline"` + + RouteStatusFields `json:",inline"` + + ConfigurationStatusFields `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/v1alpha1/service_validation.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_validation.go new file mode 100644 index 0000000000..d47ce57838 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_validation.go @@ -0,0 +1,182 @@ +/* +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" + "fmt" + + "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) (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 +func (ss *ServiceSpec) Validate(ctx context.Context) *apis.FieldError { + // We would do this semantic DeepEqual, but the spec is comprised + // entirely of a oneof, the validation for which produces a clearer + // error message. + // if equality.Semantic.DeepEqual(ss, &ServiceSpec{}) { + // return apis.ErrMissingField(currentField) + // } + + errs := apis.CheckDeprecated(ctx, ss) + + set := []string{} + + if ss.DeprecatedRunLatest != nil { + set = append(set, "runLatest") + errs = errs.Also(ss.DeprecatedRunLatest.Validate(ctx).ViaField("runLatest")) + } + if ss.DeprecatedRelease != nil { + set = append(set, "release") + errs = errs.Also(ss.DeprecatedRelease.Validate(ctx).ViaField("release")) + } + if ss.DeprecatedManual != nil { + set = append(set, "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", "pinned", "template")) + } + return errs +} + +// Validate validates the fields belonging to PinnedType +func (pt *PinnedType) Validate(ctx context.Context) *apis.FieldError { + var errs *apis.FieldError + if pt.RevisionName == "" { + errs = apis.ErrMissingField("revisionName") + } + return errs.Also(pt.Configuration.Validate(ctx).ViaField("configuration")) +} + +// Validate validates the fields belonging to RunLatestType +func (rlt *RunLatestType) Validate(ctx context.Context) *apis.FieldError { + return rlt.Configuration.Validate(ctx).ViaField("configuration") +} + +// 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(numRevisions, 1, 2, "revisions")) + } + for i, r := range rt.Revisions { + // Skip over the last revision special keyword. + if r == ReleaseLatestRevisionKeyword { + continue + } + if msgs := validation.IsDNS1035Label(r); len(msgs) > 0 { + errs = errs.Also(apis.ErrInvalidArrayValue( + fmt.Sprintf("not a DNS 1035 label: %v", msgs), + "revisions", i)) + } + } + + if numRevisions < 2 && rt.RolloutPercent != 0 { + errs = errs.Also(apis.ErrInvalidValue(rt.RolloutPercent, "rolloutPercent")) + } + + if rt.RolloutPercent < 0 || rt.RolloutPercent > 99 { + 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 new file mode 100644 index 0000000000..915e638958 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,635 @@ +// +build !ignore_autogenerated + +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" + 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 + 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 Configuration. +func (in *Configuration) DeepCopy() *Configuration { + if in == nil { + return nil + } + out := new(Configuration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Configuration) 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 *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([]Configuration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// 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(ConfigurationList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ConfigurationList) 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 *ConfigurationSpec) DeepCopyInto(out *ConfigurationSpec) { + *out = *in + 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) + } + return +} + +// 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(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 *ConfigurationStatus) DeepCopyInto(out *ConfigurationStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + 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 ConfigurationStatusFields. +func (in *ConfigurationStatusFields) DeepCopy() *ConfigurationStatusFields { + if in == nil { + return nil + } + 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 *ManualType) DeepCopyInto(out *ManualType) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManualType. +func (in *ManualType) DeepCopy() *ManualType { + if in == nil { + return nil + } + out := new(ManualType) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PinnedType) DeepCopyInto(out *PinnedType) { + *out = *in + in.Configuration.DeepCopyInto(&out.Configuration) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PinnedType. +func (in *PinnedType) DeepCopy() *PinnedType { + if in == nil { + return nil + } + out := new(PinnedType) + 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 + if in.Revisions != nil { + in, out := &in.Revisions, &out.Revisions + *out = make([]string, len(*in)) + copy(*out, *in) + } + in.Configuration.DeepCopyInto(&out.Configuration) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReleaseType. +func (in *ReleaseType) DeepCopy() *ReleaseType { + if in == nil { + return nil + } + out := new(ReleaseType) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +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 Revision. +func (in *Revision) DeepCopy() *Revision { + if in == nil { + return nil + } + out := new(Revision) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Revision) 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 *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([]Revision, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// 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(RevisionList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *RevisionList) 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 *RevisionSpec) DeepCopyInto(out *RevisionSpec) { + *out = *in + in.RevisionSpec.DeepCopyInto(&out.RevisionSpec) + if in.DeprecatedBuildRef != nil { + in, out := &in.DeprecatedBuildRef, &out.DeprecatedBuildRef + *out = new(v1.ObjectReference) + **out = **in + } + if in.DeprecatedContainer != nil { + in, out := &in.DeprecatedContainer, &out.DeprecatedContainer + *out = new(v1.Container) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionSpec. +func (in *RevisionSpec) DeepCopy() *RevisionSpec { + if in == nil { + return nil + } + 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 RevisionTemplateSpec. +func (in *RevisionTemplateSpec) DeepCopy() *RevisionTemplateSpec { + if in == nil { + return nil + } + 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 *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 Route. +func (in *Route) DeepCopy() *Route { + if in == nil { + return nil + } + out := new(Route) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Route) 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 *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([]Route, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// 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(RouteList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *RouteList) 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 *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 RouteSpec. +func (in *RouteSpec) DeepCopy() *RouteSpec { + if in == nil { + return nil + } + 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 *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 RouteStatus. +func (in *RouteStatus) DeepCopy() *RouteStatus { + if in == nil { + return nil + } + 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 *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(duckv1alpha1.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 RouteStatusFields. +func (in *RouteStatusFields) DeepCopy() *RouteStatusFields { + if in == nil { + return nil + } + 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 *RunLatestType) DeepCopyInto(out *RunLatestType) { + *out = *in + in.Configuration.DeepCopyInto(&out.Configuration) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RunLatestType. +func (in *RunLatestType) DeepCopy() *RunLatestType { + if in == nil { + return nil + } + out := new(RunLatestType) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +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 Service. +func (in *Service) DeepCopy() *Service { + if in == nil { + return nil + } + 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 *ServiceList) DeepCopyInto(out *ServiceList) { + *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 ServiceList. +func (in *ServiceList) DeepCopy() *ServiceList { + if in == nil { + return nil + } + 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 *ServiceSpec) DeepCopyInto(out *ServiceSpec) { + *out = *in + 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 + *out = new(PinnedType) + (*in).DeepCopyInto(*out) + } + if in.DeprecatedManual != nil { + in, out := &in.DeprecatedManual, &out.DeprecatedManual + *out = new(ManualType) + **out = **in + } + 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 +} + +// 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) + in.RouteStatusFields.DeepCopyInto(&out.RouteStatusFields) + out.ConfigurationStatusFields = in.ConfigurationStatusFields + return +} + +// 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(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 *TrafficTarget) DeepCopyInto(out *TrafficTarget) { + *out = *in + in.TrafficTarget.DeepCopyInto(&out.TrafficTarget) + return +} + +// 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(TrafficTarget) + in.DeepCopyInto(out) + return out +} 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/serving/pkg/apis/serving/v1beta1/zz_generated.deepcopy.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..c07bd927fb --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,516 @@ +// +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 v1beta1 + +import ( + 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 *Configuration) DeepCopyInto(out *Configuration) { + *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 Configuration. +func (in *Configuration) DeepCopy() *Configuration { + if in == nil { + return nil + } + out := new(Configuration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Configuration) 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 *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([]Configuration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// 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(ConfigurationList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ConfigurationList) 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 *ConfigurationSpec) DeepCopyInto(out *ConfigurationSpec) { + *out = *in + in.Template.DeepCopyInto(&out.Template) + return +} + +// 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(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 *ConfigurationStatus) DeepCopyInto(out *ConfigurationStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + 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 ConfigurationStatusFields. +func (in *ConfigurationStatusFields) DeepCopy() *ConfigurationStatusFields { + if in == nil { + return nil + } + 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 *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 Revision. +func (in *Revision) DeepCopy() *Revision { + if in == nil { + return nil + } + out := new(Revision) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Revision) 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 *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([]Revision, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// 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(RevisionList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *RevisionList) 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 *RevisionSpec) DeepCopyInto(out *RevisionSpec) { + *out = *in + in.PodSpec.DeepCopyInto(&out.PodSpec) + if in.TimeoutSeconds != nil { + in, out := &in.TimeoutSeconds, &out.TimeoutSeconds + *out = new(int64) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionSpec. +func (in *RevisionSpec) DeepCopy() *RevisionSpec { + if in == nil { + return nil + } + 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 RevisionTemplateSpec. +func (in *RevisionTemplateSpec) DeepCopy() *RevisionTemplateSpec { + if in == nil { + return nil + } + 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 *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 Route. +func (in *Route) DeepCopy() *Route { + if in == nil { + return nil + } + out := new(Route) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Route) 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 *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([]Route, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// 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(RouteList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *RouteList) 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 *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 RouteSpec. +func (in *RouteSpec) DeepCopy() *RouteSpec { + if in == nil { + return nil + } + 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 *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 RouteStatus. +func (in *RouteStatus) DeepCopy() *RouteStatus { + if in == nil { + return nil + } + 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 *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 RouteStatusFields. +func (in *RouteStatusFields) DeepCopy() *RouteStatusFields { + if in == nil { + return nil + } + 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 *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 Service. +func (in *Service) DeepCopy() *Service { + if in == nil { + return nil + } + 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 *ServiceList) DeepCopyInto(out *ServiceList) { + *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 ServiceList. +func (in *ServiceList) DeepCopy() *ServiceList { + if in == nil { + return nil + } + 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 *ServiceSpec) DeepCopyInto(out *ServiceSpec) { + *out = *in + 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 ServiceStatus. +func (in *ServiceStatus) DeepCopy() *ServiceStatus { + if in == nil { + return nil + } + 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 *TrafficTarget) DeepCopyInto(out *TrafficTarget) { + *out = *in + 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 TrafficTarget. +func (in *TrafficTarget) DeepCopy() *TrafficTarget { + if in == nil { + return nil + } + out := new(TrafficTarget) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/github.com/knative/serving/pkg/autoscaler/testdata/config-autoscaler.yaml b/vendor/github.com/knative/serving/pkg/autoscaler/testdata/config-autoscaler.yaml new file mode 120000 index 0000000000..855fbd8994 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/autoscaler/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/client/clientset/versioned/clientset.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/clientset.go new file mode 100644 index 0000000000..6707ffd1b9 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/clientset.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. +*/ + +// 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" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + AutoscalingV1alpha1() autoscalingv1alpha1.AutoscalingV1alpha1Interface + // Deprecated: please explicitly pick a version if possible. + Autoscaling() autoscalingv1alpha1.AutoscalingV1alpha1Interface + NetworkingV1alpha1() networkingv1alpha1.NetworkingV1alpha1Interface + // 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() servingv1beta1.ServingV1beta1Interface +} + +// Clientset contains the clients for groups. Each group has exactly one +// version included in a Clientset. +type Clientset struct { + *discovery.DiscoveryClient + autoscalingV1alpha1 *autoscalingv1alpha1.AutoscalingV1alpha1Client + networkingV1alpha1 *networkingv1alpha1.NetworkingV1alpha1Client + servingV1alpha1 *servingv1alpha1.ServingV1alpha1Client + servingV1beta1 *servingv1beta1.ServingV1beta1Client +} + +// AutoscalingV1alpha1 retrieves the AutoscalingV1alpha1Client +func (c *Clientset) AutoscalingV1alpha1() autoscalingv1alpha1.AutoscalingV1alpha1Interface { + return c.autoscalingV1alpha1 +} + +// Deprecated: Autoscaling retrieves the default version of AutoscalingClient. +// Please explicitly pick a version. +func (c *Clientset) Autoscaling() autoscalingv1alpha1.AutoscalingV1alpha1Interface { + return c.autoscalingV1alpha1 +} + +// NetworkingV1alpha1 retrieves the NetworkingV1alpha1Client +func (c *Clientset) NetworkingV1alpha1() networkingv1alpha1.NetworkingV1alpha1Interface { + return c.networkingV1alpha1 +} + +// Deprecated: Networking retrieves the default version of NetworkingClient. +// Please explicitly pick a version. +func (c *Clientset) Networking() networkingv1alpha1.NetworkingV1alpha1Interface { + return c.networkingV1alpha1 +} + +// ServingV1alpha1 retrieves the ServingV1alpha1Client +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() servingv1beta1.ServingV1beta1Interface { + return c.servingV1beta1 +} + +// Discovery retrieves the DiscoveryClient +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + if c == nil { + return nil + } + return c.DiscoveryClient +} + +// NewForConfig creates a new Clientset for the given config. +func NewForConfig(c *rest.Config) (*Clientset, error) { + configShallowCopy := *c + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) + } + var cs Clientset + var err error + cs.autoscalingV1alpha1, err = autoscalingv1alpha1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + cs.networkingV1alpha1, err = networkingv1alpha1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + cs.servingV1alpha1, err = servingv1alpha1.NewForConfig(&configShallowCopy) + 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 { + return nil, err + } + return &cs, nil +} + +// NewForConfigOrDie creates a new Clientset for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *Clientset { + var cs 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 +} + +// New creates a new Clientset for the given RESTClient. +func New(c rest.Interface) *Clientset { + var cs 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 new file mode 100644 index 0000000000..1122e50bfc --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/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 clientset. +package versioned diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/fake/clientset_generated.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/fake/clientset_generated.go new file mode 100644 index 0000000000..a33b0a708d --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/fake/clientset_generated.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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + clientset "github.com/knative/serving/pkg/client/clientset/versioned" + autoscalingv1alpha1 "github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1" + fakeautoscalingv1alpha1 "github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake" + networkingv1alpha1 "github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1" + fakenetworkingv1alpha1 "github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake" + servingv1alpha1 "github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1" + fakeservingv1alpha1 "github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake" + servingv1beta1 "github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1" + fakeservingv1beta1 "github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/discovery" + fakediscovery "k8s.io/client-go/discovery/fake" + "k8s.io/client-go/testing" +) + +// NewSimpleClientset returns a clientset that will respond with the provided objects. +// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, +// without applying any validations and/or defaults. It shouldn't be considered a replacement +// for a real clientset and is mostly useful in simple unit tests. +func NewSimpleClientset(objects ...runtime.Object) *Clientset { + o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) + for _, obj := range objects { + if err := o.Add(obj); err != nil { + panic(err) + } + } + + cs := &Clientset{} + cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} + cs.AddReactor("*", "*", testing.ObjectReaction(o)) + cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { + gvr := action.GetResource() + ns := action.GetNamespace() + watch, err := o.Watch(gvr, ns) + if err != nil { + return false, nil, err + } + return true, watch, nil + }) + + return cs +} + +// Clientset implements clientset.Interface. Meant to be embedded into a +// struct to get a default implementation. This makes faking out just the method +// you want to test easier. +type Clientset struct { + testing.Fake + discovery *fakediscovery.FakeDiscovery +} + +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return c.discovery +} + +var _ clientset.Interface = &Clientset{} + +// AutoscalingV1alpha1 retrieves the AutoscalingV1alpha1Client +func (c *Clientset) AutoscalingV1alpha1() autoscalingv1alpha1.AutoscalingV1alpha1Interface { + return &fakeautoscalingv1alpha1.FakeAutoscalingV1alpha1{Fake: &c.Fake} +} + +// Autoscaling retrieves the AutoscalingV1alpha1Client +func (c *Clientset) Autoscaling() autoscalingv1alpha1.AutoscalingV1alpha1Interface { + return &fakeautoscalingv1alpha1.FakeAutoscalingV1alpha1{Fake: &c.Fake} +} + +// NetworkingV1alpha1 retrieves the NetworkingV1alpha1Client +func (c *Clientset) NetworkingV1alpha1() networkingv1alpha1.NetworkingV1alpha1Interface { + return &fakenetworkingv1alpha1.FakeNetworkingV1alpha1{Fake: &c.Fake} +} + +// Networking retrieves the NetworkingV1alpha1Client +func (c *Clientset) Networking() networkingv1alpha1.NetworkingV1alpha1Interface { + return &fakenetworkingv1alpha1.FakeNetworkingV1alpha1{Fake: &c.Fake} +} + +// ServingV1alpha1 retrieves the ServingV1alpha1Client +func (c *Clientset) ServingV1alpha1() servingv1alpha1.ServingV1alpha1Interface { + return &fakeservingv1alpha1.FakeServingV1alpha1{Fake: &c.Fake} +} + +// ServingV1beta1 retrieves the ServingV1beta1Client +func (c *Clientset) ServingV1beta1() servingv1beta1.ServingV1beta1Interface { + return &fakeservingv1beta1.FakeServingV1beta1{Fake: &c.Fake} +} + +// Serving retrieves the ServingV1beta1Client +func (c *Clientset) Serving() servingv1beta1.ServingV1beta1Interface { + return &fakeservingv1beta1.FakeServingV1beta1{Fake: &c.Fake} +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/fake/doc.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/fake/doc.go new file mode 100644 index 0000000000..87f3c3e0b0 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/fake/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 fake clientset. +package fake diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/fake/register.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/fake/register.go new file mode 100644 index 0000000000..f0d4c3e0e4 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/fake/register.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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +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" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) +var parameterCodec = runtime.NewParameterCodec(scheme) +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 +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(scheme)) +} 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 new file mode 100644 index 0000000000..7d76538485 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/scheme/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 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 new file mode 100644 index 0000000000..b7aed539d6 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/scheme/register.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. +*/ + +// 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" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) +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 +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + 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 new file mode 100644 index 0000000000..8d0ce8489e --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/autoscaling_client.go @@ -0,0 +1,90 @@ +/* +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/autoscaling/v1alpha1" + "github.com/knative/serving/pkg/client/clientset/versioned/scheme" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" +) + +type AutoscalingV1alpha1Interface interface { + RESTClient() rest.Interface + PodAutoscalersGetter +} + +// AutoscalingV1alpha1Client is used to interact with features provided by the autoscaling.internal.knative.dev group. +type AutoscalingV1alpha1Client struct { + restClient rest.Interface +} + +func (c *AutoscalingV1alpha1Client) PodAutoscalers(namespace string) PodAutoscalerInterface { + return newPodAutoscalers(c, namespace) +} + +// NewForConfig creates a new AutoscalingV1alpha1Client for the given config. +func NewForConfig(c *rest.Config) (*AutoscalingV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &AutoscalingV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new AutoscalingV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *AutoscalingV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new AutoscalingV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *AutoscalingV1alpha1Client { + return &AutoscalingV1alpha1Client{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 *AutoscalingV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} 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 new file mode 100644 index 0000000000..a1c6bb9fe8 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/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/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/doc.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/doc.go new file mode 100644 index 0000000000..a00e5d7b21 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/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. + +// Package fake has the automatically generated clients. +package fake diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_autoscaling_client.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_autoscaling_client.go new file mode 100644 index 0000000000..869f008895 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_autoscaling_client.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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeAutoscalingV1alpha1 struct { + *testing.Fake +} + +func (c *FakeAutoscalingV1alpha1) PodAutoscalers(namespace string) v1alpha1.PodAutoscalerInterface { + return &FakePodAutoscalers{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeAutoscalingV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_podautoscaler.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_podautoscaler.go new file mode 100644 index 0000000000..c974a5e28d --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_podautoscaler.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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/autoscaling/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakePodAutoscalers implements PodAutoscalerInterface +type FakePodAutoscalers struct { + Fake *FakeAutoscalingV1alpha1 + ns string +} + +var podautoscalersResource = schema.GroupVersionResource{Group: "autoscaling.internal.knative.dev", Version: "v1alpha1", Resource: "podautoscalers"} + +var podautoscalersKind = schema.GroupVersionKind{Group: "autoscaling.internal.knative.dev", Version: "v1alpha1", Kind: "PodAutoscaler"} + +// Get takes name of the podAutoscaler, and returns the corresponding podAutoscaler object, and an error if there is any. +func (c *FakePodAutoscalers) Get(name string, options v1.GetOptions) (result *v1alpha1.PodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(podautoscalersResource, c.ns, name), &v1alpha1.PodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodAutoscaler), err +} + +// List takes label and field selectors, and returns the list of PodAutoscalers that match those selectors. +func (c *FakePodAutoscalers) List(opts v1.ListOptions) (result *v1alpha1.PodAutoscalerList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(podautoscalersResource, podautoscalersKind, c.ns, opts), &v1alpha1.PodAutoscalerList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.PodAutoscalerList{ListMeta: obj.(*v1alpha1.PodAutoscalerList).ListMeta} + for _, item := range obj.(*v1alpha1.PodAutoscalerList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested podAutoscalers. +func (c *FakePodAutoscalers) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(podautoscalersResource, c.ns, opts)) + +} + +// Create takes the representation of a podAutoscaler and creates it. Returns the server's representation of the podAutoscaler, and an error, if there is any. +func (c *FakePodAutoscalers) Create(podAutoscaler *v1alpha1.PodAutoscaler) (result *v1alpha1.PodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(podautoscalersResource, c.ns, podAutoscaler), &v1alpha1.PodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodAutoscaler), err +} + +// Update takes the representation of a podAutoscaler and updates it. Returns the server's representation of the podAutoscaler, and an error, if there is any. +func (c *FakePodAutoscalers) Update(podAutoscaler *v1alpha1.PodAutoscaler) (result *v1alpha1.PodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(podautoscalersResource, c.ns, podAutoscaler), &v1alpha1.PodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodAutoscaler), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakePodAutoscalers) UpdateStatus(podAutoscaler *v1alpha1.PodAutoscaler) (*v1alpha1.PodAutoscaler, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(podautoscalersResource, "status", c.ns, podAutoscaler), &v1alpha1.PodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodAutoscaler), err +} + +// Delete takes name of the podAutoscaler and deletes it. Returns an error if one occurs. +func (c *FakePodAutoscalers) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(podautoscalersResource, c.ns, name), &v1alpha1.PodAutoscaler{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakePodAutoscalers) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(podautoscalersResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.PodAutoscalerList{}) + return err +} + +// Patch applies the patch and returns the patched podAutoscaler. +func (c *FakePodAutoscalers) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(podautoscalersResource, c.ns, name, data, subresources...), &v1alpha1.PodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodAutoscaler), err +} 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 new file mode 100644 index 0000000000..66c99940e1 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +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 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 new file mode 100644 index 0000000000..81411091f2 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/podautoscaler.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/autoscaling/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" +) + +// PodAutoscalersGetter has a method to return a PodAutoscalerInterface. +// A group's client should implement this interface. +type PodAutoscalersGetter interface { + PodAutoscalers(namespace string) PodAutoscalerInterface +} + +// PodAutoscalerInterface has methods to work with PodAutoscaler resources. +type PodAutoscalerInterface interface { + Create(*v1alpha1.PodAutoscaler) (*v1alpha1.PodAutoscaler, error) + Update(*v1alpha1.PodAutoscaler) (*v1alpha1.PodAutoscaler, error) + UpdateStatus(*v1alpha1.PodAutoscaler) (*v1alpha1.PodAutoscaler, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.PodAutoscaler, error) + List(opts v1.ListOptions) (*v1alpha1.PodAutoscalerList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PodAutoscaler, err error) + PodAutoscalerExpansion +} + +// podAutoscalers implements PodAutoscalerInterface +type podAutoscalers struct { + client rest.Interface + ns string +} + +// newPodAutoscalers returns a PodAutoscalers +func newPodAutoscalers(c *AutoscalingV1alpha1Client, namespace string) *podAutoscalers { + return &podAutoscalers{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the podAutoscaler, and returns the corresponding podAutoscaler object, and an error if there is any. +func (c *podAutoscalers) Get(name string, options v1.GetOptions) (result *v1alpha1.PodAutoscaler, err error) { + result = &v1alpha1.PodAutoscaler{} + err = c.client.Get(). + Namespace(c.ns). + Resource("podautoscalers"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of PodAutoscalers that match those selectors. +func (c *podAutoscalers) List(opts v1.ListOptions) (result *v1alpha1.PodAutoscalerList, err error) { + result = &v1alpha1.PodAutoscalerList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("podautoscalers"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested podAutoscalers. +func (c *podAutoscalers) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("podautoscalers"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a podAutoscaler and creates it. Returns the server's representation of the podAutoscaler, and an error, if there is any. +func (c *podAutoscalers) Create(podAutoscaler *v1alpha1.PodAutoscaler) (result *v1alpha1.PodAutoscaler, err error) { + result = &v1alpha1.PodAutoscaler{} + err = c.client.Post(). + Namespace(c.ns). + Resource("podautoscalers"). + Body(podAutoscaler). + Do(). + Into(result) + return +} + +// Update takes the representation of a podAutoscaler and updates it. Returns the server's representation of the podAutoscaler, and an error, if there is any. +func (c *podAutoscalers) Update(podAutoscaler *v1alpha1.PodAutoscaler) (result *v1alpha1.PodAutoscaler, err error) { + result = &v1alpha1.PodAutoscaler{} + err = c.client.Put(). + Namespace(c.ns). + Resource("podautoscalers"). + Name(podAutoscaler.Name). + Body(podAutoscaler). + 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 *podAutoscalers) UpdateStatus(podAutoscaler *v1alpha1.PodAutoscaler) (result *v1alpha1.PodAutoscaler, err error) { + result = &v1alpha1.PodAutoscaler{} + err = c.client.Put(). + Namespace(c.ns). + Resource("podautoscalers"). + Name(podAutoscaler.Name). + SubResource("status"). + Body(podAutoscaler). + Do(). + Into(result) + return +} + +// Delete takes name of the podAutoscaler and deletes it. Returns an error if one occurs. +func (c *podAutoscalers) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("podautoscalers"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *podAutoscalers) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("podautoscalers"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched podAutoscaler. +func (c *podAutoscalers) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PodAutoscaler, err error) { + result = &v1alpha1.PodAutoscaler{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("podautoscalers"). + 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/certificate.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/certificate.go new file mode 100644 index 0000000000..ee8cc2719b --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/certificate.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" +) + +// CertificatesGetter has a method to return a CertificateInterface. +// A group's client should implement this interface. +type CertificatesGetter interface { + Certificates(namespace string) CertificateInterface +} + +// CertificateInterface has methods to work with Certificate resources. +type CertificateInterface interface { + Create(*v1alpha1.Certificate) (*v1alpha1.Certificate, error) + Update(*v1alpha1.Certificate) (*v1alpha1.Certificate, error) + UpdateStatus(*v1alpha1.Certificate) (*v1alpha1.Certificate, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.Certificate, error) + List(opts v1.ListOptions) (*v1alpha1.CertificateList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Certificate, err error) + CertificateExpansion +} + +// certificates implements CertificateInterface +type certificates struct { + client rest.Interface + ns string +} + +// newCertificates returns a Certificates +func newCertificates(c *NetworkingV1alpha1Client, namespace string) *certificates { + return &certificates{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the certificate, and returns the corresponding certificate object, and an error if there is any. +func (c *certificates) Get(name string, options v1.GetOptions) (result *v1alpha1.Certificate, err error) { + result = &v1alpha1.Certificate{} + err = c.client.Get(). + Namespace(c.ns). + Resource("certificates"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Certificates that match those selectors. +func (c *certificates) List(opts v1.ListOptions) (result *v1alpha1.CertificateList, err error) { + result = &v1alpha1.CertificateList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("certificates"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested certificates. +func (c *certificates) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("certificates"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a certificate and creates it. Returns the server's representation of the certificate, and an error, if there is any. +func (c *certificates) Create(certificate *v1alpha1.Certificate) (result *v1alpha1.Certificate, err error) { + result = &v1alpha1.Certificate{} + err = c.client.Post(). + Namespace(c.ns). + Resource("certificates"). + Body(certificate). + Do(). + Into(result) + return +} + +// Update takes the representation of a certificate and updates it. Returns the server's representation of the certificate, and an error, if there is any. +func (c *certificates) Update(certificate *v1alpha1.Certificate) (result *v1alpha1.Certificate, err error) { + result = &v1alpha1.Certificate{} + err = c.client.Put(). + Namespace(c.ns). + Resource("certificates"). + Name(certificate.Name). + Body(certificate). + 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 *certificates) UpdateStatus(certificate *v1alpha1.Certificate) (result *v1alpha1.Certificate, err error) { + result = &v1alpha1.Certificate{} + err = c.client.Put(). + Namespace(c.ns). + Resource("certificates"). + Name(certificate.Name). + SubResource("status"). + Body(certificate). + Do(). + Into(result) + return +} + +// Delete takes name of the certificate and deletes it. Returns an error if one occurs. +func (c *certificates) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("certificates"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *certificates) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("certificates"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched certificate. +func (c *certificates) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Certificate, err error) { + result = &v1alpha1.Certificate{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("certificates"). + 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/clusteringress.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/clusteringress.go new file mode 100644 index 0000000000..55777ab244 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/clusteringress.go @@ -0,0 +1,163 @@ +/* +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" +) + +// ClusterIngressesGetter has a method to return a ClusterIngressInterface. +// A group's client should implement this interface. +type ClusterIngressesGetter interface { + ClusterIngresses() ClusterIngressInterface +} + +// ClusterIngressInterface has methods to work with ClusterIngress resources. +type ClusterIngressInterface interface { + Create(*v1alpha1.ClusterIngress) (*v1alpha1.ClusterIngress, error) + Update(*v1alpha1.ClusterIngress) (*v1alpha1.ClusterIngress, error) + UpdateStatus(*v1alpha1.ClusterIngress) (*v1alpha1.ClusterIngress, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.ClusterIngress, error) + List(opts v1.ListOptions) (*v1alpha1.ClusterIngressList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ClusterIngress, err error) + ClusterIngressExpansion +} + +// clusterIngresses implements ClusterIngressInterface +type clusterIngresses struct { + client rest.Interface +} + +// newClusterIngresses returns a ClusterIngresses +func newClusterIngresses(c *NetworkingV1alpha1Client) *clusterIngresses { + return &clusterIngresses{ + client: c.RESTClient(), + } +} + +// Get takes name of the clusterIngress, and returns the corresponding clusterIngress object, and an error if there is any. +func (c *clusterIngresses) Get(name string, options v1.GetOptions) (result *v1alpha1.ClusterIngress, err error) { + result = &v1alpha1.ClusterIngress{} + err = c.client.Get(). + Resource("clusteringresses"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ClusterIngresses that match those selectors. +func (c *clusterIngresses) List(opts v1.ListOptions) (result *v1alpha1.ClusterIngressList, err error) { + result = &v1alpha1.ClusterIngressList{} + err = c.client.Get(). + Resource("clusteringresses"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested clusterIngresses. +func (c *clusterIngresses) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Resource("clusteringresses"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a clusterIngress and creates it. Returns the server's representation of the clusterIngress, and an error, if there is any. +func (c *clusterIngresses) Create(clusterIngress *v1alpha1.ClusterIngress) (result *v1alpha1.ClusterIngress, err error) { + result = &v1alpha1.ClusterIngress{} + err = c.client.Post(). + Resource("clusteringresses"). + Body(clusterIngress). + Do(). + Into(result) + return +} + +// Update takes the representation of a clusterIngress and updates it. Returns the server's representation of the clusterIngress, and an error, if there is any. +func (c *clusterIngresses) Update(clusterIngress *v1alpha1.ClusterIngress) (result *v1alpha1.ClusterIngress, err error) { + result = &v1alpha1.ClusterIngress{} + err = c.client.Put(). + Resource("clusteringresses"). + Name(clusterIngress.Name). + Body(clusterIngress). + 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 *clusterIngresses) UpdateStatus(clusterIngress *v1alpha1.ClusterIngress) (result *v1alpha1.ClusterIngress, err error) { + result = &v1alpha1.ClusterIngress{} + err = c.client.Put(). + Resource("clusteringresses"). + Name(clusterIngress.Name). + SubResource("status"). + Body(clusterIngress). + Do(). + Into(result) + return +} + +// Delete takes name of the clusterIngress and deletes it. Returns an error if one occurs. +func (c *clusterIngresses) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Resource("clusteringresses"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *clusterIngresses) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Resource("clusteringresses"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched clusterIngress. +func (c *clusterIngresses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ClusterIngress, err error) { + result = &v1alpha1.ClusterIngress{} + err = c.client.Patch(pt). + Resource("clusteringresses"). + 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/doc.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/doc.go new file mode 100644 index 0000000000..a1c6bb9fe8 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/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/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/doc.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/doc.go new file mode 100644 index 0000000000..a00e5d7b21 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/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. + +// Package fake has the automatically generated clients. +package fake diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_certificate.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_certificate.go new file mode 100644 index 0000000000..e5122b7ebd --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_certificate.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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/networking/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeCertificates implements CertificateInterface +type FakeCertificates struct { + Fake *FakeNetworkingV1alpha1 + ns string +} + +var certificatesResource = schema.GroupVersionResource{Group: "networking.internal.knative.dev", Version: "v1alpha1", Resource: "certificates"} + +var certificatesKind = schema.GroupVersionKind{Group: "networking.internal.knative.dev", Version: "v1alpha1", Kind: "Certificate"} + +// Get takes name of the certificate, and returns the corresponding certificate object, and an error if there is any. +func (c *FakeCertificates) Get(name string, options v1.GetOptions) (result *v1alpha1.Certificate, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(certificatesResource, c.ns, name), &v1alpha1.Certificate{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Certificate), err +} + +// List takes label and field selectors, and returns the list of Certificates that match those selectors. +func (c *FakeCertificates) List(opts v1.ListOptions) (result *v1alpha1.CertificateList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(certificatesResource, certificatesKind, c.ns, opts), &v1alpha1.CertificateList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.CertificateList{ListMeta: obj.(*v1alpha1.CertificateList).ListMeta} + for _, item := range obj.(*v1alpha1.CertificateList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested certificates. +func (c *FakeCertificates) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(certificatesResource, c.ns, opts)) + +} + +// Create takes the representation of a certificate and creates it. Returns the server's representation of the certificate, and an error, if there is any. +func (c *FakeCertificates) Create(certificate *v1alpha1.Certificate) (result *v1alpha1.Certificate, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(certificatesResource, c.ns, certificate), &v1alpha1.Certificate{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Certificate), err +} + +// Update takes the representation of a certificate and updates it. Returns the server's representation of the certificate, and an error, if there is any. +func (c *FakeCertificates) Update(certificate *v1alpha1.Certificate) (result *v1alpha1.Certificate, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(certificatesResource, c.ns, certificate), &v1alpha1.Certificate{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Certificate), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeCertificates) UpdateStatus(certificate *v1alpha1.Certificate) (*v1alpha1.Certificate, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(certificatesResource, "status", c.ns, certificate), &v1alpha1.Certificate{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Certificate), err +} + +// Delete takes name of the certificate and deletes it. Returns an error if one occurs. +func (c *FakeCertificates) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(certificatesResource, c.ns, name), &v1alpha1.Certificate{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeCertificates) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(certificatesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.CertificateList{}) + return err +} + +// Patch applies the patch and returns the patched certificate. +func (c *FakeCertificates) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Certificate, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(certificatesResource, c.ns, name, data, subresources...), &v1alpha1.Certificate{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Certificate), err +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_clusteringress.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_clusteringress.go new file mode 100644 index 0000000000..19e153bcd3 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_clusteringress.go @@ -0,0 +1,131 @@ +/* +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 fake + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/networking/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeClusterIngresses implements ClusterIngressInterface +type FakeClusterIngresses struct { + Fake *FakeNetworkingV1alpha1 +} + +var clusteringressesResource = schema.GroupVersionResource{Group: "networking.internal.knative.dev", Version: "v1alpha1", Resource: "clusteringresses"} + +var clusteringressesKind = schema.GroupVersionKind{Group: "networking.internal.knative.dev", Version: "v1alpha1", Kind: "ClusterIngress"} + +// Get takes name of the clusterIngress, and returns the corresponding clusterIngress object, and an error if there is any. +func (c *FakeClusterIngresses) Get(name string, options v1.GetOptions) (result *v1alpha1.ClusterIngress, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(clusteringressesResource, name), &v1alpha1.ClusterIngress{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterIngress), err +} + +// List takes label and field selectors, and returns the list of ClusterIngresses that match those selectors. +func (c *FakeClusterIngresses) List(opts v1.ListOptions) (result *v1alpha1.ClusterIngressList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(clusteringressesResource, clusteringressesKind, opts), &v1alpha1.ClusterIngressList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ClusterIngressList{ListMeta: obj.(*v1alpha1.ClusterIngressList).ListMeta} + for _, item := range obj.(*v1alpha1.ClusterIngressList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested clusterIngresses. +func (c *FakeClusterIngresses) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(clusteringressesResource, opts)) +} + +// Create takes the representation of a clusterIngress and creates it. Returns the server's representation of the clusterIngress, and an error, if there is any. +func (c *FakeClusterIngresses) Create(clusterIngress *v1alpha1.ClusterIngress) (result *v1alpha1.ClusterIngress, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(clusteringressesResource, clusterIngress), &v1alpha1.ClusterIngress{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterIngress), err +} + +// Update takes the representation of a clusterIngress and updates it. Returns the server's representation of the clusterIngress, and an error, if there is any. +func (c *FakeClusterIngresses) Update(clusterIngress *v1alpha1.ClusterIngress) (result *v1alpha1.ClusterIngress, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(clusteringressesResource, clusterIngress), &v1alpha1.ClusterIngress{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterIngress), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeClusterIngresses) UpdateStatus(clusterIngress *v1alpha1.ClusterIngress) (*v1alpha1.ClusterIngress, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(clusteringressesResource, "status", clusterIngress), &v1alpha1.ClusterIngress{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterIngress), err +} + +// Delete takes name of the clusterIngress and deletes it. Returns an error if one occurs. +func (c *FakeClusterIngresses) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteAction(clusteringressesResource, name), &v1alpha1.ClusterIngress{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeClusterIngresses) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(clusteringressesResource, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.ClusterIngressList{}) + return err +} + +// Patch applies the patch and returns the patched clusterIngress. +func (c *FakeClusterIngresses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ClusterIngress, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(clusteringressesResource, name, data, subresources...), &v1alpha1.ClusterIngress{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterIngress), err +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_ingress.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_ingress.go new file mode 100644 index 0000000000..a79a70f8a0 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_ingress.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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/networking/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeIngresses implements IngressInterface +type FakeIngresses struct { + Fake *FakeNetworkingV1alpha1 + ns string +} + +var ingressesResource = schema.GroupVersionResource{Group: "networking.internal.knative.dev", Version: "v1alpha1", Resource: "ingresses"} + +var ingressesKind = schema.GroupVersionKind{Group: "networking.internal.knative.dev", Version: "v1alpha1", Kind: "Ingress"} + +// Get takes name of the ingress, and returns the corresponding ingress object, and an error if there is any. +func (c *FakeIngresses) Get(name string, options v1.GetOptions) (result *v1alpha1.Ingress, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(ingressesResource, c.ns, name), &v1alpha1.Ingress{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Ingress), err +} + +// List takes label and field selectors, and returns the list of Ingresses that match those selectors. +func (c *FakeIngresses) List(opts v1.ListOptions) (result *v1alpha1.IngressList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(ingressesResource, ingressesKind, c.ns, opts), &v1alpha1.IngressList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.IngressList{ListMeta: obj.(*v1alpha1.IngressList).ListMeta} + for _, item := range obj.(*v1alpha1.IngressList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested ingresses. +func (c *FakeIngresses) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(ingressesResource, c.ns, opts)) + +} + +// 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 *FakeIngresses) Create(ingress *v1alpha1.Ingress) (result *v1alpha1.Ingress, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(ingressesResource, c.ns, ingress), &v1alpha1.Ingress{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Ingress), err +} + +// 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 *FakeIngresses) Update(ingress *v1alpha1.Ingress) (result *v1alpha1.Ingress, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(ingressesResource, c.ns, ingress), &v1alpha1.Ingress{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Ingress), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeIngresses) UpdateStatus(ingress *v1alpha1.Ingress) (*v1alpha1.Ingress, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(ingressesResource, "status", c.ns, ingress), &v1alpha1.Ingress{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Ingress), err +} + +// Delete takes name of the ingress and deletes it. Returns an error if one occurs. +func (c *FakeIngresses) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(ingressesResource, c.ns, name), &v1alpha1.Ingress{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeIngresses) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(ingressesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.IngressList{}) + return err +} + +// Patch applies the patch and returns the patched ingress. +func (c *FakeIngresses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Ingress, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(ingressesResource, c.ns, name, data, subresources...), &v1alpha1.Ingress{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Ingress), err +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_networking_client.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_networking_client.go new file mode 100644 index 0000000000..7438d4e936 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_networking_client.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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeNetworkingV1alpha1 struct { + *testing.Fake +} + +func (c *FakeNetworkingV1alpha1) Certificates(namespace string) v1alpha1.CertificateInterface { + return &FakeCertificates{c, namespace} +} + +func (c *FakeNetworkingV1alpha1) ClusterIngresses() v1alpha1.ClusterIngressInterface { + return &FakeClusterIngresses{c} +} + +func (c *FakeNetworkingV1alpha1) Ingresses(namespace string) v1alpha1.IngressInterface { + return &FakeIngresses{c, namespace} +} + +func (c *FakeNetworkingV1alpha1) ServerlessServices(namespace string) v1alpha1.ServerlessServiceInterface { + return &FakeServerlessServices{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeNetworkingV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_serverlessservice.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_serverlessservice.go new file mode 100644 index 0000000000..1011a9e270 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_serverlessservice.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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/networking/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeServerlessServices implements ServerlessServiceInterface +type FakeServerlessServices struct { + Fake *FakeNetworkingV1alpha1 + ns string +} + +var serverlessservicesResource = schema.GroupVersionResource{Group: "networking.internal.knative.dev", Version: "v1alpha1", Resource: "serverlessservices"} + +var serverlessservicesKind = schema.GroupVersionKind{Group: "networking.internal.knative.dev", Version: "v1alpha1", Kind: "ServerlessService"} + +// Get takes name of the serverlessService, and returns the corresponding serverlessService object, and an error if there is any. +func (c *FakeServerlessServices) Get(name string, options v1.GetOptions) (result *v1alpha1.ServerlessService, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(serverlessservicesResource, c.ns, name), &v1alpha1.ServerlessService{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ServerlessService), err +} + +// List takes label and field selectors, and returns the list of ServerlessServices that match those selectors. +func (c *FakeServerlessServices) List(opts v1.ListOptions) (result *v1alpha1.ServerlessServiceList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(serverlessservicesResource, serverlessservicesKind, c.ns, opts), &v1alpha1.ServerlessServiceList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ServerlessServiceList{ListMeta: obj.(*v1alpha1.ServerlessServiceList).ListMeta} + for _, item := range obj.(*v1alpha1.ServerlessServiceList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested serverlessServices. +func (c *FakeServerlessServices) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(serverlessservicesResource, c.ns, opts)) + +} + +// Create takes the representation of a serverlessService and creates it. Returns the server's representation of the serverlessService, and an error, if there is any. +func (c *FakeServerlessServices) Create(serverlessService *v1alpha1.ServerlessService) (result *v1alpha1.ServerlessService, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(serverlessservicesResource, c.ns, serverlessService), &v1alpha1.ServerlessService{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ServerlessService), err +} + +// Update takes the representation of a serverlessService and updates it. Returns the server's representation of the serverlessService, and an error, if there is any. +func (c *FakeServerlessServices) Update(serverlessService *v1alpha1.ServerlessService) (result *v1alpha1.ServerlessService, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(serverlessservicesResource, c.ns, serverlessService), &v1alpha1.ServerlessService{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ServerlessService), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeServerlessServices) UpdateStatus(serverlessService *v1alpha1.ServerlessService) (*v1alpha1.ServerlessService, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(serverlessservicesResource, "status", c.ns, serverlessService), &v1alpha1.ServerlessService{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ServerlessService), err +} + +// Delete takes name of the serverlessService and deletes it. Returns an error if one occurs. +func (c *FakeServerlessServices) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(serverlessservicesResource, c.ns, name), &v1alpha1.ServerlessService{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeServerlessServices) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(serverlessservicesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.ServerlessServiceList{}) + return err +} + +// Patch applies the patch and returns the patched serverlessService. +func (c *FakeServerlessServices) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ServerlessService, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(serverlessservicesResource, c.ns, name, data, subresources...), &v1alpha1.ServerlessService{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ServerlessService), err +} 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 new file mode 100644 index 0000000000..808a1cd98c --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/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 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 new file mode 100644 index 0000000000..31681c7caa --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/networking_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 v1alpha1 + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/networking/v1alpha1" + "github.com/knative/serving/pkg/client/clientset/versioned/scheme" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" +) + +type NetworkingV1alpha1Interface interface { + RESTClient() rest.Interface + CertificatesGetter + ClusterIngressesGetter + IngressesGetter + ServerlessServicesGetter +} + +// NetworkingV1alpha1Client is used to interact with features provided by the networking.internal.knative.dev group. +type NetworkingV1alpha1Client struct { + restClient rest.Interface +} + +func (c *NetworkingV1alpha1Client) Certificates(namespace string) CertificateInterface { + return newCertificates(c, namespace) +} + +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) +} + +// NewForConfig creates a new NetworkingV1alpha1Client for the given config. +func NewForConfig(c *rest.Config) (*NetworkingV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &NetworkingV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new NetworkingV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *NetworkingV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new NetworkingV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *NetworkingV1alpha1Client { + return &NetworkingV1alpha1Client{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 *NetworkingV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} 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 new file mode 100644 index 0000000000..c728b95a00 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/serverlessservice.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" +) + +// ServerlessServicesGetter has a method to return a ServerlessServiceInterface. +// A group's client should implement this interface. +type ServerlessServicesGetter interface { + ServerlessServices(namespace string) ServerlessServiceInterface +} + +// ServerlessServiceInterface has methods to work with ServerlessService resources. +type ServerlessServiceInterface interface { + Create(*v1alpha1.ServerlessService) (*v1alpha1.ServerlessService, error) + Update(*v1alpha1.ServerlessService) (*v1alpha1.ServerlessService, error) + UpdateStatus(*v1alpha1.ServerlessService) (*v1alpha1.ServerlessService, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.ServerlessService, error) + List(opts v1.ListOptions) (*v1alpha1.ServerlessServiceList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ServerlessService, err error) + ServerlessServiceExpansion +} + +// serverlessServices implements ServerlessServiceInterface +type serverlessServices struct { + client rest.Interface + ns string +} + +// newServerlessServices returns a ServerlessServices +func newServerlessServices(c *NetworkingV1alpha1Client, namespace string) *serverlessServices { + return &serverlessServices{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the serverlessService, and returns the corresponding serverlessService object, and an error if there is any. +func (c *serverlessServices) Get(name string, options v1.GetOptions) (result *v1alpha1.ServerlessService, err error) { + result = &v1alpha1.ServerlessService{} + err = c.client.Get(). + Namespace(c.ns). + Resource("serverlessservices"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ServerlessServices that match those selectors. +func (c *serverlessServices) List(opts v1.ListOptions) (result *v1alpha1.ServerlessServiceList, err error) { + result = &v1alpha1.ServerlessServiceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("serverlessservices"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested serverlessServices. +func (c *serverlessServices) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("serverlessservices"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a serverlessService and creates it. Returns the server's representation of the serverlessService, and an error, if there is any. +func (c *serverlessServices) Create(serverlessService *v1alpha1.ServerlessService) (result *v1alpha1.ServerlessService, err error) { + result = &v1alpha1.ServerlessService{} + err = c.client.Post(). + Namespace(c.ns). + Resource("serverlessservices"). + Body(serverlessService). + Do(). + Into(result) + return +} + +// Update takes the representation of a serverlessService and updates it. Returns the server's representation of the serverlessService, and an error, if there is any. +func (c *serverlessServices) Update(serverlessService *v1alpha1.ServerlessService) (result *v1alpha1.ServerlessService, err error) { + result = &v1alpha1.ServerlessService{} + err = c.client.Put(). + Namespace(c.ns). + Resource("serverlessservices"). + Name(serverlessService.Name). + Body(serverlessService). + 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 *serverlessServices) UpdateStatus(serverlessService *v1alpha1.ServerlessService) (result *v1alpha1.ServerlessService, err error) { + result = &v1alpha1.ServerlessService{} + err = c.client.Put(). + Namespace(c.ns). + Resource("serverlessservices"). + Name(serverlessService.Name). + SubResource("status"). + Body(serverlessService). + Do(). + Into(result) + return +} + +// Delete takes name of the serverlessService and deletes it. Returns an error if one occurs. +func (c *serverlessServices) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("serverlessservices"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *serverlessServices) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("serverlessservices"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched serverlessService. +func (c *serverlessServices) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ServerlessService, err error) { + result = &v1alpha1.ServerlessService{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("serverlessservices"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} 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 new file mode 100644 index 0000000000..17c02afdc8 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/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 v1alpha1 + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/serving/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" +) + +// 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(*v1alpha1.Configuration) (*v1alpha1.Configuration, error) + Update(*v1alpha1.Configuration) (*v1alpha1.Configuration, error) + UpdateStatus(*v1alpha1.Configuration) (*v1alpha1.Configuration, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.Configuration, error) + List(opts v1.ListOptions) (*v1alpha1.ConfigurationList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Configuration, err error) + ConfigurationExpansion +} + +// configurations implements ConfigurationInterface +type configurations struct { + client rest.Interface + ns string +} + +// newConfigurations returns a Configurations +func newConfigurations(c *ServingV1alpha1Client, 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 *v1alpha1.Configuration, err error) { + result = &v1alpha1.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 *v1alpha1.ConfigurationList, err error) { + result = &v1alpha1.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 *v1alpha1.Configuration) (result *v1alpha1.Configuration, err error) { + result = &v1alpha1.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 *v1alpha1.Configuration) (result *v1alpha1.Configuration, err error) { + result = &v1alpha1.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 *v1alpha1.Configuration) (result *v1alpha1.Configuration, err error) { + result = &v1alpha1.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 *v1alpha1.Configuration, err error) { + result = &v1alpha1.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/v1alpha1/doc.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/doc.go new file mode 100644 index 0000000000..a1c6bb9fe8 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/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/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/doc.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/doc.go new file mode 100644 index 0000000000..a00e5d7b21 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/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. + +// Package fake has the automatically generated clients. +package fake diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_configuration.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_configuration.go new file mode 100644 index 0000000000..2c51bec82b --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_configuration.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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeConfigurations implements ConfigurationInterface +type FakeConfigurations struct { + Fake *FakeServingV1alpha1 + ns string +} + +var configurationsResource = schema.GroupVersionResource{Group: "serving.knative.dev", Version: "v1alpha1", Resource: "configurations"} + +var configurationsKind = schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1alpha1", Kind: "Configuration"} + +// Get takes name of the configuration, and returns the corresponding configuration object, and an error if there is any. +func (c *FakeConfigurations) Get(name string, options v1.GetOptions) (result *v1alpha1.Configuration, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(configurationsResource, c.ns, name), &v1alpha1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Configuration), err +} + +// List takes label and field selectors, and returns the list of Configurations that match those selectors. +func (c *FakeConfigurations) List(opts v1.ListOptions) (result *v1alpha1.ConfigurationList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(configurationsResource, configurationsKind, c.ns, opts), &v1alpha1.ConfigurationList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ConfigurationList{ListMeta: obj.(*v1alpha1.ConfigurationList).ListMeta} + for _, item := range obj.(*v1alpha1.ConfigurationList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested configurations. +func (c *FakeConfigurations) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(configurationsResource, c.ns, opts)) + +} + +// 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 *FakeConfigurations) Create(configuration *v1alpha1.Configuration) (result *v1alpha1.Configuration, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(configurationsResource, c.ns, configuration), &v1alpha1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Configuration), err +} + +// 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 *FakeConfigurations) Update(configuration *v1alpha1.Configuration) (result *v1alpha1.Configuration, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(configurationsResource, c.ns, configuration), &v1alpha1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Configuration), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeConfigurations) UpdateStatus(configuration *v1alpha1.Configuration) (*v1alpha1.Configuration, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(configurationsResource, "status", c.ns, configuration), &v1alpha1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Configuration), err +} + +// Delete takes name of the configuration and deletes it. Returns an error if one occurs. +func (c *FakeConfigurations) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(configurationsResource, c.ns, name), &v1alpha1.Configuration{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeConfigurations) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(configurationsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.ConfigurationList{}) + return err +} + +// Patch applies the patch and returns the patched configuration. +func (c *FakeConfigurations) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Configuration, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(configurationsResource, c.ns, name, data, subresources...), &v1alpha1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Configuration), err +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_revision.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_revision.go new file mode 100644 index 0000000000..c74ee900ce --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_revision.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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeRevisions implements RevisionInterface +type FakeRevisions struct { + Fake *FakeServingV1alpha1 + ns string +} + +var revisionsResource = schema.GroupVersionResource{Group: "serving.knative.dev", Version: "v1alpha1", Resource: "revisions"} + +var revisionsKind = schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1alpha1", Kind: "Revision"} + +// Get takes name of the revision, and returns the corresponding revision object, and an error if there is any. +func (c *FakeRevisions) Get(name string, options v1.GetOptions) (result *v1alpha1.Revision, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(revisionsResource, c.ns, name), &v1alpha1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Revision), err +} + +// List takes label and field selectors, and returns the list of Revisions that match those selectors. +func (c *FakeRevisions) List(opts v1.ListOptions) (result *v1alpha1.RevisionList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(revisionsResource, revisionsKind, c.ns, opts), &v1alpha1.RevisionList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.RevisionList{ListMeta: obj.(*v1alpha1.RevisionList).ListMeta} + for _, item := range obj.(*v1alpha1.RevisionList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested revisions. +func (c *FakeRevisions) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(revisionsResource, c.ns, opts)) + +} + +// 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 *FakeRevisions) Create(revision *v1alpha1.Revision) (result *v1alpha1.Revision, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(revisionsResource, c.ns, revision), &v1alpha1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Revision), err +} + +// 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 *FakeRevisions) Update(revision *v1alpha1.Revision) (result *v1alpha1.Revision, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(revisionsResource, c.ns, revision), &v1alpha1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Revision), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeRevisions) UpdateStatus(revision *v1alpha1.Revision) (*v1alpha1.Revision, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(revisionsResource, "status", c.ns, revision), &v1alpha1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Revision), err +} + +// Delete takes name of the revision and deletes it. Returns an error if one occurs. +func (c *FakeRevisions) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(revisionsResource, c.ns, name), &v1alpha1.Revision{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeRevisions) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(revisionsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.RevisionList{}) + return err +} + +// Patch applies the patch and returns the patched revision. +func (c *FakeRevisions) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Revision, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(revisionsResource, c.ns, name, data, subresources...), &v1alpha1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Revision), err +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_route.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_route.go new file mode 100644 index 0000000000..dfd64ce30f --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_route.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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeRoutes implements RouteInterface +type FakeRoutes struct { + Fake *FakeServingV1alpha1 + ns string +} + +var routesResource = schema.GroupVersionResource{Group: "serving.knative.dev", Version: "v1alpha1", Resource: "routes"} + +var routesKind = schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1alpha1", Kind: "Route"} + +// Get takes name of the route, and returns the corresponding route object, and an error if there is any. +func (c *FakeRoutes) Get(name string, options v1.GetOptions) (result *v1alpha1.Route, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(routesResource, c.ns, name), &v1alpha1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Route), err +} + +// List takes label and field selectors, and returns the list of Routes that match those selectors. +func (c *FakeRoutes) List(opts v1.ListOptions) (result *v1alpha1.RouteList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(routesResource, routesKind, c.ns, opts), &v1alpha1.RouteList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.RouteList{ListMeta: obj.(*v1alpha1.RouteList).ListMeta} + for _, item := range obj.(*v1alpha1.RouteList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested routes. +func (c *FakeRoutes) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(routesResource, c.ns, opts)) + +} + +// 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 *FakeRoutes) Create(route *v1alpha1.Route) (result *v1alpha1.Route, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(routesResource, c.ns, route), &v1alpha1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Route), err +} + +// 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 *FakeRoutes) Update(route *v1alpha1.Route) (result *v1alpha1.Route, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(routesResource, c.ns, route), &v1alpha1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Route), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeRoutes) UpdateStatus(route *v1alpha1.Route) (*v1alpha1.Route, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(routesResource, "status", c.ns, route), &v1alpha1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Route), err +} + +// Delete takes name of the route and deletes it. Returns an error if one occurs. +func (c *FakeRoutes) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(routesResource, c.ns, name), &v1alpha1.Route{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeRoutes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(routesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.RouteList{}) + return err +} + +// Patch applies the patch and returns the patched route. +func (c *FakeRoutes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Route, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(routesResource, c.ns, name, data, subresources...), &v1alpha1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Route), err +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_service.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_service.go new file mode 100644 index 0000000000..d270541e3a --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_service.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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeServices implements ServiceInterface +type FakeServices struct { + Fake *FakeServingV1alpha1 + ns string +} + +var servicesResource = schema.GroupVersionResource{Group: "serving.knative.dev", Version: "v1alpha1", Resource: "services"} + +var servicesKind = schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1alpha1", Kind: "Service"} + +// Get takes name of the service, and returns the corresponding service object, and an error if there is any. +func (c *FakeServices) Get(name string, options v1.GetOptions) (result *v1alpha1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(servicesResource, c.ns, name), &v1alpha1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Service), err +} + +// List takes label and field selectors, and returns the list of Services that match those selectors. +func (c *FakeServices) List(opts v1.ListOptions) (result *v1alpha1.ServiceList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(servicesResource, servicesKind, c.ns, opts), &v1alpha1.ServiceList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ServiceList{ListMeta: obj.(*v1alpha1.ServiceList).ListMeta} + for _, item := range obj.(*v1alpha1.ServiceList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested services. +func (c *FakeServices) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(servicesResource, c.ns, opts)) + +} + +// 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 *FakeServices) Create(service *v1alpha1.Service) (result *v1alpha1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(servicesResource, c.ns, service), &v1alpha1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Service), err +} + +// 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 *FakeServices) Update(service *v1alpha1.Service) (result *v1alpha1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(servicesResource, c.ns, service), &v1alpha1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Service), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeServices) UpdateStatus(service *v1alpha1.Service) (*v1alpha1.Service, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(servicesResource, "status", c.ns, service), &v1alpha1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Service), err +} + +// Delete takes name of the service and deletes it. Returns an error if one occurs. +func (c *FakeServices) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(servicesResource, c.ns, name), &v1alpha1.Service{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeServices) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(servicesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.ServiceList{}) + return err +} + +// Patch applies the patch and returns the patched service. +func (c *FakeServices) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(servicesResource, c.ns, name, data, subresources...), &v1alpha1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Service), err +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_serving_client.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_serving_client.go new file mode 100644 index 0000000000..eff1c692ad --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_serving_client.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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeServingV1alpha1 struct { + *testing.Fake +} + +func (c *FakeServingV1alpha1) Configurations(namespace string) v1alpha1.ConfigurationInterface { + return &FakeConfigurations{c, namespace} +} + +func (c *FakeServingV1alpha1) Revisions(namespace string) v1alpha1.RevisionInterface { + return &FakeRevisions{c, namespace} +} + +func (c *FakeServingV1alpha1) Routes(namespace string) v1alpha1.RouteInterface { + return &FakeRoutes{c, namespace} +} + +func (c *FakeServingV1alpha1) Services(namespace string) v1alpha1.ServiceInterface { + return &FakeServices{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeServingV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} 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 new file mode 100644 index 0000000000..6ce17decf7 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/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 v1alpha1 + +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/v1alpha1/revision.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/revision.go new file mode 100644 index 0000000000..4299306610 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/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 v1alpha1 + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/serving/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" +) + +// 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(*v1alpha1.Revision) (*v1alpha1.Revision, error) + Update(*v1alpha1.Revision) (*v1alpha1.Revision, error) + UpdateStatus(*v1alpha1.Revision) (*v1alpha1.Revision, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.Revision, error) + List(opts v1.ListOptions) (*v1alpha1.RevisionList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Revision, err error) + RevisionExpansion +} + +// revisions implements RevisionInterface +type revisions struct { + client rest.Interface + ns string +} + +// newRevisions returns a Revisions +func newRevisions(c *ServingV1alpha1Client, 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 *v1alpha1.Revision, err error) { + result = &v1alpha1.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 *v1alpha1.RevisionList, err error) { + result = &v1alpha1.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 *v1alpha1.Revision) (result *v1alpha1.Revision, err error) { + result = &v1alpha1.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 *v1alpha1.Revision) (result *v1alpha1.Revision, err error) { + result = &v1alpha1.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 *v1alpha1.Revision) (result *v1alpha1.Revision, err error) { + result = &v1alpha1.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 *v1alpha1.Revision, err error) { + result = &v1alpha1.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/v1alpha1/route.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/route.go new file mode 100644 index 0000000000..320477113f --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/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 v1alpha1 + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/serving/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" +) + +// 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(*v1alpha1.Route) (*v1alpha1.Route, error) + Update(*v1alpha1.Route) (*v1alpha1.Route, error) + UpdateStatus(*v1alpha1.Route) (*v1alpha1.Route, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.Route, error) + List(opts v1.ListOptions) (*v1alpha1.RouteList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Route, err error) + RouteExpansion +} + +// routes implements RouteInterface +type routes struct { + client rest.Interface + ns string +} + +// newRoutes returns a Routes +func newRoutes(c *ServingV1alpha1Client, 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 *v1alpha1.Route, err error) { + result = &v1alpha1.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 *v1alpha1.RouteList, err error) { + result = &v1alpha1.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 *v1alpha1.Route) (result *v1alpha1.Route, err error) { + result = &v1alpha1.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 *v1alpha1.Route) (result *v1alpha1.Route, err error) { + result = &v1alpha1.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 *v1alpha1.Route) (result *v1alpha1.Route, err error) { + result = &v1alpha1.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 *v1alpha1.Route, err error) { + result = &v1alpha1.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/v1alpha1/service.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/service.go new file mode 100644 index 0000000000..1309f2fb37 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/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 v1alpha1 + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/serving/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" +) + +// 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(*v1alpha1.Service) (*v1alpha1.Service, error) + Update(*v1alpha1.Service) (*v1alpha1.Service, error) + UpdateStatus(*v1alpha1.Service) (*v1alpha1.Service, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.Service, error) + List(opts v1.ListOptions) (*v1alpha1.ServiceList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Service, err error) + ServiceExpansion +} + +// services implements ServiceInterface +type services struct { + client rest.Interface + ns string +} + +// newServices returns a Services +func newServices(c *ServingV1alpha1Client, 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 *v1alpha1.Service, err error) { + result = &v1alpha1.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 *v1alpha1.ServiceList, err error) { + result = &v1alpha1.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 *v1alpha1.Service) (result *v1alpha1.Service, err error) { + result = &v1alpha1.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 *v1alpha1.Service) (result *v1alpha1.Service, err error) { + result = &v1alpha1.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 *v1alpha1.Service) (result *v1alpha1.Service, err error) { + result = &v1alpha1.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 *v1alpha1.Service, err error) { + result = &v1alpha1.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/v1alpha1/serving_client.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/serving_client.go new file mode 100644 index 0000000000..0a75f4a864 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/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 v1alpha1 + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" + "github.com/knative/serving/pkg/client/clientset/versioned/scheme" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" +) + +type ServingV1alpha1Interface interface { + RESTClient() rest.Interface + ConfigurationsGetter + RevisionsGetter + RoutesGetter + ServicesGetter +} + +// ServingV1alpha1Client is used to interact with features provided by the serving.knative.dev group. +type ServingV1alpha1Client struct { + restClient rest.Interface +} + +func (c *ServingV1alpha1Client) Configurations(namespace string) ConfigurationInterface { + return newConfigurations(c, namespace) +} + +func (c *ServingV1alpha1Client) Revisions(namespace string) RevisionInterface { + return newRevisions(c, namespace) +} + +func (c *ServingV1alpha1Client) Routes(namespace string) RouteInterface { + return newRoutes(c, namespace) +} + +func (c *ServingV1alpha1Client) Services(namespace string) ServiceInterface { + return newServices(c, namespace) +} + +// NewForConfig creates a new ServingV1alpha1Client for the given config. +func NewForConfig(c *rest.Config) (*ServingV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &ServingV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new ServingV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *ServingV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new ServingV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *ServingV1alpha1Client { + return &ServingV1alpha1Client{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 *ServingV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} 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/fake/doc.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/doc.go new file mode 100644 index 0000000000..a00e5d7b21 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/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. + +// Package fake has the automatically generated clients. +package fake diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_configuration.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_configuration.go new file mode 100644 index 0000000000..f89c67e2eb --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_configuration.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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeConfigurations implements ConfigurationInterface +type FakeConfigurations struct { + Fake *FakeServingV1beta1 + ns string +} + +var configurationsResource = schema.GroupVersionResource{Group: "serving.knative.dev", Version: "v1beta1", Resource: "configurations"} + +var configurationsKind = schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1beta1", Kind: "Configuration"} + +// Get takes name of the configuration, and returns the corresponding configuration object, and an error if there is any. +func (c *FakeConfigurations) Get(name string, options v1.GetOptions) (result *v1beta1.Configuration, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(configurationsResource, c.ns, name), &v1beta1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Configuration), err +} + +// List takes label and field selectors, and returns the list of Configurations that match those selectors. +func (c *FakeConfigurations) List(opts v1.ListOptions) (result *v1beta1.ConfigurationList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(configurationsResource, configurationsKind, c.ns, opts), &v1beta1.ConfigurationList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.ConfigurationList{ListMeta: obj.(*v1beta1.ConfigurationList).ListMeta} + for _, item := range obj.(*v1beta1.ConfigurationList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested configurations. +func (c *FakeConfigurations) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(configurationsResource, c.ns, opts)) + +} + +// 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 *FakeConfigurations) Create(configuration *v1beta1.Configuration) (result *v1beta1.Configuration, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(configurationsResource, c.ns, configuration), &v1beta1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Configuration), err +} + +// 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 *FakeConfigurations) Update(configuration *v1beta1.Configuration) (result *v1beta1.Configuration, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(configurationsResource, c.ns, configuration), &v1beta1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Configuration), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeConfigurations) UpdateStatus(configuration *v1beta1.Configuration) (*v1beta1.Configuration, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(configurationsResource, "status", c.ns, configuration), &v1beta1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Configuration), err +} + +// Delete takes name of the configuration and deletes it. Returns an error if one occurs. +func (c *FakeConfigurations) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(configurationsResource, c.ns, name), &v1beta1.Configuration{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeConfigurations) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(configurationsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1beta1.ConfigurationList{}) + return err +} + +// Patch applies the patch and returns the patched configuration. +func (c *FakeConfigurations) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Configuration, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(configurationsResource, c.ns, name, data, subresources...), &v1beta1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Configuration), err +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_revision.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_revision.go new file mode 100644 index 0000000000..181dcd1fd7 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_revision.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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeRevisions implements RevisionInterface +type FakeRevisions struct { + Fake *FakeServingV1beta1 + ns string +} + +var revisionsResource = schema.GroupVersionResource{Group: "serving.knative.dev", Version: "v1beta1", Resource: "revisions"} + +var revisionsKind = schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1beta1", Kind: "Revision"} + +// Get takes name of the revision, and returns the corresponding revision object, and an error if there is any. +func (c *FakeRevisions) Get(name string, options v1.GetOptions) (result *v1beta1.Revision, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(revisionsResource, c.ns, name), &v1beta1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Revision), err +} + +// List takes label and field selectors, and returns the list of Revisions that match those selectors. +func (c *FakeRevisions) List(opts v1.ListOptions) (result *v1beta1.RevisionList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(revisionsResource, revisionsKind, c.ns, opts), &v1beta1.RevisionList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.RevisionList{ListMeta: obj.(*v1beta1.RevisionList).ListMeta} + for _, item := range obj.(*v1beta1.RevisionList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested revisions. +func (c *FakeRevisions) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(revisionsResource, c.ns, opts)) + +} + +// 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 *FakeRevisions) Create(revision *v1beta1.Revision) (result *v1beta1.Revision, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(revisionsResource, c.ns, revision), &v1beta1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Revision), err +} + +// 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 *FakeRevisions) Update(revision *v1beta1.Revision) (result *v1beta1.Revision, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(revisionsResource, c.ns, revision), &v1beta1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Revision), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeRevisions) UpdateStatus(revision *v1beta1.Revision) (*v1beta1.Revision, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(revisionsResource, "status", c.ns, revision), &v1beta1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Revision), err +} + +// Delete takes name of the revision and deletes it. Returns an error if one occurs. +func (c *FakeRevisions) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(revisionsResource, c.ns, name), &v1beta1.Revision{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeRevisions) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(revisionsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1beta1.RevisionList{}) + return err +} + +// Patch applies the patch and returns the patched revision. +func (c *FakeRevisions) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Revision, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(revisionsResource, c.ns, name, data, subresources...), &v1beta1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Revision), err +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_route.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_route.go new file mode 100644 index 0000000000..1db25a922d --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_route.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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeRoutes implements RouteInterface +type FakeRoutes struct { + Fake *FakeServingV1beta1 + ns string +} + +var routesResource = schema.GroupVersionResource{Group: "serving.knative.dev", Version: "v1beta1", Resource: "routes"} + +var routesKind = schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1beta1", Kind: "Route"} + +// Get takes name of the route, and returns the corresponding route object, and an error if there is any. +func (c *FakeRoutes) Get(name string, options v1.GetOptions) (result *v1beta1.Route, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(routesResource, c.ns, name), &v1beta1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Route), err +} + +// List takes label and field selectors, and returns the list of Routes that match those selectors. +func (c *FakeRoutes) List(opts v1.ListOptions) (result *v1beta1.RouteList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(routesResource, routesKind, c.ns, opts), &v1beta1.RouteList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.RouteList{ListMeta: obj.(*v1beta1.RouteList).ListMeta} + for _, item := range obj.(*v1beta1.RouteList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested routes. +func (c *FakeRoutes) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(routesResource, c.ns, opts)) + +} + +// 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 *FakeRoutes) Create(route *v1beta1.Route) (result *v1beta1.Route, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(routesResource, c.ns, route), &v1beta1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Route), err +} + +// 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 *FakeRoutes) Update(route *v1beta1.Route) (result *v1beta1.Route, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(routesResource, c.ns, route), &v1beta1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Route), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeRoutes) UpdateStatus(route *v1beta1.Route) (*v1beta1.Route, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(routesResource, "status", c.ns, route), &v1beta1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Route), err +} + +// Delete takes name of the route and deletes it. Returns an error if one occurs. +func (c *FakeRoutes) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(routesResource, c.ns, name), &v1beta1.Route{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeRoutes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(routesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1beta1.RouteList{}) + return err +} + +// Patch applies the patch and returns the patched route. +func (c *FakeRoutes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Route, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(routesResource, c.ns, name, data, subresources...), &v1beta1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Route), err +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_service.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_service.go new file mode 100644 index 0000000000..ca2919af85 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_service.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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeServices implements ServiceInterface +type FakeServices struct { + Fake *FakeServingV1beta1 + ns string +} + +var servicesResource = schema.GroupVersionResource{Group: "serving.knative.dev", Version: "v1beta1", Resource: "services"} + +var servicesKind = schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1beta1", Kind: "Service"} + +// Get takes name of the service, and returns the corresponding service object, and an error if there is any. +func (c *FakeServices) Get(name string, options v1.GetOptions) (result *v1beta1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(servicesResource, c.ns, name), &v1beta1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Service), err +} + +// List takes label and field selectors, and returns the list of Services that match those selectors. +func (c *FakeServices) List(opts v1.ListOptions) (result *v1beta1.ServiceList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(servicesResource, servicesKind, c.ns, opts), &v1beta1.ServiceList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.ServiceList{ListMeta: obj.(*v1beta1.ServiceList).ListMeta} + for _, item := range obj.(*v1beta1.ServiceList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested services. +func (c *FakeServices) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(servicesResource, c.ns, opts)) + +} + +// 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 *FakeServices) Create(service *v1beta1.Service) (result *v1beta1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(servicesResource, c.ns, service), &v1beta1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Service), err +} + +// 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 *FakeServices) Update(service *v1beta1.Service) (result *v1beta1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(servicesResource, c.ns, service), &v1beta1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Service), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeServices) UpdateStatus(service *v1beta1.Service) (*v1beta1.Service, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(servicesResource, "status", c.ns, service), &v1beta1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Service), err +} + +// Delete takes name of the service and deletes it. Returns an error if one occurs. +func (c *FakeServices) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(servicesResource, c.ns, name), &v1beta1.Service{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeServices) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(servicesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1beta1.ServiceList{}) + return err +} + +// Patch applies the patch and returns the patched service. +func (c *FakeServices) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(servicesResource, c.ns, name, data, subresources...), &v1beta1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Service), err +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_serving_client.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_serving_client.go new file mode 100644 index 0000000000..78559c5d16 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_serving_client.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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1beta1 "github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeServingV1beta1 struct { + *testing.Fake +} + +func (c *FakeServingV1beta1) Configurations(namespace string) v1beta1.ConfigurationInterface { + return &FakeConfigurations{c, namespace} +} + +func (c *FakeServingV1beta1) Revisions(namespace string) v1beta1.RevisionInterface { + return &FakeRevisions{c, namespace} +} + +func (c *FakeServingV1beta1) Routes(namespace string) v1beta1.RouteInterface { + return &FakeRoutes{c, namespace} +} + +func (c *FakeServingV1beta1) Services(namespace string) v1beta1.ServiceInterface { + return &FakeServices{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeServingV1beta1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} 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/client/informers/externalversions/autoscaling/interface.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/autoscaling/interface.go new file mode 100644 index 0000000000..ee2140ad2f --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/autoscaling/interface.go @@ -0,0 +1,46 @@ +/* +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 informer-gen. DO NOT EDIT. + +package autoscaling + +import ( + v1alpha1 "github.com/knative/serving/pkg/client/informers/externalversions/autoscaling/v1alpha1" + internalinterfaces "github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/autoscaling/v1alpha1/interface.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/autoscaling/v1alpha1/interface.go new file mode 100644 index 0000000000..f533c698f0 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/autoscaling/v1alpha1/interface.go @@ -0,0 +1,45 @@ +/* +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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + internalinterfaces "github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // PodAutoscalers returns a PodAutoscalerInformer. + PodAutoscalers() PodAutoscalerInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// PodAutoscalers returns a PodAutoscalerInformer. +func (v *version) PodAutoscalers() PodAutoscalerInformer { + return &podAutoscalerInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/autoscaling/v1alpha1/podautoscaler.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/autoscaling/v1alpha1/podautoscaler.go new file mode 100644 index 0000000000..7a39068167 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/autoscaling/v1alpha1/podautoscaler.go @@ -0,0 +1,89 @@ +/* +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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + autoscalingv1alpha1 "github.com/knative/serving/pkg/apis/autoscaling/v1alpha1" + versioned "github.com/knative/serving/pkg/client/clientset/versioned" + internalinterfaces "github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/knative/serving/pkg/client/listers/autoscaling/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// PodAutoscalerInformer provides access to a shared informer and lister for +// PodAutoscalers. +type PodAutoscalerInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.PodAutoscalerLister +} + +type podAutoscalerInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewPodAutoscalerInformer constructs a new informer for PodAutoscaler type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewPodAutoscalerInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredPodAutoscalerInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredPodAutoscalerInformer constructs a new informer for PodAutoscaler type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredPodAutoscalerInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AutoscalingV1alpha1().PodAutoscalers(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AutoscalingV1alpha1().PodAutoscalers(namespace).Watch(options) + }, + }, + &autoscalingv1alpha1.PodAutoscaler{}, + resyncPeriod, + indexers, + ) +} + +func (f *podAutoscalerInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredPodAutoscalerInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *podAutoscalerInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&autoscalingv1alpha1.PodAutoscaler{}, f.defaultInformer) +} + +func (f *podAutoscalerInformer) Lister() v1alpha1.PodAutoscalerLister { + return v1alpha1.NewPodAutoscalerLister(f.Informer().GetIndexer()) +} diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/factory.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/factory.go new file mode 100644 index 0000000000..155de575fd --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/factory.go @@ -0,0 +1,192 @@ +/* +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 informer-gen. DO NOT EDIT. + +package externalversions + +import ( + reflect "reflect" + sync "sync" + time "time" + + versioned "github.com/knative/serving/pkg/client/clientset/versioned" + autoscaling "github.com/knative/serving/pkg/client/informers/externalversions/autoscaling" + internalinterfaces "github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces" + networking "github.com/knative/serving/pkg/client/informers/externalversions/networking" + serving "github.com/knative/serving/pkg/client/informers/externalversions/serving" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// SharedInformerOption defines the functional option type for SharedInformerFactory. +type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory + +type sharedInformerFactory struct { + client versioned.Interface + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc + lock sync.Mutex + defaultResync time.Duration + customResync map[reflect.Type]time.Duration + + informers map[reflect.Type]cache.SharedIndexInformer + // startedInformers is used for tracking which informers have been started. + // This allows Start() to be called multiple times safely. + startedInformers map[reflect.Type]bool +} + +// WithCustomResyncConfig sets a custom resync period for the specified informer types. +func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + for k, v := range resyncConfig { + factory.customResync[reflect.TypeOf(k)] = v + } + return factory + } +} + +// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. +func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.tweakListOptions = tweakListOptions + return factory + } +} + +// WithNamespace limits the SharedInformerFactory to the specified namespace. +func WithNamespace(namespace string) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.namespace = namespace + return factory + } +} + +// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. +func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync) +} + +// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. +// Listers obtained via this SharedInformerFactory will be subject to the same filters +// as specified here. +// Deprecated: Please use NewSharedInformerFactoryWithOptions instead +func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions)) +} + +// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. +func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { + factory := &sharedInformerFactory{ + client: client, + namespace: v1.NamespaceAll, + defaultResync: defaultResync, + informers: make(map[reflect.Type]cache.SharedIndexInformer), + startedInformers: make(map[reflect.Type]bool), + customResync: make(map[reflect.Type]time.Duration), + } + + // Apply all options + for _, opt := range options { + factory = opt(factory) + } + + return factory +} + +// Start initializes all requested informers. +func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { + f.lock.Lock() + defer f.lock.Unlock() + + for informerType, informer := range f.informers { + if !f.startedInformers[informerType] { + go informer.Run(stopCh) + f.startedInformers[informerType] = true + } + } +} + +// WaitForCacheSync waits for all started informers' cache were synced. +func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { + informers := func() map[reflect.Type]cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informers := map[reflect.Type]cache.SharedIndexInformer{} + for informerType, informer := range f.informers { + if f.startedInformers[informerType] { + informers[informerType] = informer + } + } + return informers + }() + + res := map[reflect.Type]bool{} + for informType, informer := range informers { + res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) + } + return res +} + +// InternalInformerFor returns the SharedIndexInformer for obj using an internal +// client. +func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informerType := reflect.TypeOf(obj) + informer, exists := f.informers[informerType] + if exists { + return informer + } + + resyncPeriod, exists := f.customResync[informerType] + if !exists { + resyncPeriod = f.defaultResync + } + + informer = newFunc(f.client, resyncPeriod) + f.informers[informerType] = informer + + return informer +} + +// SharedInformerFactory provides shared informers for resources in all known +// API group versions. +type SharedInformerFactory interface { + internalinterfaces.SharedInformerFactory + ForResource(resource schema.GroupVersionResource) (GenericInformer, error) + WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + + Autoscaling() autoscaling.Interface + Networking() networking.Interface + Serving() serving.Interface +} + +func (f *sharedInformerFactory) Autoscaling() autoscaling.Interface { + return autoscaling.New(f, f.namespace, f.tweakListOptions) +} + +func (f *sharedInformerFactory) Networking() networking.Interface { + return networking.New(f, f.namespace, f.tweakListOptions) +} + +func (f *sharedInformerFactory) Serving() serving.Interface { + return serving.New(f, f.namespace, f.tweakListOptions) +} diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/generic.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/generic.go new file mode 100644 index 0000000000..d1535dde6f --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/generic.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 informer-gen. DO NOT EDIT. + +package externalversions + +import ( + "fmt" + + v1alpha1 "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" + v1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// GenericInformer is type of SharedIndexInformer which will locate and delegate to other +// sharedInformers based on type +type GenericInformer interface { + Informer() cache.SharedIndexInformer + Lister() cache.GenericLister +} + +type genericInformer struct { + informer cache.SharedIndexInformer + resource schema.GroupResource +} + +// Informer returns the SharedIndexInformer. +func (f *genericInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +// Lister returns the GenericLister. +func (f *genericInformer) Lister() cache.GenericLister { + return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) +} + +// ForResource gives generic access to a shared informer of the matching type +// TODO extend this to unknown resources with a client pool +func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { + switch resource { + // Group=autoscaling.internal.knative.dev, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("podautoscalers"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Autoscaling().V1alpha1().PodAutoscalers().Informer()}, nil + + // Group=networking.internal.knative.dev, Version=v1alpha1 + case networkingv1alpha1.SchemeGroupVersion.WithResource("certificates"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Networking().V1alpha1().Certificates().Informer()}, nil + case networkingv1alpha1.SchemeGroupVersion.WithResource("clusteringresses"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Networking().V1alpha1().ClusterIngresses().Informer()}, nil + case networkingv1alpha1.SchemeGroupVersion.WithResource("ingresses"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Networking().V1alpha1().Ingresses().Informer()}, nil + case networkingv1alpha1.SchemeGroupVersion.WithResource("serverlessservices"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Networking().V1alpha1().ServerlessServices().Informer()}, nil + + // Group=serving.knative.dev, Version=v1alpha1 + case servingv1alpha1.SchemeGroupVersion.WithResource("configurations"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Serving().V1alpha1().Configurations().Informer()}, nil + case servingv1alpha1.SchemeGroupVersion.WithResource("revisions"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Serving().V1alpha1().Revisions().Informer()}, nil + case servingv1alpha1.SchemeGroupVersion.WithResource("routes"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Serving().V1alpha1().Routes().Informer()}, nil + case servingv1alpha1.SchemeGroupVersion.WithResource("services"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Serving().V1alpha1().Services().Informer()}, nil + + // Group=serving.knative.dev, Version=v1beta1 + case v1beta1.SchemeGroupVersion.WithResource("configurations"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Serving().V1beta1().Configurations().Informer()}, nil + case v1beta1.SchemeGroupVersion.WithResource("revisions"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Serving().V1beta1().Revisions().Informer()}, nil + case v1beta1.SchemeGroupVersion.WithResource("routes"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Serving().V1beta1().Routes().Informer()}, nil + case v1beta1.SchemeGroupVersion.WithResource("services"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Serving().V1beta1().Services().Informer()}, nil + + } + + return nil, fmt.Errorf("no informer found for %v", resource) +} diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go new file mode 100644 index 0000000000..633a138b20 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -0,0 +1,38 @@ +/* +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 informer-gen. DO NOT EDIT. + +package internalinterfaces + +import ( + time "time" + + versioned "github.com/knative/serving/pkg/client/clientset/versioned" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + cache "k8s.io/client-go/tools/cache" +) + +type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer + +// SharedInformerFactory a small interface to allow for adding an informer without an import cycle +type SharedInformerFactory interface { + Start(stopCh <-chan struct{}) + InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer +} + +type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/networking/interface.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/networking/interface.go new file mode 100644 index 0000000000..d5411bdbe9 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/networking/interface.go @@ -0,0 +1,46 @@ +/* +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 informer-gen. DO NOT EDIT. + +package networking + +import ( + internalinterfaces "github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/knative/serving/pkg/client/informers/externalversions/networking/v1alpha1" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/networking/v1alpha1/certificate.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/networking/v1alpha1/certificate.go new file mode 100644 index 0000000000..62c43f424d --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/networking/v1alpha1/certificate.go @@ -0,0 +1,89 @@ +/* +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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + networkingv1alpha1 "github.com/knative/serving/pkg/apis/networking/v1alpha1" + versioned "github.com/knative/serving/pkg/client/clientset/versioned" + internalinterfaces "github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/knative/serving/pkg/client/listers/networking/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// CertificateInformer provides access to a shared informer and lister for +// Certificates. +type CertificateInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.CertificateLister +} + +type certificateInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewCertificateInformer constructs a new informer for Certificate type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewCertificateInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredCertificateInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredCertificateInformer constructs a new informer for Certificate type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredCertificateInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NetworkingV1alpha1().Certificates(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NetworkingV1alpha1().Certificates(namespace).Watch(options) + }, + }, + &networkingv1alpha1.Certificate{}, + resyncPeriod, + indexers, + ) +} + +func (f *certificateInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredCertificateInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *certificateInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&networkingv1alpha1.Certificate{}, f.defaultInformer) +} + +func (f *certificateInformer) Lister() v1alpha1.CertificateLister { + return v1alpha1.NewCertificateLister(f.Informer().GetIndexer()) +} diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/networking/v1alpha1/clusteringress.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/networking/v1alpha1/clusteringress.go new file mode 100644 index 0000000000..e111729f3e --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/networking/v1alpha1/clusteringress.go @@ -0,0 +1,88 @@ +/* +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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + networkingv1alpha1 "github.com/knative/serving/pkg/apis/networking/v1alpha1" + versioned "github.com/knative/serving/pkg/client/clientset/versioned" + internalinterfaces "github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/knative/serving/pkg/client/listers/networking/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ClusterIngressInformer provides access to a shared informer and lister for +// ClusterIngresses. +type ClusterIngressInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ClusterIngressLister +} + +type clusterIngressInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewClusterIngressInformer constructs a new informer for ClusterIngress type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewClusterIngressInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredClusterIngressInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredClusterIngressInformer constructs a new informer for ClusterIngress type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredClusterIngressInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NetworkingV1alpha1().ClusterIngresses().List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NetworkingV1alpha1().ClusterIngresses().Watch(options) + }, + }, + &networkingv1alpha1.ClusterIngress{}, + resyncPeriod, + indexers, + ) +} + +func (f *clusterIngressInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredClusterIngressInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *clusterIngressInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&networkingv1alpha1.ClusterIngress{}, f.defaultInformer) +} + +func (f *clusterIngressInformer) Lister() v1alpha1.ClusterIngressLister { + return v1alpha1.NewClusterIngressLister(f.Informer().GetIndexer()) +} diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/networking/v1alpha1/ingress.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/networking/v1alpha1/ingress.go new file mode 100644 index 0000000000..93df3ea59b --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/networking/v1alpha1/ingress.go @@ -0,0 +1,89 @@ +/* +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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + networkingv1alpha1 "github.com/knative/serving/pkg/apis/networking/v1alpha1" + versioned "github.com/knative/serving/pkg/client/clientset/versioned" + internalinterfaces "github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/knative/serving/pkg/client/listers/networking/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// IngressInformer provides access to a shared informer and lister for +// Ingresses. +type IngressInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.IngressLister +} + +type ingressInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewIngressInformer constructs a new informer for Ingress type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewIngressInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredIngressInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredIngressInformer constructs a new informer for Ingress type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredIngressInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NetworkingV1alpha1().Ingresses(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NetworkingV1alpha1().Ingresses(namespace).Watch(options) + }, + }, + &networkingv1alpha1.Ingress{}, + resyncPeriod, + indexers, + ) +} + +func (f *ingressInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredIngressInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *ingressInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&networkingv1alpha1.Ingress{}, f.defaultInformer) +} + +func (f *ingressInformer) Lister() v1alpha1.IngressLister { + return v1alpha1.NewIngressLister(f.Informer().GetIndexer()) +} diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/networking/v1alpha1/interface.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/networking/v1alpha1/interface.go new file mode 100644 index 0000000000..e96c1a9235 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/networking/v1alpha1/interface.go @@ -0,0 +1,66 @@ +/* +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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + internalinterfaces "github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // Certificates returns a CertificateInformer. + Certificates() CertificateInformer + // ClusterIngresses returns a ClusterIngressInformer. + ClusterIngresses() ClusterIngressInformer + // Ingresses returns a IngressInformer. + Ingresses() IngressInformer + // ServerlessServices returns a ServerlessServiceInformer. + ServerlessServices() ServerlessServiceInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// Certificates returns a CertificateInformer. +func (v *version) Certificates() CertificateInformer { + return &certificateInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// ClusterIngresses returns a ClusterIngressInformer. +func (v *version) ClusterIngresses() ClusterIngressInformer { + return &clusterIngressInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// Ingresses returns a IngressInformer. +func (v *version) Ingresses() IngressInformer { + return &ingressInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// ServerlessServices returns a ServerlessServiceInformer. +func (v *version) ServerlessServices() ServerlessServiceInformer { + return &serverlessServiceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/networking/v1alpha1/serverlessservice.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/networking/v1alpha1/serverlessservice.go new file mode 100644 index 0000000000..6f2b1ceaab --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/networking/v1alpha1/serverlessservice.go @@ -0,0 +1,89 @@ +/* +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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + networkingv1alpha1 "github.com/knative/serving/pkg/apis/networking/v1alpha1" + versioned "github.com/knative/serving/pkg/client/clientset/versioned" + internalinterfaces "github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/knative/serving/pkg/client/listers/networking/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ServerlessServiceInformer provides access to a shared informer and lister for +// ServerlessServices. +type ServerlessServiceInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ServerlessServiceLister +} + +type serverlessServiceInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewServerlessServiceInformer constructs a new informer for ServerlessService type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewServerlessServiceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredServerlessServiceInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredServerlessServiceInformer constructs a new informer for ServerlessService type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredServerlessServiceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NetworkingV1alpha1().ServerlessServices(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NetworkingV1alpha1().ServerlessServices(namespace).Watch(options) + }, + }, + &networkingv1alpha1.ServerlessService{}, + resyncPeriod, + indexers, + ) +} + +func (f *serverlessServiceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredServerlessServiceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *serverlessServiceInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&networkingv1alpha1.ServerlessService{}, f.defaultInformer) +} + +func (f *serverlessServiceInformer) Lister() v1alpha1.ServerlessServiceLister { + return v1alpha1.NewServerlessServiceLister(f.Informer().GetIndexer()) +} diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/interface.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/interface.go new file mode 100644 index 0000000000..3feccd2e35 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/interface.go @@ -0,0 +1,54 @@ +/* +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 informer-gen. DO NOT EDIT. + +package serving + +import ( + internalinterfaces "github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/knative/serving/pkg/client/informers/externalversions/serving/v1alpha1" + v1beta1 "github.com/knative/serving/pkg/client/informers/externalversions/serving/v1beta1" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() v1beta1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} + +// V1beta1 returns a new v1beta1.Interface. +func (g *group) V1beta1() v1beta1.Interface { + return v1beta1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1alpha1/configuration.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1alpha1/configuration.go new file mode 100644 index 0000000000..1347f0f1ed --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1alpha1/configuration.go @@ -0,0 +1,89 @@ +/* +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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + servingv1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" + versioned "github.com/knative/serving/pkg/client/clientset/versioned" + internalinterfaces "github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/knative/serving/pkg/client/listers/serving/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ConfigurationInformer provides access to a shared informer and lister for +// Configurations. +type ConfigurationInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ConfigurationLister +} + +type configurationInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewConfigurationInformer constructs a new informer for Configuration type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewConfigurationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredConfigurationInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredConfigurationInformer constructs a new informer for Configuration type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredConfigurationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1alpha1().Configurations(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1alpha1().Configurations(namespace).Watch(options) + }, + }, + &servingv1alpha1.Configuration{}, + resyncPeriod, + indexers, + ) +} + +func (f *configurationInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredConfigurationInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *configurationInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&servingv1alpha1.Configuration{}, f.defaultInformer) +} + +func (f *configurationInformer) Lister() v1alpha1.ConfigurationLister { + return v1alpha1.NewConfigurationLister(f.Informer().GetIndexer()) +} diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1alpha1/interface.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1alpha1/interface.go new file mode 100644 index 0000000000..0358c84c1d --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1alpha1/interface.go @@ -0,0 +1,66 @@ +/* +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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + internalinterfaces "github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // Configurations returns a ConfigurationInformer. + Configurations() ConfigurationInformer + // Revisions returns a RevisionInformer. + Revisions() RevisionInformer + // Routes returns a RouteInformer. + Routes() RouteInformer + // Services returns a ServiceInformer. + Services() ServiceInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// Configurations returns a ConfigurationInformer. +func (v *version) Configurations() ConfigurationInformer { + return &configurationInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Revisions returns a RevisionInformer. +func (v *version) Revisions() RevisionInformer { + return &revisionInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Routes returns a RouteInformer. +func (v *version) Routes() RouteInformer { + return &routeInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Services returns a ServiceInformer. +func (v *version) Services() ServiceInformer { + return &serviceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1alpha1/revision.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1alpha1/revision.go new file mode 100644 index 0000000000..dac7a35f76 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1alpha1/revision.go @@ -0,0 +1,89 @@ +/* +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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + servingv1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" + versioned "github.com/knative/serving/pkg/client/clientset/versioned" + internalinterfaces "github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/knative/serving/pkg/client/listers/serving/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// RevisionInformer provides access to a shared informer and lister for +// Revisions. +type RevisionInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.RevisionLister +} + +type revisionInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewRevisionInformer constructs a new informer for Revision type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewRevisionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredRevisionInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredRevisionInformer constructs a new informer for Revision type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredRevisionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1alpha1().Revisions(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1alpha1().Revisions(namespace).Watch(options) + }, + }, + &servingv1alpha1.Revision{}, + resyncPeriod, + indexers, + ) +} + +func (f *revisionInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredRevisionInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *revisionInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&servingv1alpha1.Revision{}, f.defaultInformer) +} + +func (f *revisionInformer) Lister() v1alpha1.RevisionLister { + return v1alpha1.NewRevisionLister(f.Informer().GetIndexer()) +} diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1alpha1/route.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1alpha1/route.go new file mode 100644 index 0000000000..d7c0c0c30b --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1alpha1/route.go @@ -0,0 +1,89 @@ +/* +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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + servingv1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" + versioned "github.com/knative/serving/pkg/client/clientset/versioned" + internalinterfaces "github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/knative/serving/pkg/client/listers/serving/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// RouteInformer provides access to a shared informer and lister for +// Routes. +type RouteInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.RouteLister +} + +type routeInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewRouteInformer constructs a new informer for Route type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewRouteInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredRouteInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredRouteInformer constructs a new informer for Route type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredRouteInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1alpha1().Routes(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1alpha1().Routes(namespace).Watch(options) + }, + }, + &servingv1alpha1.Route{}, + resyncPeriod, + indexers, + ) +} + +func (f *routeInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredRouteInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *routeInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&servingv1alpha1.Route{}, f.defaultInformer) +} + +func (f *routeInformer) Lister() v1alpha1.RouteLister { + return v1alpha1.NewRouteLister(f.Informer().GetIndexer()) +} diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1alpha1/service.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1alpha1/service.go new file mode 100644 index 0000000000..ce6b6502e1 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1alpha1/service.go @@ -0,0 +1,89 @@ +/* +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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + servingv1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" + versioned "github.com/knative/serving/pkg/client/clientset/versioned" + internalinterfaces "github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/knative/serving/pkg/client/listers/serving/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ServiceInformer provides access to a shared informer and lister for +// Services. +type ServiceInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ServiceLister +} + +type serviceInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewServiceInformer constructs a new informer for Service type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewServiceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredServiceInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredServiceInformer constructs a new informer for Service type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredServiceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1alpha1().Services(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1alpha1().Services(namespace).Watch(options) + }, + }, + &servingv1alpha1.Service{}, + resyncPeriod, + indexers, + ) +} + +func (f *serviceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredServiceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *serviceInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&servingv1alpha1.Service{}, f.defaultInformer) +} + +func (f *serviceInformer) Lister() v1alpha1.ServiceLister { + return v1alpha1.NewServiceLister(f.Informer().GetIndexer()) +} diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1beta1/configuration.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1beta1/configuration.go new file mode 100644 index 0000000000..8308b7af0f --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1beta1/configuration.go @@ -0,0 +1,89 @@ +/* +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 informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + time "time" + + servingv1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + versioned "github.com/knative/serving/pkg/client/clientset/versioned" + internalinterfaces "github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces" + v1beta1 "github.com/knative/serving/pkg/client/listers/serving/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ConfigurationInformer provides access to a shared informer and lister for +// Configurations. +type ConfigurationInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta1.ConfigurationLister +} + +type configurationInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewConfigurationInformer constructs a new informer for Configuration type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewConfigurationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredConfigurationInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredConfigurationInformer constructs a new informer for Configuration type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredConfigurationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1beta1().Configurations(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1beta1().Configurations(namespace).Watch(options) + }, + }, + &servingv1beta1.Configuration{}, + resyncPeriod, + indexers, + ) +} + +func (f *configurationInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredConfigurationInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *configurationInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&servingv1beta1.Configuration{}, f.defaultInformer) +} + +func (f *configurationInformer) Lister() v1beta1.ConfigurationLister { + return v1beta1.NewConfigurationLister(f.Informer().GetIndexer()) +} diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1beta1/interface.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1beta1/interface.go new file mode 100644 index 0000000000..7413851b4d --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1beta1/interface.go @@ -0,0 +1,66 @@ +/* +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 informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + internalinterfaces "github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // Configurations returns a ConfigurationInformer. + Configurations() ConfigurationInformer + // Revisions returns a RevisionInformer. + Revisions() RevisionInformer + // Routes returns a RouteInformer. + Routes() RouteInformer + // Services returns a ServiceInformer. + Services() ServiceInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// Configurations returns a ConfigurationInformer. +func (v *version) Configurations() ConfigurationInformer { + return &configurationInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Revisions returns a RevisionInformer. +func (v *version) Revisions() RevisionInformer { + return &revisionInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Routes returns a RouteInformer. +func (v *version) Routes() RouteInformer { + return &routeInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Services returns a ServiceInformer. +func (v *version) Services() ServiceInformer { + return &serviceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1beta1/revision.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1beta1/revision.go new file mode 100644 index 0000000000..ec1fcb3e08 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1beta1/revision.go @@ -0,0 +1,89 @@ +/* +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 informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + time "time" + + servingv1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + versioned "github.com/knative/serving/pkg/client/clientset/versioned" + internalinterfaces "github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces" + v1beta1 "github.com/knative/serving/pkg/client/listers/serving/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// RevisionInformer provides access to a shared informer and lister for +// Revisions. +type RevisionInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta1.RevisionLister +} + +type revisionInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewRevisionInformer constructs a new informer for Revision type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewRevisionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredRevisionInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredRevisionInformer constructs a new informer for Revision type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredRevisionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1beta1().Revisions(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1beta1().Revisions(namespace).Watch(options) + }, + }, + &servingv1beta1.Revision{}, + resyncPeriod, + indexers, + ) +} + +func (f *revisionInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredRevisionInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *revisionInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&servingv1beta1.Revision{}, f.defaultInformer) +} + +func (f *revisionInformer) Lister() v1beta1.RevisionLister { + return v1beta1.NewRevisionLister(f.Informer().GetIndexer()) +} diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1beta1/route.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1beta1/route.go new file mode 100644 index 0000000000..edcda9d619 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1beta1/route.go @@ -0,0 +1,89 @@ +/* +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 informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + time "time" + + servingv1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + versioned "github.com/knative/serving/pkg/client/clientset/versioned" + internalinterfaces "github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces" + v1beta1 "github.com/knative/serving/pkg/client/listers/serving/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// RouteInformer provides access to a shared informer and lister for +// Routes. +type RouteInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta1.RouteLister +} + +type routeInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewRouteInformer constructs a new informer for Route type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewRouteInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredRouteInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredRouteInformer constructs a new informer for Route type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredRouteInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1beta1().Routes(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1beta1().Routes(namespace).Watch(options) + }, + }, + &servingv1beta1.Route{}, + resyncPeriod, + indexers, + ) +} + +func (f *routeInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredRouteInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *routeInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&servingv1beta1.Route{}, f.defaultInformer) +} + +func (f *routeInformer) Lister() v1beta1.RouteLister { + return v1beta1.NewRouteLister(f.Informer().GetIndexer()) +} diff --git a/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1beta1/service.go b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1beta1/service.go new file mode 100644 index 0000000000..7a2a6069ba --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/informers/externalversions/serving/v1beta1/service.go @@ -0,0 +1,89 @@ +/* +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 informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + time "time" + + servingv1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + versioned "github.com/knative/serving/pkg/client/clientset/versioned" + internalinterfaces "github.com/knative/serving/pkg/client/informers/externalversions/internalinterfaces" + v1beta1 "github.com/knative/serving/pkg/client/listers/serving/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ServiceInformer provides access to a shared informer and lister for +// Services. +type ServiceInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta1.ServiceLister +} + +type serviceInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewServiceInformer constructs a new informer for Service type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewServiceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredServiceInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredServiceInformer constructs a new informer for Service type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredServiceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1beta1().Services(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1beta1().Services(namespace).Watch(options) + }, + }, + &servingv1beta1.Service{}, + resyncPeriod, + indexers, + ) +} + +func (f *serviceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredServiceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *serviceInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&servingv1beta1.Service{}, f.defaultInformer) +} + +func (f *serviceInformer) Lister() v1beta1.ServiceLister { + return v1beta1.NewServiceLister(f.Informer().GetIndexer()) +} diff --git a/vendor/github.com/knative/serving/pkg/client/injection/client/client.go b/vendor/github.com/knative/serving/pkg/client/injection/client/client.go new file mode 100644 index 0000000000..ec37bcf696 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/injection/client/client.go @@ -0,0 +1,49 @@ +/* +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 injection-gen. DO NOT EDIT. + +package client + +import ( + "context" + + versioned "github.com/knative/serving/pkg/client/clientset/versioned" + rest "k8s.io/client-go/rest" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" +) + +func init() { + injection.Default.RegisterClient(withClient) +} + +// Key is used as the key for associating information with a context.Context. +type Key struct{} + +func withClient(ctx context.Context, cfg *rest.Config) context.Context { + return context.WithValue(ctx, Key{}, versioned.NewForConfigOrDie(cfg)) +} + +// Get extracts the versioned.Interface client from the context. +func Get(ctx context.Context) versioned.Interface { + untyped := ctx.Value(Key{}) + if untyped == nil { + logging.FromContext(ctx).Fatalf( + "Unable to fetch %T from context.", (versioned.Interface)(nil)) + } + return untyped.(versioned.Interface) +} diff --git a/vendor/github.com/knative/serving/pkg/client/injection/client/fake/fake.go b/vendor/github.com/knative/serving/pkg/client/injection/client/fake/fake.go new file mode 100644 index 0000000000..4201954f5c --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/injection/client/fake/fake.go @@ -0,0 +1,54 @@ +/* +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 injection-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + fake "github.com/knative/serving/pkg/client/clientset/versioned/fake" + client "github.com/knative/serving/pkg/client/injection/client" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/client-go/rest" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" +) + +func init() { + injection.Fake.RegisterClient(withClient) +} + +func withClient(ctx context.Context, cfg *rest.Config) context.Context { + ctx, _ = With(ctx) + return ctx +} + +func With(ctx context.Context, objects ...runtime.Object) (context.Context, *fake.Clientset) { + cs := fake.NewSimpleClientset(objects...) + return context.WithValue(ctx, client.Key{}, cs), cs +} + +// Get extracts the Kubernetes client from the context. +func Get(ctx context.Context) *fake.Clientset { + untyped := ctx.Value(client.Key{}) + if untyped == nil { + logging.FromContext(ctx).Fatalf( + "Unable to fetch %T from context.", (*fake.Clientset)(nil)) + } + return untyped.(*fake.Clientset) +} diff --git a/vendor/github.com/knative/serving/pkg/client/injection/informers/serving/factory/fake/fake.go b/vendor/github.com/knative/serving/pkg/client/injection/informers/serving/factory/fake/fake.go new file mode 100644 index 0000000000..92ec6cac4d --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/injection/informers/serving/factory/fake/fake.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. +*/ + +// Code generated by injection-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + externalversions "github.com/knative/serving/pkg/client/informers/externalversions" + fake "github.com/knative/serving/pkg/client/injection/client/fake" + factory "github.com/knative/serving/pkg/client/injection/informers/serving/factory" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" +) + +var Get = factory.Get + +func init() { + injection.Fake.RegisterInformerFactory(withInformerFactory) +} + +func withInformerFactory(ctx context.Context) context.Context { + c := fake.Get(ctx) + return context.WithValue(ctx, factory.Key{}, + externalversions.NewSharedInformerFactory(c, controller.GetResyncPeriod(ctx))) +} diff --git a/vendor/github.com/knative/serving/pkg/client/injection/informers/serving/factory/servingfactory.go b/vendor/github.com/knative/serving/pkg/client/injection/informers/serving/factory/servingfactory.go new file mode 100644 index 0000000000..a1e750dcd2 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/injection/informers/serving/factory/servingfactory.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. +*/ + +// Code generated by injection-gen. DO NOT EDIT. + +package servingfactory + +import ( + "context" + + externalversions "github.com/knative/serving/pkg/client/informers/externalversions" + client "github.com/knative/serving/pkg/client/injection/client" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" +) + +func init() { + injection.Default.RegisterInformerFactory(withInformerFactory) +} + +// Key is used as the key for associating information with a context.Context. +type Key struct{} + +func withInformerFactory(ctx context.Context) context.Context { + c := client.Get(ctx) + return context.WithValue(ctx, Key{}, + externalversions.NewSharedInformerFactory(c, controller.GetResyncPeriod(ctx))) +} + +// Get extracts the InformerFactory from the context. +func Get(ctx context.Context) externalversions.SharedInformerFactory { + untyped := ctx.Value(Key{}) + if untyped == nil { + logging.FromContext(ctx).Fatalf( + "Unable to fetch %T from context.", (externalversions.SharedInformerFactory)(nil)) + } + return untyped.(externalversions.SharedInformerFactory) +} diff --git a/vendor/github.com/knative/serving/pkg/client/injection/informers/serving/v1beta1/service/fake/fake.go b/vendor/github.com/knative/serving/pkg/client/injection/informers/serving/v1beta1/service/fake/fake.go new file mode 100644 index 0000000000..1efe4d1d05 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/injection/informers/serving/v1beta1/service/fake/fake.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. +*/ + +// Code generated by injection-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + fake "github.com/knative/serving/pkg/client/injection/informers/serving/factory/fake" + service "github.com/knative/serving/pkg/client/injection/informers/serving/v1beta1/service" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" +) + +var Get = service.Get + +func init() { + injection.Fake.RegisterInformer(withInformer) +} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + f := fake.Get(ctx) + inf := f.Serving().V1beta1().Services() + return context.WithValue(ctx, service.Key{}, inf), inf.Informer() +} diff --git a/vendor/github.com/knative/serving/pkg/client/injection/informers/serving/v1beta1/service/service.go b/vendor/github.com/knative/serving/pkg/client/injection/informers/serving/v1beta1/service/service.go new file mode 100644 index 0000000000..d799dcde99 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/injection/informers/serving/v1beta1/service/service.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. +*/ + +// Code generated by injection-gen. DO NOT EDIT. + +package service + +import ( + "context" + + v1beta1 "github.com/knative/serving/pkg/client/informers/externalversions/serving/v1beta1" + factory "github.com/knative/serving/pkg/client/injection/informers/serving/factory" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" +) + +func init() { + injection.Default.RegisterInformer(withInformer) +} + +// Key is used for associating the Informer inside the context.Context. +type Key struct{} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + f := factory.Get(ctx) + inf := f.Serving().V1beta1().Services() + return context.WithValue(ctx, Key{}, inf), inf.Informer() +} + +// Get extracts the typed informer from the context. +func Get(ctx context.Context) v1beta1.ServiceInformer { + untyped := ctx.Value(Key{}) + if untyped == nil { + logging.FromContext(ctx).Fatalf( + "Unable to fetch %T from context.", (v1beta1.ServiceInformer)(nil)) + } + return untyped.(v1beta1.ServiceInformer) +} diff --git a/vendor/github.com/knative/serving/pkg/client/listers/autoscaling/v1alpha1/expansion_generated.go b/vendor/github.com/knative/serving/pkg/client/listers/autoscaling/v1alpha1/expansion_generated.go new file mode 100644 index 0000000000..5231877038 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/listers/autoscaling/v1alpha1/expansion_generated.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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +// PodAutoscalerListerExpansion allows custom methods to be added to +// PodAutoscalerLister. +type PodAutoscalerListerExpansion interface{} + +// PodAutoscalerNamespaceListerExpansion allows custom methods to be added to +// PodAutoscalerNamespaceLister. +type PodAutoscalerNamespaceListerExpansion interface{} diff --git a/vendor/github.com/knative/serving/pkg/client/listers/autoscaling/v1alpha1/podautoscaler.go b/vendor/github.com/knative/serving/pkg/client/listers/autoscaling/v1alpha1/podautoscaler.go new file mode 100644 index 0000000000..88a29e4610 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/listers/autoscaling/v1alpha1/podautoscaler.go @@ -0,0 +1,94 @@ +/* +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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/autoscaling/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// PodAutoscalerLister helps list PodAutoscalers. +type PodAutoscalerLister interface { + // List lists all PodAutoscalers in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.PodAutoscaler, err error) + // PodAutoscalers returns an object that can list and get PodAutoscalers. + PodAutoscalers(namespace string) PodAutoscalerNamespaceLister + PodAutoscalerListerExpansion +} + +// podAutoscalerLister implements the PodAutoscalerLister interface. +type podAutoscalerLister struct { + indexer cache.Indexer +} + +// NewPodAutoscalerLister returns a new PodAutoscalerLister. +func NewPodAutoscalerLister(indexer cache.Indexer) PodAutoscalerLister { + return &podAutoscalerLister{indexer: indexer} +} + +// List lists all PodAutoscalers in the indexer. +func (s *podAutoscalerLister) List(selector labels.Selector) (ret []*v1alpha1.PodAutoscaler, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.PodAutoscaler)) + }) + return ret, err +} + +// PodAutoscalers returns an object that can list and get PodAutoscalers. +func (s *podAutoscalerLister) PodAutoscalers(namespace string) PodAutoscalerNamespaceLister { + return podAutoscalerNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// PodAutoscalerNamespaceLister helps list and get PodAutoscalers. +type PodAutoscalerNamespaceLister interface { + // List lists all PodAutoscalers in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.PodAutoscaler, err error) + // Get retrieves the PodAutoscaler from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.PodAutoscaler, error) + PodAutoscalerNamespaceListerExpansion +} + +// podAutoscalerNamespaceLister implements the PodAutoscalerNamespaceLister +// interface. +type podAutoscalerNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all PodAutoscalers in the indexer for a given namespace. +func (s podAutoscalerNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.PodAutoscaler, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.PodAutoscaler)) + }) + return ret, err +} + +// Get retrieves the PodAutoscaler from the indexer for a given namespace and name. +func (s podAutoscalerNamespaceLister) Get(name string) (*v1alpha1.PodAutoscaler, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("podautoscaler"), name) + } + return obj.(*v1alpha1.PodAutoscaler), nil +} diff --git a/vendor/github.com/knative/serving/pkg/client/listers/networking/v1alpha1/certificate.go b/vendor/github.com/knative/serving/pkg/client/listers/networking/v1alpha1/certificate.go new file mode 100644 index 0000000000..95dbb73ea8 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/listers/networking/v1alpha1/certificate.go @@ -0,0 +1,94 @@ +/* +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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/networking/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// CertificateLister helps list Certificates. +type CertificateLister interface { + // List lists all Certificates in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.Certificate, err error) + // Certificates returns an object that can list and get Certificates. + Certificates(namespace string) CertificateNamespaceLister + CertificateListerExpansion +} + +// certificateLister implements the CertificateLister interface. +type certificateLister struct { + indexer cache.Indexer +} + +// NewCertificateLister returns a new CertificateLister. +func NewCertificateLister(indexer cache.Indexer) CertificateLister { + return &certificateLister{indexer: indexer} +} + +// List lists all Certificates in the indexer. +func (s *certificateLister) List(selector labels.Selector) (ret []*v1alpha1.Certificate, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Certificate)) + }) + return ret, err +} + +// Certificates returns an object that can list and get Certificates. +func (s *certificateLister) Certificates(namespace string) CertificateNamespaceLister { + return certificateNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// CertificateNamespaceLister helps list and get Certificates. +type CertificateNamespaceLister interface { + // List lists all Certificates in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.Certificate, err error) + // Get retrieves the Certificate from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.Certificate, error) + CertificateNamespaceListerExpansion +} + +// certificateNamespaceLister implements the CertificateNamespaceLister +// interface. +type certificateNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Certificates in the indexer for a given namespace. +func (s certificateNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Certificate, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Certificate)) + }) + return ret, err +} + +// Get retrieves the Certificate from the indexer for a given namespace and name. +func (s certificateNamespaceLister) Get(name string) (*v1alpha1.Certificate, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("certificate"), name) + } + return obj.(*v1alpha1.Certificate), nil +} diff --git a/vendor/github.com/knative/serving/pkg/client/listers/networking/v1alpha1/clusteringress.go b/vendor/github.com/knative/serving/pkg/client/listers/networking/v1alpha1/clusteringress.go new file mode 100644 index 0000000000..61cec2244c --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/listers/networking/v1alpha1/clusteringress.go @@ -0,0 +1,65 @@ +/* +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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/networking/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ClusterIngressLister helps list ClusterIngresses. +type ClusterIngressLister interface { + // List lists all ClusterIngresses in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.ClusterIngress, err error) + // Get retrieves the ClusterIngress from the index for a given name. + Get(name string) (*v1alpha1.ClusterIngress, error) + ClusterIngressListerExpansion +} + +// clusterIngressLister implements the ClusterIngressLister interface. +type clusterIngressLister struct { + indexer cache.Indexer +} + +// NewClusterIngressLister returns a new ClusterIngressLister. +func NewClusterIngressLister(indexer cache.Indexer) ClusterIngressLister { + return &clusterIngressLister{indexer: indexer} +} + +// List lists all ClusterIngresses in the indexer. +func (s *clusterIngressLister) List(selector labels.Selector) (ret []*v1alpha1.ClusterIngress, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ClusterIngress)) + }) + return ret, err +} + +// Get retrieves the ClusterIngress from the index for a given name. +func (s *clusterIngressLister) Get(name string) (*v1alpha1.ClusterIngress, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("clusteringress"), name) + } + return obj.(*v1alpha1.ClusterIngress), nil +} diff --git a/vendor/github.com/knative/serving/pkg/client/listers/networking/v1alpha1/expansion_generated.go b/vendor/github.com/knative/serving/pkg/client/listers/networking/v1alpha1/expansion_generated.go new file mode 100644 index 0000000000..1baa7d9043 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/listers/networking/v1alpha1/expansion_generated.go @@ -0,0 +1,47 @@ +/* +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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +// CertificateListerExpansion allows custom methods to be added to +// CertificateLister. +type CertificateListerExpansion interface{} + +// CertificateNamespaceListerExpansion allows custom methods to be added to +// CertificateNamespaceLister. +type CertificateNamespaceListerExpansion interface{} + +// ClusterIngressListerExpansion allows custom methods to be added to +// ClusterIngressLister. +type ClusterIngressListerExpansion interface{} + +// IngressListerExpansion allows custom methods to be added to +// IngressLister. +type IngressListerExpansion interface{} + +// IngressNamespaceListerExpansion allows custom methods to be added to +// IngressNamespaceLister. +type IngressNamespaceListerExpansion interface{} + +// ServerlessServiceListerExpansion allows custom methods to be added to +// ServerlessServiceLister. +type ServerlessServiceListerExpansion interface{} + +// ServerlessServiceNamespaceListerExpansion allows custom methods to be added to +// ServerlessServiceNamespaceLister. +type ServerlessServiceNamespaceListerExpansion interface{} diff --git a/vendor/github.com/knative/serving/pkg/client/listers/networking/v1alpha1/ingress.go b/vendor/github.com/knative/serving/pkg/client/listers/networking/v1alpha1/ingress.go new file mode 100644 index 0000000000..95d474eafd --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/listers/networking/v1alpha1/ingress.go @@ -0,0 +1,94 @@ +/* +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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/networking/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// IngressLister helps list Ingresses. +type IngressLister interface { + // List lists all Ingresses in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.Ingress, err error) + // Ingresses returns an object that can list and get Ingresses. + Ingresses(namespace string) IngressNamespaceLister + IngressListerExpansion +} + +// ingressLister implements the IngressLister interface. +type ingressLister struct { + indexer cache.Indexer +} + +// NewIngressLister returns a new IngressLister. +func NewIngressLister(indexer cache.Indexer) IngressLister { + return &ingressLister{indexer: indexer} +} + +// List lists all Ingresses in the indexer. +func (s *ingressLister) List(selector labels.Selector) (ret []*v1alpha1.Ingress, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Ingress)) + }) + return ret, err +} + +// Ingresses returns an object that can list and get Ingresses. +func (s *ingressLister) Ingresses(namespace string) IngressNamespaceLister { + return ingressNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// IngressNamespaceLister helps list and get Ingresses. +type IngressNamespaceLister interface { + // List lists all Ingresses in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.Ingress, err error) + // Get retrieves the Ingress from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.Ingress, error) + IngressNamespaceListerExpansion +} + +// ingressNamespaceLister implements the IngressNamespaceLister +// interface. +type ingressNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Ingresses in the indexer for a given namespace. +func (s ingressNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Ingress, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Ingress)) + }) + return ret, err +} + +// Get retrieves the Ingress from the indexer for a given namespace and name. +func (s ingressNamespaceLister) Get(name string) (*v1alpha1.Ingress, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("ingress"), name) + } + return obj.(*v1alpha1.Ingress), nil +} diff --git a/vendor/github.com/knative/serving/pkg/client/listers/networking/v1alpha1/serverlessservice.go b/vendor/github.com/knative/serving/pkg/client/listers/networking/v1alpha1/serverlessservice.go new file mode 100644 index 0000000000..1fd0173c8b --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/listers/networking/v1alpha1/serverlessservice.go @@ -0,0 +1,94 @@ +/* +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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/networking/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ServerlessServiceLister helps list ServerlessServices. +type ServerlessServiceLister interface { + // List lists all ServerlessServices in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.ServerlessService, err error) + // ServerlessServices returns an object that can list and get ServerlessServices. + ServerlessServices(namespace string) ServerlessServiceNamespaceLister + ServerlessServiceListerExpansion +} + +// serverlessServiceLister implements the ServerlessServiceLister interface. +type serverlessServiceLister struct { + indexer cache.Indexer +} + +// NewServerlessServiceLister returns a new ServerlessServiceLister. +func NewServerlessServiceLister(indexer cache.Indexer) ServerlessServiceLister { + return &serverlessServiceLister{indexer: indexer} +} + +// List lists all ServerlessServices in the indexer. +func (s *serverlessServiceLister) List(selector labels.Selector) (ret []*v1alpha1.ServerlessService, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ServerlessService)) + }) + return ret, err +} + +// ServerlessServices returns an object that can list and get ServerlessServices. +func (s *serverlessServiceLister) ServerlessServices(namespace string) ServerlessServiceNamespaceLister { + return serverlessServiceNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ServerlessServiceNamespaceLister helps list and get ServerlessServices. +type ServerlessServiceNamespaceLister interface { + // List lists all ServerlessServices in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.ServerlessService, err error) + // Get retrieves the ServerlessService from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.ServerlessService, error) + ServerlessServiceNamespaceListerExpansion +} + +// serverlessServiceNamespaceLister implements the ServerlessServiceNamespaceLister +// interface. +type serverlessServiceNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all ServerlessServices in the indexer for a given namespace. +func (s serverlessServiceNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.ServerlessService, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ServerlessService)) + }) + return ret, err +} + +// Get retrieves the ServerlessService from the indexer for a given namespace and name. +func (s serverlessServiceNamespaceLister) Get(name string) (*v1alpha1.ServerlessService, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("serverlessservice"), name) + } + return obj.(*v1alpha1.ServerlessService), nil +} diff --git a/vendor/github.com/knative/serving/pkg/client/listers/serving/v1alpha1/configuration.go b/vendor/github.com/knative/serving/pkg/client/listers/serving/v1alpha1/configuration.go new file mode 100644 index 0000000000..9f6a593e24 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/listers/serving/v1alpha1/configuration.go @@ -0,0 +1,94 @@ +/* +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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ConfigurationLister helps list Configurations. +type ConfigurationLister interface { + // List lists all Configurations in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.Configuration, err error) + // Configurations returns an object that can list and get Configurations. + Configurations(namespace string) ConfigurationNamespaceLister + ConfigurationListerExpansion +} + +// configurationLister implements the ConfigurationLister interface. +type configurationLister struct { + indexer cache.Indexer +} + +// NewConfigurationLister returns a new ConfigurationLister. +func NewConfigurationLister(indexer cache.Indexer) ConfigurationLister { + return &configurationLister{indexer: indexer} +} + +// List lists all Configurations in the indexer. +func (s *configurationLister) List(selector labels.Selector) (ret []*v1alpha1.Configuration, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Configuration)) + }) + return ret, err +} + +// Configurations returns an object that can list and get Configurations. +func (s *configurationLister) Configurations(namespace string) ConfigurationNamespaceLister { + return configurationNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ConfigurationNamespaceLister helps list and get Configurations. +type ConfigurationNamespaceLister interface { + // List lists all Configurations in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.Configuration, err error) + // Get retrieves the Configuration from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.Configuration, error) + ConfigurationNamespaceListerExpansion +} + +// configurationNamespaceLister implements the ConfigurationNamespaceLister +// interface. +type configurationNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Configurations in the indexer for a given namespace. +func (s configurationNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Configuration, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Configuration)) + }) + return ret, err +} + +// Get retrieves the Configuration from the indexer for a given namespace and name. +func (s configurationNamespaceLister) Get(name string) (*v1alpha1.Configuration, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("configuration"), name) + } + return obj.(*v1alpha1.Configuration), nil +} diff --git a/vendor/github.com/knative/serving/pkg/client/listers/serving/v1alpha1/expansion_generated.go b/vendor/github.com/knative/serving/pkg/client/listers/serving/v1alpha1/expansion_generated.go new file mode 100644 index 0000000000..ab65259117 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/listers/serving/v1alpha1/expansion_generated.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. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +// ConfigurationListerExpansion allows custom methods to be added to +// ConfigurationLister. +type ConfigurationListerExpansion interface{} + +// ConfigurationNamespaceListerExpansion allows custom methods to be added to +// ConfigurationNamespaceLister. +type ConfigurationNamespaceListerExpansion interface{} + +// RevisionListerExpansion allows custom methods to be added to +// RevisionLister. +type RevisionListerExpansion interface{} + +// RevisionNamespaceListerExpansion allows custom methods to be added to +// RevisionNamespaceLister. +type RevisionNamespaceListerExpansion interface{} + +// RouteListerExpansion allows custom methods to be added to +// RouteLister. +type RouteListerExpansion interface{} + +// RouteNamespaceListerExpansion allows custom methods to be added to +// RouteNamespaceLister. +type RouteNamespaceListerExpansion interface{} + +// ServiceListerExpansion allows custom methods to be added to +// ServiceLister. +type ServiceListerExpansion interface{} + +// ServiceNamespaceListerExpansion allows custom methods to be added to +// ServiceNamespaceLister. +type ServiceNamespaceListerExpansion interface{} diff --git a/vendor/github.com/knative/serving/pkg/client/listers/serving/v1alpha1/revision.go b/vendor/github.com/knative/serving/pkg/client/listers/serving/v1alpha1/revision.go new file mode 100644 index 0000000000..8a8be30fa7 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/listers/serving/v1alpha1/revision.go @@ -0,0 +1,94 @@ +/* +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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// RevisionLister helps list Revisions. +type RevisionLister interface { + // List lists all Revisions in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.Revision, err error) + // Revisions returns an object that can list and get Revisions. + Revisions(namespace string) RevisionNamespaceLister + RevisionListerExpansion +} + +// revisionLister implements the RevisionLister interface. +type revisionLister struct { + indexer cache.Indexer +} + +// NewRevisionLister returns a new RevisionLister. +func NewRevisionLister(indexer cache.Indexer) RevisionLister { + return &revisionLister{indexer: indexer} +} + +// List lists all Revisions in the indexer. +func (s *revisionLister) List(selector labels.Selector) (ret []*v1alpha1.Revision, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Revision)) + }) + return ret, err +} + +// Revisions returns an object that can list and get Revisions. +func (s *revisionLister) Revisions(namespace string) RevisionNamespaceLister { + return revisionNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// RevisionNamespaceLister helps list and get Revisions. +type RevisionNamespaceLister interface { + // List lists all Revisions in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.Revision, err error) + // Get retrieves the Revision from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.Revision, error) + RevisionNamespaceListerExpansion +} + +// revisionNamespaceLister implements the RevisionNamespaceLister +// interface. +type revisionNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Revisions in the indexer for a given namespace. +func (s revisionNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Revision, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Revision)) + }) + return ret, err +} + +// Get retrieves the Revision from the indexer for a given namespace and name. +func (s revisionNamespaceLister) Get(name string) (*v1alpha1.Revision, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("revision"), name) + } + return obj.(*v1alpha1.Revision), nil +} diff --git a/vendor/github.com/knative/serving/pkg/client/listers/serving/v1alpha1/route.go b/vendor/github.com/knative/serving/pkg/client/listers/serving/v1alpha1/route.go new file mode 100644 index 0000000000..0baa0adf89 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/listers/serving/v1alpha1/route.go @@ -0,0 +1,94 @@ +/* +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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// RouteLister helps list Routes. +type RouteLister interface { + // List lists all Routes in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.Route, err error) + // Routes returns an object that can list and get Routes. + Routes(namespace string) RouteNamespaceLister + RouteListerExpansion +} + +// routeLister implements the RouteLister interface. +type routeLister struct { + indexer cache.Indexer +} + +// NewRouteLister returns a new RouteLister. +func NewRouteLister(indexer cache.Indexer) RouteLister { + return &routeLister{indexer: indexer} +} + +// List lists all Routes in the indexer. +func (s *routeLister) List(selector labels.Selector) (ret []*v1alpha1.Route, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Route)) + }) + return ret, err +} + +// Routes returns an object that can list and get Routes. +func (s *routeLister) Routes(namespace string) RouteNamespaceLister { + return routeNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// RouteNamespaceLister helps list and get Routes. +type RouteNamespaceLister interface { + // List lists all Routes in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.Route, err error) + // Get retrieves the Route from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.Route, error) + RouteNamespaceListerExpansion +} + +// routeNamespaceLister implements the RouteNamespaceLister +// interface. +type routeNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Routes in the indexer for a given namespace. +func (s routeNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Route, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Route)) + }) + return ret, err +} + +// Get retrieves the Route from the indexer for a given namespace and name. +func (s routeNamespaceLister) Get(name string) (*v1alpha1.Route, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("route"), name) + } + return obj.(*v1alpha1.Route), nil +} diff --git a/vendor/github.com/knative/serving/pkg/client/listers/serving/v1alpha1/service.go b/vendor/github.com/knative/serving/pkg/client/listers/serving/v1alpha1/service.go new file mode 100644 index 0000000000..5c31998bb0 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/listers/serving/v1alpha1/service.go @@ -0,0 +1,94 @@ +/* +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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ServiceLister helps list Services. +type ServiceLister interface { + // List lists all Services in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.Service, err error) + // Services returns an object that can list and get Services. + Services(namespace string) ServiceNamespaceLister + ServiceListerExpansion +} + +// serviceLister implements the ServiceLister interface. +type serviceLister struct { + indexer cache.Indexer +} + +// NewServiceLister returns a new ServiceLister. +func NewServiceLister(indexer cache.Indexer) ServiceLister { + return &serviceLister{indexer: indexer} +} + +// List lists all Services in the indexer. +func (s *serviceLister) List(selector labels.Selector) (ret []*v1alpha1.Service, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Service)) + }) + return ret, err +} + +// Services returns an object that can list and get Services. +func (s *serviceLister) Services(namespace string) ServiceNamespaceLister { + return serviceNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ServiceNamespaceLister helps list and get Services. +type ServiceNamespaceLister interface { + // List lists all Services in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.Service, err error) + // Get retrieves the Service from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.Service, error) + ServiceNamespaceListerExpansion +} + +// serviceNamespaceLister implements the ServiceNamespaceLister +// interface. +type serviceNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Services in the indexer for a given namespace. +func (s serviceNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Service, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Service)) + }) + return ret, err +} + +// Get retrieves the Service from the indexer for a given namespace and name. +func (s serviceNamespaceLister) Get(name string) (*v1alpha1.Service, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("service"), name) + } + return obj.(*v1alpha1.Service), nil +} diff --git a/vendor/github.com/knative/serving/pkg/client/listers/serving/v1beta1/configuration.go b/vendor/github.com/knative/serving/pkg/client/listers/serving/v1beta1/configuration.go new file mode 100644 index 0000000000..fb5f5591de --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/listers/serving/v1beta1/configuration.go @@ -0,0 +1,94 @@ +/* +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 lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ConfigurationLister helps list Configurations. +type ConfigurationLister interface { + // List lists all Configurations in the indexer. + List(selector labels.Selector) (ret []*v1beta1.Configuration, err error) + // Configurations returns an object that can list and get Configurations. + Configurations(namespace string) ConfigurationNamespaceLister + ConfigurationListerExpansion +} + +// configurationLister implements the ConfigurationLister interface. +type configurationLister struct { + indexer cache.Indexer +} + +// NewConfigurationLister returns a new ConfigurationLister. +func NewConfigurationLister(indexer cache.Indexer) ConfigurationLister { + return &configurationLister{indexer: indexer} +} + +// List lists all Configurations in the indexer. +func (s *configurationLister) List(selector labels.Selector) (ret []*v1beta1.Configuration, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.Configuration)) + }) + return ret, err +} + +// Configurations returns an object that can list and get Configurations. +func (s *configurationLister) Configurations(namespace string) ConfigurationNamespaceLister { + return configurationNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ConfigurationNamespaceLister helps list and get Configurations. +type ConfigurationNamespaceLister interface { + // List lists all Configurations in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1beta1.Configuration, err error) + // Get retrieves the Configuration from the indexer for a given namespace and name. + Get(name string) (*v1beta1.Configuration, error) + ConfigurationNamespaceListerExpansion +} + +// configurationNamespaceLister implements the ConfigurationNamespaceLister +// interface. +type configurationNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Configurations in the indexer for a given namespace. +func (s configurationNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Configuration, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.Configuration)) + }) + return ret, err +} + +// Get retrieves the Configuration from the indexer for a given namespace and name. +func (s configurationNamespaceLister) Get(name string) (*v1beta1.Configuration, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("configuration"), name) + } + return obj.(*v1beta1.Configuration), nil +} diff --git a/vendor/github.com/knative/serving/pkg/client/listers/serving/v1beta1/expansion_generated.go b/vendor/github.com/knative/serving/pkg/client/listers/serving/v1beta1/expansion_generated.go new file mode 100644 index 0000000000..acaa8f21c3 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/listers/serving/v1beta1/expansion_generated.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. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta1 + +// ConfigurationListerExpansion allows custom methods to be added to +// ConfigurationLister. +type ConfigurationListerExpansion interface{} + +// ConfigurationNamespaceListerExpansion allows custom methods to be added to +// ConfigurationNamespaceLister. +type ConfigurationNamespaceListerExpansion interface{} + +// RevisionListerExpansion allows custom methods to be added to +// RevisionLister. +type RevisionListerExpansion interface{} + +// RevisionNamespaceListerExpansion allows custom methods to be added to +// RevisionNamespaceLister. +type RevisionNamespaceListerExpansion interface{} + +// RouteListerExpansion allows custom methods to be added to +// RouteLister. +type RouteListerExpansion interface{} + +// RouteNamespaceListerExpansion allows custom methods to be added to +// RouteNamespaceLister. +type RouteNamespaceListerExpansion interface{} + +// ServiceListerExpansion allows custom methods to be added to +// ServiceLister. +type ServiceListerExpansion interface{} + +// ServiceNamespaceListerExpansion allows custom methods to be added to +// ServiceNamespaceLister. +type ServiceNamespaceListerExpansion interface{} diff --git a/vendor/github.com/knative/serving/pkg/client/listers/serving/v1beta1/revision.go b/vendor/github.com/knative/serving/pkg/client/listers/serving/v1beta1/revision.go new file mode 100644 index 0000000000..666ac8ed13 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/listers/serving/v1beta1/revision.go @@ -0,0 +1,94 @@ +/* +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 lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// RevisionLister helps list Revisions. +type RevisionLister interface { + // List lists all Revisions in the indexer. + List(selector labels.Selector) (ret []*v1beta1.Revision, err error) + // Revisions returns an object that can list and get Revisions. + Revisions(namespace string) RevisionNamespaceLister + RevisionListerExpansion +} + +// revisionLister implements the RevisionLister interface. +type revisionLister struct { + indexer cache.Indexer +} + +// NewRevisionLister returns a new RevisionLister. +func NewRevisionLister(indexer cache.Indexer) RevisionLister { + return &revisionLister{indexer: indexer} +} + +// List lists all Revisions in the indexer. +func (s *revisionLister) List(selector labels.Selector) (ret []*v1beta1.Revision, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.Revision)) + }) + return ret, err +} + +// Revisions returns an object that can list and get Revisions. +func (s *revisionLister) Revisions(namespace string) RevisionNamespaceLister { + return revisionNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// RevisionNamespaceLister helps list and get Revisions. +type RevisionNamespaceLister interface { + // List lists all Revisions in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1beta1.Revision, err error) + // Get retrieves the Revision from the indexer for a given namespace and name. + Get(name string) (*v1beta1.Revision, error) + RevisionNamespaceListerExpansion +} + +// revisionNamespaceLister implements the RevisionNamespaceLister +// interface. +type revisionNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Revisions in the indexer for a given namespace. +func (s revisionNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Revision, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.Revision)) + }) + return ret, err +} + +// Get retrieves the Revision from the indexer for a given namespace and name. +func (s revisionNamespaceLister) Get(name string) (*v1beta1.Revision, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("revision"), name) + } + return obj.(*v1beta1.Revision), nil +} diff --git a/vendor/github.com/knative/serving/pkg/client/listers/serving/v1beta1/route.go b/vendor/github.com/knative/serving/pkg/client/listers/serving/v1beta1/route.go new file mode 100644 index 0000000000..489b710cfe --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/listers/serving/v1beta1/route.go @@ -0,0 +1,94 @@ +/* +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 lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// RouteLister helps list Routes. +type RouteLister interface { + // List lists all Routes in the indexer. + List(selector labels.Selector) (ret []*v1beta1.Route, err error) + // Routes returns an object that can list and get Routes. + Routes(namespace string) RouteNamespaceLister + RouteListerExpansion +} + +// routeLister implements the RouteLister interface. +type routeLister struct { + indexer cache.Indexer +} + +// NewRouteLister returns a new RouteLister. +func NewRouteLister(indexer cache.Indexer) RouteLister { + return &routeLister{indexer: indexer} +} + +// List lists all Routes in the indexer. +func (s *routeLister) List(selector labels.Selector) (ret []*v1beta1.Route, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.Route)) + }) + return ret, err +} + +// Routes returns an object that can list and get Routes. +func (s *routeLister) Routes(namespace string) RouteNamespaceLister { + return routeNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// RouteNamespaceLister helps list and get Routes. +type RouteNamespaceLister interface { + // List lists all Routes in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1beta1.Route, err error) + // Get retrieves the Route from the indexer for a given namespace and name. + Get(name string) (*v1beta1.Route, error) + RouteNamespaceListerExpansion +} + +// routeNamespaceLister implements the RouteNamespaceLister +// interface. +type routeNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Routes in the indexer for a given namespace. +func (s routeNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Route, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.Route)) + }) + return ret, err +} + +// Get retrieves the Route from the indexer for a given namespace and name. +func (s routeNamespaceLister) Get(name string) (*v1beta1.Route, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("route"), name) + } + return obj.(*v1beta1.Route), nil +} diff --git a/vendor/github.com/knative/serving/pkg/client/listers/serving/v1beta1/service.go b/vendor/github.com/knative/serving/pkg/client/listers/serving/v1beta1/service.go new file mode 100644 index 0000000000..5b7791920b --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/listers/serving/v1beta1/service.go @@ -0,0 +1,94 @@ +/* +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 lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/knative/serving/pkg/apis/serving/v1beta1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ServiceLister helps list Services. +type ServiceLister interface { + // List lists all Services in the indexer. + List(selector labels.Selector) (ret []*v1beta1.Service, err error) + // Services returns an object that can list and get Services. + Services(namespace string) ServiceNamespaceLister + ServiceListerExpansion +} + +// serviceLister implements the ServiceLister interface. +type serviceLister struct { + indexer cache.Indexer +} + +// NewServiceLister returns a new ServiceLister. +func NewServiceLister(indexer cache.Indexer) ServiceLister { + return &serviceLister{indexer: indexer} +} + +// List lists all Services in the indexer. +func (s *serviceLister) List(selector labels.Selector) (ret []*v1beta1.Service, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.Service)) + }) + return ret, err +} + +// Services returns an object that can list and get Services. +func (s *serviceLister) Services(namespace string) ServiceNamespaceLister { + return serviceNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ServiceNamespaceLister helps list and get Services. +type ServiceNamespaceLister interface { + // List lists all Services in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1beta1.Service, err error) + // Get retrieves the Service from the indexer for a given namespace and name. + Get(name string) (*v1beta1.Service, error) + ServiceNamespaceListerExpansion +} + +// serviceNamespaceLister implements the ServiceNamespaceLister +// interface. +type serviceNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Services in the indexer for a given namespace. +func (s serviceNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Service, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.Service)) + }) + return ret, err +} + +// Get retrieves the Service from the indexer for a given namespace and name. +func (s serviceNamespaceLister) Get(name string) (*v1beta1.Service, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("service"), name) + } + return obj.(*v1beta1.Service), nil +} 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/gc/testdata/config-gc.yaml b/vendor/github.com/knative/serving/pkg/gc/testdata/config-gc.yaml new file mode 120000 index 0000000000..f6ee95a326 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/gc/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/logging/testdata/config-logging.yaml b/vendor/github.com/knative/serving/pkg/logging/testdata/config-logging.yaml new file mode 120000 index 0000000000..581e985f9c --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/logging/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/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/network/testdata/config-network.yaml b/vendor/github.com/knative/serving/pkg/network/testdata/config-network.yaml new file mode 120000 index 0000000000..e316b0466b --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/network/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/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/test/config/100-istio-default-domain.yaml b/vendor/github.com/knative/serving/test/config/100-istio-default-domain.yaml new file mode 120000 index 0000000000..7d6227ed31 --- /dev/null +++ b/vendor/github.com/knative/serving/test/config/100-istio-default-domain.yaml @@ -0,0 +1 @@ +../../config/post-install/100-istio-default-domain.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/third_party/config/monitoring/logging/elasticsearch/LICENSE b/vendor/github.com/knative/serving/third_party/config/monitoring/logging/elasticsearch/LICENSE new file mode 100644 index 0000000000..8dada3edaf --- /dev/null +++ b/vendor/github.com/knative/serving/third_party/config/monitoring/logging/elasticsearch/LICENSE @@ -0,0 +1,201 @@ + 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/serving/third_party/config/monitoring/metrics/prometheus/kubernetes/LICENSE b/vendor/github.com/knative/serving/third_party/config/monitoring/metrics/prometheus/kubernetes/LICENSE new file mode 100644 index 0000000000..8dada3edaf --- /dev/null +++ b/vendor/github.com/knative/serving/third_party/config/monitoring/metrics/prometheus/kubernetes/LICENSE @@ -0,0 +1,201 @@ + 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/serving/third_party/config/monitoring/metrics/prometheus/prometheus-operator/LICENSE b/vendor/github.com/knative/serving/third_party/config/monitoring/metrics/prometheus/prometheus-operator/LICENSE new file mode 100644 index 0000000000..e06d208186 --- /dev/null +++ b/vendor/github.com/knative/serving/third_party/config/monitoring/metrics/prometheus/prometheus-operator/LICENSE @@ -0,0 +1,202 @@ +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/serving/third_party/config/monitoring/metrics/prometheus/prometheus-operator/NOTICE b/vendor/github.com/knative/serving/third_party/config/monitoring/metrics/prometheus/prometheus-operator/NOTICE new file mode 100644 index 0000000000..e520005cdd --- /dev/null +++ b/vendor/github.com/knative/serving/third_party/config/monitoring/metrics/prometheus/prometheus-operator/NOTICE @@ -0,0 +1,5 @@ +CoreOS Project +Copyright 2015 CoreOS, Inc + +This product includes software developed at CoreOS, Inc. +(http://www.coreos.com/). 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