-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feature: update for porter v1.0.0 Signed-off-by: Brian DeGeeter <[email protected]> * feature: update for porter v1.0.0 Signed-off-by: Brian DeGeeter <[email protected]> * feature: update for porter v1.0.0 Signed-off-by: Brian DeGeeter <[email protected]> * feature: update for porter v1.0.0 Signed-off-by: Brian DeGeeter <[email protected]> * chore: addressing comments (#2) Signed-off-by: Steven Gettys <[email protected]> * chore: Updated magefile to use getporter.sh/magefiles Signed-off-by: Steven Gettys <[email protected]> * chore: inject version into test image Signed-off-by: Brian DeGeeter <[email protected]> * chore: move more make to mage Signed-off-by: Brian DeGeeter <[email protected]> * chore: Moved local integration test out of make to mage Signed-off-by: Steven Gettys <[email protected]> * chore: Add porter-runtime to mage downloads Signed-off-by: Steven Gettys <[email protected]> * chore: magefile deps cleanup and must stuff Signed-off-by: Steven Gettys <[email protected]> * docs: update for refactor Signed-off-by: Brian DeGeeter <[email protected]> * chore: add install target Signed-off-by: Brian DeGeeter <[email protected]> * chore: Addressing review comments Signed-off-by: Steven Gettys <[email protected]> * chore: update error message for missing secret Signed-off-by: Steven Gettys <[email protected]> * chore: Updated azure pipelines Signed-off-by: Steven Gettys <[email protected]> * chore: Specifying ginkgo version Signed-off-by: Steven Gettys <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: sgettys <[email protected]> Co-authored-by: Steven Gettys <[email protected]>
- Loading branch information
1 parent
c3c9b88
commit 90d10d4
Showing
58 changed files
with
2,673 additions
and
1,525 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,36 @@ | ||
name: build | ||
on: | ||
push: | ||
branches-ignore: | ||
- '**' | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./ | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17 | ||
- name: Set up Mage | ||
run: go run mage.go EnsureMage | ||
- name: Test Integration | ||
run: build/run-integration-tests.sh | ||
- name: Report Integration Test Coverage | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
files: ./coverage-integration.out | ||
flags: integration-tests |
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
/bin | ||
.DS_Store | ||
kind.config.yaml | ||
/kind.config.yaml | ||
**/.cnab/** | ||
/tests/testdata/Dockerfile | ||
/tests/testdata/Dockerfile | ||
/vendor | ||
.porter/ | ||
kind.config | ||
coverage-integration.out |
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,89 @@ | ||
# Contributing Guide | ||
|
||
--- | ||
* [New Contributor Guide](#new-contributor-guide) | ||
* [Developer Tasks](#developer-tasks) | ||
* [Initial setup](#initial-setup) | ||
* [Makefile explained](#makefile-explained) | ||
* [Run a test installation](#run-a-test-installation) | ||
--- | ||
|
||
# New Contributor Guide | ||
|
||
The [Porter New Contributor Guide](https://porter.sh/src/CONTRIBUTING.md) has information on how to find issues, what | ||
type of help we are looking for, what to expect in your first pull request and | ||
more. | ||
|
||
# Developer Tasks | ||
|
||
## Initial setup | ||
|
||
We have a [tutorial] that walks you through how to setup your developer | ||
environment for Porter, make a change and test it. | ||
|
||
We recommend that you start there so that you understand how to use Porter. | ||
|
||
You will need a Porter, Porter Operator KinD, Go, and Docker to work on the Kubernetes secrets plugin. | ||
|
||
[tutorial]: https://porter.sh/contribute/tutorial/ | ||
|
||
``` | ||
# Install mage | ||
go run mage.go EnsureMage | ||
# Build and deploy the to a local porter test environment. | ||
# The Porter install is relative to this project directory (PORTER_HOME=${PWD}/bin) | ||
mage TestLocalIntegration | ||
# Build and deploy the to a k8s porter operator test environment. | ||
mage TestIntegration | ||
``` | ||
|
||
## Magefile explained | ||
|
||
We use [mage](https://magefile.org) instead of make. If you don't have mage installed already, | ||
you can install it with `go run mage.go EnsureMage`. | ||
|
||
[mage]: https://magefile.org | ||
|
||
Mage targets are not case-sensitive, but in our docs we use camel case to make | ||
it easier to read. You can run either `mage Build` or `mage build` for | ||
example. Run `mage` without any arguments to see a list of the available targets. | ||
|
||
* **Build** builds the plugin, runs unit-test and cross compiles for local and in cluster testing. | ||
|
||
**NOTE** This project is still moving targets from the original `Makefile` into mage. Please | ||
file an issue for any problems encountered. Make will continue to be deprecated as functionality is | ||
migrated into mage and all new functionality should be added directly to mage. | ||
|
||
### Utility Targets | ||
These are targets that you won't usually run directly, other targets use them as dependencies. | ||
|
||
* **BuildLocalPorterAgent** builds an agent image with plugin for operator integration testing | ||
* **EnsureTestCluster** starts a KIND cluster if it's not already running. | ||
* **PublishLocalPorterAgent** builds and publishes agent image to KIND cluster. | ||
* **CreateTestCluster** creates a new KIND cluster named porter. | ||
* **DeleteTestCluster** deletes the KIND cluster named porter. | ||
* **Clean** removes all | ||
* **CleanTestdata** removes any namespaces created by the test suite (with label porter.sh/testdata=true). | ||
|
||
## Run a test installation | ||
|
||
There are two primary test integration environments. The first for testing the `porter` command | ||
locally with the Kubernetes secrets plugin. The second environment is for testing via | ||
the [porter operator](https://github.com/getporter/operator). | ||
|
||
The `mage EnsureTestCluster` target sets up everything needed to manually troubleshoot the | ||
environment. | ||
|
||
`mage TestLocalIntegration` run the porter command locally with the tests defined at | ||
[tests/integration/local](tests/integration/local). | ||
|
||
`mage TestIntegration` run the porter command via the operator with the tests defined at | ||
[tests/integration/operator](tests/integration/operator). | ||
|
||
|
||
|
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 |
---|---|---|
@@ -1,127 +1,25 @@ | ||
PLUGIN = kubernetes | ||
PKG = get.porter.sh/plugin/$(PLUGIN) | ||
SHELL = /bin/bash | ||
MAGE:= go run mage.go -v | ||
|
||
PORTER_HOME = $(HOME)/.porter | ||
build: | ||
$(MAGE) Build | ||
|
||
COMMIT ?= $(shell git rev-parse --short HEAD) | ||
VERSION ?= $(shell git describe --tags 2> /dev/null || echo v0) | ||
PERMALINK ?= $(shell git describe --tags --exact-match &> /dev/null && echo latest || echo canary) | ||
test: | ||
$(MAGE) Test | ||
|
||
GO = GO111MODULE=on go | ||
RECORDTEST = RECORDER_MODE=record $(GO) | ||
LDFLAGS = -w -X $(PKG)/pkg.Version=$(VERSION) -X $(PKG)/pkg.Commit=$(COMMIT) | ||
XBUILD = CGO_ENABLED=0 $(GO) build -a -tags netgo -ldflags '$(LDFLAGS)' | ||
BINDIR = bin/plugins/$(PLUGIN) | ||
KUBERNETES_CONTEXT = kind-porter | ||
TEST_NAMESPACE=porter-plugin-test-ns | ||
test-unit: | ||
$(MAGE) TestUnit | ||
|
||
CLIENT_PLATFORM ?= $(shell go env GOOS) | ||
CLIENT_ARCH ?= $(shell go env GOARCH) | ||
SUPPORTED_PLATFORMS = linux darwin windows | ||
SUPPORTED_ARCHES = amd64 | ||
TESTS = secret storage both | ||
TIMEOUT = 240s | ||
test-integration: | ||
$(MAGE) TestIntegration | ||
|
||
ifeq ($(CLIENT_PLATFORM),windows) | ||
FILE_EXT=.exe | ||
else | ||
FILE_EXT= | ||
endif | ||
|
||
debug: clean build-for-debug bin/porter$(FILE_EXT) | ||
|
||
debug-in-vscode: clean build-for-debug install | ||
|
||
build-for-debug: | ||
mkdir -p $(BINDIR) | ||
$(GO) build -o $(BINDIR)/$(PLUGIN)$(FILE_EXT) ./cmd/$(PLUGIN) | ||
|
||
.PHONY: build | ||
build: clean | ||
mkdir -p $(BINDIR) | ||
$(GO) build -ldflags '$(LDFLAGS)' -o $(BINDIR)/$(PLUGIN)$(FILE_EXT) ./cmd/$(PLUGIN) | ||
|
||
xbuild-all: | ||
$(foreach OS, $(SUPPORTED_PLATFORMS), \ | ||
$(foreach ARCH, $(SUPPORTED_ARCHES), \ | ||
$(MAKE) $(MAKE_OPTS) CLIENT_PLATFORM=$(OS) CLIENT_ARCH=$(ARCH) PLUGIN=$(PLUGIN) xbuild; \ | ||
)) | ||
|
||
xbuild: $(BINDIR)/$(VERSION)/$(PLUGIN)-$(CLIENT_PLATFORM)-$(CLIENT_ARCH)$(FILE_EXT) | ||
$(BINDIR)/$(VERSION)/$(PLUGIN)-$(CLIENT_PLATFORM)-$(CLIENT_ARCH)$(FILE_EXT): | ||
mkdir -p $(dir $@) | ||
GOOS=$(CLIENT_PLATFORM) GOARCH=$(CLIENT_ARCH) $(XBUILD) -o $@ ./cmd/$(PLUGIN) | ||
|
||
test: test-unit test-integration test-in-kubernetes | ||
$(BINDIR)/$(PLUGIN)$(FILE_EXT) version | ||
|
||
test-unit: build | ||
$(GO) test ./...; | ||
test-integration: export CURRENT_CONTEXT=$(shell kubectl config current-context) | ||
test-integration: export PORTER_HOME=$(shell echo $${PWD}/bin) | ||
test-integration: build bin/porter$(FILE_EXT) setup-tests clean-last-testrun | ||
kubectl config use-context $(KUBERNETES_CONTEXT) | ||
kubectl create namespace $(TEST_NAMESPACE) --dry-run=client -o yaml | kubectl apply -f - | ||
kubectl create secret generic password --from-literal=credential=test --namespace $(TEST_NAMESPACE) --dry-run=client -o yaml | kubectl apply -f - | ||
$(foreach TEST,$(TESTS), \ | ||
cp ./tests/integration/scripts/config-$(TEST)-ns.toml $$PORTER_HOME/config.toml; \ | ||
cp ./tests/testdata/kubernetes-plugin-test-$(TEST).json $$PORTER_HOME/credentials/kubernetes-plugin-test.json; \ | ||
if [[ $(TEST) == "storage" ]]; then kubectl apply -f ./tests/testdata/credentials-storage.yaml -n $(TEST_NAMESPACE); fi; \ | ||
if [[ $(TEST) == "both" ]]; then kubectl apply -f ./tests/testdata/credentials-secret.yaml -n $(TEST_NAMESPACE); fi; \ | ||
./bin/porter storage migrate; \ | ||
cd tests/testdata && ../../bin/porter install --cred kubernetes-plugin-test && cd ../..; \ | ||
if [[ $$(./bin/porter installations outputs show test_out -i kubernetes-plugin-test) != "test" ]]; then (exit 1); fi; \ | ||
./bin/porter installations show kubernetes-plugin-test; \ | ||
) | ||
$(GO) test -tags=integration ./tests/integration/...; | ||
kubectl delete namespace $(TEST_NAMESPACE) | ||
if [[ $$CURRENT_CONTEXT ]]; then \ | ||
kubectl config use-context $$CURRENT_CONTEXT; \ | ||
fi | ||
|
||
test-in-kubernetes: export CURRENT_CONTEXT=$(shell kubectl config current-context) | ||
test-in-kubernetes: export PORTER_HOME=$(shell echo $${PWD}/bin) | ||
test-in-kubernetes: build bin/porter$(FILE_EXT) setup-tests clean-last-testrun | ||
kubectl config use-context $(KUBERNETES_CONTEXT) | ||
kubectl apply -f ./tests/integration/scripts/setup.yaml | ||
kubectl wait --timeout=$(TIMEOUT) --for=condition=ready pod/docker-registry --namespace $(TEST_NAMESPACE) | ||
cd tests/testdata && ../../bin/porter publish | ||
docker build -f ./tests/integration/scripts/Dockerfile -t localhost:5000/test:latest . | ||
docker push localhost:5000/test:latest | ||
kubectl apply -f ./tests/integration/scripts/run-test-pod.yaml --namespace $(TEST_NAMESPACE) | ||
kubectl wait --timeout=$(TIMEOUT) --for=condition=ready pod/test --namespace $(TEST_NAMESPACE) | ||
cd tests/testdata && ../../bin/porter publish | ||
kubectl create secret generic password --from-literal=credential=test --namespace $(TEST_NAMESPACE) --dry-run=client -o yaml | kubectl apply -f - | ||
kubectl exec --stdin --tty test -n $(TEST_NAMESPACE) -- go test -tags=integration ./tests/integration/... | ||
kubectl exec --stdin --tty test -n $(TEST_NAMESPACE) -- tests/integration/scripts/test-with-porter.sh | ||
kubectl delete -f ./tests/integration/scripts/setup.yaml | ||
if [[ $$CURRENT_CONTEXT ]]; then \ | ||
kubectl config use-context $$CURRENT_CONTEXT; \ | ||
fi | ||
|
||
publish: bin/porter$(FILE_EXT) | ||
go run mage.go -v Publish $(PLUGIN) $(VERSION) $(PERMALINK) | ||
|
||
bin/porter$(FILE_EXT): export PORTER_HOME=$(shell echo $${PWD}/bin) | ||
bin/porter$(FILE_EXT): | ||
curl --http1.1 -lvfsSLo bin/porter$(FILE_EXT) https://cdn.porter.sh/latest/porter-$(CLIENT_PLATFORM)-$(CLIENT_ARCH)$(FILE_EXT) | ||
chmod +x bin/porter$(FILE_EXT) | ||
|
||
setup-tests: | ||
mkdir -p $$PORTER_HOME/credentials | ||
cp tests/integration/scripts/config-*.toml $$PORTER_HOME | ||
cp tests/testdata/kubernetes-plugin-test-*.json $$PORTER_HOME/credentials | ||
mkdir -p $$PORTER_HOME/runtimes | ||
cp bin/porter $$PORTER_HOME/runtimes/porter-runtime | ||
./bin/porter mixin install exec | ||
test-local-integration: | ||
$(MAGE) TestLocalIntegration | ||
|
||
install: | ||
mkdir -p $(PORTER_HOME)/plugins/$(PLUGIN) | ||
install $(BINDIR)/$(PLUGIN)$(FILE_EXT) $(PORTER_HOME)/plugins/$(PLUGIN)/$(PLUGIN)$(FILE_EXT) | ||
$(MAGE) Install | ||
|
||
clean-last-testrun: | ||
-rm -fr testdata/.cnab | ||
publish: | ||
$(MAGE) Publish | ||
|
||
clean: | ||
-rm -fr bin/ | ||
$(MAGE) Clean |
Oops, something went wrong.