Skip to content

Commit

Permalink
Add gohelloworld sample in test folder
Browse files Browse the repository at this point in the history
will follow up with another pr to update helm test to use this
instead of external repo, but need it to be in git source
  • Loading branch information
nader-ziada authored and knative-prow-robot committed Oct 20, 2018
1 parent b2cf37d commit 6e96911
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 0 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)
}

0 comments on commit 6e96911

Please sign in to comment.