-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests for Kubernetes manifests deserialization (#1)
* Forgot to do dynamic organizations * Add Organization to pipeline example * Add tests for converting k8s manifests to internal types * Remove dead files from spinnaker * Add Makefile for pushing releases for k8s-pipeliner * Bubble up scheme conversion errors
- Loading branch information
1 parent
2b5900c
commit 73a9ab6
Showing
10 changed files
with
146 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# assign the current version from the binary | ||
VERSION = $(shell go run cmd/k8s-pipeliner/main.go --version | awk '{print $$3}') | ||
|
||
test: | ||
go test -cover ./... | ||
golint -set_exit_status ./... | ||
|
||
build: | ||
mkdir -p bin/darwin | ||
mkdir -p bin/linux | ||
GOOS=darwin go build -o bin/darwin/k8s-pipeliner cmd/k8s-pipeliner/main.go | ||
GOOS=linux go build -o bin/linux/k8s-pipeliner cmd/k8s-pipeliner/main.go | ||
|
||
release: test build; | ||
git tag v$(VERSION) && git push --tags | ||
github-release release \ | ||
--user namely \ | ||
--repo k8s-pipeliner \ | ||
--tag v$(VERSION) \ | ||
--name "k8s-pipeliner release $(VERSION)" \ | ||
--description ""; | ||
github-release upload \ | ||
--user namely \ | ||
--repo k8s-pipeliner \ | ||
--tag v$(VERSION) \ | ||
--name "k8s-pipeliner-osx-amd64" \ | ||
--file bin/darwin/k8s-pipeliner; | ||
github-release upload \ | ||
--user namely \ | ||
--repo k8s-pipeliner \ | ||
--tag v$(VERSION) \ | ||
--name "k8s-pipeliner-linux-amd64" \ | ||
--file bin/linux/k8s-pipeliner; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package builder_test | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/namely/k8s-pipeliner/pipeline/builder" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestContainersFromManifests(t *testing.T) { | ||
wd, _ := os.Getwd() | ||
|
||
t.Run("Deployment manifests are returned correctly", func(t *testing.T) { | ||
file := filepath.Join(wd, "testdata", "deployment.full.yml") | ||
group, err := builder.ContainersFromManifest(file) | ||
|
||
require.NoError(t, err, "error on retrieving the deployment manifests") | ||
|
||
assert.Len(t, group.Containers, 1) | ||
assert.Len(t, group.Annotations, 2) | ||
assert.Equal(t, "fake-namespace", group.Namespace) | ||
}) | ||
|
||
t.Run("Deployments schemes are converted to latest", func(t *testing.T) { | ||
file := filepath.Join(wd, "testdata", "deployment.v1beta1.yml") | ||
group, err := builder.ContainersFromManifest(file) | ||
|
||
require.NoError(t, err, "error on retrieving the deployment manifests") | ||
|
||
assert.Len(t, group.Containers, 1) | ||
assert.Len(t, group.Annotations, 2) | ||
assert.Equal(t, "fake-namespace", group.Namespace) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: example | ||
namespace: fake-namespace | ||
annotations: | ||
fake-annotation-1: "Hello" | ||
fake-annotation-2: "World" | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
app: example | ||
spec: | ||
containers: | ||
- command: | ||
- echo | ||
- hello | ||
env: | ||
- name: WHATS_THE_WORD | ||
value: "bird is the word" | ||
image: bird.word/latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: apps/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: example | ||
namespace: fake-namespace | ||
annotations: | ||
fake-annotation-1: "Hello" | ||
fake-annotation-2: "World" | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
app: example | ||
spec: | ||
containers: | ||
- command: | ||
- echo | ||
- hello | ||
env: | ||
- name: WHATS_THE_WORD | ||
value: "bird is the word" | ||
image: bird.word/latest |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.