diff --git a/test/gohelloworld/Dockerfile b/test/gohelloworld/Dockerfile new file mode 100644 index 00000000000..6c599e2168f --- /dev/null +++ b/test/gohelloworld/Dockerfile @@ -0,0 +1,11 @@ +FROM golang + +# Copy the local package files to the container's workspace. +ADD . /go/src/github.com/knative/build-pipeline/test/gohelloworld + +RUN go install github.com/knative/build-pipeline/test/gohelloworld + +ENTRYPOINT /go/bin/gohelloworld + +# Document that the service listens on port 8080. +EXPOSE 8080 \ No newline at end of file diff --git a/test/gohelloworld/gohelloworld-chart/.helmignore b/test/gohelloworld/gohelloworld-chart/.helmignore new file mode 100644 index 00000000000..f0c13194444 --- /dev/null +++ b/test/gohelloworld/gohelloworld-chart/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/test/gohelloworld/gohelloworld-chart/Chart.yaml b/test/gohelloworld/gohelloworld-chart/Chart.yaml new file mode 100644 index 00000000000..189a140a8f7 --- /dev/null +++ b/test/gohelloworld/gohelloworld-chart/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: gohelloworld-chart +version: 0.1.0 diff --git a/test/gohelloworld/gohelloworld-chart/templates/_helpers.tpl b/test/gohelloworld/gohelloworld-chart/templates/_helpers.tpl new file mode 100644 index 00000000000..9c9b9c3c987 --- /dev/null +++ b/test/gohelloworld/gohelloworld-chart/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "gohelloworld-chart.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "gohelloworld-chart.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "gohelloworld-chart.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/test/gohelloworld/gohelloworld-chart/templates/deployment.yaml b/test/gohelloworld/gohelloworld-chart/templates/deployment.yaml new file mode 100644 index 00000000000..8862d5ecfe7 --- /dev/null +++ b/test/gohelloworld/gohelloworld-chart/templates/deployment.yaml @@ -0,0 +1,37 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ template "gohelloworld-chart.name" . }} + labels: + app: {{ template "gohelloworld-chart.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + app: {{ template "gohelloworld-chart.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: {{ .Values.service.internalPort }} + livenessProbe: + httpGet: + path: / + port: {{ .Values.service.internalPort }} + readinessProbe: + httpGet: + path: / + port: {{ .Values.service.internalPort }} + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} \ No newline at end of file diff --git a/test/gohelloworld/gohelloworld-chart/templates/service.yaml b/test/gohelloworld/gohelloworld-chart/templates/service.yaml new file mode 100644 index 00000000000..409ed379b2e --- /dev/null +++ b/test/gohelloworld/gohelloworld-chart/templates/service.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "gohelloworld-chart.name" . }} + labels: + app: {{ template "gohelloworld-chart.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + name: {{ .Values.service.name }} + selector: + app: {{ template "gohelloworld-chart.name" . }} + release: {{ .Release.Name }} \ No newline at end of file diff --git a/test/gohelloworld/gohelloworld-chart/values.yaml b/test/gohelloworld/gohelloworld-chart/values.yaml new file mode 100644 index 00000000000..4608fb113f5 --- /dev/null +++ b/test/gohelloworld/gohelloworld-chart/values.yaml @@ -0,0 +1,23 @@ +# Default values for gohelloworld-chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + tag: latest + pullPolicy: Always + +service: + name: gohelloworld + type: LoadBalancer + externalPort: 8080 + internalPort: 8080 + +resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi diff --git a/test/gohelloworld/main.go b/test/gohelloworld/main.go new file mode 100644 index 00000000000..eb7670ddc3f --- /dev/null +++ b/test/gohelloworld/main.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "log" + "net/http" +) + +func handler(w http.ResponseWriter, r *http.Request) { + log.Print("Hello world received a request.") + fmt.Fprintf(w, "Hello World! \n") +} + +func main() { + log.Print("Hello world sample started.") + + http.HandleFunc("/", handler) + http.ListenAndServe(":8080", nil) +} diff --git a/test/helm_task_test.go b/test/helm_task_test.go index 50f7e806de3..0f38638e98e 100644 --- a/test/helm_task_test.go +++ b/test/helm_task_test.go @@ -149,7 +149,7 @@ func getGoHelloworldGitResource(namespace string) *v1alpha1.PipelineResource { Params: []v1alpha1.Param{ v1alpha1.Param{ Name: "Url", - Value: "https://github.com/pivotal-nader-ziada/gohelloworld", + Value: "https://github.com/knative/build-pipeline", }, }, }, @@ -186,7 +186,7 @@ func getCreateImageTask(namespace string, t *testing.T) *v1alpha1.Task { Steps: []corev1.Container{{ Name: "kaniko", Image: "gcr.io/kaniko-project/executor", - Args: []string{"--dockerfile=/workspace/Dockerfile", + Args: []string{"--dockerfile=/workspace/test/gohelloworld/Dockerfile", fmt.Sprintf("--destination=%s", imageName), }, }}, @@ -274,7 +274,7 @@ func getHelmDeployPipeline(namespace string) *v1alpha1.Pipeline { }}, Params: []v1alpha1.Param{{ Name: "pathToHelmCharts", - Value: "/workspace/gohelloworld-chart", + Value: "/workspace/test/gohelloworld/gohelloworld-chart", }, { Name: "chartname", Value: "gohelloworld",