apiVersion: v1
data:
  cert: aHVzaCBodXNoIGh1c2gK
  key: c2VjcmV0IHNlY3JldAo=
kind: Secret
metadata:
  name: httpbin-credential
  namespace: istio-system
type: Opaque
---
apiVersion: v1
kind: Pod
metadata:
  labels:
    myapp: custom-gateway
  name: custom-gateway
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: defaultgateway-noerrors
spec:
  selector:
    istio: ingressgateway # use istio default ingress gateway, so we expect the credential in istio-system
  servers:
  - port:
      number: 443
      name: https
      protocol: HTTPS
    tls:
      mode: SIMPLE
      credentialName: "httpbin-credential" # Correct credential, should not produce an error message
    hosts:
    - "httpbin.example.com"
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: defaultgateway-bogusCredentialName
spec:
  selector:
    istio: ingressgateway # use istio default ingress gateway, so we expect the credential in istio-system
  servers:
  - port:
      number: 443
      name: https
      protocol: HTTPS
    tls:
      mode: SIMPLE
      credentialName: "httpbin-credential-bogus" # Should break, wrong credential name
    hosts:
    - "httpbin.example.com"
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: customgateway-wrongnamespace
spec:
  selector:
    istio: custom-gateway # Custom gateway
  servers:
  - port:
      number: 443
      name: https
      protocol: HTTPS
    tls:
      mode: SIMPLE
      credentialName: "httpbin-credential" # Should break, doesn't exist in custom-gateway's namespace
    hosts:
    - "httpbin.example.com"
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: bogusgateway
spec:
  selector:
    istio: custom-gateway # Nothing matches this, should generate an error
  servers:
  - port:
      number: 443
      name: https
      protocol: HTTPS
    tls:
      mode: SIMPLE
      credentialName: "httpbin-credential"
    hosts:
    - "httpbin.example.com"
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: defaultgateway-nocredential # No credentialName specified, we shouldn't generate any errors
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 443
      name: https
      protocol: HTTPS
    tls:
      mode: SIMPLE
    hosts:
    - "httpbin.example.com"