Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Ship init supports arbitrary upstreams #399

Merged
merged 1 commit into from
Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
$GOPATH/bin/ginkgo -p -stream integration/base
$GOPATH/bin/ginkgo -p -stream integration/update
$GOPATH/bin/ginkgo -p -stream integration/init_app
$GOPATH/bin/ginkgo -p -stream integration/init_chart
$GOPATH/bin/ginkgo -p -stream integration/init

deploy_unstable:
docker:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ integration/*/_test_*

/.state/
/chart/
/chart.bak/
/overlays/
/base/
/base.bak/
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ _mockgen:
mkdir -p pkg/test-mocks/daemon
mkdir -p pkg/test-mocks/tfplan
mkdir -p pkg/test-mocks/state
mkdir -p pkg/test-mocks/apptype
mkdir -p pkg/test-mocks/replicatedapp
mockgen \
-destination pkg/test-mocks/ui/ui.go \
-package ui \
Expand Down Expand Up @@ -158,6 +160,16 @@ _mockgen:
-package lifecycle \
github.com/replicatedhq/ship/pkg/lifecycle \
Renderer
mockgen \
-destination pkg/test-mocks/apptype/determine_type_mock.go \
-package apptype \
github.com/replicatedhq/ship/pkg/specs/apptype \
Inspector
mockgen \
-destination pkg/test-mocks/replicatedapp/resolve_replicated_app.go \
-package replicatedapp \
github.com/replicatedhq/ship/pkg/specs/replicatedapp \
Resolver

mockgen: _mockgen fmt

Expand Down
18 changes: 0 additions & 18 deletions deploy/e2e.yml

This file was deleted.

Empty file.
Empty file.
4 changes: 2 additions & 2 deletions integration/base/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ type TestMetadata struct {

func TestShipApp(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "ship app ...")
RunSpecs(t, "ship app")
}

var _ = Describe("ship app ...", func() {
var _ = Describe("ship app", func() {
dockerClient, err := client.NewEnvClient()
if err != nil {
panic(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,19 @@ import (
)

type TestMetadata struct {
Chart string `yaml:"chart"`
Version string `yaml:"version"`
RepoURL string `yaml:"repo_url"`
Upstream string `yaml:"upstream"`
Args []string `yaml:"args"`

// debugging
SkipCleanup bool `yaml:"skip_cleanup"`
}

func TestInitChartWithHelmFetch(t *testing.T) {
func TestInit(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "ship init <chart> with helm fetch")
RunSpecs(t, "ship init")
}

var _ = Describe("ship init with 'helm fetch'", func() {
var _ = Describe("ship init with arbitrary upstream", func() {
dockerClient, err := client.NewEnvClient()
if err != nil {
panic(err)
Expand Down Expand Up @@ -81,14 +80,10 @@ var _ = Describe("ship init with 'helm fetch'", func() {
cmd.SetOutput(buf)
cmd.SetArgs(append([]string{
"init",
testMetadata.Chart,
testMetadata.Upstream,
"--headless",
"--log-level=off",
"--chart-version",
testMetadata.Version,
"--chart-repo-url",
testMetadata.RepoURL,
}))
}, testMetadata.Args...))
err := cmd.Execute()
Expect(err).NotTo(HaveOccurred())

Expand Down
7 changes: 7 additions & 0 deletions integration/init/plain-k8s/expected/.ship/state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"v1": {
"config": {},
"upstream": "github.com/replicatedhq/test-charts/plain-k8s",
"contentSHA": "7d52a28c5b78539223c3548c2ee677b8b9d624f178e3aac1a15c0097f4e7cb62"
}
}
23 changes: 23 additions & 0 deletions integration/init/plain-k8s/expected/base/MAINTENANCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Building the Docker images

```console
$ docker build -t gcr.io/google-samples/gb-frontend:v5 php-redis

$ docker build -t gcr.io/google-samples/gb-redisslave:v2 redis-slave
```

Building Multi-architecture docker images

```console
$ make -C php-redis

$ make -C redis-slave
```

Push:

```console
$ make -C php-redis all-push

$ make -C redis-slave all-push
```
6 changes: 6 additions & 0 deletions integration/init/plain-k8s/expected/base/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Example: Guestbook application on Kubernetes

This directory contains the source code and Kubernetes manifests for PHP
Guestbook application.

Follow the tutorial at https://kubernetes.io/docs/tutorials/stateless-application/guestbook/.
33 changes: 33 additions & 0 deletions integration/init/plain-k8s/expected/base/frontend-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: apps/v1 # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1
kind: Deployment
metadata:
name: frontend
spec:
selector:
matchLabels:
app: guestbook
tier: frontend
replicas: 3
template:
metadata:
labels:
app: guestbook
tier: frontend
spec:
containers:
- name: php-redis
image: gcr.io/google-samples/gb-frontend:v4
resources:
requests:
cpu: 100m
memory: 100Mi
env:
- name: GET_HOSTS_FROM
value: dns
# If your cluster config does not include a dns service, then to
# instead access environment variables to find service host
# info, comment out the 'value: dns' line above, and uncomment the
# line below:
# value: env
ports:
- containerPort: 80
18 changes: 18 additions & 0 deletions integration/init/plain-k8s/expected/base/frontend-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Service
metadata:
name: frontend
labels:
app: guestbook
tier: frontend
spec:
# comment or delete the following line if you want to use a LoadBalancer
type: NodePort
# if your cluster supports it, uncomment the following to automatically create
# an external load-balanced IP for the frontend service.
# type: LoadBalancer
ports:
- port: 80
selector:
app: guestbook
tier: frontend
7 changes: 7 additions & 0 deletions integration/init/plain-k8s/expected/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resources:
- frontend-deployment.yaml
- frontend-service.yaml
- redis-master-deployment.yaml
- redis-master-service.yaml
- redis-slave-deployment.yaml
- redis-slave-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: apps/v1 # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1
kind: Deployment
metadata:
name: redis-master
spec:
selector:
matchLabels:
app: redis
role: master
tier: backend
replicas: 1
template:
metadata:
labels:
app: redis
role: master
tier: backend
spec:
containers:
- name: master
image: k8s.gcr.io/redis:e2e # or just image: redis
resources:
requests:
cpu: 100m
memory: 100Mi
ports:
- containerPort: 6379
16 changes: 16 additions & 0 deletions integration/init/plain-k8s/expected/base/redis-master-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: redis-master
labels:
app: redis
role: master
tier: backend
spec:
ports:
- port: 6379
targetPort: 6379
selector:
app: redis
role: master
tier: backend
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: apps/v1 # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1
kind: Deployment
metadata:
name: redis-slave
spec:
selector:
matchLabels:
app: redis
role: slave
tier: backend
replicas: 2
template:
metadata:
labels:
app: redis
role: slave
tier: backend
spec:
containers:
- name: slave
image: gcr.io/google_samples/gb-redisslave:v1
resources:
requests:
cpu: 100m
memory: 100Mi
env:
- name: GET_HOSTS_FROM
value: dns
# If your cluster config does not include a dns service, then to
# instead access an environment variable to find the master
# service's host, comment out the 'value: dns' line above, and
# uncomment the line below:
# value: env
ports:
- containerPort: 6379
15 changes: 15 additions & 0 deletions integration/init/plain-k8s/expected/base/redis-slave-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: redis-slave
labels:
app: redis
role: slave
tier: backend
spec:
ports:
- port: 6379
selector:
app: redis
role: slave
tier: backend
3 changes: 3 additions & 0 deletions integration/init/plain-k8s/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
upstream: "github.com/replicatedhq/test-charts/plain-k8s"
args: []
skip_cleanup: false
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"v1": {
"config": {},
"chartURL": "stable/mysql",
"upstream": "stable/mysql",
"ChartVersion": "0.8.1",
"contentSHA": "58d9ac4317f420275e1e05f1144eeadbfdcdeff373762625d58001a42e013092"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bases:
- ../../base
5 changes: 5 additions & 0 deletions integration/init/stable-mysql/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
upstream: "stable/mysql"
args:
- --chart-version=0.8.1


10 changes: 5 additions & 5 deletions integration/init_app/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ var _ = Describe("ship init replicated.app/...", func() {
}

isStaging := strings.Contains(customerEndpoint, "staging")
initTarget := "replicated.app/some-cool-ci-tool"
upstream := "replicated.app/some-cool-ci-tool"
if isStaging {
initTarget = "staging.replicated.app/some-cool-ci-tool"
upstream = "staging.replicated.app/some-cool-ci-tool"
}

// this should probably be url encoded but whatever
initTarget = fmt.Sprintf(
upstream = fmt.Sprintf(
"%s?installation_id=%s&customer_id=%s",
initTarget,
upstream,
installationID,
testMetadata.CustomerID,
)
Expand All @@ -127,7 +127,7 @@ var _ = Describe("ship init replicated.app/...", func() {
cmd.SetOutput(buf)
cmd.SetArgs(append([]string{
"init",
initTarget,
upstream,
"--headless",
fmt.Sprintf("--state-file=%s", path.Join(testInputPath, ".ship/state.json")),
"--log-level=off",
Expand Down
3 changes: 0 additions & 3 deletions integration/init_chart/stable-mysql/metadata.yaml

This file was deleted.

Empty file.
2 changes: 1 addition & 1 deletion integration/update/basic/expected/.ship/state.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"v1":{"config":{},"helmValues":"# Default values for basic.\n# This is a YAML-formatted file.\n# Declare variables to be passed into your templates.\n\nreplicaCount: 5\n\nimage:\n repository: nginx\n tag: stable\n pullPolicy: IfNotPresent\n\nservice:\n type: ClusterIP\n port: 80\n\ningress:\n enabled: false\n annotations: {}\n # kubernetes.io/ingress.class: nginx\n # kubernetes.io/tls-acme: \"true\"\n path: /\n hosts:\n - chart-example.local\n tls: []\n # - secretName: chart-example-tls\n # hosts:\n # - chart-example.local\n\nresources: {}\n # We usually recommend not to specify default resources and to leave this as a conscious\n # choice for the user. This also increases chances charts run on environments with little\n # resources, such as Minikube. If you do want to specify resources, uncomment the following\n # lines, adjust them as necessary, and remove the curly braces after 'resources:'.\n # limits:\n # cpu: 100m\n # memory: 128Mi\n # requests:\n # cpu: 100m\n # memory: 128Mi\n\nnodeSelector: {}\n\ntolerations: []\n\naffinity: {}\n","kustomize":{"overlays":{"ship":{"patches":{"/templates/deployment.yaml":"--- \napiVersion: apps/v1beta2\nkind: Deployment\nmetadata:\n name: 'basic'\n"}}}},"chartURL":"github.com/replicatedhq/test-charts/basic","contentSHA":"94d255c48a20929dbfbe341109a7ab86dae1ecfab3b8f01151bb36a2ebea7bbe"}}
{"v1":{"config":{},"helmValues":"# Default values for basic.\n# This is a YAML-formatted file.\n# Declare variables to be passed into your templates.\n\nreplicaCount: 5\n\nimage:\n repository: nginx\n tag: stable\n pullPolicy: IfNotPresent\n\nservice:\n type: ClusterIP\n port: 80\n\ningress:\n enabled: false\n annotations: {}\n # kubernetes.io/ingress.class: nginx\n # kubernetes.io/tls-acme: \"true\"\n path: /\n hosts:\n - chart-example.local\n tls: []\n # - secretName: chart-example-tls\n # hosts:\n # - chart-example.local\n\nresources: {}\n # We usually recommend not to specify default resources and to leave this as a conscious\n # choice for the user. This also increases chances charts run on environments with little\n # resources, such as Minikube. If you do want to specify resources, uncomment the following\n # lines, adjust them as necessary, and remove the curly braces after 'resources:'.\n # limits:\n # cpu: 100m\n # memory: 128Mi\n # requests:\n # cpu: 100m\n # memory: 128Mi\n\nnodeSelector: {}\n\ntolerations: []\n\naffinity: {}\n","kustomize":{"overlays":{"ship":{"patches":{"/templates/deployment.yaml":"--- \napiVersion: apps/v1beta2\nkind: Deployment\nmetadata:\n name: 'basic'\n"}}}},"upstream":"github.com/replicatedhq/test-charts/basic","contentSHA":"94d255c48a20929dbfbe341109a7ab86dae1ecfab3b8f01151bb36a2ebea7bbe"}}
2 changes: 1 addition & 1 deletion integration/update/basic/input/.ship/state.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"v1":{"config":{},"helmValues":"# Default values for basic.\n# This is a YAML-formatted file.\n# Declare variables to be passed into your templates.\n\nreplicaCount: 5\n\nimage:\n repository: nginx\n tag: stable\n pullPolicy: IfNotPresent\n\nservice:\n type: ClusterIP\n port: 80\n\ningress:\n enabled: false\n annotations: {}\n # kubernetes.io/ingress.class: nginx\n # kubernetes.io/tls-acme: \"true\"\n path: /\n hosts:\n - chart-example.local\n tls: []\n # - secretName: chart-example-tls\n # hosts:\n # - chart-example.local\n\nresources: {}\n # We usually recommend not to specify default resources and to leave this as a conscious\n # choice for the user. This also increases chances charts run on environments with little\n # resources, such as Minikube. If you do want to specify resources, uncomment the following\n # lines, adjust them as necessary, and remove the curly braces after 'resources:'.\n # limits:\n # cpu: 100m\n # memory: 128Mi\n # requests:\n # cpu: 100m\n # memory: 128Mi\n\nnodeSelector: {}\n\ntolerations: []\n\naffinity: {}\n","kustomize":{"overlays":{"ship":{"patches":{"/templates/deployment.yaml":"--- \napiVersion: apps/v1beta2\nkind: Deployment\nmetadata:\n name: 'basic'\n"}}}},"chartURL":"github.com/replicatedhq/test-charts/basic"}}
{"v1":{"config":{},"helmValues":"# Default values for basic.\n# This is a YAML-formatted file.\n# Declare variables to be passed into your templates.\n\nreplicaCount: 5\n\nimage:\n repository: nginx\n tag: stable\n pullPolicy: IfNotPresent\n\nservice:\n type: ClusterIP\n port: 80\n\ningress:\n enabled: false\n annotations: {}\n # kubernetes.io/ingress.class: nginx\n # kubernetes.io/tls-acme: \"true\"\n path: /\n hosts:\n - chart-example.local\n tls: []\n # - secretName: chart-example-tls\n # hosts:\n # - chart-example.local\n\nresources: {}\n # We usually recommend not to specify default resources and to leave this as a conscious\n # choice for the user. This also increases chances charts run on environments with little\n # resources, such as Minikube. If you do want to specify resources, uncomment the following\n # lines, adjust them as necessary, and remove the curly braces after 'resources:'.\n # limits:\n # cpu: 100m\n # memory: 128Mi\n # requests:\n # cpu: 100m\n # memory: 128Mi\n\nnodeSelector: {}\n\ntolerations: []\n\naffinity: {}\n","kustomize":{"overlays":{"ship":{"patches":{"/templates/deployment.yaml":"--- \napiVersion: apps/v1beta2\nkind: Deployment\nmetadata:\n name: 'basic'\n"}}}},"upstream":"github.com/replicatedhq/test-charts/basic"}}
Loading