Skip to content

Commit

Permalink
remove dependency on external repo for source and helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
nader-ziada committed Oct 19, 2018
1 parent 4adfd60 commit b85dbad
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 3 deletions.
11 changes: 11 additions & 0 deletions test/gohelloworld/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions test/gohelloworld/gohelloworld-chart/.helmignore
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions test/gohelloworld/gohelloworld-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
appVersion: "1.0"
description: A Helm chart for Kubernetes
name: gohelloworld-chart
version: 0.1.0
32 changes: 32 additions & 0 deletions test/gohelloworld/gohelloworld-chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -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 -}}
37 changes: 37 additions & 0 deletions test/gohelloworld/gohelloworld-chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
18 changes: 18 additions & 0 deletions test/gohelloworld/gohelloworld-chart/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
23 changes: 23 additions & 0 deletions test/gohelloworld/gohelloworld-chart/values.yaml
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions test/gohelloworld/main.go
Original file line number Diff line number Diff line change
@@ -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)
}
6 changes: 3 additions & 3 deletions test/helm_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
},
Expand Down Expand Up @@ -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),
},
}},
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit b85dbad

Please sign in to comment.