diff --git a/Gopkg.lock b/Gopkg.lock index 5677e8cc498..372db7175db 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -250,6 +250,16 @@ revision = "ca39e5af3ece67bbcda3d0f4f56a8e24d9f2dad4" version = "1.1.3" +[[projects]] + digest = "1:3b8adce8bbe5865d7155ddfadbd063915265f04a22ab47a3f5cddd7b32333d1e" + name = "github.com/knative/build" + packages = [ + "pkg/apis/build", + "pkg/apis/build/v1alpha1", + ] + pruneopts = "NUT" + revision = "5c1d8c8469d1ed34b2aecf4c2305b3a57fff2ee3" + [[projects]] digest = "1:c19f87a341b72c2121456397006116f9496006d62722315e43940e7d42744672" name = "github.com/knative/pkg" @@ -272,6 +282,23 @@ pruneopts = "NUT" revision = "a088fee6227f7c6842ce7f7406cb75af8a6e0643" +[[projects]] + digest = "1:63f3974f3afe3dc5b6a115c0d53b0897cd01be6880c4bf5d014fc69a95db6ed1" + name = "github.com/knative/serving" + packages = [ + "pkg/apis/istio", + "pkg/apis/istio/v1alpha3", + "pkg/apis/serving", + "pkg/apis/serving/v1alpha1", + "pkg/client/clientset/versioned", + "pkg/client/clientset/versioned/scheme", + "pkg/client/clientset/versioned/typed/istio/v1alpha3", + "pkg/client/clientset/versioned/typed/serving/v1alpha1", + ] + pruneopts = "NUT" + revision = "091d4519394bb7bee5ae4d3ab764c3f4f6f2a51b" + version = "v0.1.0" + [[projects]] branch = "master" digest = "1:0e9bfc47ab9941ecc3344e580baca5deb4091177e84dd9773b48b38ec26b93d5" @@ -1001,6 +1028,8 @@ "github.com/knative/pkg/configmap", "github.com/knative/pkg/logging", "github.com/knative/pkg/logging/logkey", + "github.com/knative/serving/pkg/apis/serving/v1alpha1", + "github.com/knative/serving/pkg/client/clientset/versioned", "github.com/mattbaird/jsonpatch", "github.com/prometheus/client_golang/prometheus/promhttp", "go.uber.org/zap", diff --git a/pkg/sources/github/eventsource.yaml b/pkg/sources/github/eventsource.yaml index 7f4f83113e8..ee8e685bfb2 100644 --- a/pkg/sources/github/eventsource.yaml +++ b/pkg/sources/github/eventsource.yaml @@ -21,3 +21,5 @@ spec: type: github source: github image: github.com/knative/eventing/pkg/sources/github + parameters: + image: github.com/knative/eventing/pkg/sources/github/receive_adapter diff --git a/pkg/sources/github/feedlet.go b/pkg/sources/github/feedlet.go new file mode 100644 index 00000000000..f4cbcfa83be --- /dev/null +++ b/pkg/sources/github/feedlet.go @@ -0,0 +1,461 @@ +/* +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 main + +import ( + "context" + "flag" + "fmt" + "strconv" + "strings" + + apierrs "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/knative/eventing/pkg/sources" + servingclientset "github.com/knative/serving/pkg/client/clientset/versioned" + "golang.org/x/oauth2" + + "encoding/base64" + "encoding/json" + "os" + + ghclient "github.com/google/go-github/github" + "github.com/knative/eventing/pkg/sources/github/resources" + "github.com/knative/serving/pkg/apis/serving/v1alpha1" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/tools/clientcmd" + "log" + "time" +) + +/* +A Feedlet is a container to create or destroy event source bindings. +The Feedlet is run as a Job by the Feed controller. +*/ + +const ( + webhookIDKey = "id" + + // property bag keys + accessTokenKey = "accessToken" + secretTokenKey = "secretToken" + + // receiveAdapterSuffix is appended to the name of the service running the Receive Adapter + receiveAdapterSuffix = "rcvadptr" + + // watchTimeout is the timeout that the feedlet will wait for the Receiver Adapter to get a domain name. + watchTimeout = 5 * time.Minute + + // secretNameKey is the name of the secret that contains the GitHub credentials. + secretNameKey = "secretName" + // secretKeyKey is the name of key inside the secret that contains the GitHub credentials. + secretKeyKey = "secretKey" +) + +type githubEventSource struct { + // kubeclientset is a standard kubernetes clientset + kubeclientset kubernetes.Interface + // servingclientset is a clientset for serving API groups + servingclientset servingclientset.Interface + // namespace where the feed is created + feedNamespace string + // serviceAccount that the container runs as. Launches Receive Adapter with the + // same Service Account + feedServiceAccountName string + // image for the receive adapter + image string +} + +func NewGithubEventSource(kubeclientset kubernetes.Interface, servingclientset servingclientset.Interface, feedNamespace, feedServiceAccountName, image string) sources.EventSource { + return &githubEventSource{ + kubeclientset: kubeclientset, + servingclientset: servingclientset, + feedNamespace: feedNamespace, + feedServiceAccountName: feedServiceAccountName, + image: image, + } +} + +// TODO(n3wscott): Add a timeout for StopFeed. +func (t *githubEventSource) StopFeed(trigger sources.EventTrigger, feedContext sources.FeedContext) error { + log.Printf("stopping github webhook feed with context %+v", feedContext) + + return t.deleteWebhook(trigger, feedContext) +} + +// TODO(n3wscott): Add a timeout for StartFeed. +func (t *githubEventSource) StartFeed(trigger sources.EventTrigger, target string) (*sources.FeedContext, error) { + + // Create the Receive Adapter Service that will accept incoming requests from GitHub. + service, err := t.createReceiveAdapter(trigger, target) + if err != nil { + return nil, fmt.Errorf("failed to create service: %v", err) + } + + log.Printf("created Service: %+v", service) + + // Start watching the Receive Adapter Service for it's updated domain name. This will be passed + // to GitHub as part of the webhook registration. + receiveAdapterDomain, err := t.waitForServiceDomain(service.GetObjectMeta().GetName()) + if err != nil { + return nil, fmt.Errorf("failed to get the service: %v", err) + } + + return t.createWebhook(trigger, service.GetObjectMeta().GetName(), receiveAdapterDomain) +} + +func (t *githubEventSource) waitForServiceDomain(serviceName string) (string, error) { + sc := t.servingclientset.ServingV1alpha1().Services(t.feedNamespace) + + wt := int64(watchTimeout / time.Second) + opts := metav1.ListOptions{ + TypeMeta: metav1.TypeMeta{ + Kind: "Service", + APIVersion: "v1alpha1", + }, + FieldSelector: fmt.Sprintf("metadata.name=%s", serviceName), + LabelSelector: "receive-adapter=github", + Watch: true, + TimeoutSeconds: &wt, + } + + w, err := sc.Watch(opts) + if err != nil { + log.Printf("[%s] failed to create watch: %v", serviceName, err) + return "", err + } + + eventChan := w.ResultChan() + for { + event, more := <-eventChan + if !more { + return "", fmt.Errorf("[%s] watch channel closed, failed to observe Service domain update", serviceName) + } + switch event.Type { + case watch.Error: + return "", fmt.Errorf("[%s] watched Service error", serviceName) + case watch.Deleted: + return "", fmt.Errorf("[%s] watched Service deleted", serviceName) + case watch.Added, watch.Modified: + service, ok := event.Object.(*v1alpha1.Service) + if !ok { + log.Printf("[%s] expected a Service object, but got %T", serviceName, event.Object) + continue + } + if service.Name != serviceName { + log.Printf("Error: [%s] expected a service.Name %q to match expected serviceName %q", + serviceName, service.Name, serviceName) + continue + } + status := service.Status + if status.Domain != "" { + w.Stop() + return status.Domain, nil + } + + } + } +} + +func receiveAdapterName(trigger sources.EventTrigger) string { + // TODO(n3wscott): this needs more UUID on the end of it? + // TODO(n3wscott): Currently this needs to be deterministic so StopFeed can find the receive adapter. If the receive + // adapter name were added to the feed context, then this could be a uuid. There is an issue where where we will + // get blocked by a pre-existing conflicting name and we are not able to unblock or regenerate without deleting + // the feed and trying it again. + serviceName := fmt.Sprintf("%s-%s-%s", "github", trigger.Resource, receiveAdapterSuffix) + serviceName = strings.Replace(serviceName, "/", "-", -1) + serviceName = strings.Replace(serviceName, ".", "-", -1) + serviceName = strings.ToLower(serviceName) + return serviceName +} + +func (t *githubEventSource) createReceiveAdapter(trigger sources.EventTrigger, target string) (*v1alpha1.Service, error) { + sc := t.servingclientset.ServingV1alpha1().Services(t.feedNamespace) + + serviceName := receiveAdapterName(trigger) + + // First, check if service exists already. + if sc, err := sc.Get(serviceName, metav1.GetOptions{}); err != nil { + if !apierrs.IsNotFound(err) { + return nil, fmt.Errorf("service.Get for %q failed: %v", serviceName, err) + } + log.Printf("service %q doesn't exist, creating", serviceName) + } else { + log.Printf("found existing service %q", serviceName) + // Don't try again. + return sc, nil + } + + secretName, err := stringFrom(trigger.Parameters, secretNameKey) + if err != nil { + return nil, fmt.Errorf("failed to get secret name from trigger parameters: %v", err) + } + + secretKey, err := stringFrom(trigger.Parameters, secretKeyKey) + if err != nil { + return nil, fmt.Errorf("failed to get secret key from trigger parameters: %v", err) + } + + // TODO(n3wscott): if we add an owner reference here we can remove the delete service call on stopFeed + service := resources.MakeService(t.feedNamespace, serviceName, t.image, t.feedServiceAccountName, target, secretName, secretKey) + service, err = sc.Create(service) + if err != nil { + return nil, fmt.Errorf("failed to create service: %s", err) + } + + return service, nil +} + +func (t *githubEventSource) deleteReceiveAdapter(namespace string, serviceName string) error { + sc := t.servingclientset.ServingV1alpha1().Services(t.feedNamespace) + + // First, check if deployment exists already. + if _, err := sc.Get(serviceName, metav1.GetOptions{}); err != nil { + if !apierrs.IsNotFound(err) { + return fmt.Errorf("services.Get for %q failed: %v", serviceName, err) + } + log.Printf("service %q already deleted", serviceName) + // Don't try again. + return nil + } + + return sc.Delete(serviceName, &metav1.DeleteOptions{}) +} + +func (t *githubEventSource) deleteWebhook(trigger sources.EventTrigger, feedContext sources.FeedContext) error { + serviceName := receiveAdapterName(trigger) + err := t.deleteReceiveAdapter(t.feedNamespace, serviceName) + if err != nil { + log.Printf("Error: Failed to delete the ReceiveAdapter \"%s/%s\": %v", t.feedNamespace, serviceName, err) + // Continue deleting the webhook. + } + + owner, repo, err := parseOwnerRepoFrom(trigger.Resource) + if err != nil { + log.Printf("Error: Failed to parse owner and repo from tigger.resource: %v; bailing...", err) + // Don't try again. + return nil + } + + webhookID, err := webhookIDFrom(feedContext) + if err != nil { + log.Printf("Error: Failed to get webhook id from context: %v; bailing...", err) + // Don't try again. + return nil + } + + accessToken, err := stringFrom(trigger.Parameters, accessTokenKey) + if err != nil { + log.Printf("Error: Failed to get access token from trigger parameters: %v; bailing...", err) + // Don't try again. + return nil + } + + ctx := context.Background() + ts := oauth2.StaticTokenSource( + &oauth2.Token{AccessToken: accessToken}, + ) + tc := oauth2.NewClient(ctx, ts) + client := ghclient.NewClient(tc) + + _, err = client.Repositories.DeleteHook(ctx, owner, repo, webhookID) + if err != nil { + // Note: errResp.Message == "Not Found" is not ideal, but the gh errors are not very easy to parse. + // It would be better to look into the errResp.Errors[] and confirm that the issue is "not found". + if errResp, ok := err.(*ghclient.ErrorResponse); ok && errResp.Message == "Not Found" { + // If the webhook doesn't exist, nothing to do + log.Printf("webhook doesn't exist, nothing to delete") + return nil + } + return fmt.Errorf("failed to delete the webhook: %v", err) + } + log.Printf("deleted webhook \"%d\" successfully", webhookID) + return nil +} + +func (t *githubEventSource) createWebhook(trigger sources.EventTrigger, name, domain string) (*sources.FeedContext, error) { + + log.Printf("creating GitHub webhook") + + owner, repo, err := parseOwnerRepoFrom(trigger.Resource) + if err != nil { + return nil, err + } + + events, err := parseEventsFrom(trigger.EventType) + if err != nil { + return nil, err + } + + accessToken, err := stringFrom(trigger.Parameters, accessTokenKey) + if err != nil { + return nil, fmt.Errorf("failed to get access token from trigger parameters: %v", err) + } + + secretToken, err := stringFrom(trigger.Parameters, secretTokenKey) + if err != nil { + return nil, fmt.Errorf("failed to get secret token from trigger parameters: %v", err) + } + + ctx := context.Background() + ts := oauth2.StaticTokenSource( + &oauth2.Token{AccessToken: accessToken}, + ) + tc := oauth2.NewClient(ctx, ts) + + client := ghclient.NewClient(tc) + active := true + config := make(map[string]interface{}) + config["url"] = fmt.Sprintf("http://%s", domain) + config["content_type"] = "json" + config["secret"] = secretToken + hook := ghclient.Hook{ + Name: &name, + URL: &domain, + Events: events, + Active: &active, + Config: config, + } + + h, r, err := client.Repositories.CreateHook(ctx, owner, repo, &hook) + if err != nil { + log.Printf("create webhook error response:\n%+v", r) + return nil, fmt.Errorf("failed to create the webhook: %v", err) + } + log.Printf("created hook: %+v", h) + + return &sources.FeedContext{ + Context: map[string]interface{}{ + webhookIDKey: strconv.FormatInt(*h.ID, 10), + }}, nil +} + +type parameters struct { + Image string `json:"image,omitempty"` +} + +// The main entry point for the GitHub Feedlet +func main() { + flag.Parse() + + log.Printf("GitHub Feedlet starting...") + + decodedParameters, _ := base64.StdEncoding.DecodeString(os.Getenv(sources.EventSourceParametersKey)) + + var p parameters + err := json.Unmarshal(decodedParameters, &p) + if err != nil { + log.Printf("Fatal: can not unmarshal %q : %v", decodedParameters, err) + os.Exit(1) + } + + feedNamespace := os.Getenv(sources.FeedNamespaceKey) + if len(feedNamespace) != 0 { + log.Printf("Fatal: feed namespace not provided, expected envvar %q to be set", sources.FeedNamespaceKey) + os.Exit(1) + } + + feedServiceAccountName := os.Getenv(sources.FeedServiceAccountKey) + if len(feedServiceAccountName) != 0 { + log.Printf("Fatal: feed service account not provided, expected envvar %q to be set", sources.FeedServiceAccountKey) + os.Exit(1) + } + + cfg, err := clientcmd.BuildConfigFromFlags("", "") + if err != nil { + log.Printf("Error: error building kubeconfig: %v", err) + } + + kubeClient, err := kubernetes.NewForConfig(cfg) + if err != nil { + log.Printf("Error: error building kubernetes clientset: %v", err) + } + + servingClient, err := servingclientset.NewForConfig(cfg) + if err != nil { + log.Printf("Error: error building serving clientset: %v", err) + } + + sources.RunEventSource(NewGithubEventSource(kubeClient, servingClient, feedNamespace, feedServiceAccountName, p.Image)) + log.Printf("GitHub Feedlet finsihed") +} + +func webhookIDFrom(feedContext sources.FeedContext) (int64, error) { + webhookID, err := stringFrom(feedContext.Context, webhookIDKey) + if err != nil { + return 0, err + + } + id, err := int64From(webhookID) + if err != nil { + return 0, fmt.Errorf("failed to convert webhook %q to int64 : %v", webhookID, err) + } + return id, nil +} + +func int64From(strNum string) (int64, error) { + return strconv.ParseInt(strNum, 10, 64) +} + +// TODO(n3wscott): Move this to knative/pkg/context. +func stringFrom(bag map[string]interface{}, key string) (string, error) { + // check to see if the key is in the bag. + if _, ok := bag[key]; !ok { + return "", fmt.Errorf("%s not found", key) + } + value, ok := bag[key].(string) + if !ok { + return "", fmt.Errorf("value for %s was not a valid string", key) + } + return value, nil +} + +func parseOwnerRepoFrom(resource string) (string, string, error) { + if len(resource) == 0 { + return "", "", fmt.Errorf("resouce is empty") + } + components := strings.Split(resource, "/") + if len(components) != 2 { + return "", "", fmt.Errorf("resouce is malformatted, expected 'owner/repo' but found %q", resource) + } + owner := components[0] + if len(owner) == 0 { + return "", "", fmt.Errorf("owner is empty, expected 'owner/repo' but found %q", resource) + } + repo := components[1] + if len(repo) == 0 { + return "", "", fmt.Errorf("repo is empty, expected 'owner/repo' but found %q", resource) + } + + return owner, repo, nil +} + +func parseEventsFrom(eventType string) ([]string, error) { + if len(eventType) == 0 { + return []string(nil), fmt.Errorf("event type is empty") + } + switch eventType { + case "pullrequest": + return []string{"pull_request"}, nil + // TODO: Add more supported event types. + default: + return []string(nil), fmt.Errorf("event type is unknown: %s", eventType) + } +} diff --git a/sample/github/route.yaml b/pkg/sources/github/github-serviceentry.yaml similarity index 74% rename from sample/github/route.yaml rename to pkg/sources/github/github-serviceentry.yaml index a8cb0f26dd4..9c9576aae7e 100644 --- a/sample/github/route.yaml +++ b/pkg/sources/github/github-serviceentry.yaml @@ -11,13 +11,15 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - -apiVersion: serving.knative.dev/v1alpha1 -kind: Route +apiVersion: networking.istio.io/v1alpha3 +kind: ServiceEntry metadata: - name: git-webhook - namespace: default + name: github-receive-adapter-ext spec: - traffic: - - configurationName: git-webhook - percent: 100 + hosts: + - "*.github.com" + ports: + - number: 443 + name: https + protocol: HTTPS + location: MESH_EXTERNAL diff --git a/pkg/sources/github/github.go b/pkg/sources/github/github.go deleted file mode 100644 index a3a9c3d7ffc..00000000000 --- a/pkg/sources/github/github.go +++ /dev/null @@ -1,139 +0,0 @@ -/* -Copyright 2018 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package main - -import ( - "context" - "flag" - "fmt" - "log" - "strconv" - "strings" - - "github.com/knative/eventing/pkg/sources" - "golang.org/x/oauth2" - - ghclient "github.com/google/go-github/github" -) - -const ( - webhookIDKey = "id" - ownerKey = "owner" - repoKey = "repo" - - // SuccessSynced is used as part of the Event 'reason' when a Feed is synced - SuccessSynced = "Synced" - - // MessageResourceSynced is the message used for an Event fired when a Feed - // is synced successfully - MessageResourceSynced = "Feed synced successfully" -) - -type GithubEventSource struct { -} - -func NewGithubEventSource() sources.EventSource { - return &GithubEventSource{} -} - -func (t *GithubEventSource) StopFeed(trigger sources.EventTrigger, feedContext sources.FeedContext) error { - log.Printf("Stopping github webhook feed with context %+v", feedContext) - - components := strings.Split(trigger.Resource, "/") - owner := components[0] - repo := components[1] - - if _, ok := feedContext.Context[webhookIDKey]; !ok { - // there's no webhook id, nothing to do. - log.Printf("No Webhook ID Found, bailing...") - return nil - } - webhookID := feedContext.Context[webhookIDKey].(string) - - ctx := context.Background() - ts := oauth2.StaticTokenSource( - &oauth2.Token{AccessToken: trigger.Parameters["accessToken"].(string)}, - ) - tc := oauth2.NewClient(ctx, ts) - client := ghclient.NewClient(tc) - - id, err := strconv.ParseInt(webhookID, 10, 64) - if err != nil { - log.Printf("Failed to convert webhook %q to int64 : %s", webhookID, err) - return err - } - _, err = client.Repositories.DeleteHook(ctx, owner, repo, id) - if err != nil { - if errResp, ok := err.(*ghclient.ErrorResponse); ok { - // If the webhook doesn't exist, nothing to do - if errResp.Message == "Not Found" { - log.Printf("Webhook doesn't exist, nothing to delete.") - return nil - } - } - log.Printf("Failed to delete the webhook: %#v", err) - return err - } - log.Printf("Deleted webhook %q successfully", webhookID) - return nil -} - -func (t *GithubEventSource) StartFeed(trigger sources.EventTrigger, route string) (*sources.FeedContext, error) { - log.Printf("CREATING GITHUB WEBHOOK") - - ctx := context.Background() - ts := oauth2.StaticTokenSource( - &oauth2.Token{AccessToken: trigger.Parameters["accessToken"].(string)}, - ) - tc := oauth2.NewClient(ctx, ts) - - client := ghclient.NewClient(tc) - active := true - name := "web" - config := make(map[string]interface{}) - config["url"] = fmt.Sprintf("http://%s", route) - config["content_type"] = "json" - config["secret"] = trigger.Parameters["secretToken"].(string) - hook := ghclient.Hook{ - Name: &name, - URL: &route, - Events: []string{"pull_request"}, - Active: &active, - Config: config, - } - - components := strings.Split(trigger.Resource, "/") - owner := components[0] - repo := components[1] - h, _, err := client.Repositories.CreateHook(ctx, owner, repo, &hook) - if err != nil { - log.Printf("Failed to create the webhook: %s", err) - return nil, err - } - log.Printf("Created hook: %+v", h) - return &sources.FeedContext{ - Context: map[string]interface{}{ - webhookIDKey: strconv.FormatInt(*h.ID, 10), - }}, nil -} - -func main() { - flag.Parse() - - sources.RunEventSource(NewGithubEventSource()) - log.Printf("Done...") -} diff --git a/pkg/sources/github/receive_adapter/receive_adapter.go b/pkg/sources/github/receive_adapter/receive_adapter.go new file mode 100644 index 00000000000..7ff51036574 --- /dev/null +++ b/pkg/sources/github/receive_adapter/receive_adapter.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 + + 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 main + +import ( + "encoding/json" + "flag" + "fmt" + "os" + + webhooks "gopkg.in/go-playground/webhooks.v3" + "gopkg.in/go-playground/webhooks.v3/github" + + "bytes" + "io/ioutil" + "net/http" + + ghclient "github.com/google/go-github/github" + "log" +) + +const ( + // Target for messages + envTarget = "TARGET" + // Environment variable containing json credentials + envSecret = "GITHUB_SECRET" +) + +// GithubHandler holds necessary objects for communicating with the Github. +type GithubHandler struct { + client *ghclient.Client + target string +} + +type GithubSecrets struct { + AccessToken string `json:"accessToken"` + SecretToken string `json:"secretToken"` +} + +// HandlePullRequest is invoked whenever a PullRequest is modified (created, updated, etc.) +func (h *GithubHandler) HandlePullRequest(payload interface{}, header webhooks.Header) { + log.Print("Handling Pull Request") + pl := payload.(github.PullRequestPayload) + postMessage(h.target, &pl) +} + +func main() { + flag.Parse() + // set the logs to stderr so kube will see them. + flag.Lookup("logtostderr").Value.Set("true") + + target := os.Getenv(envTarget) + + log.Printf("Target is: %q", target) + + githubSecrets := os.Getenv(envSecret) + + var credentials GithubSecrets + err := json.Unmarshal([]byte(githubSecrets), &credentials) + if err != nil { + log.Fatalf("Failed to unmarshal credentials: %v", err) + return + } + + // Set up the auth for being able to talk to Github. + var tc *http.Client = nil + + client := ghclient.NewClient(tc) + + h := &GithubHandler{ + client: client, + target: target, + } + + hook := github.New(&github.Config{Secret: credentials.SecretToken}) + // TODO: GitHub has more than just Pull Request Events. This needs to + // handle them all? + hook.RegisterEvents(h.HandlePullRequest, github.PullRequestEvent) + + // TODO(n3wscott): Do we need to configure the PORT? + err = webhooks.Run(hook, ":8080", "/") + if err != nil { + log.Fatalf("Failed to run the webhook") + } +} + +func postMessage(target string, m *github.PullRequestPayload) error { + jsonStr, err := json.Marshal(m) + if err != nil { + log.Printf("Error: Failed to marshal the message: %+v : %v", m, err) + return err + } + + URL := fmt.Sprintf("http://%s/", target) + req, err := http.NewRequest("POST", URL, bytes.NewBuffer(jsonStr)) + if err != nil { + log.Printf("Error: Failed to create http request: %v", err) + return err + } + + req.Header.Set("Content-Type", "application/json") + client := &http.Client{} + resp, err := client.Do(req) + if err != nil { + log.Printf("Error: Failed to do POST: %v", err) + return err + } + defer resp.Body.Close() + log.Printf("Error: response Status: %s", resp.Status) + body, _ := ioutil.ReadAll(resp.Body) + log.Printf("Error: response Body: %s", string(body)) + return nil +} diff --git a/pkg/sources/github/resources/service.go b/pkg/sources/github/resources/service.go new file mode 100644 index 00000000000..23d1576b6bb --- /dev/null +++ b/pkg/sources/github/resources/service.go @@ -0,0 +1,68 @@ +/* +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 resources + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/knative/serving/pkg/apis/serving/v1alpha1" +) + +func MakeService(namespace, name, image, serviceAccount, target, githubSecret, githubSecretKey string) *v1alpha1.Service { + labels := map[string]string{ + "receive-adapter": "github", + } + return &v1alpha1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: namespace, + Labels: labels, + }, + Spec: v1alpha1.ServiceSpec{ + RunLatest: &v1alpha1.RunLatestType{ + Configuration: v1alpha1.ConfigurationSpec{ + RevisionTemplate: v1alpha1.RevisionTemplateSpec{ + Spec: v1alpha1.RevisionSpec{ + ServiceAccountName: serviceAccount, + Container: corev1.Container{ + Image: image, + Env: []corev1.EnvVar{ + { + Name: "GITHUB_SECRET", + ValueFrom: &corev1.EnvVarSource{ + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: githubSecret, + }, + Key: githubSecretKey, + }, + }, + }, + { + Name: "TARGET", + Value: target, + }, + }, + }, + }, + }, + }, + }, + }, + } +} diff --git a/sample/github/README.md b/sample/github/README.md index 5a161d12015..af796115b44 100644 --- a/sample/github/README.md +++ b/sample/github/README.md @@ -1,50 +1,61 @@ -# gitwebhook +# GitHub Flow -A simple git webhook handler that demonstrates interacting with -github. -[Modeled after GCF example](https://cloud.google.com/community/tutorials/github-auto-assign-reviewers-cloud-functions) -But by introducing a Feed object, we make the subscription to github automatically by calling a github API -and hence the developer does not have to manually wire things together in the UI, by creating the Feed object -the webhook gets created by Knative Eventing. +A GitHub webhook will be created on a repository and a Knative `Service` will be +deployed to receive the webhook's event deliveries and forward them into a +`Channel`, through a `Bus`, and out to the consumer via a `Subscription`. The +`Flow` resource takes care of provisioning the webhook, the `Service`, the +`Channel`, and the `Subscription`. ## Prerequisites 1. [Setup your development environment](../../DEVELOPMENT.md#getting-started) 2. [Start Knative](../../README.md#start-knative) -3. Decide on the DNS name that git can then call. Update knative/serving/config/config-domain.yaml. -For example I used aikas.org as my hostname, so my knative/serving/config/config-domain.yaml looks like so: +3. For GitHub to be able to call into the cluster, + [configure a custom domain](https://github.com/knative/docs/blob/master/serving/using-a-custom-domain.md) and + [assign a static IP address](https://github.com/knative/docs/blob/master/serving/gke-assigning-static-ip-address.md). +4. Install a ClusterBus + +update `knative/eventing/config/buses/stub-bus.yaml`, changing `kind` to `ClusterBus`, like: ```yaml -apiVersion: v1 -kind: ConfigMap +apiVersion: channels.knative.dev/v1alpha1 +kind: ClusterBus metadata: - name: ela-config - namespace: ela-system -data: - aikas.org: | -``` + name: stub +spec: + dispatcher: + name: dispatcher + image: github.com/knative/eventing/pkg/buses/stub + args: [ + "-logtostderr", + "-stderrthreshold", "INFO", + ] +``` -If you were already running the knative controllers, you will need to update this configmap from the -root of the knative/serving +and apply the stub bus ```shell -ko apply -f config/config-domain.yaml +ko apply -f config/buses/stub ``` -4. Install Github as an event source +5. Install GitHub as an event source ```shell ko apply -f pkg/sources/github/ ``` -5. Check that the github is now showing up as an event source and there's an event type for pullrequests +5. Check that the GitHub is now showing up as an event source and there's an event type for *pullrequests* ```shell kubectl get eventsources kubectl get eventtypes ``` -6. Create a [personal access token](https://github.com/settings/tokens) to github repo that you can use to register webhooks with the Github API. Also decide on a token that your code will authenticate the incoming webhooks from github (accessSoken). Update sample/github/githubsecret.yaml with those values. If your generated access token is 'asdfasfdsaf' and you choose your secretToken as 'password', you'd modify githubsecret.yaml like so: +6. Create a [personal access token](https://github.com/settings/tokens) to GitHub repo that you can use to register + webhooks with the GitHub API. Also decide on a token that your code will use to authenticate the incoming webhooks + from GitHub (*accessToken*). Update `sample/github/githubsecret.yaml` with those values. If your generated access + token is `'asdfasfdsaf'` and you choose your *secretToken* as `'password'`, you'd modify + `sample/github/githubsecret.yaml` like so: ```yaml apiVersion: v1 @@ -62,89 +73,85 @@ stringData: ## Running -You can deploy a function that handles the pullrequest events to Knative from the root directory via: +In response to a pull request event, the _legit_ Service will add `(looks pretty legit)` to the PR title. + +Deploy the _legit_ service via: + ```shell -ko apply -f sample/github/configuration.yaml -ko apply -f sample/github/route.yaml +ko apply sample/github/legit-service.yaml ``` Once deployed, you can inspect the created resources with `kubectl` commands: ```shell -# This will show the Route that we created: +# This will show the Service that we created: +kubectl get service.serving.knative.dev -o yaml + +# This will show the Route that the Service created: kubectl get route -o yaml -# This will show the Configuration that we created: +# This will show the Configuration that the Service created: kubectl get configurations -o yaml -# This will show the Revision that was created by our configuration: +# This will show the Revision that was created by the Configuration: kubectl get revisions -o yaml +``` + +The `Flow` will accept the Webhook calls from GitHub and pass them to the _legit_ service. +You can inspect those resources with the following `kubectl` commands: + +```shell # This will show the available EventSources that you can generate feeds from: kubectl get eventsources -o yaml # This will show the available EventTypes that you can generate feeds from: kubectl get eventtypes -o yaml - ``` -To make this service accessible to github, we first need to determine its ingress address -(might have to wait a little while until 'ADDRESS' gets assigned): +Configure the `Flow` to point to a GitHub repository you are able to control and update +`spec.trigger.resource` in `samples/github/flow.yaml`. + +And then apply the resources: + ```shell -$ kubectl get ingress --watch -NAME HOSTS ADDRESS PORTS AGE -git-webhook-ingress git-webhook.default.aikas.org 104.197.125.124 80 12m -``` +ko apply -f sample/github/auth.yaml +ko apply -f sample/github/flow.yaml +``` + +Once deployed, you can inspect the created resources with `kubectl` commands: -Once the `ADDRESS` gets assigned to the cluster, you need to assign a DNS name for that IP address. This DNS address needs to be: -git-webhook.default. so for me, I would create a DNS entry from: -git-webhook.default.aikas.org pointing to 104.197.125.124 -[Using GCP DNS](https://support.google.com/domains/answer/3290350) +```shell +# This will show the available Flows we created: +kubectl get flows -o yaml -So, you'd need to create an A record for git-webhook.default.aikas.org pointing to 104.197.125.124 +# This will show the available Feeds created from the Flow: +kubectl get feeds -o yaml -To now send events via the github webhook for pull requests to the function we created above, you need to - create a Feed object. Modify sample/github/feed.yaml to point to owner of the repo as well - as the particular repo you want to subscribe to. So, change spec.trigger.resource with the owner/repo - you want. +# This will show the available Channels created from the Flow: +kubectl get channels -o yaml - For example, if I wanted to receive notifications to: - github.com/inlined/robots repo, my Feed object would look like so: +# This will show the available Subscriptions created from the Flow: +kubectl get subscriptions -o yaml -```yaml -apiVersion: knative.dev/v1alpha1 -kind: Feed -metadata: - name: feed-example - namespace: default -spec: - trigger: - service: github - eventType: pullrequest - resource: inlined/robots - parametersFrom: - - secretKeyRef: - name: githubsecret - key: githubCredentials - action: - routeName: git-webhook +# This will show the available ClusterBuses we created in the prerequisites: +kubectl get clusterbuses -o yaml ``` -Then create the secret and a feed so that you can see changes +Then create the secret so that you can see changes: ```shell ko apply -f sample/github/githubsecret.yaml - ko apply -f sample/github/feed.yaml ``` Then create a PR for the repo you configured the webhook for, and you'll see that the Title -will be modified with the suffix '(I buy it)' +will be modified with the suffix '(looks pretty legit)' ## Cleaning up -To clean up the sample feed: +To clean up the sample `Flow`: ```shell - ko delete -f sample/github/feed.yaml + ko delete -f sample/github/flow.yaml ``` And you can check the repo and see the webhook has been removed diff --git a/sample/github/auth.yaml b/sample/github/auth.yaml new file mode 100644 index 00000000000..45a5a8c15a0 --- /dev/null +++ b/sample/github/auth.yaml @@ -0,0 +1,31 @@ +# 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. +apiVersion: v1 +kind: ServiceAccount +metadata: + name: feed-sa + namespace: default +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRoleBinding +metadata: + name: feed-admin +subjects: + - kind: ServiceAccount + name: feed-sa + namespace: default +roleRef: + kind: ClusterRole + name: cluster-admin + apiGroup: rbac.authorization.k8s.io diff --git a/sample/github/feed.yaml b/sample/github/flow.yaml similarity index 70% rename from sample/github/feed.yaml rename to sample/github/flow.yaml index 05a82123632..150bfcd693e 100644 --- a/sample/github/feed.yaml +++ b/sample/github/flow.yaml @@ -12,22 +12,26 @@ # See the License for the specific language governing permissions and # limitations under the License. -apiVersion: feeds.knative.dev/v1alpha1 -kind: Feed +apiVersion: flows.knative.dev/v1alpha1 +kind: Flow metadata: - name: feed-example + name: github-flow namespace: default spec: + serviceAccountName: feed-sa trigger: - # TODO: eventType doesn't match the normal naming scheme. At min should - # make this "com.github.pullrequest". May consider making it something - # like "com.github.pull.create" eventType: pullrequest - resource: vaikas/misc + resource: / # TODO: Fill this out service: github + parameters: + secretName: githubsecret + secretKey: githubCredentials parametersFrom: - secretKeyRef: name: githubsecret key: githubCredentials action: - routeName: git-webhook + target: + kind: Route + apiVersion: serving.knative.dev/v1alpha1 + name: legit diff --git a/sample/github/configuration.yaml b/sample/github/legit-service.yaml similarity index 59% rename from sample/github/configuration.yaml rename to sample/github/legit-service.yaml index 1dda35e11a8..28fabed5aca 100644 --- a/sample/github/configuration.yaml +++ b/sample/github/legit-service.yaml @@ -13,21 +13,22 @@ # limitations under the License. apiVersion: serving.knative.dev/v1alpha1 -kind: Configuration +kind: Service metadata: - name: git-webhook - namespace: default + name: legit spec: - revisionTemplate: - metadata: - labels: - knative.dev/type: container - spec: - container: - image: github.com/knative/eventing/sample/github - env: - - name: GITHUB_SECRET - valueFrom: - secretKeyRef: - name: githubsecret - key: githubCredentials + runLatest: + configuration: + revisionTemplate: + metadata: + labels: + knative.dev/type: function + spec: + container: + image: github.com/knative/eventing/sample/github + env: + - name: GITHUB_SECRET + valueFrom: + secretKeyRef: + key: githubCredentials + name: githubsecret diff --git a/sample/github/gitwebhook.go b/sample/github/legit.go similarity index 67% rename from sample/github/gitwebhook.go rename to sample/github/legit.go index 2ad68695980..766b2ef62f5 100644 --- a/sample/github/gitwebhook.go +++ b/sample/github/legit.go @@ -21,22 +21,21 @@ import ( "encoding/json" "flag" "fmt" - "os" - "strings" - - "github.com/golang/glog" + ghclient "github.com/google/go-github/github" "golang.org/x/oauth2" - webhooks "gopkg.in/go-playground/webhooks.v3" "gopkg.in/go-playground/webhooks.v3/github" - - ghclient "github.com/google/go-github/github" + "io/ioutil" + "log" + "net/http" + "os" + "strings" ) const ( // Environment variable containing json credentials envSecret = "GITHUB_SECRET" // this is what we tack onto each PR title if not there already - titleSuffix = "I buy it" + titleSuffix = "looks pretty legit" ) // GithubHandler holds necessary objects for communicating with the Github. @@ -50,15 +49,22 @@ type GithubSecrets struct { SecretToken string `json:"secretToken"` } -// HandlePullRequest is invoked whenever a PullRequest is modified (created, updated, etc.) -func (handler *GithubHandler) HandlePullRequest(payload interface{}, header webhooks.Header) { - glog.Info("Handling Pull Request") +func (h *GithubHandler) handlePost(rw http.ResponseWriter, req *http.Request) { + body, err := ioutil.ReadAll(req.Body) + if err != nil { + panic(err) + } + rw.WriteHeader(200) - pl := payload.(github.PullRequestPayload) + var pl github.PullRequestPayload + if err := json.Unmarshal(body, &pl); err != nil { + log.Printf("error: could not unmarshal payload %v", err) + return + } // Do whatever you want from here... title := pl.PullRequest.Title - glog.Infof("GOT PR with Title: %q", title) + log.Printf("GOT PR with Title: %q", title) // Check the title and if it contains 'looks pretty legit' leave it alone if strings.Contains(title, titleSuffix) { @@ -70,28 +76,26 @@ func (handler *GithubHandler) HandlePullRequest(payload interface{}, header webh updatedPR := ghclient.PullRequest{ Title: &newTitle, } - newPR, response, err := handler.client.PullRequests.Edit(handler.ctx, pl.Repository.Owner.Login, pl.Repository.Name, int(pl.Number), &updatedPR) + newPR, response, err := h.client.PullRequests.Edit(h.ctx, pl.Repository.Owner.Login, pl.Repository.Name, int(pl.Number), &updatedPR) if err != nil { - glog.Warningf("Failed to update PR: %s\n%s", err, response) + log.Printf("Failed to update PR: %s\n%s", err, response) return } if newPR.Title != nil { - glog.Infof("New PR Title: %q", *newPR.Title) + log.Printf("New PR Title: %q", *newPR.Title) } else { - glog.Infof("New PR title is nil") + log.Printf("New PR title is nil") } } func main() { flag.Parse() - // set the logs to stderr so kube will see them. - flag.Lookup("logtostderr").Value.Set("true") githubSecrets := os.Getenv(envSecret) var credentials GithubSecrets err := json.Unmarshal([]byte(githubSecrets), &credentials) if err != nil { - glog.Fatalf("Failed to unmarshal credentials: %s", err) + log.Fatalf("Failed to unmarshal credentials: %s", err) return } @@ -111,11 +115,6 @@ func main() { ctx: ctx, } - hook := github.New(&github.Config{Secret: credentials.SecretToken}) - hook.RegisterEvents(h.HandlePullRequest, github.PullRequestEvent) - - err = webhooks.Run(hook, ":8080", "/") - if err != nil { - glog.Fatalf("Failed to run the webhook") - } + http.HandleFunc("/", h.handlePost) + log.Fatal(http.ListenAndServe(":8080", nil)) } diff --git a/vendor/github.com/knative/build/AUTHORS b/vendor/github.com/knative/build/AUTHORS new file mode 100644 index 00000000000..ab85282788a --- /dev/null +++ b/vendor/github.com/knative/build/AUTHORS @@ -0,0 +1,7 @@ +# 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. diff --git a/vendor/github.com/knative/build/LICENSE b/vendor/github.com/knative/build/LICENSE new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/vendor/github.com/knative/build/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/build/pkg/apis/build/register.go b/vendor/github.com/knative/build/pkg/apis/build/register.go new file mode 100644 index 00000000000..ec8299fe8c2 --- /dev/null +++ b/vendor/github.com/knative/build/pkg/apis/build/register.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. +*/ + +package build + +const GroupName = "build.knative.dev" diff --git a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_template_types.go b/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_template_types.go new file mode 100644 index 00000000000..7d63ea4b722 --- /dev/null +++ b/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_template_types.go @@ -0,0 +1,85 @@ +/* +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 ( + "encoding/json" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +genclient:noStatus +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// BuildTemplate is a template that can used to easily create Builds. +type BuildTemplate struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec BuildTemplateSpec `json:"spec"` +} + +// BuildTemplateSpec is the spec for a BuildTemplate. +type BuildTemplateSpec struct { + // TODO: Generation does not work correctly with CRD. They are scrubbed + // by the APIserver (https://github.com/kubernetes/kubernetes/issues/58778) + // So, we add Generation here. Once that gets fixed, remove this and use + // ObjectMeta.Generation instead. + // +optional + Generation int64 `json:"generation,omitempty"` + + // Parameters defines the parameters that can be populated in a template. + Parameters []ParameterSpec `json:"parameters,omitempty"` + + // Steps are the steps of the build; each step is run sequentially with the + // source mounted into /workspace. + Steps []corev1.Container `json:"steps"` + + // Volumes is a collection of volumes that are available to mount into the + // steps of the build. + Volumes []corev1.Volume `json:"volumes"` +} + +// ParameterSpec defines the possible parameters that can be populated in a +// template. +type ParameterSpec struct { + // Name is the unique name of this template parameter. + Name string `json:"name"` + + // Description is a human-readable explanation of this template parameter. + Description string `json:"description,omitempty"` + + // Default, if specified, defines the default value that should be applied if + // the build does not specify the value for this parameter. + Default *string `json:"default,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// BuildTemplateList is a list of BuildTemplate resources. +type BuildTemplateList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []BuildTemplate `json:"items"` +} + +func (bt *BuildTemplate) GetGeneration() int64 { return bt.Spec.Generation } +func (bt *BuildTemplate) SetGeneration(generation int64) { bt.Spec.Generation = generation } +func (bt *BuildTemplate) GetSpecJSON() ([]byte, error) { return json.Marshal(bt.Spec) } diff --git a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_types.go b/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_types.go new file mode 100644 index 00000000000..9a2640db1bf --- /dev/null +++ b/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/build_types.go @@ -0,0 +1,233 @@ +/* +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 ( + "encoding/json" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +genclient:noStatus +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Build represents a build of a container image. A Build is made up of a +// source, and a set of steps. Steps can mount volumes to share data between +// themselves. A build may be created by instantiating a BuildTemplate. +type Build struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec BuildSpec `json:"spec"` + Status BuildStatus `json:"status"` +} + +// BuildSpec is the spec for a Build resource. +type BuildSpec struct { + // TODO: Generation does not work correctly with CRD. They are scrubbed + // by the APIserver (https://github.com/kubernetes/kubernetes/issues/58778) + // So, we add Generation here. Once that gets fixed, remove this and use + // ObjectMeta.Generation instead. + // +optional + Generation int64 `json:"generation,omitempty"` + + // Source specifies the input to the build. + Source *SourceSpec `json:"source,omitempty"` + + // Steps are the steps of the build; each step is run sequentially with the + // source mounted into /workspace. + Steps []corev1.Container `json:"steps,omitempty"` + + // Volumes is a collection of volumes that are available to mount into the + // steps of the build. + Volumes []corev1.Volume `json:"volumes,omitempty"` + + // The name of the service account as which to run this build. + ServiceAccountName string `json:"serviceAccountName,omitempty"` + + // Template, if specified, references a BuildTemplate resource to use to + // populate fields in the build, and optional Arguments to pass to the + // template. + Template *TemplateInstantiationSpec `json:"template,omitempty"` +} + +// TemplateInstantiationSpec specifies how a BuildTemplate is instantiated into +// a Build. +type TemplateInstantiationSpec struct { + // Name references the BuildTemplate resource to use. + // + // The template is assumed to exist in the Build's namespace. + Name string `json:"name"` + + // Arguments, if specified, lists values that should be applied to the + // parameters specified by the template. + Arguments []ArgumentSpec `json:"arguments,omitempty"` + + // Env, if specified will provide variables to all build template steps. + // This will override any of the template's steps environment variables. + Env []corev1.EnvVar `json:"env,omitempty"` +} + +// ArgumentSpec defines the actual values to use to populate a template's +// parameters. +type ArgumentSpec struct { + Name string `json:"name"` + Value string `json:"value"` + // TODO(jasonhall): ValueFrom? +} + +// SourceSpec defines the input to the Build +type SourceSpec struct { + Git *GitSourceSpec `json:"git,omitempty"` + GCS *GCSSourceSpec `json:"gcs,omitempty"` + Custom *corev1.Container `json:"custom,omitempty"` +} + +// GitSourceSpec describes a Git repo source input to the Build. +type GitSourceSpec struct { + // URL of the Git repository to clone from. + Url string `json:"url"` + + // Git revision (branch, tag, commit SHA or ref) to clone. See + // https://git-scm.com/docs/gitrevisions#_specifying_revisions for more + // information. + Revision string `json:"revision"` +} + +// GCSSourceSpec describes source input to the Build in the form of an archive, +// or a source manifest describing files to fetch. +type GCSSourceSpec struct { + Type GCSSourceType `json:"type,omitempty"` + Location string `json:"location,omitempty"` +} + +type GCSSourceType string + +const ( + GCSArchive GCSSourceType = "Archive" + GCSManifest GCSSourceType = "Manifest" +) + +type BuildProvider string + +const ( + // GoogleBuildProvider indicates that this build was performed with Google Container Builder. + GoogleBuildProvider BuildProvider = "Google" + // ClusterBuildProvider indicates that this build was performed on-cluster. + ClusterBuildProvider BuildProvider = "Cluster" +) + +// BuildStatus is the status for a Build resource +type BuildStatus struct { + Builder BuildProvider `json:"builder,omitempty"` + + // Additional information based on the Builder executing this build. + Cluster *ClusterSpec `json:"cluster,omitempty"` + Google *GoogleSpec `json:"google,omitempty"` + + // Information about the execution of the build. + StartTime metav1.Time `json:"startTime,omitEmpty"` + CompletionTime metav1.Time `json:"completionTime,omitEmpty"` + + // Parallel list to spec.Containers + StepStates []corev1.ContainerState `json:"stepStates,omitEmpty"` + Conditions []BuildCondition `json:"conditions,omitempty"` +} + +type ClusterSpec struct { + Namespace string `json:"namespace"` + PodName string `json:"podName"` +} + +type GoogleSpec struct { + Operation string `json:"operation"` +} + +type BuildConditionType string + +const ( + // BuildSucceeded is set when the build is running, and becomes True + // when the build finishes successfully. + // + // If the build is ongoing, its status will be Unknown. If it fails, + // its status will be False. + BuildSucceeded BuildConditionType = "Succeeded" +) + +// BuildCondition defines a readiness condition for a Build. +// See: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#typical-status-properties +type BuildCondition struct { + Type BuildConditionType `json:"state"` + + Status corev1.ConditionStatus `json:"status" description:"status of the condition, one of True, False, Unknown"` + + // +optional + Reason string `json:"reason,omitempty" description:"one-word CamelCase reason for the condition's last transition"` + // +optional + Message string `json:"message,omitempty" description:"human-readable message indicating details about last transition"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// BuildList is a list of Build resources +type BuildList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Build `json:"items"` +} + +func (bs *BuildStatus) GetCondition(t BuildConditionType) *BuildCondition { + for _, cond := range bs.Conditions { + if cond.Type == t { + return &cond + } + } + return nil +} + +func (b *BuildStatus) SetCondition(newCond *BuildCondition) { + if newCond == nil { + return + } + + t := newCond.Type + var conditions []BuildCondition + for _, cond := range b.Conditions { + if cond.Type != t { + conditions = append(conditions, cond) + } + } + conditions = append(conditions, *newCond) + b.Conditions = conditions +} + +func (b *BuildStatus) RemoveCondition(t BuildConditionType) { + var conditions []BuildCondition + for _, cond := range b.Conditions { + if cond.Type != t { + conditions = append(conditions, cond) + } + } + b.Conditions = conditions +} + +func (b *Build) GetGeneration() int64 { return b.Spec.Generation } +func (b *Build) SetGeneration(generation int64) { b.Spec.Generation = generation } +func (b *Build) GetSpecJSON() ([]byte, error) { return json.Marshal(b.Spec) } diff --git a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/doc.go b/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/doc.go new file mode 100644 index 00000000000..df551590c00 --- /dev/null +++ b/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/doc.go @@ -0,0 +1,21 @@ +/* +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 + +// Package v1alpha1 is the v1alpha1 version of the API. +// +groupName=build.knative.dev +package v1alpha1 diff --git a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/register.go b/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/register.go new file mode 100644 index 00000000000..95c900c26ee --- /dev/null +++ b/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/register.go @@ -0,0 +1,55 @@ +/* +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" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + + "github.com/knative/build/pkg/apis/build" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: build.GroupName, Version: "v1alpha1"} + +// 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, + &Build{}, + &BuildList{}, + &BuildTemplate{}, + &BuildTemplateList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..a73da3e46ac --- /dev/null +++ b/vendor/github.com/knative/build/pkg/apis/build/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,472 @@ +// +build !ignore_autogenerated + +/* +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. +*/ + +// This file was autogenerated by deepcopy-gen. Do not edit it manually! + +package v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArgumentSpec) DeepCopyInto(out *ArgumentSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArgumentSpec. +func (in *ArgumentSpec) DeepCopy() *ArgumentSpec { + if in == nil { + return nil + } + out := new(ArgumentSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Build) DeepCopyInto(out *Build) { + *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 Build. +func (in *Build) DeepCopy() *Build { + if in == nil { + return nil + } + out := new(Build) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Build) DeepCopyObject() runtime.Object { + 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 *BuildCondition) DeepCopyInto(out *BuildCondition) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuildCondition. +func (in *BuildCondition) DeepCopy() *BuildCondition { + if in == nil { + return nil + } + out := new(BuildCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BuildList) DeepCopyInto(out *BuildList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Build, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuildList. +func (in *BuildList) DeepCopy() *BuildList { + if in == nil { + return nil + } + out := new(BuildList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *BuildList) DeepCopyObject() runtime.Object { + 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 *BuildSpec) DeepCopyInto(out *BuildSpec) { + *out = *in + if in.Source != nil { + in, out := &in.Source, &out.Source + if *in == nil { + *out = nil + } else { + *out = new(SourceSpec) + (*in).DeepCopyInto(*out) + } + } + if in.Steps != nil { + in, out := &in.Steps, &out.Steps + *out = make([]v1.Container, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Volumes != nil { + in, out := &in.Volumes, &out.Volumes + *out = make([]v1.Volume, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Template != nil { + in, out := &in.Template, &out.Template + if *in == nil { + *out = nil + } else { + *out = new(TemplateInstantiationSpec) + (*in).DeepCopyInto(*out) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuildSpec. +func (in *BuildSpec) DeepCopy() *BuildSpec { + if in == nil { + return nil + } + out := new(BuildSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BuildStatus) DeepCopyInto(out *BuildStatus) { + *out = *in + if in.Cluster != nil { + in, out := &in.Cluster, &out.Cluster + if *in == nil { + *out = nil + } else { + *out = new(ClusterSpec) + **out = **in + } + } + if in.Google != nil { + in, out := &in.Google, &out.Google + if *in == nil { + *out = nil + } else { + *out = new(GoogleSpec) + **out = **in + } + } + in.StartTime.DeepCopyInto(&out.StartTime) + in.CompletionTime.DeepCopyInto(&out.CompletionTime) + if in.StepStates != nil { + in, out := &in.StepStates, &out.StepStates + *out = make([]v1.ContainerState, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]BuildCondition, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuildStatus. +func (in *BuildStatus) DeepCopy() *BuildStatus { + if in == nil { + return nil + } + out := new(BuildStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BuildTemplate) DeepCopyInto(out *BuildTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuildTemplate. +func (in *BuildTemplate) DeepCopy() *BuildTemplate { + if in == nil { + return nil + } + out := new(BuildTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *BuildTemplate) DeepCopyObject() runtime.Object { + 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 *BuildTemplateList) DeepCopyInto(out *BuildTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]BuildTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuildTemplateList. +func (in *BuildTemplateList) DeepCopy() *BuildTemplateList { + if in == nil { + return nil + } + out := new(BuildTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *BuildTemplateList) DeepCopyObject() runtime.Object { + 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 *BuildTemplateSpec) DeepCopyInto(out *BuildTemplateSpec) { + *out = *in + if in.Parameters != nil { + in, out := &in.Parameters, &out.Parameters + *out = make([]ParameterSpec, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Steps != nil { + in, out := &in.Steps, &out.Steps + *out = make([]v1.Container, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Volumes != nil { + in, out := &in.Volumes, &out.Volumes + *out = make([]v1.Volume, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuildTemplateSpec. +func (in *BuildTemplateSpec) DeepCopy() *BuildTemplateSpec { + if in == nil { + return nil + } + out := new(BuildTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterSpec. +func (in *ClusterSpec) DeepCopy() *ClusterSpec { + if in == nil { + return nil + } + out := new(ClusterSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GCSSourceSpec) DeepCopyInto(out *GCSSourceSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GCSSourceSpec. +func (in *GCSSourceSpec) DeepCopy() *GCSSourceSpec { + if in == nil { + return nil + } + out := new(GCSSourceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GitSourceSpec) DeepCopyInto(out *GitSourceSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitSourceSpec. +func (in *GitSourceSpec) DeepCopy() *GitSourceSpec { + if in == nil { + return nil + } + out := new(GitSourceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GoogleSpec) DeepCopyInto(out *GoogleSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GoogleSpec. +func (in *GoogleSpec) DeepCopy() *GoogleSpec { + if in == nil { + return nil + } + out := new(GoogleSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ParameterSpec) DeepCopyInto(out *ParameterSpec) { + *out = *in + if in.Default != nil { + in, out := &in.Default, &out.Default + if *in == nil { + *out = nil + } else { + *out = new(string) + **out = **in + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ParameterSpec. +func (in *ParameterSpec) DeepCopy() *ParameterSpec { + if in == nil { + return nil + } + out := new(ParameterSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SourceSpec) DeepCopyInto(out *SourceSpec) { + *out = *in + if in.Git != nil { + in, out := &in.Git, &out.Git + if *in == nil { + *out = nil + } else { + *out = new(GitSourceSpec) + **out = **in + } + } + if in.GCS != nil { + in, out := &in.GCS, &out.GCS + if *in == nil { + *out = nil + } else { + *out = new(GCSSourceSpec) + **out = **in + } + } + if in.Custom != nil { + in, out := &in.Custom, &out.Custom + if *in == nil { + *out = nil + } else { + *out = new(v1.Container) + (*in).DeepCopyInto(*out) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SourceSpec. +func (in *SourceSpec) DeepCopy() *SourceSpec { + if in == nil { + return nil + } + out := new(SourceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TemplateInstantiationSpec) DeepCopyInto(out *TemplateInstantiationSpec) { + *out = *in + if in.Arguments != nil { + in, out := &in.Arguments, &out.Arguments + *out = make([]ArgumentSpec, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]v1.EnvVar, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TemplateInstantiationSpec. +func (in *TemplateInstantiationSpec) DeepCopy() *TemplateInstantiationSpec { + if in == nil { + return nil + } + out := new(TemplateInstantiationSpec) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/github.com/knative/serving/AUTHORS b/vendor/github.com/knative/serving/AUTHORS new file mode 100644 index 00000000000..4e068958755 --- /dev/null +++ b/vendor/github.com/knative/serving/AUTHORS @@ -0,0 +1,9 @@ +# 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. \ No newline at end of file diff --git a/vendor/github.com/knative/serving/LICENSE b/vendor/github.com/knative/serving/LICENSE new file mode 100644 index 00000000000..d6456956733 --- /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/pkg/apis/istio/register.go b/vendor/github.com/knative/serving/pkg/apis/istio/register.go new file mode 100644 index 00000000000..647eb38a0e1 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/istio/register.go @@ -0,0 +1,21 @@ +/* +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 istio + +const ( + GroupName = "networking.istio.io" +) diff --git a/vendor/github.com/knative/serving/pkg/apis/istio/v1alpha3/doc.go b/vendor/github.com/knative/serving/pkg/apis/istio/v1alpha3/doc.go new file mode 100644 index 00000000000..47ec83daedf --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/istio/v1alpha3/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=networking.istio.io +package v1alpha3 diff --git a/vendor/github.com/knative/serving/pkg/apis/istio/v1alpha3/gateway_types.go b/vendor/github.com/knative/serving/pkg/apis/istio/v1alpha3/gateway_types.go new file mode 100644 index 00000000000..0822a5e3b4e --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/istio/v1alpha3/gateway_types.go @@ -0,0 +1,318 @@ +/* +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 v1alpha3 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Gateway describes a load balancer operating at the edge of the mesh +// receiving incoming or outgoing HTTP/TCP connections. The specification +// describes a set of ports that should be exposed, the type of protocol to +// use, SNI configuration for the load balancer, etc. +// +// For example, the following gateway spec sets up a proxy to act as a load +// balancer exposing port 80 and 9080 (http), 443 (https), and port 2379 +// (TCP) for ingress. The gateway will be applied to the proxy running on +// a pod with labels "app: my-gateway-controller". While Istio will configure the +// proxy to listen on these ports, it is the responsibility of the user to +// ensure that external traffic to these ports are allowed into the mesh. +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: Gateway +// metadata: +// name: my-gateway +// spec: +// selector: +// app: my-gatweway-controller +// servers: +// - port: +// number: 80 +// name: http +// protocol: HTTP +// hosts: +// - uk.bookinfo.com +// - eu.bookinfo.com +// tls: +// httpsRedirect: true # sends 302 redirect for http requests +// - port: +// number: 443 +// name: https +// protocol: HTTPS +// hosts: +// - uk.bookinfo.com +// - eu.bookinfo.com +// tls: +// mode: SIMPLE #enables HTTPS on this port +// serverCertificate: /etc/certs/servercert.pem +// privateKey: /etc/certs/privatekey.pem +// - port: +// number: 9080 +// name: http-wildcard +// protocol: HTTP +// # no hosts implies wildcard match +// - port: +// number: 2379 #to expose internal service via external port 2379 +// name: mongo +// protocol: MONGO +// +// The gateway specification above describes the L4-L6 properties of a load +// balancer. A VirtualService can then be bound to a gateway to control +// the forwarding of traffic arriving at a particular host or gateway port. +// +// For example, the following VirtualService splits traffic for +// https://uk.bookinfo.com/reviews, https://eu.bookinfo.com/reviews, +// http://uk.bookinfo.com:9080/reviews, http://eu.bookinfo.com:9080/reviews +// into two versions (prod and qa) of an internal reviews service on port +// 9080. In addition, requests containing the cookie user: dev-123 will be +// sent to special port 7777 in the qa version. The same rule is also +// applicable inside the mesh for requests to the reviews.prod +// service. This rule is applicable across ports 443, 9080. Note that +// http://uk.bookinfo.com gets redirected to https://uk.bookinfo.com +// (i.e. 80 redirects to 443). +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: bookinfo-rule +// spec: +// hosts: +// - reviews.prod +// - uk.bookinfo.com +// - eu.bookinfo.com +// gateways: +// - my-gateway +// - mesh # applies to all the sidecars in the mesh +// http: +// - match: +// - headers: +// cookie: +// user: dev-123 +// route: +// - destination: +// port: +// number: 7777 +// name: reviews.qa +// - match: +// uri: +// prefix: /reviews/ +// route: +// - destination: +// port: +// number: 9080 # can be omitted if its the only port for reviews +// name: reviews.prod +// weight: 80 +// - destination: +// name: reviews.qa +// weight: 20 +// +// The following VirtualService forwards traffic arriving at (external) port +// 2379 from 172.17.16.0/24 subnet to internal Mongo server on port 5555. This +// rule is not applicable internally in the mesh as the gateway list omits +// the reserved name "mesh". +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: bookinfo-Mongo +// spec: +// hosts: +// - mongosvr #name of Mongo service +// gateways: +// - my-gateway +// tcp: +// - match: +// - port: +// number: 2379 +// sourceSubnet: "172.17.16.0/24" +// route: +// - destination: +// name: mongo.prod +// +type Gateway struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec GatewaySpec `json:"spec"` +} + +type GatewaySpec struct { + // REQUIRED: A list of server specifications. + Servers []Server `json:"servers"` + + // One or more labels that indicate a specific set of pods/VMs + // on which this gateway configuration should be applied. + // If no selectors are provided, the gateway will be implemented by + // the default istio-ingress controller. + Selector map[string]string `json:"selector,omitempty"` +} + +// Server describes the properties of the proxy on a given load balancer port. +// For example, +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: Gateway +// metadata: +// name: my-ingress +// spec: +// selector: +// app: my-ingress-controller +// servers: +// - port: +// number: 80 +// name: http2 +// protocol: HTTP2 +// +// Another example +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: Gateway +// metadata: +// name: my-tcp-ingress +// spec: +// selector: +// app: my-tcp-ingress-controller +// servers: +// - port: +// number: 27018 +// name: mongo +// protocol: MONGO +// +// The following is an example of TLS configuration for port 443 +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: Gateway +// metadata: +// name: my-tls-ingress +// spec: +// selector: +// app: my-tls-ingress-controller +// servers: +// - port: +// number: 443 +// name: https +// protocol: HTTPS +// tls: +// mode: SIMPLE +// serverCertificate: /etc/certs/server.pem +// privateKey: /etc/certs/privatekey.pem +// +type Server struct { + // REQUIRED: The Port on which the proxy should listen for incoming + // connections + Port Port `json:"port"` + + // A list of hosts exposed by this gateway. While + // typically applicable to HTTP services, it can also be used for TCP + // services using TLS with SNI. Standard DNS wildcard prefix syntax + // is permitted. + // + // A VirtualService that is bound to a gateway must having a matching host + // in its default destination. Specifically one of the VirtualService + // destination hosts is a strict suffix of a gateway host or + // a gateway host is a suffix of one of the VirtualService hosts. + Hosts []string `json:"hosts,omitempty"` + + // Set of TLS related options that govern the server's behavior. Use + // these options to control if all http requests should be redirected to + // https, and the TLS modes to use. + TLS *TLSOptions `json:"tls,omitempty"` +} + +type TLSOptions struct { + // If set to true, the load balancer will send a 302 redirect for all + // http connections, asking the clients to use HTTPS. + HttpsRedirect bool `json:"httpsRedirect"` + + // Optional: Indicates whether connections to this port should be + // secured using TLS. The value of this field determines how TLS is + // enforced. + Mode TLSMode `json:"mode,omitempty"` + + // REQUIRED if mode is "SIMPLE" or "MUTUAL". The path to the file + // holding the server-side TLS certificate to use. + ServerCertificate string `json:"serverCertificate"` + + // REQUIRED if mode is "SIMPLE" or "MUTUAL". The path to the file + // holding the server's private key. + PrivateKey string `json:"privateKey"` + + // REQUIRED if mode is "MUTUAL". The path to a file containing + // certificate authority certificates to use in verifying a presented + // client side certificate. + CaCertificates string `json:"caCertificates"` + + // A list of alternate names to verify the subject identity in the + // certificate presented by the client. + SubjectAltNames []string `json:"subjectAltNames"` +} + +// TLS modes enforced by the proxy +type TLSMode string + +const ( + // If set to "PASSTHROUGH", the proxy will forward the connection + // to the upstream server selected based on the SNI string presented + // by the client. + TLSModePassThrough TLSMode = "PASSTHROUGH" + + // If set to "SIMPLE", the proxy will secure connections with + // standard TLS semantics. + TLSModeSimple TLSMode = "SIMPLE" + + // If set to "MUTUAL", the proxy will secure connections to the + // upstream using mutual TLS by presenting client certificates for + // authentication. + TLSModeMutual TLSMode = "MUTUAL" +) + +// Port describes the properties of a specific port of a service. +type Port struct { + // REQUIRED: A valid non-negative integer port number. + Number int `json:"number"` + + // REQUIRED: The protocol exposed on the port. + // MUST BE one of HTTP|HTTPS|GRPC|HTTP2|MONGO|TCP. + Protocol PortProtocol `json:"protocol"` + + // Label assigned to the port. + Name string `json:"name,omitempty"` +} + +type PortProtocol string + +const ( + ProtocolHTTP PortProtocol = "HTTP" + ProtocolHTTPS PortProtocol = "HTTPS" + ProtocolGRPC PortProtocol = "GRPC" + ProtocolHTTP2 PortProtocol = "HTTP2" + ProtocolMongo PortProtocol = "Mongo" + ProtocolTCP PortProtocol = "TCP" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// GatewayList is a list of Gateway resources +type GatewayList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Gateway `json:"items"` +} diff --git a/vendor/github.com/knative/serving/pkg/apis/istio/v1alpha3/register.go b/vendor/github.com/knative/serving/pkg/apis/istio/v1alpha3/register.go new file mode 100644 index 00000000000..2a70cb2340d --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/istio/v1alpha3/register.go @@ -0,0 +1,54 @@ +/* +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 v1alpha3 + +import ( + "github.com/knative/serving/pkg/apis/istio" + 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: istio.GroupName, Version: "v1alpha3"} + +// 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, + &VirtualService{}, + &Gateway{}, + &VirtualServiceList{}, + &GatewayList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/github.com/knative/serving/pkg/apis/istio/v1alpha3/virtualservice_types.go b/vendor/github.com/knative/serving/pkg/apis/istio/v1alpha3/virtualservice_types.go new file mode 100644 index 00000000000..87e2f9815ef --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/istio/v1alpha3/virtualservice_types.go @@ -0,0 +1,783 @@ +/* +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 v1alpha3 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// VirtualService +type VirtualService struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec VirtualServiceSpec `json:"spec"` +} + +// A VirtualService defines a set of traffic routing rules to apply when a host is +// addressed. Each routing rule defines matching criteria for traffic of a specific +// protocol. If the traffic is matched, then it is sent to a named destination service +// (or subset/version of it) defined in the registry. +// +// The source of traffic can also be matched in a routing rule. This allows routing +// to be customized for specific client contexts. +// +// The following example routes all HTTP traffic by default to +// pods of the reviews service with label "version: v1". In addition, +// HTTP requests containing /wpcatalog/, /consumercatalog/ url prefixes will +// be rewritten to /newcatalog and sent to pods with label "version: v2". The +// rules will be applied at the gateway named "bookinfo" as well as at all +// the sidecars in the mesh (indicated by the reserved gateway name +// "mesh"). +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: reviews-route +// spec: +// hosts: +// - reviews +// gateways: # if omitted, defaults to "mesh" +// - bookinfo +// - mesh +// http: +// - match: +// - uri: +// prefix: "/wpcatalog" +// - uri: +// prefix: "/consumercatalog" +// rewrite: +// uri: "/newcatalog" +// route: +// - destination: +// host: reviews +// subset: v2 +// - route: +// - destination: +// host: reviews +// subset: v1 +// +// A subset/version of a route destination is identified with a reference +// to a named service subset which must be declared in a corresponding +// DestinationRule. +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: DestinationRule +// metadata: +// name: reviews-destination +// spec: +// host: reviews +// subsets: +// - name: v1 +// labels: +// version: v1 +// - name: v2 +// labels: +// version: v2 +// +// A host name can be defined by only one VirtualService. A single +// VirtualService can be used to describe traffic properties for multiple +// HTTP and TCP ports. +type VirtualServiceSpec struct { + // REQUIRED. The destination address for traffic captured by this virtual + // service. Could be a DNS name with wildcard prefix or a CIDR + // prefix. Depending on the platform, short-names can also be used + // instead of a FQDN (i.e. has no dots in the name). In such a scenario, + // the FQDN of the host would be derived based on the underlying + // platform. + // + // For example on Kubernetes, when hosts contains a short name, Istio will + // interpret the short name based on the namespace of the rule. Thus, when a + // client namespace applies a rule in the "default" namespace containing a name + // "reviews, Istio will setup routes to the "reviews.default.svc.cluster.local" + // service. However, if a different name such as "reviews.sales.svc.cluster.local" + // is used, it would be treated as a FQDN during virtual host matching. + // In Consul, a plain service name would be resolved to the FQDN + // "reviews.service.consul". + // + // Note that the hosts field applies to both HTTP and TCP + // services. Service inside the mesh, i.e., those found in the service + // registry, must always be referred to using their alphanumeric + // names. IP addresses or CIDR prefixes are allowed only for services + // defined via the Gateway. + Hosts []string `json:"hosts"` + + // The names of gateways and sidecars that should apply these routes. A + // single VirtualService is used for sidecars inside the mesh as well + // as for one or more gateways. The selection condition imposed by this field + // can be overridden using the source field in the match conditions of HTTP/TCP + // routes. The reserved word "mesh" is used to imply all the sidecars in + // the mesh. When this field is omitted, the default gateway ("mesh") + // will be used, which would apply the rule to all sidecars in the + // mesh. If a list of gateway names is provided, the rules will apply + // only to the gateways. To apply the rules to both gateways and sidecars, + // specify "mesh" as one of the gateway names. + Gateways []string `json:"gateways,omitempty"` + + // An ordered list of route rules for HTTP traffic. + // The first rule matching an incoming request is used. + Http []HTTPRoute `json:"http,omitempty"` + + // An ordered list of route rules for TCP traffic. + // The first rule matching an incoming request is used. + Tcp []TCPRoute `json:"tcp,omitempty"` +} + +// Describes match conditions and actions for routing HTTP/1.1, HTTP2, and +// gRPC traffic. See VirtualService for usage examples. +type HTTPRoute struct { + // Match conditions to be satisfied for the rule to be + // activated. All conditions inside a single match block have AND + // semantics, while the list of match blocks have OR semantics. The rule + // is matched if any one of the match blocks succeed. + Match []HTTPMatchRequest `json:"match,omitempty"` + + // A http rule can either redirect or forward (default) traffic. The + // forwarding target can be one of several versions of a service (see + // glossary in beginning of document). Weights associated with the + // service version determine the proportion of traffic it receives. + Route []DestinationWeight `json:"route,omitempty"` + + // A http rule can either redirect or forward (default) traffic. If + // traffic passthrough option is specified in the rule, + // route/redirect will be ignored. The redirect primitive can be used to + // send a HTTP 302 redirect to a different URI or Authority. + Redirect *HTTPRedirect `json:"redirect,omitempty"` + + // Rewrite HTTP URIs and Authority headers. Rewrite cannot be used with + // Redirect primitive. Rewrite will be performed before forwarding. + Rewrite *HTTPRewrite `json:"rewrite,omitempty"` + + // Indicates that a HTTP/1.1 client connection to this particular route + // should be allowed (and expected) to upgrade to a WebSocket connection. + // The default is false. Istio's reference sidecar implementation (Envoy) + // expects the first request to this route to contain the WebSocket + // upgrade headers. Otherwise, the request will be rejected. Note that + // Websocket allows secondary protocol negotiation which may then be + // subject to further routing rules based on the protocol selected. + WebsocketUpgrade bool `json:"websocketUpgrade,omitempty"` + + // Timeout for HTTP requests. + Timeout string `json:"timeout,omitempty"` + + // Retry policy for HTTP requests. + Retries *HTTPRetry `json:"retries,omitempty"` + + // Fault injection policy to apply on HTTP traffic. + Fault *HTTPFaultInjection `json:"fault,omitempty"` + + // Mirror HTTP traffic to a another destination in addition to forwarding + // the requests to the intended destination. Mirrored traffic is on a + // best effort basis where the sidecar/gateway will not wait for the + // mirrored cluster to respond before returning the response from the + // original destination. Statistics will be generated for the mirrored + // destination. + Mirror *Destination `json:"mirror,omitempty"` + + // Additional HTTP headers to add before forwarding a request to the + // destination service. + AppendHeaders map[string]string `json:"appendHeaders,omitempty"` + + // Http headers to remove before returning the response to the caller + RemoveResponseHeaders map[string]string `json:"removeResponseHeaders,omitempty"` +} + +// HttpMatchRequest specifies a set of criterion to be met in order for the +// rule to be applied to the HTTP request. For example, the following +// restricts the rule to match only requests where the URL path +// starts with /ratings/v2/ and the request contains a "cookie" with value +// "user=jason". +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: ratings-route +// spec: +// hosts: +// - ratings +// http: +// - match: +// - headers: +// cookie: +// regex: "^(.*?;)?(user=jason)(;.*)?" +// uri: +// prefix: "/ratings/v2/" +// route: +// - destination: +// host: ratings +// +// HTTPMatchRequest CANNOT be empty. +type HTTPMatchRequest struct { + // URI to match + // values are case-sensitive and formatted as follows: + // + // - `exact: "value"` for exact string match + // + // - `prefix: "value"` for prefix-based match + // + // - `regex: "value"` for ECMAscript style regex-based match + // + Uri *StringMatch `json:"uri,omitempty"` + + // URI Scheme + // values are case-sensitive and formatted as follows: + // + // - `exact: "value"` for exact string match + // + // - `prefix: "value"` for prefix-based match + // + // - `regex: "value"` for ECMAscript style regex-based match + // + Scheme *StringMatch `json:"scheme,omitempty"` + + // HTTP Method + // values are case-sensitive and formatted as follows: + // + // - `exact: "value"` for exact string match + // + // - `prefix: "value"` for prefix-based match + // + // - `regex: "value"` for ECMAscript style regex-based match + // + Method *StringMatch `json:"method,omitempty"` + + // HTTP Authority + // values are case-sensitive and formatted as follows: + // + // - `exact: "value"` for exact string match + // + // - `prefix: "value"` for prefix-based match + // + // - `regex: "value"` for ECMAscript style regex-based match + // + Authority *StringMatch `json:"authority,omitempty"` + + // The header keys must be lowercase and use hyphen as the separator, + // e.g. _x-request-id_. + // + // Header values are case-sensitive and formatted as follows: + // + // - `exact: "value"` for exact string match + // + // - `prefix: "value"` for prefix-based match + // + // - `regex: "value"` for ECMAscript style regex-based match + // + // **Note:** The keys `uri`, `scheme`, `method`, and `authority` will be ignored. + Headers map[string]StringMatch `json:"headers,omitempty"` +} + +// Describes how to match a given string in HTTP headers. Match is +// case-sensitive. +type StringMatch struct { + // Specified exactly one of the fields below. + + // exact string match + Exact string `json:"exact,omitempty"` + + // prefix-based match + Prefix string `json:"prefix,omitempty"` + + // ECMAscript style regex-based match + Regex string `json:"regex,omitempty"` +} + +type DestinationWeight struct { + // REQUIRED. Destination uniquely identifies the instances of a service + // to which the request/connection should be forwarded to. + Destination Destination `json:"destination"` + + // REQUIRED. The proportion of traffic to be forwarded to the service + // version. (0-100). Sum of weights across destinations SHOULD BE == 100. + // If there is only destination in a rule, the weight value is assumed to + // be 100. + Weight int `json:"weight"` +} + +// Destination indicates the network addressable service to which the +// request/connection will be sent after processing a routing rule. The +// destination.name should unambiguously refer to a service in the service +// registry. It can be a short name or a fully qualified domain name from +// the service registry, a resolvable DNS name, an IP address or a service +// name from the service registry and a subset name. The order of inference +// is as follows: +// +// 1. Service registry lookup. The entire name is looked up in the service +// registry. If the lookup succeeds, the search terminates. The requests +// will be routed to any instance of the service in the mesh. When the +// service name consists of a single word, the FQDN will be constructed in +// a platform specific manner. For example, in Kubernetes, the namespace +// associated with the routing rule will be used to identify the service as +// .. However, if the service name contains +// multiple words separated by a dot (e.g., reviews.prod), the name in its +// entirety would be looked up in the service registry. +// +// 2. Runtime DNS lookup by the proxy. If step 1 fails, and the name is not +// an IP address, it will be considered as a DNS name that is not in the +// service registry (e.g., wikipedia.org). The sidecar/gateway will resolve +// the DNS and load balance requests appropriately. See Envoy's strict_dns +// for details. +// +// The following example routes all traffic by default to pods of the +// reviews service with label "version: v1" (i.e., subset v1), and some +// to subset v2, in a kubernetes environment. +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: reviews-route +// spec: +// hosts: +// - reviews # namespace is same as the client/caller's namespace +// http: +// - match: +// - uri: +// prefix: "/wpcatalog" +// - uri: +// prefix: "/consumercatalog" +// rewrite: +// uri: "/newcatalog" +// route: +// - destination: +// host: reviews +// subset: v2 +// - route: +// - destination: +// host: reviews +// subset: v1 +// +// And the associated DestinationRule +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: DestinationRule +// metadata: +// name: reviews-destination +// spec: +// host: reviews +// subsets: +// - name: v1 +// labels: +// version: v1 +// - name: v2 +// labels: +// version: v2 +// +// The following VirtualService sets a timeout of 5s for all calls to +// productpage.prod service. Notice that there are no subsets defined in +// this rule. Istio will fetch all instances of productpage.prod service +// from the service registry and populate the sidecar's load balancing +// pool. +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: my-productpage-rule +// spec: +// hosts: +// - productpage.prod # in kubernetes, this applies only to prod namespace +// http: +// - timeout: 5s +// route: +// - destination: +// host: productpage.prod +// +// The following sets a timeout of 5s for all calls to the external +// service wikipedia.org, as there is no internal service of that name. +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: my-wiki-rule +// spec: +// hosts: +// - wikipedia.org +// http: +// - timeout: 5s +// route: +// - destination: +// host: wikipedia.org +// +type Destination struct { + // REQUIRED. The name of a service from the service registry. Service + // names are looked up from the platform's service registry (e.g., + // Kubernetes services, Consul services, etc.) and from the hosts + // declared by [ServiceEntry](#ServiceEntry). Traffic forwarded to + // destinations that are not found in either of the two, will be dropped. + // + // *Note for Kubernetes users*: When short names are used (e.g. "reviews" + // instead of "reviews.default.svc.cluster.local"), Istio will interpret + // the short name based on the namespace of the rule, not the service. A + // rule in the "default" namespace containing a host "reviews will be + // interpreted as "reviews.default.svc.cluster.local", irrespective of + // the actual namespace associated with the reviews service. _To avoid + // potential misconfigurations, it is recommended to always use fully + // qualified domain names over short names._ + Host string `json:"host"` + + // The name of a subset within the service. Applicable only to services + // within the mesh. The subset must be defined in a corresponding + // DestinationRule. + Subset string `json:"subset,omitempty"` + + // Specifies the port on the host that is being addressed. If a service + // exposes only a single port it is not required to explicitly select the + // port. + Port PortSelector `json:"port,omitempty"` +} + +// PortSelector specifies the number of a port to be used for +// matching or selection for final routing. +type PortSelector struct { + // Choose one of the fields below. + + // Valid port number + Number uint32 `json:"number,omitempty"` + + // Valid port name + Name string `json:"name,omitempty"` +} + +// Describes match conditions and actions for routing TCP traffic. The +// following routing rule forwards traffic arriving at port 27017 for +// mongo.prod.svc.cluster.local from 172.17.16.* subnet to another Mongo +// server on port 5555. +// +// ```yaml +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: bookinfo-Mongo +// spec: +// hosts: +// - mongo.prod.svc.cluster.local +// tcp: +// - match: +// - port: 27017 +// sourceSubnet: "172.17.16.0/24" +// route: +// - destination: +// host: mongo.backup.svc.cluster.local +// port: +// number: 5555 +// ``` +type TCPRoute struct { + // Match conditions to be satisfied for the rule to be + // activated. All conditions inside a single match block have AND + // semantics, while the list of match blocks have OR semantics. The rule + // is matched if any one of the match blocks succeed. + Match []L4MatchAttributes `json:"match"` + + // The destination to which the connection should be forwarded to. + // Currently, only one destination is allowed for TCP services. When TCP + // weighted routing support is introduced in Envoy, multiple destinations + // with weights can be specified. + Route DestinationWeight `json:"route"` +} + +// L4 connection match attributes. Note that L4 connection matching support +// is incomplete. +type L4MatchAttributes struct { + // IPv4 or IPv6 ip address of destination with optional subnet. E.g., + // a.b.c.d/xx form or just a.b.c.d. This is only valid when the + // destination service has several IPs and the application explicitly + // specifies a particular IP. + DestinationSubnet string `json:"destinationSubnet,omitempty"` + + // Specifies the port on the host that is being addressed. Many services + // only expose a single port or label ports with the protocols they support, + // in these cases it is not required to explicitly select the port. + Port int `json:"port,omitempty"` + + // IPv4 or IPv6 ip address of source with optional subnet. E.g., a.b.c.d/xx + // form or just a.b.c.d + SourceSubnet string `json:"sourceSubnet,omitempty"` + + // One or more labels that constrain the applicability of a rule to + // workloads with the given labels. If the VirtualService has a list of + // gateways specified at the top, it should include the reserved gateway + // `mesh` in order for this field to be applicable. + SourceLabel map[string]string `json:"sourceLabel,omitempty"` + + // Names of gateways where the rule should be applied to. Gateway names + // at the top of the VirtualService (if any) are overridden. The gateway match is + // independent of sourceLabels. + Gateways []string `json:"gateways,omitempty"` +} + +// HTTPRedirect can be used to send a 302 redirect response to the caller, +// where the Authority/Host and the URI in the response can be swapped with +// the specified values. For example, the following rule redirects +// requests for /v1/getProductRatings API on the ratings service to +// /v1/bookRatings provided by the bookratings service. +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: ratings-route +// spec: +// hosts: +// - ratings +// http: +// - match: +// - uri: +// exact: /v1/getProductRatings +// redirect: +// uri: /v1/bookRatings +// authority: bookratings.default.svc.cluster.local +// ... +// +type HTTPRedirect struct { + // On a redirect, overwrite the Path portion of the URL with this + // value. Note that the entire path will be replaced, irrespective of the + // request URI being matched as an exact path or prefix. + Uri string `json:"uri,omitempty"` + + // On a redirect, overwrite the Authority/Host portion of the URL with + // this value. + Authority string `json:"authority,omitempty"` +} + +// HTTPRewrite can be used to rewrite specific parts of a HTTP request +// before forwarding the request to the destination. Rewrite primitive can +// be used only with the DestinationWeights. The following example +// demonstrates how to rewrite the URL prefix for api call (/ratings) to +// ratings service before making the actual API call. +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: ratings-route +// spec: +// hosts: +// - ratings +// http: +// - match: +// - uri: +// prefix: /ratings +// rewrite: +// uri: /v1/bookRatings +// route: +// - destination: +// host: ratings +// subset: v1 +// +type HTTPRewrite struct { + // rewrite the path (or the prefix) portion of the URI with this + // value. If the original URI was matched based on prefix, the value + // provided in this field will replace the corresponding matched prefix. + Uri string `json:"uri,omitempty"` + + // rewrite the Authority/Host header with this value. + Authority string `json:"authority,omitempty"` +} + +// Describes the retry policy to use when a HTTP request fails. For +// example, the following rule sets the maximum number of retries to 3 when +// calling ratings:v1 service, with a 2s timeout per retry attempt. +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: ratings-route +// spec: +// hosts: +// - ratings +// http: +// - route: +// - destination: +// host: ratings +// subset: v1 +// retries: +// attempts: 3 +// perTryTimeout: 2s +// +type HTTPRetry struct { + // REQUIRED. Number of retries for a given request. The interval + // between retries will be determined automatically (25ms+). Actual + // number of retries attempted depends on the httpReqTimeout. + Attempts int `json:"attempts"` + + // Timeout per retry attempt for a given request. format: 1h/1m/1s/1ms. MUST BE >=1ms. + PerTryTimeout string `json:"perTryTimeout"` +} + +// Describes the Cross-Origin Resource Sharing (CORS) policy, for a given +// service. Refer to +// https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS +// for further details about cross origin resource sharing. For example, +// the following rule restricts cross origin requests to those originating +// from example.com domain using HTTP POST/GET, and sets the +// Access-Control-Allow-Credentials header to false. In addition, it only +// exposes X-Foo-bar header and sets an expiry period of 1 day. +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: ratings-route +// spec: +// hosts: +// - ratings +// http: +// - route: +// - destination: +// host: ratings +// subset: v1 +// corsPolicy: +// allowOrigin: +// - example.com +// allowMethods: +// - POST +// - GET +// allowCredentials: false +// allowHeaders: +// - X-Foo-Bar +// maxAge: "1d" +// +type CorsPolicy struct { + // The list of origins that are allowed to perform CORS requests. The + // content will be serialized into the Access-Control-Allow-Origin + // header. Wildcard * will allow all origins. + AllowOrigin []string `json:"allowOrigin,omitempty"` + + // List of HTTP methods allowed to access the resource. The content will + // be serialized into the Access-Control-Allow-Methods header. + AllowMethods []string `json:"allowMethods,omitempty"` + + // List of HTTP headers that can be used when requesting the + // resource. Serialized to Access-Control-Allow-Methods header. + AllowHeaders []string `json:"allowHeaders,omitempty"` + + // A white list of HTTP headers that the browsers are allowed to + // access. Serialized into Access-Control-Expose-Headers header. + ExposeHeaders []string `json:"exposeHeaders,omitempty"` + + // Specifies how long the the results of a preflight request can be + // cached. Translates to the Access-Control-Max-Age header. + MaxAge string `json:"maxAge,omitempty"` + + // Indicates whether the caller is allowed to send the actual request + // (not the preflight) using credentials. Translates to + // Access-Control-Allow-Credentials header. + AllowCredentials bool `json:"allowCredentials,omitempty"` +} + +// HTTPFaultInjection can be used to specify one or more faults to inject +// while forwarding http requests to the destination specified in a route. +// Fault specification is part of a VirtualService rule. Faults include +// aborting the Http request from downstream service, and/or delaying +// proxying of requests. A fault rule MUST HAVE delay or abort or both. +// +// *Note:* Delay and abort faults are independent of one another, even if +// both are specified simultaneously. +type HTTPFaultInjection struct { + // Delay requests before forwarding, emulating various failures such as + // network issues, overloaded upstream service, etc. + Delay *InjectDelay `json:"delay,omitempty"` + + // Abort Http request attempts and return error codes back to downstream + // service, giving the impression that the upstream service is faulty. + Abort *InjectAbort `json:"abort,omitempty"` +} + +// Delay specification is used to inject latency into the request +// forwarding path. The following example will introduce a 5 second delay +// in 10% of the requests to the "v1" version of the "reviews" +// service from all pods with label env: prod +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: reviews-route +// spec: +// hosts: +// - reviews +// http: +// - match: +// - sourceLabels: +// env: prod +// route: +// - destination: +// host: reviews +// subset: v1 +// fault: +// delay: +// percent: 10 +// fixedDelay: 5s +// +// The _fixedDelay_ field is used to indicate the amount of delay in +// seconds. An optional _percent_ field, a value between 0 and 100, can +// be used to only delay a certain percentage of requests. If left +// unspecified, all request will be delayed. +type InjectDelay struct { + // Percentage of requests on which the delay will be injected (0-100). + Percent int `json:"percent,omitempty"` + + // REQUIRED. Add a fixed delay before forwarding the request. Format: + // 1h/1m/1s/1ms. MUST be >=1ms. + FixedDelay string `json:"fixedDelay"` + + // (-- Add a delay (based on an exponential function) before forwarding + // the request. mean delay needed to derive the exponential delay + // values --) + ExponentialDelay string `json:"exponentialDelay,omitempty"` +} + +// Abort specification is used to prematurely abort a request with a +// pre-specified error code. The following example will return an HTTP +// 400 error code for 10% of the requests to the "ratings" service "v1". +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: ratings-route +// spec: +// hosts: +// - ratings +// http: +// - route: +// - destination: +// host: ratings +// subset: v1 +// fault: +// abort: +// percent: 10 +// httpStatus: 400 +// +// The _httpStatus_ field is used to indicate the HTTP status code to +// return to the caller. The optional _percent_ field, a value between 0 +// and 100, is used to only abort a certain percentage of requests. If +// not specified, all requests are aborted. +type InjectAbort struct { + // Percentage of requests to be aborted with the error code provided (0-100). + Perecent int `json:"percent,omitempty"` + + // REQUIRED. HTTP status code to use to abort the Http request. + HttpStatus int `json:"httpStatus"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// VirtualServiceList is a list of VirtualService resources +type VirtualServiceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []VirtualService `json:"items"` +} diff --git a/vendor/github.com/knative/serving/pkg/apis/istio/v1alpha3/zz_generated.deepcopy.go b/vendor/github.com/knative/serving/pkg/apis/istio/v1alpha3/zz_generated.deepcopy.go new file mode 100644 index 00000000000..5857c8585ae --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/istio/v1alpha3/zz_generated.deepcopy.go @@ -0,0 +1,701 @@ +// +build !ignore_autogenerated + +/* +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. +*/ + +// This file was autogenerated by deepcopy-gen. Do not edit it manually! + +package v1alpha3 + +import ( + 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 *CorsPolicy) DeepCopyInto(out *CorsPolicy) { + *out = *in + if in.AllowOrigin != nil { + in, out := &in.AllowOrigin, &out.AllowOrigin + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.AllowMethods != nil { + in, out := &in.AllowMethods, &out.AllowMethods + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.AllowHeaders != nil { + in, out := &in.AllowHeaders, &out.AllowHeaders + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.ExposeHeaders != nil { + in, out := &in.ExposeHeaders, &out.ExposeHeaders + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CorsPolicy. +func (in *CorsPolicy) DeepCopy() *CorsPolicy { + if in == nil { + return nil + } + out := new(CorsPolicy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Destination) DeepCopyInto(out *Destination) { + *out = *in + out.Port = in.Port + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Destination. +func (in *Destination) DeepCopy() *Destination { + if in == nil { + return nil + } + out := new(Destination) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DestinationWeight) DeepCopyInto(out *DestinationWeight) { + *out = *in + out.Destination = in.Destination + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DestinationWeight. +func (in *DestinationWeight) DeepCopy() *DestinationWeight { + if in == nil { + return nil + } + out := new(DestinationWeight) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Gateway) DeepCopyInto(out *Gateway) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Gateway. +func (in *Gateway) DeepCopy() *Gateway { + if in == nil { + return nil + } + out := new(Gateway) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Gateway) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GatewayList) DeepCopyInto(out *GatewayList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Gateway, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GatewayList. +func (in *GatewayList) DeepCopy() *GatewayList { + if in == nil { + return nil + } + out := new(GatewayList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *GatewayList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GatewaySpec) DeepCopyInto(out *GatewaySpec) { + *out = *in + if in.Servers != nil { + in, out := &in.Servers, &out.Servers + *out = make([]Server, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GatewaySpec. +func (in *GatewaySpec) DeepCopy() *GatewaySpec { + if in == nil { + return nil + } + out := new(GatewaySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HTTPFaultInjection) DeepCopyInto(out *HTTPFaultInjection) { + *out = *in + if in.Delay != nil { + in, out := &in.Delay, &out.Delay + if *in == nil { + *out = nil + } else { + *out = new(InjectDelay) + **out = **in + } + } + if in.Abort != nil { + in, out := &in.Abort, &out.Abort + if *in == nil { + *out = nil + } else { + *out = new(InjectAbort) + **out = **in + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPFaultInjection. +func (in *HTTPFaultInjection) DeepCopy() *HTTPFaultInjection { + if in == nil { + return nil + } + out := new(HTTPFaultInjection) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HTTPMatchRequest) DeepCopyInto(out *HTTPMatchRequest) { + *out = *in + if in.Uri != nil { + in, out := &in.Uri, &out.Uri + if *in == nil { + *out = nil + } else { + *out = new(StringMatch) + **out = **in + } + } + if in.Scheme != nil { + in, out := &in.Scheme, &out.Scheme + if *in == nil { + *out = nil + } else { + *out = new(StringMatch) + **out = **in + } + } + if in.Method != nil { + in, out := &in.Method, &out.Method + if *in == nil { + *out = nil + } else { + *out = new(StringMatch) + **out = **in + } + } + if in.Authority != nil { + in, out := &in.Authority, &out.Authority + if *in == nil { + *out = nil + } else { + *out = new(StringMatch) + **out = **in + } + } + if in.Headers != nil { + in, out := &in.Headers, &out.Headers + *out = make(map[string]StringMatch, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPMatchRequest. +func (in *HTTPMatchRequest) DeepCopy() *HTTPMatchRequest { + if in == nil { + return nil + } + out := new(HTTPMatchRequest) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HTTPRedirect) DeepCopyInto(out *HTTPRedirect) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPRedirect. +func (in *HTTPRedirect) DeepCopy() *HTTPRedirect { + if in == nil { + return nil + } + out := new(HTTPRedirect) + 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 + 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 *HTTPRewrite) DeepCopyInto(out *HTTPRewrite) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPRewrite. +func (in *HTTPRewrite) DeepCopy() *HTTPRewrite { + if in == nil { + return nil + } + out := new(HTTPRewrite) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HTTPRoute) DeepCopyInto(out *HTTPRoute) { + *out = *in + if in.Match != nil { + in, out := &in.Match, &out.Match + *out = make([]HTTPMatchRequest, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Route != nil { + in, out := &in.Route, &out.Route + *out = make([]DestinationWeight, len(*in)) + copy(*out, *in) + } + if in.Redirect != nil { + in, out := &in.Redirect, &out.Redirect + if *in == nil { + *out = nil + } else { + *out = new(HTTPRedirect) + **out = **in + } + } + if in.Rewrite != nil { + in, out := &in.Rewrite, &out.Rewrite + if *in == nil { + *out = nil + } else { + *out = new(HTTPRewrite) + **out = **in + } + } + if in.Retries != nil { + in, out := &in.Retries, &out.Retries + if *in == nil { + *out = nil + } else { + *out = new(HTTPRetry) + **out = **in + } + } + if in.Fault != nil { + in, out := &in.Fault, &out.Fault + if *in == nil { + *out = nil + } else { + *out = new(HTTPFaultInjection) + (*in).DeepCopyInto(*out) + } + } + if in.Mirror != nil { + in, out := &in.Mirror, &out.Mirror + if *in == nil { + *out = nil + } else { + *out = new(Destination) + **out = **in + } + } + 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.RemoveResponseHeaders != nil { + in, out := &in.RemoveResponseHeaders, &out.RemoveResponseHeaders + *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 HTTPRoute. +func (in *HTTPRoute) DeepCopy() *HTTPRoute { + if in == nil { + return nil + } + out := new(HTTPRoute) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InjectAbort) DeepCopyInto(out *InjectAbort) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InjectAbort. +func (in *InjectAbort) DeepCopy() *InjectAbort { + if in == nil { + return nil + } + out := new(InjectAbort) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InjectDelay) DeepCopyInto(out *InjectDelay) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InjectDelay. +func (in *InjectDelay) DeepCopy() *InjectDelay { + if in == nil { + return nil + } + out := new(InjectDelay) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *L4MatchAttributes) DeepCopyInto(out *L4MatchAttributes) { + *out = *in + if in.SourceLabel != nil { + in, out := &in.SourceLabel, &out.SourceLabel + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Gateways != nil { + in, out := &in.Gateways, &out.Gateways + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new L4MatchAttributes. +func (in *L4MatchAttributes) DeepCopy() *L4MatchAttributes { + if in == nil { + return nil + } + out := new(L4MatchAttributes) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Port) DeepCopyInto(out *Port) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Port. +func (in *Port) DeepCopy() *Port { + if in == nil { + return nil + } + out := new(Port) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PortSelector) DeepCopyInto(out *PortSelector) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortSelector. +func (in *PortSelector) DeepCopy() *PortSelector { + if in == nil { + return nil + } + out := new(PortSelector) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Server) DeepCopyInto(out *Server) { + *out = *in + out.Port = in.Port + if in.Hosts != nil { + in, out := &in.Hosts, &out.Hosts + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.TLS != nil { + in, out := &in.TLS, &out.TLS + if *in == nil { + *out = nil + } else { + *out = new(TLSOptions) + (*in).DeepCopyInto(*out) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Server. +func (in *Server) DeepCopy() *Server { + if in == nil { + return nil + } + out := new(Server) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StringMatch) DeepCopyInto(out *StringMatch) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StringMatch. +func (in *StringMatch) DeepCopy() *StringMatch { + if in == nil { + return nil + } + out := new(StringMatch) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TCPRoute) DeepCopyInto(out *TCPRoute) { + *out = *in + if in.Match != nil { + in, out := &in.Match, &out.Match + *out = make([]L4MatchAttributes, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + out.Route = in.Route + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TCPRoute. +func (in *TCPRoute) DeepCopy() *TCPRoute { + if in == nil { + return nil + } + out := new(TCPRoute) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TLSOptions) DeepCopyInto(out *TLSOptions) { + *out = *in + if in.SubjectAltNames != nil { + in, out := &in.SubjectAltNames, &out.SubjectAltNames + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TLSOptions. +func (in *TLSOptions) DeepCopy() *TLSOptions { + if in == nil { + return nil + } + out := new(TLSOptions) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualService) DeepCopyInto(out *VirtualService) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualService. +func (in *VirtualService) DeepCopy() *VirtualService { + if in == nil { + return nil + } + out := new(VirtualService) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VirtualService) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualServiceList) DeepCopyInto(out *VirtualServiceList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]VirtualService, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualServiceList. +func (in *VirtualServiceList) DeepCopy() *VirtualServiceList { + if in == nil { + return nil + } + out := new(VirtualServiceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VirtualServiceList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualServiceSpec) DeepCopyInto(out *VirtualServiceSpec) { + *out = *in + if in.Hosts != nil { + in, out := &in.Hosts, &out.Hosts + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Gateways != nil { + in, out := &in.Gateways, &out.Gateways + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Http != nil { + in, out := &in.Http, &out.Http + *out = make([]HTTPRoute, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Tcp != nil { + in, out := &in.Tcp, &out.Tcp + *out = make([]TCPRoute, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualServiceSpec. +func (in *VirtualServiceSpec) DeepCopy() *VirtualServiceSpec { + if in == nil { + return nil + } + out := new(VirtualServiceSpec) + in.DeepCopyInto(out) + return out +} 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 00000000000..d4c7ae5f880 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/register.go @@ -0,0 +1,49 @@ +/* +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" + + // ConfigurationGenerationAnnotationKey is the annotation key attached to a Revision indicating the + // generation of the Configuration that created this revision + ConfigurationGenerationAnnotationKey = GroupName + "/configurationGeneration" + + // RouteLabelKey is the label key attached to a Configuration indicating by + // which Route it is configured as traffic target. + RouteLabelKey = GroupName + "/route" + + // 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" + + // AutoscalerLabelKey is the label key attached to a autoscaler pod indicating by + // which Autoscaler deployment it is created. + AutoscalerLabelKey = GroupName + "/autoscaler" + + // ServiceLabelKey is the label key attached to a Route and Configuration indicating by + // which Service they are created. + ServiceLabelKey = GroupName + "/service" +) 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 00000000000..559ede792d8 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_defaults.go @@ -0,0 +1,24 @@ +/* +Copyright 2017 The Knative Authors +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT 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 + +func (c *Configuration) SetDefaults() { + c.Spec.SetDefaults() +} + +func (cs *ConfigurationSpec) SetDefaults() { + cs.RevisionTemplate.Spec.SetDefaults() +} 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 00000000000..0bb54743e30 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_types.go @@ -0,0 +1,282 @@ +/* +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 ( + "encoding/json" + "fmt" + "reflect" + "time" + + build "github.com/knative/build/pkg/apis/build/v1alpha1" + + 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 + +// 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"` +} + +// Check that Configuration may be validated and defaulted. +var _ Validatable = (*Configuration)(nil) +var _ Defaultable = (*Configuration)(nil) + +// ConfigurationSpec holds the desired state of the Configuration (from the client). +type ConfigurationSpec struct { + // TODO: Generation does not work correctly with CRD. They are scrubbed + // by the APIserver (https://github.com/kubernetes/kubernetes/issues/58778) + // So, we add Generation here. Once that gets fixed, remove this and use + // ObjectMeta.Generation instead. + // +optional + Generation int64 `json:"generation,omitempty"` + + // Build optionally holds the specification for the build to + // perform to produce the Revision's container image. + // +optional + Build *build.BuildSpec `json:"build,omitempty"` + + // RevisionTemplate holds the latest specification for the Revision to + // be stamped out. If a Build specification is provided, then the + // RevisionTemplate's BuildName field will be populated with the name of + // the Build object created to produce the container for the Revision. + // +optional + RevisionTemplate RevisionTemplateSpec `json:"revisionTemplate"` +} + +// ConfigurationConditionType is used to communicate the status of the reconciliation process. +// See also: https://github.com/knative/serving/blob/master/docs/spec/errors.md#error-conditions-and-reporting +type ConfigurationConditionType string + +const ( + // ConfigurationConditionReady is set when the configuration's latest + // underlying revision has reported readiness. + ConfigurationConditionReady ConfigurationConditionType = "Ready" +) + +// ConfigurationCondition defines a readiness condition for a Configuration. +// See: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#typical-status-properties +type ConfigurationCondition struct { + Type ConfigurationConditionType `json:"type" description:"type of Configuration condition"` + + Status corev1.ConditionStatus `json:"status" description:"status of the condition, one of True, False, Unknown"` + + // +optional + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" description:"last time the condition transit from one status to another"` + + // +optional + Reason string `json:"reason,omitempty" description:"one-word CamelCase reason for the condition's last transition"` + + // +optional + Message string `json:"message,omitempty" description:"human-readable message indicating details about last transition"` +} + +// ConfigurationStatus communicates the observed state of the Configuration (from the controller). +type ConfigurationStatus struct { + // Conditions communicates information about ongoing/complete + // reconciliation processes that bring the "spec" inline with the observed + // state of the world. + // +optional + Conditions []ConfigurationCondition `json:"conditions,omitempty"` + + // 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"` + + // ObservedGeneration is the 'Generation' of the Configuration that + // was last processed by the controller. The observed generation is updated + // even if the controller failed to process the spec and create the Revision. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` +} + +// +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"` +} + +func (r *Configuration) GetGeneration() int64 { + return r.Spec.Generation +} + +func (r *Configuration) SetGeneration(generation int64) { + r.Spec.Generation = generation +} + +func (r *Configuration) GetSpecJSON() ([]byte, error) { + return json.Marshal(r.Spec) +} + +// IsReady looks at the conditions on the ConfigurationStatus. +// ConfigurationConditionReady returns true if ConditionStatus is True +func (cs *ConfigurationStatus) IsReady() bool { + if c := cs.GetCondition(ConfigurationConditionReady); c != nil { + return c.Status == corev1.ConditionTrue + } + return false +} + +// 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 (config *ConfigurationStatus) GetCondition(t ConfigurationConditionType) *ConfigurationCondition { + for _, cond := range config.Conditions { + if cond.Type == t { + return &cond + } + } + return nil +} + +func (cs *ConfigurationStatus) setCondition(new *ConfigurationCondition) { + if new == nil { + return + } + t := new.Type + var conditions []ConfigurationCondition + for _, cond := range cs.Conditions { + if cond.Type != t { + conditions = append(conditions, cond) + } else { + // If we'd only update the LastTransitionTime, then return. + new.LastTransitionTime = cond.LastTransitionTime + if reflect.DeepEqual(new, &cond) { + return + } + } + } + new.LastTransitionTime = metav1.NewTime(time.Now()) + conditions = append(conditions, *new) + cs.Conditions = conditions +} + +func (cs *ConfigurationStatus) RemoveCondition(t ConfigurationConditionType) { + var conditions []ConfigurationCondition + for _, cond := range cs.Conditions { + if cond.Type != t { + conditions = append(conditions, cond) + } + } + cs.Conditions = conditions +} + +func (cs *ConfigurationStatus) InitializeConditions() { + for _, cond := range []ConfigurationConditionType{ + ConfigurationConditionReady, + } { + if rc := cs.GetCondition(cond); rc == nil { + cs.setCondition(&ConfigurationCondition{ + Type: cond, + Status: corev1.ConditionUnknown, + }) + } + } +} + +func (cs *ConfigurationStatus) SetLatestCreatedRevisionName(name string) { + cs.LatestCreatedRevisionName = name + if cs.LatestReadyRevisionName != name { + cs.setCondition(&ConfigurationCondition{ + Type: ConfigurationConditionReady, + Status: corev1.ConditionUnknown, + }) + } +} + +func (cs *ConfigurationStatus) SetLatestReadyRevisionName(name string) { + cs.LatestReadyRevisionName = name + for _, cond := range []ConfigurationConditionType{ + ConfigurationConditionReady, + } { + cs.setCondition(&ConfigurationCondition{ + Type: cond, + Status: corev1.ConditionTrue, + }) + } +} + +func (cs *ConfigurationStatus) MarkLatestCreatedFailed(name, message string) { + cct := []ConfigurationConditionType{ConfigurationConditionReady} + if cs.LatestReadyRevisionName == "" { + cct = append(cct, ConfigurationConditionReady) + } + for _, cond := range cct { + cs.setCondition(&ConfigurationCondition{ + Type: cond, + Status: corev1.ConditionFalse, + Reason: "RevisionFailed", + Message: fmt.Sprintf("Revision %q failed with message: %q.", name, message), + }) + } +} + +func (cs *ConfigurationStatus) MarkRevisionCreationFailed(message string) { + cs.setCondition(&ConfigurationCondition{ + Type: ConfigurationConditionReady, + Status: corev1.ConditionFalse, + Reason: "RevisionFailed", + Message: fmt.Sprintf("Revision creation failed with message: %q.", message), + }) +} + +func (cs *ConfigurationStatus) MarkLatestReadyDeleted() { + cct := []ConfigurationConditionType{ConfigurationConditionReady} + for _, cond := range cct { + cs.setCondition(&ConfigurationCondition{ + Type: cond, + Status: corev1.ConditionFalse, + Reason: "RevisionDeleted", + Message: fmt.Sprintf("Revision %q was deleted.", cs.LatestReadyRevisionName), + }) + } + cs.LatestReadyRevisionName = "" +} 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 00000000000..5a28faeb40d --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/configuration_validation.go @@ -0,0 +1,36 @@ +/* +Copyright 2017 The Knative Authors +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT 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/api/equality" +) + +func (c *Configuration) Validate() *FieldError { + return c.Spec.Validate().ViaField("spec") +} + +func (cs *ConfigurationSpec) Validate() *FieldError { + if equality.Semantic.DeepEqual(cs, &ConfigurationSpec{}) { + return errMissingField(currentField) + } + // In the context of Configuration, serving state may not be specified at all. + // TODO(mattmoor): Check ObjectMeta for Name/Namespace/GenerateName + if cs.RevisionTemplate.Spec.ServingState != "" { + return errDisallowedFields("revisionTemplate.spec.servingState") + } + return cs.RevisionTemplate.Validate().ViaField("revisionTemplate") +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/defaults.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/defaults.go new file mode 100644 index 00000000000..f458c0650f7 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/defaults.go @@ -0,0 +1,22 @@ +/* +Copyright 2017 The Knative Authors +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT 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 + +// Defaultable defines an interface for setting the defaults for the +// uninitialized fields of this instance. +type Defaultable interface { + SetDefaults() +} 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 00000000000..b0c5ebaf7c1 --- /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/field_error.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/field_error.go new file mode 100644 index 00000000000..18321cfb74e --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/field_error.go @@ -0,0 +1,106 @@ +/* +Copyright 2017 The Knative Authors +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT 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" + "strings" +) + +// currentField is a constant to supply as a fieldPath for when there is +// a problem with the current field itself. +const currentField = "" + +// FieldError is used to propagate the context of errors pertaining to +// specific fields in a manner suitable for use in a recursive walk, so +// that errors contain the appropriate field context. +// +k8s:deepcopy-gen=false +type FieldError struct { + Message string + Paths []string + // Details contains an optional longer payload. + Details string +} + +// FieldError implements error +var _ error = (*FieldError)(nil) + +// Validatable indicates that a particular type may have its fields validated. +type Validatable interface { + // Validate checks the validity of this types fields. + Validate() *FieldError +} + +// HasImmutableFields indicates that a particular type has fields that should +// not change after creation. +type HasImmutableFields interface { + // CheckImmutableFields checks that the current instance's immutable + // fields haven't changed from the provided original. + CheckImmutableFields(original HasImmutableFields) *FieldError +} + +// ViaField is used to propagate a validation error along a field access. +// For example, if a type recursively validates its "spec" via: +// if err := foo.Spec.Validate(); err != nil { +// // Augment any field paths with the context that they were accessed +// // via "spec". +// return err.ViaField("spec") +// } +func (fe *FieldError) ViaField(prefix ...string) *FieldError { + if fe == nil { + return nil + } + var newPaths []string + for _, oldPath := range fe.Paths { + if oldPath == currentField { + newPaths = append(newPaths, strings.Join(prefix, ".")) + } else { + newPaths = append(newPaths, + strings.Join(append(prefix, oldPath), ".")) + } + } + fe.Paths = newPaths + return fe +} + +// Error implements error +func (fe *FieldError) Error() string { + if fe.Details == "" { + return fmt.Sprintf("%v: %v", fe.Message, strings.Join(fe.Paths, ", ")) + } + return fmt.Sprintf("%v: %v\n%v", fe.Message, strings.Join(fe.Paths, ", "), fe.Details) +} + +func errMissingField(fieldPaths ...string) *FieldError { + return &FieldError{ + Message: "missing field(s)", + Paths: fieldPaths, + } +} + +func errDisallowedFields(fieldPaths ...string) *FieldError { + return &FieldError{ + Message: "must not set the field(s)", + Paths: fieldPaths, + } +} + +func errInvalidValue(value string, fieldPath string) *FieldError { + return &FieldError{ + Message: fmt.Sprintf("invalid value %q", value), + Paths: []string{fieldPath}, + } +} diff --git a/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/immutable.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/immutable.go new file mode 100644 index 00000000000..d2883e221cd --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/immutable.go @@ -0,0 +1,16 @@ +/* +Copyright 2017 The Knative Authors +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT 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 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 00000000000..0bad032a10e --- /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_defaults.go b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_defaults.go new file mode 100644 index 00000000000..db4bedfb6f1 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_defaults.go @@ -0,0 +1,32 @@ +/* +Copyright 2017 The Knative Authors +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT 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 + +func (r *Revision) SetDefaults() { + // We only set the default ServingState in the context of Revision + // because we want it unspecified in other contexts (e.g. RevisionTemplateSpec). + if r.Spec.ServingState == "" { + r.Spec.ServingState = RevisionServingStateActive + } + + r.Spec.SetDefaults() +} + +func (rs *RevisionSpec) SetDefaults() { + if rs.ConcurrencyModel == "" { + rs.ConcurrencyModel = RevisionRequestConcurrencyModelMulti + } +} 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 00000000000..7bafa1fd914 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_types.go @@ -0,0 +1,443 @@ +/* +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 ( + "encoding/json" + "reflect" + "time" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + buildv1alpha1 "github.com/knative/build/pkg/apis/build/v1alpha1" +) + +// +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"` +} + +// Check that Revision can be validated, can be defaulted, and has immutable fields. +var _ Validatable = (*Revision)(nil) +var _ Defaultable = (*Revision)(nil) +var _ HasImmutableFields = (*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"` +} + +// RevisionServingStateType 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 RevisionServingStateType 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. + RevisionServingStateActive RevisionServingStateType = "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. + RevisionServingStateReserve RevisionServingStateType = "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 + RevisionServingStateRetired RevisionServingStateType = "Retired" +) + +// RevisionRequestConcurrencyModelType is an enumeration of the +// concurrency models supported by a Revision. +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 { + // TODO: Generation does not work correctly with CRD. They are scrubbed + // by the APIserver (https://github.com/kubernetes/kubernetes/issues/58778) + // So, we add Generation here. Once that gets fixed, remove this and use + // ObjectMeta.Generation instead. + // +optional + Generation int64 `json:"generation,omitempty"` + + // ServingState 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. It is expected + // that the system will manipulate this based on routability and load. + // +optional + ServingState RevisionServingStateType `json:"servingState,omitempty"` + + // ConcurrencyModel specifies the desired concurrency model + // (Single or Multi) for the + // Revision. Defaults to Multi. + // +optional + ConcurrencyModel RevisionRequestConcurrencyModelType `json:"concurrencyModel,omitempty"` + + // ServiceAccountName holds the name of the Kubernetes service account + // as which the underlying K8s resources should be run. If unspecified + // this will default to the "default" service account for the namespace + // in which the Revision exists. + // This may be used to provide access to private container images by + // following: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#add-imagepullsecrets-to-a-service-account + // TODO(ZhiminXiang): verify the corresponding service account exists. + // +optional + ServiceAccountName string `json:"serviceAccountName,omitempty"` + + // BuildName optionally holds the name of the Build responsible for + // producing the container image for its Revision. + // +optional + BuildName string `json:"buildName,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, resources, ports, and volumeMounts. + // TODO(mattmoor): Link to the runtime contract tracked by: + // https://github.com/knative/serving/issues/627 + // +optional + Container corev1.Container `json:"container,omitempty"` +} + +// RevisionConditionType is used to communicate the status of the reconciliation process. +// See also: https://github.com/knative/serving/blob/master/docs/spec/errors.md#error-conditions-and-reporting +type RevisionConditionType string + +const ( + // RevisionConditionReady is set when the revision is starting to materialize + // runtime resources, and becomes true when those resources are ready. + RevisionConditionReady RevisionConditionType = "Ready" + // RevisionConditionBuildComplete is set when the revision has an associated build + // and is marked True if/once the Build has completed succesfully. + RevisionConditionBuildSucceeded RevisionConditionType = "BuildSucceeded" + // RevisionConditionResourcesAvailable is set when underlying + // Kubernetes resources have been provisioned. + RevisionConditionResourcesAvailable RevisionConditionType = "ResourcesAvailable" + // RevisionConditionContainerHealthy is set when the revision readiness check completes. + RevisionConditionContainerHealthy RevisionConditionType = "ContainerHealthy" +) + +// RevisionCondition defines a readiness condition for a Revision. +// See: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#typical-status-properties +type RevisionCondition struct { + Type RevisionConditionType `json:"type" description:"type of Revision condition"` + + Status corev1.ConditionStatus `json:"status" description:"status of the condition, one of True, False, Unknown"` + + // +optional + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" description:"last time the condition transit from one status to another"` + + // +optional + Reason string `json:"reason,omitempty" description:"one-word CamelCase reason for the condition's last transition"` + + // +optional + Message string `json:"message,omitempty" description:"human-readable message indicating details about last transition"` +} + +// RevisionStatus communicates the observed state of the Revision (from the controller). +type RevisionStatus struct { + // ServiceName holds the name of a core Kubernetes Service resource that + // load balances over the pods backing this Revision. When the Revision + // is Active, this service would be an appropriate ingress target for + // targeting the revision. + // +optional + ServiceName string `json:"serviceName,omitempty"` + + // Conditions communicates information about ongoing/complete + // reconciliation processes that bring the "spec" inline with the observed + // state of the world. + // +optional + Conditions []RevisionCondition `json:"conditions,omitempty"` + + // ObservedGeneration is the 'Generation' of the Configuration that + // was last processed by the controller. The observed generation is updated + // even if the controller failed to process the spec and create the Revision. + // +optional + ObservedGeneration int64 `json:"observedGeneration,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"` +} + +// +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"` +} + +func (r *Revision) GetGeneration() int64 { + return r.Spec.Generation +} + +func (r *Revision) SetGeneration(generation int64) { + r.Spec.Generation = generation +} + +func (r *Revision) GetSpecJSON() ([]byte, error) { + return json.Marshal(r.Spec) +} + +// IsReady looks at the conditions and if the Status has a condition +// RevisionConditionReady returns true if ConditionStatus is True +func (rs *RevisionStatus) IsReady() bool { + if c := rs.GetCondition(RevisionConditionReady); c != nil { + return c.Status == corev1.ConditionTrue + } + return false +} + +func (rs *RevisionStatus) IsActivationRequired() bool { + if c := rs.GetCondition(RevisionConditionReady); c != nil { + return (c.Reason == "Inactive" && c.Status == corev1.ConditionFalse) || + (c.Reason == "Updating" && c.Status == corev1.ConditionUnknown) + } + return false +} + +func (rs *RevisionStatus) IsRoutable() bool { + return rs.IsReady() || rs.IsActivationRequired() +} + +func (rs *RevisionStatus) GetCondition(t RevisionConditionType) *RevisionCondition { + for _, cond := range rs.Conditions { + if cond.Type == t { + return &cond + } + } + return nil +} + +func (rs *RevisionStatus) setCondition(new *RevisionCondition) { + if new == nil { + return + } + + t := new.Type + var conditions []RevisionCondition + for _, cond := range rs.Conditions { + if cond.Type != t { + conditions = append(conditions, cond) + } else { + // If we'd only update the LastTransitionTime, then return. + new.LastTransitionTime = cond.LastTransitionTime + if reflect.DeepEqual(new, &cond) { + return + } + } + } + new.LastTransitionTime = metav1.NewTime(time.Now()) + conditions = append(conditions, *new) + rs.Conditions = conditions +} + +func (rs *RevisionStatus) RemoveCondition(t RevisionConditionType) { + var conditions []RevisionCondition + for _, cond := range rs.Conditions { + if cond.Type != t { + conditions = append(conditions, cond) + } + } + rs.Conditions = conditions +} + +func (rs *RevisionStatus) InitializeConditions() { + // We don't include BuildSucceeded here because it could confuse users if + // no `buildName` was specified. + for _, cond := range []RevisionConditionType{ + RevisionConditionResourcesAvailable, + RevisionConditionContainerHealthy, + RevisionConditionReady, + } { + if rc := rs.GetCondition(cond); rc == nil { + rs.setCondition(&RevisionCondition{ + Type: cond, + Status: corev1.ConditionUnknown, + }) + } + } +} + +func (rs *RevisionStatus) InitializeBuildCondition() { + if rc := rs.GetCondition(RevisionConditionBuildSucceeded); rc == nil { + rs.setCondition(&RevisionCondition{ + Type: RevisionConditionBuildSucceeded, + Status: corev1.ConditionUnknown, + }) + } +} + +func (rs *RevisionStatus) PropagateBuildStatus(bs buildv1alpha1.BuildStatus) { + bc := bs.GetCondition(buildv1alpha1.BuildSucceeded) + if bc == nil { + return + } + rct := []RevisionConditionType{RevisionConditionBuildSucceeded} + // If the underlying Build is not ready, then mark the Revision not ready. + if bc.Status != corev1.ConditionTrue { + rct = append(rct, RevisionConditionReady) + } + reason := "Building" + if bc.Status != corev1.ConditionUnknown { + reason = bc.Reason + } + for _, cond := range rct { + rs.setCondition(&RevisionCondition{ + Type: cond, + Status: bc.Status, + Reason: reason, + Message: bc.Message, + }) + } +} + +func (rs *RevisionStatus) MarkDeploying(reason string) { + for _, cond := range []RevisionConditionType{ + RevisionConditionResourcesAvailable, + RevisionConditionContainerHealthy, + RevisionConditionReady, + } { + rs.setCondition(&RevisionCondition{ + Type: cond, + Status: corev1.ConditionUnknown, + Reason: reason, + }) + } +} + +func (rs *RevisionStatus) MarkServiceTimeout() { + for _, cond := range []RevisionConditionType{ + RevisionConditionResourcesAvailable, + RevisionConditionReady, + } { + rs.setCondition(&RevisionCondition{ + Type: cond, + Status: corev1.ConditionFalse, + Reason: "ServiceTimeout", + Message: "Timed out waiting for a service endpoint to become ready", + }) + } +} + +func (rs *RevisionStatus) MarkProgressDeadlineExceeded(message string) { + for _, cond := range []RevisionConditionType{ + RevisionConditionResourcesAvailable, + RevisionConditionReady, + } { + rs.setCondition(&RevisionCondition{ + Type: cond, + Status: corev1.ConditionFalse, + Reason: "ProgressDeadlineExceeded", + Message: message, + }) + } +} + +func (rs *RevisionStatus) MarkContainerHealthy() { + rs.setCondition(&RevisionCondition{ + Type: RevisionConditionContainerHealthy, + Status: corev1.ConditionTrue, + }) + rs.checkAndMarkReady() +} + +func (rs *RevisionStatus) MarkResourcesAvailable() { + rs.setCondition(&RevisionCondition{ + Type: RevisionConditionResourcesAvailable, + Status: corev1.ConditionTrue, + }) + rs.checkAndMarkReady() +} + +func (rs *RevisionStatus) MarkInactive() { + rs.setCondition(&RevisionCondition{ + Type: RevisionConditionReady, + Status: corev1.ConditionFalse, + Reason: "Inactive", + }) +} + +func (rs *RevisionStatus) MarkContainerMissing(message string) { + for _, cond := range []RevisionConditionType{ + RevisionConditionContainerHealthy, + RevisionConditionReady, + } { + rs.setCondition(&RevisionCondition{ + Type: cond, + Status: corev1.ConditionFalse, + Reason: "ContainerMissing", + Message: message, + }) + } +} + +func (rs *RevisionStatus) checkAndMarkReady() { + for _, cond := range []RevisionConditionType{ + RevisionConditionContainerHealthy, + RevisionConditionResourcesAvailable, + } { + c := rs.GetCondition(cond) + if c == nil || c.Status != corev1.ConditionTrue { + return + } + } + rs.markReady() +} + +func (rs *RevisionStatus) markReady() { + rs.setCondition(&RevisionCondition{ + Type: RevisionConditionReady, + Status: corev1.ConditionTrue, + }) +} 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 00000000000..fc90195fce8 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/revision_validation.go @@ -0,0 +1,141 @@ +/* +Copyright 2017 The Knative Authors +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT 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/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/equality" + "k8s.io/apimachinery/pkg/util/intstr" +) + +func (rt *Revision) Validate() *FieldError { + return rt.Spec.Validate().ViaField("spec") +} + +func (rt *RevisionTemplateSpec) Validate() *FieldError { + return rt.Spec.Validate().ViaField("spec") +} + +func (rs *RevisionSpec) Validate() *FieldError { + if equality.Semantic.DeepEqual(rs, &RevisionSpec{}) { + return errMissingField(currentField) + } + if err := rs.ServingState.Validate(); err != nil { + return err.ViaField("servingState") + } + if err := validateContainer(rs.Container); err != nil { + return err.ViaField("container") + } + return rs.ConcurrencyModel.Validate().ViaField("concurrencyModel") +} + +func (ss RevisionServingStateType) Validate() *FieldError { + switch ss { + case RevisionServingStateType(""), + RevisionServingStateRetired, + RevisionServingStateReserve, + RevisionServingStateActive: + return nil + default: + return errInvalidValue(string(ss), currentField) + } +} + +func (cm RevisionRequestConcurrencyModelType) Validate() *FieldError { + switch cm { + case RevisionRequestConcurrencyModelType(""), + RevisionRequestConcurrencyModelMulti, + RevisionRequestConcurrencyModelSingle: + return nil + default: + return errInvalidValue(string(cm), currentField) + } +} + +func validateContainer(container corev1.Container) *FieldError { + if equality.Semantic.DeepEqual(container, corev1.Container{}) { + return errMissingField(currentField) + } + // Some corev1.Container fields are set by Knative Serving controller. We disallow them + // here to avoid silently overwriting these fields and causing confusions for + // the users. See pkg/controller/revision/resources/deploy.go#makePodSpec. + var ignoredFields []string + if container.Name != "" { + ignoredFields = append(ignoredFields, "name") + } + if !equality.Semantic.DeepEqual(container.Resources, corev1.ResourceRequirements{}) { + ignoredFields = append(ignoredFields, "resources") + } + if len(container.Ports) > 0 { + ignoredFields = append(ignoredFields, "ports") + } + if len(container.VolumeMounts) > 0 { + ignoredFields = append(ignoredFields, "volumeMounts") + } + if container.Lifecycle != nil { + ignoredFields = append(ignoredFields, "lifecycle") + } + if len(ignoredFields) > 0 { + // Complain about all ignored fields so that user can remove them all at once. + return errDisallowedFields(ignoredFields...) + } + // Validate our probes + if err := validateProbe(container.ReadinessProbe); err != nil { + return err.ViaField("readinessProbe") + } + if err := validateProbe(container.LivenessProbe); err != nil { + return err.ViaField("livenessProbe") + } + return nil +} + +func validateProbe(p *corev1.Probe) *FieldError { + if p == nil { + return nil + } + emptyPort := intstr.IntOrString{} + switch { + case p.Handler.HTTPGet != nil: + if p.Handler.HTTPGet.Port != emptyPort { + return errDisallowedFields("httpGet.port") + } + case p.Handler.TCPSocket != nil: + if p.Handler.TCPSocket.Port != emptyPort { + return errDisallowedFields("tcpSocket.port") + } + } + return nil +} + +func (current *Revision) CheckImmutableFields(og HasImmutableFields) *FieldError { + original, ok := og.(*Revision) + if !ok { + return &FieldError{Message: "The provided original was not a Revision"} + } + + // The autoscaler is allowed to change ServingState, but consider the rest. + ignoreServingState := cmpopts.IgnoreFields(RevisionSpec{}, "ServingState") + if diff := cmp.Diff(original.Spec, current.Spec, ignoreServingState); diff != "" { + return &FieldError{ + Message: "Immutable fields changed (-old +new)", + Paths: []string{"spec"}, + Details: diff, + } + } + return nil +} 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 00000000000..a385269be46 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_defaults.go @@ -0,0 +1,23 @@ +/* +Copyright 2017 The Knative Authors +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT 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 + +func (r *Route) SetDefaults() { + r.Spec.SetDefaults() +} + +func (rs *RouteSpec) SetDefaults() { +} 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 00000000000..3a33ad03703 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_types.go @@ -0,0 +1,343 @@ +/* +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 ( + "encoding/json" + "fmt" + "reflect" + "time" + + 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 + +// 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"` +} + +// Check that Route may be validated and defaulted. +var _ Validatable = (*Route)(nil) +var _ Defaultable = (*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 + Name string `json:"name,omitempty"` + + // RevisionName of a specific revision to which to send this portion of traffic. + // This is mutually exclusive with ConfigurationName. + // +optional + RevisionName string `json:"revisionName,omitempty"` + + // ConfigurationName of a configuration to whose latest revision we will send + // this portion of traffic. When the "status.latestReadyRevisionName" of the + // referenced configuration changes, we will automatically migrate traffic + // from the prior "latest ready" revision to the new one. + // This field is never set in Route's status, only its spec. + // This is mutually exclusive with RevisionName. + // +optional + ConfigurationName string `json:"configurationName,omitempty"` + + // Percent specifies percent of the traffic to this Revision or Configuration. + // This defaults to zero if unspecified. + Percent int `json:"percent"` +} + +// RouteSpec holds the desired state of the Route (from the client). +type RouteSpec struct { + // TODO: Generation does not work correctly with CRD. They are scrubbed + // by the APIserver (https://github.com/kubernetes/kubernetes/issues/58778) + // So, we add Generation here. Once that gets fixed, remove this and use + // ObjectMeta.Generation instead. + // +optional + Generation 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"` +} + +// RouteCondition defines a readiness condition. +// See: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#typical-status-properties +type RouteCondition struct { + Type RouteConditionType `json:"type"` + + Status corev1.ConditionStatus `json:"status" description:"status of the condition, one of True, False, Unknown"` + + // +optional + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" description:"last time the condition transit from one status to another"` + + // +optional + Reason string `json:"reason,omitempty" description:"one-word CamelCase reason for the condition's last transition"` + // +optional + Message string `json:"message,omitempty" description:"human-readable message indicating details about last transition"` +} + +// RouteConditionType is used to communicate the status of the reconciliation process. +// See also: https://github.com/knative/serving/blob/master/docs/spec/errors.md#error-conditions-and-reporting +type RouteConditionType string + +const ( + // RouteConditionReady is set when the service is configured + // and has available backends ready to receive traffic. + RouteConditionReady RouteConditionType = "Ready" + + // RouteConditionAllTrafficAssigned is set to False when the + // service is not configured properly or has no available + // backends ready to receive traffic. + RouteConditionAllTrafficAssigned RouteConditionType = "AllTrafficAssigned" +) + +// RouteStatus communicates the observed state of the Route (from the controller). +type RouteStatus struct { + // Domain holds the top-level domain that will distribute traffic over the provided targets. + // It generally has the form {route-name}.{route-namespace}.{cluster-level-suffix} + // +optional + Domain string `json:"domain,omitempty"` + + // DomainInternal 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.local + // +optional + DomainInternal string `json:"domainInternal,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"` + + // Conditions communicates information about ongoing/complete + // reconciliation processes that bring the "spec" inline with the observed + // state of the world. + // +optional + Conditions []RouteCondition `json:"conditions,omitempty"` + + // ObservedGeneration is the 'Generation' of the Configuration that + // was last processed by the controller. The observed generation is updated + // even if the controller failed to process the spec and create the Revision. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` +} + +// +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"` +} + +func (r *Route) GetGeneration() int64 { + return r.Spec.Generation +} + +func (r *Route) SetGeneration(generation int64) { + r.Spec.Generation = generation +} + +func (r *Route) GetSpecJSON() ([]byte, error) { + return json.Marshal(r.Spec) +} + +func (rs *RouteStatus) IsReady() bool { + if c := rs.GetCondition(RouteConditionReady); c != nil { + return c.Status == corev1.ConditionTrue + } + return false +} + +func (rs *RouteStatus) GetCondition(t RouteConditionType) *RouteCondition { + for _, cond := range rs.Conditions { + if cond.Type == t { + return &cond + } + } + return nil +} + +func (rs *RouteStatus) setCondition(new *RouteCondition) { + if new == nil { + return + } + + t := new.Type + var conditions []RouteCondition + for _, cond := range rs.Conditions { + if cond.Type != t { + conditions = append(conditions, cond) + } else { + // If we'd only update the LastTransitionTime, then return. + new.LastTransitionTime = cond.LastTransitionTime + if reflect.DeepEqual(new, &cond) { + return + } + } + } + new.LastTransitionTime = metav1.NewTime(time.Now()) + conditions = append(conditions, *new) + rs.Conditions = conditions +} + +func (rs *RouteStatus) RemoveCondition(t RouteConditionType) { + var conditions []RouteCondition + for _, cond := range rs.Conditions { + if cond.Type != t { + conditions = append(conditions, cond) + } + } + rs.Conditions = conditions +} + +func (rs *RouteStatus) InitializeConditions() { + for _, cond := range []RouteConditionType{ + RouteConditionAllTrafficAssigned, + RouteConditionReady, + } { + if rc := rs.GetCondition(cond); rc == nil { + rs.setCondition(&RouteCondition{ + Type: cond, + Status: corev1.ConditionUnknown, + }) + } + } +} + +func (rs *RouteStatus) MarkTrafficAssigned() { + rs.setCondition(&RouteCondition{ + Type: RouteConditionAllTrafficAssigned, + Status: corev1.ConditionTrue, + }) + rs.checkAndMarkReady() +} + +func (rs *RouteStatus) markTrafficTargetNotReady(reason, msg string) { + rs.setCondition(&RouteCondition{ + Type: RouteConditionAllTrafficAssigned, + Status: corev1.ConditionUnknown, + Reason: reason, + Message: msg, + }) + // TODO(tcnghia): when we start with new RouteConditionReady every revision, + // uncomment the short-circuiting below. + // + // // Do not downgrade Ready condition. + // if c := rs.GetCondition(RouteConditionReady); c != nil && c.Status == corev1.ConditionFalse { + // return + // } + // + // For now, the following is harmless because RouteConditionAllTrafficAssigned + // is the only condition RouteConditionReady depends on. + rs.setCondition(&RouteCondition{ + Type: RouteConditionReady, + Status: corev1.ConditionUnknown, + Reason: reason, + Message: msg, + }) +} + +func (rs *RouteStatus) markTrafficTargetFailed(reason, msg string) { + for _, cond := range []RouteConditionType{ + RouteConditionAllTrafficAssigned, + RouteConditionReady, + } { + rs.setCondition(&RouteCondition{ + Type: cond, + Status: corev1.ConditionFalse, + Reason: reason, + Message: msg, + }) + } +} + +func (rs *RouteStatus) MarkUnknownTrafficError(msg string) { + rs.markTrafficTargetNotReady("Unknown", msg) +} + +func (rs *RouteStatus) MarkConfigurationNotReady(name string) { + reason := "RevisionMissing" + msg := fmt.Sprintf("Configuration %q is waiting for a Revision to become ready.", name) + rs.markTrafficTargetNotReady(reason, msg) +} + +func (rs *RouteStatus) MarkConfigurationFailed(name string) { + reason := "RevisionMissing" + msg := fmt.Sprintf("Configuration %q does not have any ready Revision.", name) + rs.markTrafficTargetFailed(reason, msg) +} + +func (rs *RouteStatus) MarkRevisionNotReady(name string) { + reason := "RevisionMissing" + msg := fmt.Sprintf("Revision %q is not yet ready.", name) + rs.markTrafficTargetNotReady(reason, msg) +} + +func (rs *RouteStatus) MarkRevisionFailed(name string) { + reason := "RevisionMissing" + msg := fmt.Sprintf("Revision %q failed to become ready.", name) + rs.markTrafficTargetFailed(reason, msg) +} + +func (rs *RouteStatus) MarkMissingTrafficTarget(kind, name string) { + reason := kind + "Missing" + msg := fmt.Sprintf("%s %q referenced in traffic not found.", kind, name) + rs.markTrafficTargetFailed(reason, msg) +} + +func (rs *RouteStatus) checkAndMarkReady() { + for _, cond := range []RouteConditionType{ + RouteConditionAllTrafficAssigned, + } { + ata := rs.GetCondition(cond) + if ata == nil || ata.Status != corev1.ConditionTrue { + return + } + } + rs.markReady() +} + +func (rs *RouteStatus) markReady() { + rs.setCondition(&RouteCondition{ + Type: RouteConditionReady, + Status: corev1.ConditionTrue, + }) +} 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 00000000000..a4356d897e3 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/route_validation.go @@ -0,0 +1,102 @@ +/* +Copyright 2017 The Knative Authors +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT 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" + + "k8s.io/apimachinery/pkg/api/equality" +) + +func (rt *Route) Validate() *FieldError { + return rt.Spec.Validate().ViaField("spec") +} + +func (rs *RouteSpec) Validate() *FieldError { + if equality.Semantic.DeepEqual(rs, &RouteSpec{}) { + return errMissingField(currentField) + } + + // Where a named traffic target points + type namedTarget struct { + r string // revision name + c string // config name + i int // index of first occurrence + } + + // Track the targets of named TrafficTarget entries (to detect duplicates). + trafficMap := make(map[string]namedTarget) + + percentSum := 0 + for i, tt := range rs.Traffic { + if err := tt.Validate(); err != nil { + return err.ViaField(fmt.Sprintf("traffic[%d]", i)) + } + percentSum += tt.Percent + + if tt.Name == "" { + // No Name field, so skip the uniqueness check. + continue + } + nt := namedTarget{ + r: tt.RevisionName, + c: tt.ConfigurationName, + i: i, + } + if ent, ok := trafficMap[tt.Name]; !ok { + // No entry exists, so add ours + trafficMap[tt.Name] = nt + } else if ent.r != nt.r || ent.c != nt.c { + return &FieldError{ + Message: fmt.Sprintf("Multiple definitions for %q", tt.Name), + Paths: []string{ + fmt.Sprintf("traffic[%d].name", ent.i), + fmt.Sprintf("traffic[%d].name", nt.i), + }, + } + } + } + + if percentSum != 100 { + return &FieldError{ + Message: fmt.Sprintf("Traffic targets sum to %d, want 100", percentSum), + Paths: []string{"traffic"}, + } + } + return nil +} + +func (tt *TrafficTarget) Validate() *FieldError { + switch { + case tt.RevisionName != "" && tt.ConfigurationName != "": + return &FieldError{ + Message: "Expected exactly one, got both", + Paths: []string{"revisionName", "configurationName"}, + } + case tt.RevisionName != "": + case tt.ConfigurationName != "": + // These are fine. + default: + return &FieldError{ + Message: "Expected exactly one, got neither", + Paths: []string{"revisionName", "configurationName"}, + } + } + if tt.Percent < 0 || tt.Percent > 100 { + return errInvalidValue(fmt.Sprintf("%d", tt.Percent), "percent") + } + return nil +} 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 00000000000..3e46151cd2e --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_defaults.go @@ -0,0 +1,28 @@ +/* +Copyright 2017 The Knative Authors +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT 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 + +func (s *Service) SetDefaults() { + s.Spec.SetDefaults() +} + +func (ss *ServiceSpec) SetDefaults() { + if ss.RunLatest != nil { + ss.RunLatest.Configuration.SetDefaults() + } else if ss.Pinned != nil { + ss.Pinned.Configuration.SetDefaults() + } +} 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 00000000000..c9df581e63c --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_types.go @@ -0,0 +1,327 @@ +/* +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 ( + "encoding/json" + "reflect" + "time" + + 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 + +// 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"` +} + +// Check that Service may be validated and defaulted. +var _ Validatable = (*Service)(nil) +var _ Defaultable = (*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 { + // TODO: Generation does not work correctly with CRD. They are scrubbed + // by the APIserver (https://github.com/kubernetes/kubernetes/issues/58778) + // So, we add Generation here. Once that gets fixed, remove this and use + // ObjectMeta.Generation instead. + // +optional + Generation int64 `json:"generation,omitempty"` + + // RunLatest defines a simple Service. It will automatically + // configure a route that keeps the latest ready revision + // from the supplied configuration running. + // +optional + RunLatest *RunLatestType `json:"runLatest,omitempty"` + + // Pins this service to a specific revision name. The revision must + // be owned by the configuration provided. + // +optional + Pinned *PinnedType `json:"pinned,omitempty"` +} + +type RunLatestType struct { + // The configuration for this service. + // +optional + Configuration ConfigurationSpec `json:"configuration,omitempty"` +} + +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"` +} + +type ServiceCondition struct { + Type ServiceConditionType `json:"type"` + + Status corev1.ConditionStatus `json:"status" description:"status of the condition, one of True, False, Unknown"` + + // +optional + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" description:"last time the condition transit from one status to another"` + + // +optional + Reason string `json:"reason,omitempty" description:"one-word CamelCase reason for the condition's last transition"` + // +optional + Message string `json:"message,omitempty" description:"human-readable message indicating details about last transition"` +} + +// ServiceConditionType represents an Service condition value +type ServiceConditionType string + +const ( + // ServiceConditionReady is set when the service is configured + // and has available backends ready to receive traffic. + ServiceConditionReady ServiceConditionType = "Ready" + // ServiceConditionRoutesReady is set when the service's underlying + // routes have reported readiness. + ServiceConditionRoutesReady ServiceConditionType = "RoutesReady" + // ServiceConditionConfigurationsReady is set when the service's underlying + // configurations have reported readiness. + ServiceConditionConfigurationsReady ServiceConditionType = "ConfigurationsReady" +) + +type ServiceStatus struct { + // +optional + Conditions []ServiceCondition `json:"conditions,omitempty"` + + // From RouteStatus. + // Domain holds the top-level domain that will distribute traffic over the provided targets. + // It generally has the form {route-name}.{route-namespace}.{cluster-level-suffix} + // +optional + Domain string `json:"domain,omitempty"` + + // From RouteStatus. + // DomainInternal 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.local + // +optional + DomainInternal string `json:"domainInternal,omitempty"` + + // From RouteStatus. + // 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"` + + // From ConfigurationStatus. + // LatestReadyRevisionName holds the name of the latest Revision stamped out + // from this Service's Configuration that has had its "Ready" condition become "True". + // +optional + LatestReadyRevisionName string `json:"latestReadyRevisionName,omitempty"` + + // From ConfigurationStatus. + // LatestCreatedRevisionName is the last revision that was created from this Service's + // Configuration. It might not be ready yet, for that use LatestReadyRevisionName. + // +optional + LatestCreatedRevisionName string `json:"latestCreatedRevisionName,omitempty"` + + // ObservedGeneration is the 'Generation' of the Service that + // was last processed by the controller. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` +} + +// +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"` +} + +func (s *Service) GetGeneration() int64 { + return s.Spec.Generation +} + +func (s *Service) SetGeneration(generation int64) { + s.Spec.Generation = generation +} + +func (s *Service) GetSpecJSON() ([]byte, error) { + return json.Marshal(s.Spec) +} + +func (ss *ServiceStatus) IsReady() bool { + if c := ss.GetCondition(ServiceConditionReady); c != nil { + return c.Status == corev1.ConditionTrue + } + return false +} + +func (ss *ServiceStatus) GetCondition(t ServiceConditionType) *ServiceCondition { + for _, cond := range ss.Conditions { + if cond.Type == t { + return &cond + } + } + return nil +} + +func (ss *ServiceStatus) setCondition(new *ServiceCondition) { + if new == nil { + return + } + + t := new.Type + var conditions []ServiceCondition + for _, cond := range ss.Conditions { + if cond.Type != t { + conditions = append(conditions, cond) + } else { + // If we'd only update the LastTransitionTime, then return. + new.LastTransitionTime = cond.LastTransitionTime + if reflect.DeepEqual(new, &cond) { + return + } + } + } + new.LastTransitionTime = metav1.NewTime(time.Now()) + conditions = append(conditions, *new) + ss.Conditions = conditions +} + +func (ss *ServiceStatus) RemoveCondition(t ServiceConditionType) { + var conditions []ServiceCondition + for _, cond := range ss.Conditions { + if cond.Type != t { + conditions = append(conditions, cond) + } + } + ss.Conditions = conditions +} + +func (ss *ServiceStatus) InitializeConditions() { + for _, cond := range []ServiceConditionType{ + ServiceConditionReady, + ServiceConditionConfigurationsReady, + ServiceConditionRoutesReady, + } { + if rc := ss.GetCondition(cond); rc == nil { + ss.setCondition(&ServiceCondition{ + Type: cond, + Status: corev1.ConditionUnknown, + }) + } + } +} + +func (ss *ServiceStatus) PropagateConfigurationStatus(cs ConfigurationStatus) { + ss.LatestReadyRevisionName = cs.LatestReadyRevisionName + ss.LatestCreatedRevisionName = cs.LatestCreatedRevisionName + + cc := cs.GetCondition(ConfigurationConditionReady) + if cc == nil { + return + } + sct := []ServiceConditionType{ServiceConditionConfigurationsReady} + // If the underlying Configuration reported not ready, then bubble it up. + if cc.Status != corev1.ConditionTrue { + sct = append(sct, ServiceConditionReady) + } + for _, cond := range sct { + ss.setCondition(&ServiceCondition{ + Type: cond, + Status: cc.Status, + Reason: cc.Reason, + Message: cc.Message, + }) + } + if cc.Status == corev1.ConditionTrue { + ss.checkAndMarkReady() + } +} + +func (ss *ServiceStatus) PropagateRouteStatus(rs RouteStatus) { + ss.Domain = rs.Domain + ss.DomainInternal = rs.DomainInternal + ss.Traffic = rs.Traffic + + rc := rs.GetCondition(RouteConditionReady) + if rc == nil { + return + } + sct := []ServiceConditionType{ServiceConditionRoutesReady} + // If the underlying Route reported not ready, then bubble it up. + if rc.Status != corev1.ConditionTrue { + sct = append(sct, ServiceConditionReady) + } + for _, cond := range sct { + ss.setCondition(&ServiceCondition{ + Type: cond, + Status: rc.Status, + Reason: rc.Reason, + Message: rc.Message, + }) + } + if rc.Status == corev1.ConditionTrue { + ss.checkAndMarkReady() + } +} + +func (ss *ServiceStatus) checkAndMarkReady() { + for _, cond := range []ServiceConditionType{ + ServiceConditionConfigurationsReady, + ServiceConditionRoutesReady, + } { + c := ss.GetCondition(cond) + if c == nil || c.Status != corev1.ConditionTrue { + return + } + } + ss.markReady() +} + +func (ss *ServiceStatus) markReady() { + ss.setCondition(&ServiceCondition{ + Type: ServiceConditionReady, + Status: corev1.ConditionTrue, + }) +} 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 00000000000..8cc2c9b3cd8 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/service_validation.go @@ -0,0 +1,57 @@ +/* +Copyright 2017 The Knative Authors +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT 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 + +func (s *Service) Validate() *FieldError { + return s.Spec.Validate().ViaField("spec") +} + +func (ss *ServiceSpec) Validate() *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 errMissingField(currentField) + // } + + switch { + case ss.RunLatest != nil && ss.Pinned != nil: + return &FieldError{ + Message: "Expected exactly one, got both", + Paths: []string{"runLatest", "pinned"}, + } + case ss.RunLatest != nil: + return ss.RunLatest.Validate().ViaField("runLatest") + case ss.Pinned != nil: + return ss.Pinned.Validate().ViaField("pinned") + default: + return &FieldError{ + Message: "Expected exactly one, got neither", + Paths: []string{"runLatest", "pinned"}, + } + } +} + +func (pt *PinnedType) Validate() *FieldError { + if pt.RevisionName == "" { + return errMissingField("revisionName") + } + return pt.Configuration.Validate().ViaField("configuration") +} + +func (rlt *RunLatestType) Validate() *FieldError { + return rlt.Configuration.Validate().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 00000000000..62e5b279e2e --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/apis/serving/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,614 @@ +// +build !ignore_autogenerated + +/* +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. +*/ + +// This file was autogenerated by deepcopy-gen. Do not edit it manually! + +package v1alpha1 + +import ( + build_v1alpha1 "github.com/knative/build/pkg/apis/build/v1alpha1" + 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 *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 + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ConfigurationCondition) DeepCopyInto(out *ConfigurationCondition) { + *out = *in + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigurationCondition. +func (in *ConfigurationCondition) DeepCopy() *ConfigurationCondition { + if in == nil { + return nil + } + out := new(ConfigurationCondition) + in.DeepCopyInto(out) + return out +} + +// 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 + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ConfigurationSpec) DeepCopyInto(out *ConfigurationSpec) { + *out = *in + if in.Build != nil { + in, out := &in.Build, &out.Build + if *in == nil { + *out = nil + } else { + *out = new(build_v1alpha1.BuildSpec) + (*in).DeepCopyInto(*out) + } + } + in.RevisionTemplate.DeepCopyInto(&out.RevisionTemplate) + 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 + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]ConfigurationCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + 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 *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 *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 + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RevisionCondition) DeepCopyInto(out *RevisionCondition) { + *out = *in + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionCondition. +func (in *RevisionCondition) DeepCopy() *RevisionCondition { + if in == nil { + return nil + } + out := new(RevisionCondition) + in.DeepCopyInto(out) + return out +} + +// 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 + } else { + 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.Container.DeepCopyInto(&out.Container) + 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 + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]RevisionCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + 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 + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RouteCondition) DeepCopyInto(out *RouteCondition) { + *out = *in + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteCondition. +func (in *RouteCondition) DeepCopy() *RouteCondition { + if in == nil { + return nil + } + out := new(RouteCondition) + in.DeepCopyInto(out) + return out +} + +// 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 + } else { + 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)) + copy(*out, *in) + } + 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 + if in.Traffic != nil { + in, out := &in.Traffic, &out.Traffic + *out = make([]TrafficTarget, len(*in)) + copy(*out, *in) + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]RouteCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + 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 *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 + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServiceCondition) DeepCopyInto(out *ServiceCondition) { + *out = *in + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceCondition. +func (in *ServiceCondition) DeepCopy() *ServiceCondition { + if in == nil { + return nil + } + out := new(ServiceCondition) + in.DeepCopyInto(out) + return out +} + +// 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 + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServiceSpec) DeepCopyInto(out *ServiceSpec) { + *out = *in + if in.RunLatest != nil { + in, out := &in.RunLatest, &out.RunLatest + if *in == nil { + *out = nil + } else { + *out = new(RunLatestType) + (*in).DeepCopyInto(*out) + } + } + if in.Pinned != nil { + in, out := &in.Pinned, &out.Pinned + if *in == nil { + *out = nil + } else { + *out = new(PinnedType) + (*in).DeepCopyInto(*out) + } + } + 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 + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]ServiceCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Traffic != nil { + in, out := &in.Traffic, &out.Traffic + *out = make([]TrafficTarget, len(*in)) + copy(*out, *in) + } + 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 + 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 00000000000..855fbd89948 --- /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 00000000000..2041ea8b12e --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/clientset.go @@ -0,0 +1,119 @@ +/* +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 versioned + +import ( + glog "github.com/golang/glog" + networkingv1alpha3 "github.com/knative/serving/pkg/client/clientset/versioned/typed/istio/v1alpha3" + servingv1alpha1 "github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1" + 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 + NetworkingV1alpha3() networkingv1alpha3.NetworkingV1alpha3Interface + // Deprecated: please explicitly pick a version if possible. + Networking() networkingv1alpha3.NetworkingV1alpha3Interface + ServingV1alpha1() servingv1alpha1.ServingV1alpha1Interface + // Deprecated: please explicitly pick a version if possible. + Serving() servingv1alpha1.ServingV1alpha1Interface +} + +// Clientset contains the clients for groups. Each group has exactly one +// version included in a Clientset. +type Clientset struct { + *discovery.DiscoveryClient + networkingV1alpha3 *networkingv1alpha3.NetworkingV1alpha3Client + servingV1alpha1 *servingv1alpha1.ServingV1alpha1Client +} + +// NetworkingV1alpha3 retrieves the NetworkingV1alpha3Client +func (c *Clientset) NetworkingV1alpha3() networkingv1alpha3.NetworkingV1alpha3Interface { + return c.networkingV1alpha3 +} + +// Deprecated: Networking retrieves the default version of NetworkingClient. +// Please explicitly pick a version. +func (c *Clientset) Networking() networkingv1alpha3.NetworkingV1alpha3Interface { + return c.networkingV1alpha3 +} + +// ServingV1alpha1 retrieves the ServingV1alpha1Client +func (c *Clientset) ServingV1alpha1() servingv1alpha1.ServingV1alpha1Interface { + return c.servingV1alpha1 +} + +// Deprecated: Serving retrieves the default version of ServingClient. +// Please explicitly pick a version. +func (c *Clientset) Serving() servingv1alpha1.ServingV1alpha1Interface { + return c.servingV1alpha1 +} + +// 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.networkingV1alpha3, err = networkingv1alpha3.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + cs.servingV1alpha1, err = servingv1alpha1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) + if err != nil { + glog.Errorf("failed to create the DiscoveryClient: %v", err) + 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.networkingV1alpha3 = networkingv1alpha3.NewForConfigOrDie(c) + cs.servingV1alpha1 = servingv1alpha1.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.networkingV1alpha3 = networkingv1alpha3.New(c) + cs.servingV1alpha1 = servingv1alpha1.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 00000000000..483c0da9de4 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/doc.go @@ -0,0 +1,17 @@ +/* +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. +*/ +// This package has the automatically generated clientset. +package versioned diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/scheme/doc.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/scheme/doc.go new file mode 100644 index 00000000000..52627884652 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/scheme/doc.go @@ -0,0 +1,17 @@ +/* +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. +*/ +// 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 00000000000..f9745bd9766 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/scheme/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 scheme + +import ( + networkingv1alpha3 "github.com/knative/serving/pkg/apis/istio/v1alpha3" + servingv1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" + 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" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) + +func init() { + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + AddToScheme(Scheme) +} + +// 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. +func AddToScheme(scheme *runtime.Scheme) { + networkingv1alpha3.AddToScheme(scheme) + servingv1alpha1.AddToScheme(scheme) +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/istio/v1alpha3/doc.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/istio/v1alpha3/doc.go new file mode 100644 index 00000000000..d1909a47d81 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/istio/v1alpha3/doc.go @@ -0,0 +1,17 @@ +/* +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. +*/ +// This package has the automatically generated typed clients. +package v1alpha3 diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/istio/v1alpha3/gateway.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/istio/v1alpha3/gateway.go new file mode 100644 index 00000000000..70ccd02d145 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/istio/v1alpha3/gateway.go @@ -0,0 +1,154 @@ +/* +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 v1alpha3 + +import ( + v1alpha3 "github.com/knative/serving/pkg/apis/istio/v1alpha3" + 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" +) + +// GatewaysGetter has a method to return a GatewayInterface. +// A group's client should implement this interface. +type GatewaysGetter interface { + Gateways(namespace string) GatewayInterface +} + +// GatewayInterface has methods to work with Gateway resources. +type GatewayInterface interface { + Create(*v1alpha3.Gateway) (*v1alpha3.Gateway, error) + Update(*v1alpha3.Gateway) (*v1alpha3.Gateway, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha3.Gateway, error) + List(opts v1.ListOptions) (*v1alpha3.GatewayList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha3.Gateway, err error) + GatewayExpansion +} + +// gateways implements GatewayInterface +type gateways struct { + client rest.Interface + ns string +} + +// newGateways returns a Gateways +func newGateways(c *NetworkingV1alpha3Client, namespace string) *gateways { + return &gateways{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the gateway, and returns the corresponding gateway object, and an error if there is any. +func (c *gateways) Get(name string, options v1.GetOptions) (result *v1alpha3.Gateway, err error) { + result = &v1alpha3.Gateway{} + err = c.client.Get(). + Namespace(c.ns). + Resource("gateways"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Gateways that match those selectors. +func (c *gateways) List(opts v1.ListOptions) (result *v1alpha3.GatewayList, err error) { + result = &v1alpha3.GatewayList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("gateways"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested gateways. +func (c *gateways) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("gateways"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a gateway and creates it. Returns the server's representation of the gateway, and an error, if there is any. +func (c *gateways) Create(gateway *v1alpha3.Gateway) (result *v1alpha3.Gateway, err error) { + result = &v1alpha3.Gateway{} + err = c.client.Post(). + Namespace(c.ns). + Resource("gateways"). + Body(gateway). + Do(). + Into(result) + return +} + +// Update takes the representation of a gateway and updates it. Returns the server's representation of the gateway, and an error, if there is any. +func (c *gateways) Update(gateway *v1alpha3.Gateway) (result *v1alpha3.Gateway, err error) { + result = &v1alpha3.Gateway{} + err = c.client.Put(). + Namespace(c.ns). + Resource("gateways"). + Name(gateway.Name). + Body(gateway). + Do(). + Into(result) + return +} + +// Delete takes name of the gateway and deletes it. Returns an error if one occurs. +func (c *gateways) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("gateways"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *gateways) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("gateways"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched gateway. +func (c *gateways) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha3.Gateway, err error) { + result = &v1alpha3.Gateway{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("gateways"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/istio/v1alpha3/generated_expansion.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/istio/v1alpha3/generated_expansion.go new file mode 100644 index 00000000000..c746b14b13e --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/istio/v1alpha3/generated_expansion.go @@ -0,0 +1,20 @@ +/* +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 v1alpha3 + +type GatewayExpansion interface{} + +type VirtualServiceExpansion interface{} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/istio/v1alpha3/istio_client.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/istio/v1alpha3/istio_client.go new file mode 100644 index 00000000000..e2869ab0b29 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/istio/v1alpha3/istio_client.go @@ -0,0 +1,92 @@ +/* +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 v1alpha3 + +import ( + v1alpha3 "github.com/knative/serving/pkg/apis/istio/v1alpha3" + "github.com/knative/serving/pkg/client/clientset/versioned/scheme" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" +) + +type NetworkingV1alpha3Interface interface { + RESTClient() rest.Interface + GatewaysGetter + VirtualServicesGetter +} + +// NetworkingV1alpha3Client is used to interact with features provided by the networking.istio.io group. +type NetworkingV1alpha3Client struct { + restClient rest.Interface +} + +func (c *NetworkingV1alpha3Client) Gateways(namespace string) GatewayInterface { + return newGateways(c, namespace) +} + +func (c *NetworkingV1alpha3Client) VirtualServices(namespace string) VirtualServiceInterface { + return newVirtualServices(c, namespace) +} + +// NewForConfig creates a new NetworkingV1alpha3Client for the given config. +func NewForConfig(c *rest.Config) (*NetworkingV1alpha3Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &NetworkingV1alpha3Client{client}, nil +} + +// NewForConfigOrDie creates a new NetworkingV1alpha3Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *NetworkingV1alpha3Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new NetworkingV1alpha3Client for the given RESTClient. +func New(c rest.Interface) *NetworkingV1alpha3Client { + return &NetworkingV1alpha3Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha3.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 *NetworkingV1alpha3Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/istio/v1alpha3/virtualservice.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/istio/v1alpha3/virtualservice.go new file mode 100644 index 00000000000..feec0590710 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/istio/v1alpha3/virtualservice.go @@ -0,0 +1,154 @@ +/* +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 v1alpha3 + +import ( + v1alpha3 "github.com/knative/serving/pkg/apis/istio/v1alpha3" + 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" +) + +// VirtualServicesGetter has a method to return a VirtualServiceInterface. +// A group's client should implement this interface. +type VirtualServicesGetter interface { + VirtualServices(namespace string) VirtualServiceInterface +} + +// VirtualServiceInterface has methods to work with VirtualService resources. +type VirtualServiceInterface interface { + Create(*v1alpha3.VirtualService) (*v1alpha3.VirtualService, error) + Update(*v1alpha3.VirtualService) (*v1alpha3.VirtualService, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha3.VirtualService, error) + List(opts v1.ListOptions) (*v1alpha3.VirtualServiceList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha3.VirtualService, err error) + VirtualServiceExpansion +} + +// virtualServices implements VirtualServiceInterface +type virtualServices struct { + client rest.Interface + ns string +} + +// newVirtualServices returns a VirtualServices +func newVirtualServices(c *NetworkingV1alpha3Client, namespace string) *virtualServices { + return &virtualServices{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the virtualService, and returns the corresponding virtualService object, and an error if there is any. +func (c *virtualServices) Get(name string, options v1.GetOptions) (result *v1alpha3.VirtualService, err error) { + result = &v1alpha3.VirtualService{} + err = c.client.Get(). + Namespace(c.ns). + Resource("virtualservices"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of VirtualServices that match those selectors. +func (c *virtualServices) List(opts v1.ListOptions) (result *v1alpha3.VirtualServiceList, err error) { + result = &v1alpha3.VirtualServiceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("virtualservices"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested virtualServices. +func (c *virtualServices) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("virtualservices"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a virtualService and creates it. Returns the server's representation of the virtualService, and an error, if there is any. +func (c *virtualServices) Create(virtualService *v1alpha3.VirtualService) (result *v1alpha3.VirtualService, err error) { + result = &v1alpha3.VirtualService{} + err = c.client.Post(). + Namespace(c.ns). + Resource("virtualservices"). + Body(virtualService). + Do(). + Into(result) + return +} + +// Update takes the representation of a virtualService and updates it. Returns the server's representation of the virtualService, and an error, if there is any. +func (c *virtualServices) Update(virtualService *v1alpha3.VirtualService) (result *v1alpha3.VirtualService, err error) { + result = &v1alpha3.VirtualService{} + err = c.client.Put(). + Namespace(c.ns). + Resource("virtualservices"). + Name(virtualService.Name). + Body(virtualService). + Do(). + Into(result) + return +} + +// Delete takes name of the virtualService and deletes it. Returns an error if one occurs. +func (c *virtualServices) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("virtualservices"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *virtualServices) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("virtualservices"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched virtualService. +func (c *virtualServices) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha3.VirtualService, err error) { + result = &v1alpha3.VirtualService{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("virtualservices"). + 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 00000000000..173be64fca7 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/configuration.go @@ -0,0 +1,171 @@ +/* +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 ( + 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 00000000000..10ede9da2f0 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/doc.go @@ -0,0 +1,17 @@ +/* +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. +*/ +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/generated_expansion.go b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/generated_expansion.go new file mode 100644 index 00000000000..af4168b8a61 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/generated_expansion.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. +*/ +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 00000000000..e4a64efb307 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/revision.go @@ -0,0 +1,171 @@ +/* +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 ( + 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 00000000000..e2d3bfb2e86 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/route.go @@ -0,0 +1,171 @@ +/* +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 ( + 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 00000000000..5f77b55f889 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/service.go @@ -0,0 +1,171 @@ +/* +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 ( + 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 00000000000..94f839d68ef --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/serving_client.go @@ -0,0 +1,102 @@ +/* +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 ( + 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/controller/revision/config/testdata/config-controller.yaml b/vendor/github.com/knative/serving/pkg/controller/revision/config/testdata/config-controller.yaml new file mode 120000 index 00000000000..f1afbe74ee7 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/controller/revision/config/testdata/config-controller.yaml @@ -0,0 +1 @@ +../../../../../config/config-controller.yaml \ No newline at end of file diff --git a/vendor/github.com/knative/serving/pkg/controller/revision/config/testdata/config-network.yaml b/vendor/github.com/knative/serving/pkg/controller/revision/config/testdata/config-network.yaml new file mode 120000 index 00000000000..b774d24cbb4 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/controller/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/controller/revision/config/testdata/config-observability.yaml b/vendor/github.com/knative/serving/pkg/controller/revision/config/testdata/config-observability.yaml new file mode 120000 index 00000000000..ecbbeaaee73 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/controller/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/controller/route/config/testdata/config-domain.yaml b/vendor/github.com/knative/serving/pkg/controller/route/config/testdata/config-domain.yaml new file mode 120000 index 00000000000..fd6402b7c48 --- /dev/null +++ b/vendor/github.com/knative/serving/pkg/controller/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/logging/testdata/config-logging.yaml b/vendor/github.com/knative/serving/pkg/logging/testdata/config-logging.yaml new file mode 120000 index 00000000000..581e985f9cb --- /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/third_party/config/build/LICENSE b/vendor/github.com/knative/serving/third_party/config/build/LICENSE new file mode 100644 index 00000000000..2c45691e883 --- /dev/null +++ b/vendor/github.com/knative/serving/third_party/config/build/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 2016 Istio Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/knative/serving/third_party/config/monitoring/common/istio/LICENSE b/vendor/github.com/knative/serving/third_party/config/monitoring/common/istio/LICENSE new file mode 100644 index 00000000000..2c45691e883 --- /dev/null +++ b/vendor/github.com/knative/serving/third_party/config/monitoring/common/istio/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 2016 Istio Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/knative/serving/third_party/config/monitoring/common/kubernetes/LICENSE b/vendor/github.com/knative/serving/third_party/config/monitoring/common/kubernetes/LICENSE new file mode 100644 index 00000000000..8dada3edaf5 --- /dev/null +++ b/vendor/github.com/knative/serving/third_party/config/monitoring/common/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/common/prometheus-operator/LICENSE b/vendor/github.com/knative/serving/third_party/config/monitoring/common/prometheus-operator/LICENSE new file mode 100644 index 00000000000..e06d2081865 --- /dev/null +++ b/vendor/github.com/knative/serving/third_party/config/monitoring/common/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/common/prometheus-operator/NOTICE b/vendor/github.com/knative/serving/third_party/config/monitoring/common/prometheus-operator/NOTICE new file mode 100644 index 00000000000..e520005cdda --- /dev/null +++ b/vendor/github.com/knative/serving/third_party/config/monitoring/common/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/config/monitoring/elasticsearch/LICENSE b/vendor/github.com/knative/serving/third_party/config/monitoring/elasticsearch/LICENSE new file mode 100644 index 00000000000..8dada3edaf5 --- /dev/null +++ b/vendor/github.com/knative/serving/third_party/config/monitoring/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.