From 0fc59e02250c73dfbb87ad175037741a128ba41a Mon Sep 17 00:00:00 2001 From: akihikokuroda Date: Wed, 25 Mar 2020 12:47:48 +0000 Subject: [PATCH] change api version --- docs/create-ingress.yaml | 79 +++++++++---------- docs/create-webhook.yaml | 53 ++++++------- docs/getting-started/ingress-run.yaml | 26 +++--- docs/getting-started/webhook-run.yaml | 30 +++---- .../v1alpha1/event_listener_validation.go | 2 +- test/e2e-tests-ingress.sh | 29 ++++--- 6 files changed, 108 insertions(+), 111 deletions(-) diff --git a/docs/create-ingress.yaml b/docs/create-ingress.yaml index 035bd6e08..1cfb4ed16 100644 --- a/docs/create-ingress.yaml +++ b/docs/create-ingress.yaml @@ -1,4 +1,4 @@ -apiVersion: tekton.dev/v1alpha1 +apiVersion: tekton.dev/v1beta1 kind: Task metadata: name: create-ingress @@ -7,24 +7,23 @@ spec: - name: work emptyDir: {} - inputs: - params: - - name: CreateCertificate - description: "Enables/disables the creation of a self-signed certificate for $(inputs.params.ExternalDomain)" - default: "true" - - name: CertificateKeyPassphrase - description: "Phrase that protects private key. This must be provided when the self-signed certificate is created" - - name: CertificateSecretName - description: "Secret name for Ingress certificate. The Secret should not exist if the self-signed certificate creation is enabled" - - name: ExternalDomain - description: "The external domain for the EventListener e.g. `$(inputs.params.EventListenerName).PROXYIP.nip.io`" - - name: Service - description: "The name of the Service used in the Ingress. This will also be the name of the Ingress." - - name: ServicePort - description: "The service port that the ingress is being created on" - - name: ServiceUID - description: "The uid of the service. If set, this creates an owner reference on the service" - default: "" + params: + - name: CreateCertificate + description: "Enables/disables the creation of a self-signed certificate for $(params.ExternalDomain)" + default: "true" + - name: CertificateKeyPassphrase + description: "Phrase that protects private key. This must be provided when the self-signed certificate is created" + - name: CertificateSecretName + description: "Secret name for Ingress certificate. The Secret should not exist if the self-signed certificate creation is enabled" + - name: ExternalDomain + description: "The external domain for the EventListener e.g. `$(params.EventListenerName).PROXYIP.nip.io`" + - name: Service + description: "The name of the Service used in the Ingress. This will also be the name of the Ingress." + - name: ServicePort + description: "The service port that the ingress is being created on" + - name: ServiceUID + description: "The uid of the service. If set, this creates an owner reference on the service" + default: "" steps: - name: generate-certificate @@ -40,13 +39,13 @@ spec: set -e cat <.nip.io`" - - name: GitHubUser - description: "The GitHub user" - - name: GitHubRepo - description: "The GitHub repo where the webhook will be created" - - name: GitHubOrg - description: "The GitHub organization where the webhook will be created" - - name: GitHubSecretName - description: "The Secret name for GitHub access token. This is always mounted and must exist" - - name: GitHubAccessTokenKey - description: "The GitHub access token key name" - - name: GitHubSecretStringKey - description: "The GitHub secret string key name" - - name: GitHubDomain - description: "The GitHub domain. Override for GitHub Enterprise" - default: "github.com" - - name: WebhookEvents - description: "List of events the webhook will send notifications for" - default: '[\"push\",\"pull_request\"]' + params: + - name: ExternalDomain + description: "The external domain for the EventListener e.g. `$(params.EventListenerName)..nip.io`" + - name: GitHubUser + description: "The GitHub user" + - name: GitHubRepo + description: "The GitHub repo where the webhook will be created" + - name: GitHubOrg + description: "The GitHub organization where the webhook will be created" + - name: GitHubSecretName + description: "The Secret name for GitHub access token. This is always mounted and must exist" + - name: GitHubAccessTokenKey + description: "The GitHub access token key name" + - name: GitHubSecretStringKey + description: "The GitHub secret string key name" + - name: GitHubDomain + description: "The GitHub domain. Override for GitHub Enterprise" + default: "github.com" + - name: WebhookEvents + description: "List of events the webhook will send notifications for" + default: '[\"push\",\"pull_request\"]' steps: - name: create-webhook image: pstauffer/curl:latest @@ -43,8 +42,8 @@ spec: - | set -e echo "Create Webhook" - if [ $(inputs.params.GitHubDomain) = "github.com" ];then - curl -v -d "{\"name\": \"web\",\"active\": true,\"events\": $(inputs.params.WebhookEvents),\"config\": {\"url\": \"https://$(inputs.params.ExternalDomain)\",\"content_type\": \"json\",\"insecure_ssl\": \"1\" ,\"secret\": \"$(cat /var/secret/$(inputs.params.GitHubSecretStringKey))\"}}" -X POST -u $(inputs.params.GitHubUser):$(cat /var/secret/$(inputs.params.GitHubAccessTokenKey)) -L https://api.github.com/repos/$(inputs.params.GitHubOrg)/$(inputs.params.GitHubRepo)/hooks + if [ $(params.GitHubDomain) = "github.com" ];then + curl -v -d "{\"name\": \"web\",\"active\": true,\"events\": $(params.WebhookEvents),\"config\": {\"url\": \"https://$(params.ExternalDomain)\",\"content_type\": \"json\",\"insecure_ssl\": \"1\" ,\"secret\": \"$(cat /var/secret/$(params.GitHubSecretStringKey))\"}}" -X POST -u $(params.GitHubUser):$(cat /var/secret/$(params.GitHubAccessTokenKey)) -L https://api.github.com/repos/$(params.GitHubOrg)/$(params.GitHubRepo)/hooks else - curl -d "{\"name\": \"web\",\"active\": true,\"events\": $(inputs.params.WebhookEvents),\"config\": {\"url\": \"https://$(inputs.params.ExternalDomain)/\",\"content_type\": \"json\",\"insecure_ssl\": \"1\" ,\"secret\": \"$(cat /var/secret/$(inputs.params.GitHubSecretStringKey))\"}}" -X POST -u $(inputs.params.GitHubUser):$(cat /var/secret/$(inputs.params.GitHubAccessTokenKey)) -L https://$(inputs.params.GitHubDomain)/api/v3/repos/$(inputs.params.GitHubOrg)/$(inputs.params.GitHubRepo)/hooks + curl -d "{\"name\": \"web\",\"active\": true,\"events\": $(params.WebhookEvents),\"config\": {\"url\": \"https://$(params.ExternalDomain)/\",\"content_type\": \"json\",\"insecure_ssl\": \"1\" ,\"secret\": \"$(cat /var/secret/$(params.GitHubSecretStringKey))\"}}" -X POST -u $(params.GitHubUser):$(cat /var/secret/$(params.GitHubAccessTokenKey)) -L https://$(params.GitHubDomain)/api/v3/repos/$(params.GitHubOrg)/$(params.GitHubRepo)/hooks fi diff --git a/docs/getting-started/ingress-run.yaml b/docs/getting-started/ingress-run.yaml index e4b217273..77fa5dae2 100644 --- a/docs/getting-started/ingress-run.yaml +++ b/docs/getting-started/ingress-run.yaml @@ -6,18 +6,18 @@ metadata: spec: taskRef: name: create-ingress - params: - - name: CreateCertificate - value: "true" - - name: CertificateKeyPassphrase - value: asecretphrase - - name: CertificateSecretName - value: ingresssecret - - name: ExternalDomain - value: getting-started.iancoffey.com - - name: Service - value: getting-started - - name: ServicePort - value: "8080" + params: + - name: CreateCertificate + value: "true" + - name: CertificateKeyPassphrase + value: asecretphrase + - name: CertificateSecretName + value: ingresssecret + - name: ExternalDomain + value: getting-started.iancoffey.com + - name: Service + value: getting-started + - name: ServicePort + value: "8080" timeout: 1000s serviceAccountName: tekton-triggers-createwebhook diff --git a/docs/getting-started/webhook-run.yaml b/docs/getting-started/webhook-run.yaml index ac0b92447..34eeee4ef 100644 --- a/docs/getting-started/webhook-run.yaml +++ b/docs/getting-started/webhook-run.yaml @@ -6,20 +6,20 @@ metadata: spec: taskRef: name: create-webhook - params: - - name: GitHubOrg - value: "iancoffey" - - name: GitHubUser - value: "iancoffey" - - name: GitHubRepo - value: "ulmaceae" - - name: GitHubSecretName - value: webhook-secret - - name: GitHubAccessTokenKey - value: token - - name: GitHubSecretStringKey - value: secret - - name: ExternalDomain - value: demo.iancoffey.com + params: + - name: GitHubOrg + value: "iancoffey" + - name: GitHubUser + value: "iancoffey" + - name: GitHubRepo + value: "ulmaceae" + - name: GitHubSecretName + value: webhook-secret + - name: GitHubAccessTokenKey + value: token + - name: GitHubSecretStringKey + value: secret + - name: ExternalDomain + value: demo.iancoffey.com timeout: 1000s serviceAccountName: tekton-triggers-createwebhook diff --git a/pkg/apis/triggers/v1alpha1/event_listener_validation.go b/pkg/apis/triggers/v1alpha1/event_listener_validation.go index c001d6924..220c587fa 100644 --- a/pkg/apis/triggers/v1alpha1/event_listener_validation.go +++ b/pkg/apis/triggers/v1alpha1/event_listener_validation.go @@ -62,7 +62,7 @@ func (t *EventListenerTrigger) validate(ctx context.Context) *apis.FieldError { } } if t.Template.Name == "" { - return apis.ErrMissingField(fmt.Sprintf("template.name")) + return apis.ErrMissingField("template.name") } for i, interceptor := range t.Interceptors { if err := interceptor.validate(ctx).ViaField(fmt.Sprintf("interceptors[%d]", i)); err != nil { diff --git a/test/e2e-tests-ingress.sh b/test/e2e-tests-ingress.sh index a48ed6fa3..e7e158932 100755 --- a/test/e2e-tests-ingress.sh +++ b/test/e2e-tests-ingress.sh @@ -140,27 +140,26 @@ EXTERNAL_DOMAIN="${SERVICE_NAME}.192.168.0.1.nip.io" # Create Ingress using Ingress Task cat << DONE | kubectl apply -f - -apiVersion: tekton.dev/v1alpha1 +apiVersion: tekton.dev/v1beta1 kind: TaskRun metadata: name: ${INGRESS_TASKRUN_NAME} spec: taskRef: name: create-ingress - inputs: - params: - - name: CertificateKeyPassphrase - value: ${CERTIFICATE_KEY_PASSPHRASE} - - name: CertificateSecretName - value: ${CERTIFICATE_SECRET_NAME} - - name: ExternalDomain - value: ${EXTERNAL_DOMAIN} - - name: Service - value: ${SERVICE_NAME} - - name: ServicePort - value: "8080" - - name: ServiceUID - value: ${SERVICE_UID} + params: + - name: CertificateKeyPassphrase + value: ${CERTIFICATE_KEY_PASSPHRASE} + - name: CertificateSecretName + value: ${CERTIFICATE_SECRET_NAME} + - name: ExternalDomain + value: ${EXTERNAL_DOMAIN} + - name: Service + value: ${SERVICE_NAME} + - name: ServicePort + value: "8080" + - name: ServiceUID + value: ${SERVICE_UID} timeout: 1000s serviceAccountName: default DONE