diff --git a/internal/k8s/testyaml/testyaml.go b/internal/k8s/testyaml/testyaml.go index 97ebec684b..babee62fb6 100644 --- a/internal/k8s/testyaml/testyaml.go +++ b/internal/k8s/testyaml/testyaml.go @@ -1625,432 +1625,6 @@ items: command: ["/go/bin/doggos"] ` -const KnativeRelease = ` - ---- -# net-istio.yaml -# Copyright 2019 The Knative Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -kind: ClusterRole -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - # These are the permissions needed by the Istio Ingress implementation. - name: knative-serving-istio - labels: - serving.knative.dev/release: "v0.15.0" - serving.knative.dev/controller: "true" - networking.knative.dev/ingress-provider: istio -rules: -- apiGroups: ["networking.istio.io"] - resources: ["virtualservices", "gateways"] - verbs: ["get", "list", "create", "update", "delete", "patch", "watch"] - ---- -# Copyright 2019 The Knative Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# This is the shared Gateway for all Knative routes to use. -apiVersion: networking.istio.io/v1alpha3 -kind: Gateway -metadata: - name: knative-ingress-gateway - namespace: knative-serving - labels: - serving.knative.dev/release: "v0.15.0" - networking.knative.dev/ingress-provider: istio -spec: - selector: - istio: ingressgateway - servers: - - port: - number: 80 - name: http - protocol: HTTP - hosts: - - "*" - ---- -# Copyright 2019 The Knative Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# A cluster local gateway to allow pods outside of the mesh to access -# Services and Routes not exposing through an ingress. If the users -# do have a service mesh setup, this isn't required. -apiVersion: networking.istio.io/v1alpha3 -kind: Gateway -metadata: - name: cluster-local-gateway - namespace: knative-serving - labels: - serving.knative.dev/release: "v0.15.0" - networking.knative.dev/ingress-provider: istio -spec: - selector: - istio: cluster-local-gateway - servers: - - port: - number: 80 - name: http - protocol: HTTP - hosts: - - "*" - ---- -# Copyright 2020 The Knative Authors -# -# Licensed under the Apache License, Version 2.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. - -apiVersion: admissionregistration.k8s.io/v1beta1 -kind: MutatingWebhookConfiguration -metadata: - name: webhook.istio.networking.internal.knative.dev - labels: - serving.knative.dev/release: "v0.15.0" - networking.knative.dev/ingress-provider: istio -webhooks: -- admissionReviewVersions: - - v1beta1 - clientConfig: - service: - name: istio-webhook - namespace: knative-serving - failurePolicy: Fail - sideEffects: None - objectSelector: - matchExpressions: - - {key: "serving.knative.dev/configuration", operator: Exists} - name: webhook.istio.networking.internal.knative.dev - ---- -# Copyright 2020 The Knative Authors -# -# Licensed under the Apache License, Version 2.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. - -apiVersion: admissionregistration.k8s.io/v1beta1 -kind: ValidatingWebhookConfiguration -metadata: - name: config.webhook.istio.networking.internal.knative.dev - labels: - serving.knative.dev/release: "v0.15.0" - networking.knative.dev/ingress-provider: istio -webhooks: -- admissionReviewVersions: - - v1beta1 - clientConfig: - service: - name: istio-webhook - namespace: knative-serving - failurePolicy: Fail - sideEffects: None - name: config.webhook.istio.networking.internal.knative.dev - namespaceSelector: - matchExpressions: - - key: serving.knative.dev/release - operator: Exists - ---- -# Copyright 2020 The Knative Authors -# -# Licensed under the Apache License, Version 2.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. - -apiVersion: v1 -kind: Secret -metadata: - name: istio-webhook-certs - namespace: knative-serving - labels: - serving.knative.dev/release: "v0.15.0" - networking.knative.dev/ingress-provider: istio - ---- -# 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. - -apiVersion: v1 -kind: ConfigMap -metadata: - name: config-istio - namespace: knative-serving - labels: - serving.knative.dev/release: "v0.15.0" - networking.knative.dev/ingress-provider: istio -data: - _example: | - gateway.knative-serving.knative-ingress-gateway: "istio-ingressgateway.istio-system.svc.cluster.local" - local-gateway.knative-serving.cluster-local-gateway: "cluster-local-gateway.istio-system.svc.cluster.local" - - # To use only Istio service mesh and no cluster-local-gateway, replace - # all local-gateway.* entries by the following entry. - local-gateway.mesh: "mesh" - # TODO(nghia): Extract the .svc.cluster.local suffix into its own config. - ---- -# Copyright 2019 The Knative Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: networking-istio - namespace: knative-serving - labels: - serving.knative.dev/release: "v0.15.0" - networking.knative.dev/ingress-provider: istio -spec: - selector: - matchLabels: - app: networking-istio - template: - metadata: - annotations: - cluster-autoscaler.kubernetes.io/safe-to-evict: "true" - # This must be outside of the mesh to probe the gateways. - # NOTE: this is allowed here and not elsewhere because - # this is the Istio controller, and so it may be Istio-aware. - sidecar.istio.io/inject: "false" - labels: - app: networking-istio - serving.knative.dev/release: "v0.15.0" - spec: - serviceAccountName: controller - containers: - - name: networking-istio - # This is the Go import path for the binary that is containerized - # and substituted here. - image: gcr.io/knative-releases/knative.dev/net-istio/cmd/controller@sha256:3f8db840f5b3778a842dbbf7e8bc9f2babd10b144b816c8497ac46430db8254e - resources: - requests: - cpu: 30m - memory: 40Mi - limits: - cpu: 300m - memory: 400Mi - env: - - name: SYSTEM_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.namespace - - name: CONFIG_LOGGING_NAME - value: config-logging - - name: CONFIG_OBSERVABILITY_NAME - value: config-observability - - # TODO(https://github.com/knative/pkg/pull/953): Remove stackdriver specific config - name: METRICS_DOMAIN - value: knative.dev/net-istio - securityContext: - allowPrivilegeEscalation: false - ports: - - name: metrics - containerPort: 9090 - - name: profiling - containerPort: 8008 - -# Unlike other controllers, this doesn't need a Service defined for metrics and -# profiling because it opts out of the mesh (see annotation above). - ---- -# Copyright 2020 The Knative Authors -# -# Licensed under the Apache License, Version 2.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. - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: istio-webhook - namespace: knative-serving - labels: - serving.knative.dev/release: "v0.15.0" - networking.knative.dev/ingress-provider: istio -spec: - selector: - matchLabels: - app: istio-webhook - role: istio-webhook - template: - metadata: - annotations: - cluster-autoscaler.kubernetes.io/safe-to-evict: "false" - labels: - app: istio-webhook - role: istio-webhook - serving.knative.dev/release: "v0.15.0" - spec: - serviceAccountName: controller - containers: - - name: webhook - # This is the Go import path for the binary that is containerized - # and substituted here. - image: gcr.io/knative-releases/knative.dev/net-istio/cmd/webhook@sha256:b691c81d117d666d479b4f57416f3edd53f282a7346c64af4ce9c4585df5bec7 - resources: - requests: - cpu: 20m - memory: 20Mi - limits: - cpu: 200m - memory: 200Mi - env: - - name: SYSTEM_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.namespace - - name: CONFIG_LOGGING_NAME - value: config-logging - - name: CONFIG_OBSERVABILITY_NAME - value: config-observability - - # TODO(https://github.com/knative/pkg/pull/953): Remove stackdriver specific config - name: METRICS_DOMAIN - value: knative.dev/net-istio - - name: WEBHOOK_NAME - value: istio-webhook - securityContext: - allowPrivilegeEscalation: false - ports: - - name: metrics - containerPort: 9090 - - name: profiling - containerPort: 8008 - - name: https-webhook - containerPort: 8443 - ---- -# Copyright 2020 The Knative Authors -# -# Licensed under the Apache License, Version 2.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. - -apiVersion: v1 -kind: Service -metadata: - name: istio-webhook - namespace: knative-serving - labels: - role: istio-webhook - serving.knative.dev/release: "v0.15.0" - networking.knative.dev/ingress-provider: istio -spec: - ports: - - # Define metrics and profiling for them to be accessible within service meshes. - name: http-metrics - port: 9090 - targetPort: 9090 - - name: http-profiling - port: 8008 - targetPort: 8008 - - name: https-webhook - port: 443 - targetPort: 8443 - selector: - app: istio-webhook - ---- - -` - const KnativeServingCore = ` --- # Copyright 2018 The Knative Authors @@ -2080,607 +1654,3 @@ spec: image: gcr.io/knative-releases/knative.dev/serving/cmd/queue@sha256:713bd548700bf7fe5452969611d1cc987051bd607d67a4e7623e140f06c209b2 ` -const KnativeServingCRDs = ` -# Copyright 2019 The Knative Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: certificates.networking.internal.knative.dev - labels: - serving.knative.dev/release: "v0.15.0" - knative.dev/crd-install: "true" -spec: - group: networking.internal.knative.dev - version: v1alpha1 - names: - kind: Certificate - plural: certificates - singular: certificate - categories: - - knative-internal - - networking - shortNames: - - kcert - scope: Namespaced - subresources: - status: {} - additionalPrinterColumns: - - name: Ready - type: string - JSONPath: ".status.conditions[?(@.type==\"Ready\")].status" - - name: Reason - type: string - JSONPath: ".status.conditions[?(@.type==\"Ready\")].reason" - ---- -# Copyright 2019 The Knative Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: configurations.serving.knative.dev - labels: - serving.knative.dev/release: "v0.15.0" - knative.dev/crd-install: "true" - duck.knative.dev/podspecable: "true" -spec: - group: serving.knative.dev - preserveUnknownFields: false - validation: - openAPIV3Schema: - type: object - # this is a work around so we don't need to flush out the - # schema for each version at this time - # - # see issue: https://github.com/knative/serving/issues/912 - x-kubernetes-preserve-unknown-fields: true - versions: - - name: v1alpha1 - served: true - storage: false - - name: v1beta1 - served: true - storage: false - - name: v1 - served: true - storage: true - names: - kind: Configuration - plural: configurations - singular: configuration - categories: - - all - - knative - - serving - shortNames: - - config - - cfg - scope: Namespaced - subresources: - status: {} - conversion: - strategy: Webhook - webhookClientConfig: - service: - name: webhook - namespace: knative-serving - additionalPrinterColumns: - - name: LatestCreated - type: string - JSONPath: .status.latestCreatedRevisionName - - name: LatestReady - type: string - JSONPath: .status.latestReadyRevisionName - - name: Ready - type: string - JSONPath: ".status.conditions[?(@.type=='Ready')].status" - - name: Reason - type: string - JSONPath: ".status.conditions[?(@.type=='Ready')].reason" - ---- -# Copyright 2019 The Knative Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: ingresses.networking.internal.knative.dev - labels: - serving.knative.dev/release: "v0.15.0" - knative.dev/crd-install: "true" -spec: - group: networking.internal.knative.dev - versions: - - name: v1alpha1 - served: true - storage: true - names: - kind: Ingress - plural: ingresses - singular: ingress - categories: - - knative-internal - - networking - shortNames: - - kingress - - king - scope: Namespaced - subresources: - status: {} - additionalPrinterColumns: - - name: Ready - type: string - JSONPath: ".status.conditions[?(@.type=='Ready')].status" - - name: Reason - type: string - JSONPath: ".status.conditions[?(@.type=='Ready')].reason" - ---- -# Copyright 2019 The Knative Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: metrics.autoscaling.internal.knative.dev - labels: - serving.knative.dev/release: "v0.15.0" - knative.dev/crd-install: "true" -spec: - group: autoscaling.internal.knative.dev - version: v1alpha1 - names: - kind: Metric - plural: metrics - singular: metric - categories: - - knative-internal - - autoscaling - scope: Namespaced - subresources: - status: {} - additionalPrinterColumns: - - name: Ready - type: string - JSONPath: ".status.conditions[?(@.type=='Ready')].status" - - name: Reason - type: string - JSONPath: ".status.conditions[?(@.type=='Ready')].reason" - ---- -# 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. - -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: podautoscalers.autoscaling.internal.knative.dev - labels: - serving.knative.dev/release: "v0.15.0" - knative.dev/crd-install: "true" -spec: - group: autoscaling.internal.knative.dev - versions: - - name: v1alpha1 - served: true - storage: true - names: - kind: PodAutoscaler - plural: podautoscalers - singular: podautoscaler - categories: - - knative-internal - - autoscaling - shortNames: - - kpa - - pa - scope: Namespaced - subresources: - status: {} - additionalPrinterColumns: - - name: DesiredScale - type: integer - JSONPath: ".status.desiredScale" - - name: ActualScale - type: integer - JSONPath: ".status.actualScale" - - name: Ready - type: string - JSONPath: ".status.conditions[?(@.type=='Ready')].status" - - name: Reason - type: string - JSONPath: ".status.conditions[?(@.type=='Ready')].reason" - ---- -# Copyright 2019 The Knative Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: revisions.serving.knative.dev - labels: - serving.knative.dev/release: "v0.15.0" - knative.dev/crd-install: "true" -spec: - group: serving.knative.dev - preserveUnknownFields: false - validation: - openAPIV3Schema: - type: object - # this is a work around so we don't need to flush out the - # schema for each version at this time - # - # see issue: https://github.com/knative/serving/issues/912 - x-kubernetes-preserve-unknown-fields: true - versions: - - name: v1alpha1 - served: true - storage: false - - name: v1beta1 - served: true - storage: false - - name: v1 - served: true - storage: true - names: - kind: Revision - plural: revisions - singular: revision - categories: - - all - - knative - - serving - shortNames: - - rev - scope: Namespaced - subresources: - status: {} - conversion: - strategy: Webhook - webhookClientConfig: - service: - name: webhook - namespace: knative-serving - additionalPrinterColumns: - - name: Config Name - type: string - JSONPath: ".metadata.labels['serving\\.knative\\.dev/configuration']" - - name: K8s Service Name - type: string - JSONPath: ".status.serviceName" - - name: Generation - type: string # int in string form :( - JSONPath: ".metadata.labels['serving\\.knative\\.dev/configurationGeneration']" - - name: Ready - type: string - JSONPath: ".status.conditions[?(@.type=='Ready')].status" - - name: Reason - type: string - JSONPath: ".status.conditions[?(@.type=='Ready')].reason" - ---- -# Copyright 2019 The Knative Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: routes.serving.knative.dev - labels: - serving.knative.dev/release: "v0.15.0" - knative.dev/crd-install: "true" - duck.knative.dev/addressable: "true" -spec: - group: serving.knative.dev - preserveUnknownFields: false - validation: - openAPIV3Schema: - type: object - # this is a work around so we don't need to flush out the - # schema for each version at this time - # - # see issue: https://github.com/knative/serving/issues/912 - x-kubernetes-preserve-unknown-fields: true - versions: - - name: v1alpha1 - served: true - storage: false - - name: v1beta1 - served: true - storage: false - - name: v1 - served: true - storage: true - names: - kind: Route - plural: routes - singular: route - categories: - - all - - knative - - serving - shortNames: - - rt - scope: Namespaced - subresources: - status: {} - conversion: - strategy: Webhook - webhookClientConfig: - service: - name: webhook - namespace: knative-serving - additionalPrinterColumns: - - name: URL - type: string - JSONPath: .status.url - - name: Ready - type: string - JSONPath: ".status.conditions[?(@.type=='Ready')].status" - - name: Reason - type: string - JSONPath: ".status.conditions[?(@.type=='Ready')].reason" - ---- -# Copyright 2019 The Knative Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: serverlessservices.networking.internal.knative.dev - labels: - serving.knative.dev/release: "v0.15.0" - knative.dev/crd-install: "true" -spec: - group: networking.internal.knative.dev - versions: - - name: v1alpha1 - served: true - storage: true - names: - kind: ServerlessService - plural: serverlessservices - singular: serverlessservice - categories: - - knative-internal - - networking - shortNames: - - sks - scope: Namespaced - subresources: - status: {} - additionalPrinterColumns: - - name: Mode - type: string - JSONPath: ".spec.mode" - - name: Activators - type: integer - JSONPath: ".spec.numActivators" - - name: ServiceName - type: string - JSONPath: ".status.serviceName" - - name: PrivateServiceName - type: string - JSONPath: ".status.privateServiceName" - - name: Ready - type: string - JSONPath: ".status.conditions[?(@.type=='Ready')].status" - - name: Reason - type: string - JSONPath: ".status.conditions[?(@.type=='Ready')].reason" - ---- -# Copyright 2019 The Knative Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: services.serving.knative.dev - labels: - serving.knative.dev/release: "v0.15.0" - knative.dev/crd-install: "true" - duck.knative.dev/addressable: "true" - duck.knative.dev/podspecable: "true" -spec: - group: serving.knative.dev - preserveUnknownFields: false - validation: - openAPIV3Schema: - type: object - # this is a work around so we don't need to flush out the - # schema for each version at this time - # - # see issue: https://github.com/knative/serving/issues/912 - x-kubernetes-preserve-unknown-fields: true - versions: - - name: v1alpha1 - served: true - storage: false - - name: v1beta1 - served: true - storage: false - - name: v1 - served: true - storage: true - names: - kind: Service - plural: services - singular: service - categories: - - all - - knative - - serving - shortNames: - - kservice - - ksvc - scope: Namespaced - subresources: - status: {} - conversion: - strategy: Webhook - webhookClientConfig: - service: - name: webhook - namespace: knative-serving - additionalPrinterColumns: - - name: URL - type: string - JSONPath: .status.url - - name: LatestCreated - type: string - JSONPath: .status.latestCreatedRevisionName - - name: LatestReady - type: string - JSONPath: .status.latestReadyRevisionName - - name: Ready - type: string - JSONPath: ".status.conditions[?(@.type=='Ready')].status" - - name: Reason - type: string - JSONPath: ".status.conditions[?(@.type=='Ready')].reason" - ---- -# 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. - -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: images.caching.internal.knative.dev - labels: - knative.dev/crd-install: "true" -spec: - group: caching.internal.knative.dev - version: v1alpha1 - names: - kind: Image - plural: images - singular: image - categories: - - knative-internal - - caching - shortNames: - - img - scope: Namespaced - subresources: - status: {} - ---- -` diff --git a/internal/tiltfile/k8s.go b/internal/tiltfile/k8s.go index 2d777fe6ad..ccd292bf9d 100644 --- a/internal/tiltfile/k8s.go +++ b/internal/tiltfile/k8s.go @@ -189,7 +189,7 @@ func (s *tiltfileState) filterYaml(thread *starlark.Thread, fn *starlark.Builtin return nil, err } - k, err := newK8sObjectSelector(apiVersion, kind, name, namespace) + k, err := newPartialMatchK8sObjectSelector(apiVersion, kind, name, namespace) if err != nil { return nil, err } @@ -546,7 +546,7 @@ func (s *tiltfileState) k8sImageJsonPath(thread *starlark.Thread, fn *starlark.B return nil, err } - k, err := newK8sObjectSelector(apiVersion, kind, name, namespace) + k, err := newPartialMatchK8sObjectSelector(apiVersion, kind, name, namespace) if err != nil { return nil, err } @@ -572,7 +572,7 @@ func (s *tiltfileState) k8sKind(thread *starlark.Thread, fn *starlark.Builtin, a return nil, err } - k, err := newK8sObjectSelector(apiVersion, kind, "", "") + k, err := newPartialMatchK8sObjectSelector(apiVersion, kind, "", "") if err != nil { return nil, err } diff --git a/internal/tiltfile/tiltfile_state.go b/internal/tiltfile/tiltfile_state.go index f1d1a4709d..ec8b9250e0 100644 --- a/internal/tiltfile/tiltfile_state.go +++ b/internal/tiltfile/tiltfile_state.go @@ -655,7 +655,7 @@ func (s *tiltfileState) assembleK8sV2() error { } for i, o := range opts.objects { - entities, ok := fragmentsToEntities[o] + entities, ok := fragmentsToEntities[strings.ToLower(o)] if !ok || len(entities) == 0 { return fmt.Errorf("No object identified by the fragment %q could be found. Possible objects are: %s", o, sliceutils.QuotedStringList(fullNames)) } @@ -720,13 +720,13 @@ func selectorFromString(s string) (k8sObjectSelector, error) { return k8sObjectSelector{}, fmt.Errorf("selector can't be empty") } if len(parts) == 1 { - return newExactK8sObjectSelector("", "", parts[0], "") + return newFullmatchCaseInsensitiveK8sObjectSelector("", "", parts[0], "") } if len(parts) == 2 { - return newExactK8sObjectSelector("", parts[1], parts[0], "") + return newFullmatchCaseInsensitiveK8sObjectSelector("", parts[1], parts[0], "") } if len(parts) == 3 { - return newExactK8sObjectSelector("", parts[1], parts[0], parts[2]) + return newFullmatchCaseInsensitiveK8sObjectSelector("", parts[1], parts[0], parts[2]) } return k8sObjectSelector{}, fmt.Errorf("Too many parts in selector. Selectors must contain between 1 and 3 parts (colon separated), found %d parts in %s", len(parts), s) @@ -1357,31 +1357,53 @@ type k8sObjectSelector struct { namespaceString string } +// TODO(dmiller): this function and newPartialMatchK8sObjectSelector +// should be written in to a form that can be used like this +// x := re{pattern: name, ignoreCase: true, fullMatch: true} +// x.compile() +// rather than passing around and mutating regex strings + // Creates a new k8sObjectSelector // If an arg is an empty string it will become an empty regex that matches all input // Otherwise the arg must match the input exactly -func newExactK8sObjectSelector(apiVersion string, kind string, name string, namespace string) (k8sObjectSelector, error) { - ret, err := newK8sObjectSelector( - exactOrEmptyRegex(apiVersion), - exactOrEmptyRegex(kind), - exactOrEmptyRegex(name), - exactOrEmptyRegex(namespace), - ) +func newFullmatchCaseInsensitiveK8sObjectSelector(apiVersion string, kind string, name string, namespace string) (k8sObjectSelector, error) { + ret := k8sObjectSelector{apiVersionString: apiVersion, kindString: kind, nameString: name, namespaceString: namespace} + var err error + + ret.apiVersion, err = regexp.Compile(exactOrEmptyRegex(apiVersion)) if err != nil { - return ret, err + return k8sObjectSelector{}, errors.Wrap(err, "error parsing apiVersion regexp") } - ret.apiVersionString = apiVersion - ret.kindString = kind - ret.nameString = name - ret.namespaceString = namespace + ret.kind, err = regexp.Compile(exactOrEmptyRegex(kind)) + if err != nil { + return k8sObjectSelector{}, errors.Wrap(err, "error parsing kind regexp") + } + + ret.name, err = regexp.Compile(exactOrEmptyRegex(name)) + if err != nil { + return k8sObjectSelector{}, errors.Wrap(err, "error parsing name regexp") + } + + ret.namespace, err = regexp.Compile(exactOrEmptyRegex(namespace)) + if err != nil { + return k8sObjectSelector{}, errors.Wrap(err, "error parsing namespace regexp") + } return ret, nil } +func makeCaseInsensitive(s string) string { + if s == "" { + return s + } else { + return "(?i)" + s + } +} + func exactOrEmptyRegex(s string) string { if s != "" { - s = fmt.Sprintf("^%s$", regexp.QuoteMeta(s)) + s = fmt.Sprintf("^%s$", makeCaseInsensitive(regexp.QuoteMeta(s))) } return s } @@ -1389,18 +1411,10 @@ func exactOrEmptyRegex(s string) string { // Creates a new k8sObjectSelector // If an arg is an empty string, it will become an empty regex that matches all input // Otherwise the arg will match input from the beginning (prefix matching) -func newK8sObjectSelector(apiVersion string, kind string, name string, namespace string) (k8sObjectSelector, error) { +func newPartialMatchK8sObjectSelector(apiVersion string, kind string, name string, namespace string) (k8sObjectSelector, error) { ret := k8sObjectSelector{apiVersionString: apiVersion, kindString: kind, nameString: name, namespaceString: namespace} var err error - makeCaseInsensitive := func(s string) string { - if s == "" { - return s - } else { - return "(?i)" + s - } - } - ret.apiVersion, err = regexp.Compile(makeCaseInsensitive(apiVersion)) if err != nil { return k8sObjectSelector{}, errors.Wrap(err, "error parsing apiVersion regexp") diff --git a/internal/tiltfile/tiltfile_test.go b/internal/tiltfile/tiltfile_test.go index 0cbb2a2fb8..49ae1898bc 100644 --- a/internal/tiltfile/tiltfile_test.go +++ b/internal/tiltfile/tiltfile_test.go @@ -4948,6 +4948,29 @@ k8s_yaml([ 'serving-core.yaml', ]) +k8s_resource( + objects=[ + 'queue-proxy:Image', + ], + new_name='knative-gateways') +`) + + f.load() + f.assertNextManifest("knative-gateways") + f.assertNoMoreManifests() +} + +func TestK8sResourceObjectsAreNotCaseSensitive(t *testing.T) { + f := newFixture(t) + defer f.TearDown() + + f.file("serving-core.yaml", testyaml.KnativeServingCore) + + f.file("Tiltfile", ` +k8s_yaml([ + 'serving-core.yaml', +]) + k8s_resource( objects=[ 'queue-proxy:image',