Skip to content

Commit

Permalink
Remove MARKETPLACE_TOOLS_PATH references. (#258)
Browse files Browse the repository at this point in the history
* Add latest tagging to cloudbuild-tag.yaml.

* Remove MARKETPLACE_TOOLS_PATH and simplify MARKETPLACE_TOOLS_TAG derivation.

* Tune cloudbuild.yaml.

* Revert "Add latest tagging to cloudbuild-tag.yaml."

This reverts commit 433a87a.

We will publish latest tags explicitly.
  • Loading branch information
trironkk authored Nov 5, 2018
1 parent 54abfb9 commit c9c8870
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 142 deletions.
22 changes: 1 addition & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,7 @@
include common.Makefile


### Submodule ###


.PHONY: submodule/init
submodule/init:
git submodule init
git submodule sync --recursive
git submodule update --init --recursive


.PHONY: submodule/init-force
submodule/init-force:
git submodule init
git submodule sync --recursive
git submodule update --init --recursive --force


### Images publishing ###


include marketplace.Makefile
include testing.Makefile

### Testing ###

Expand Down
34 changes: 4 additions & 30 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,60 +126,34 @@ steps:
- marketplace/deployer_helm_tiller_base/onbuild/Dockerfile
- .

- id: &GetKubectlCredentials Get Kubernetes Credentials
- id: &InitializeCredentials Initialize Credentials
name: gcr.io/cloud-builders/gcloud
waitFor:
- '-'
args:
- container
- clusters
- get-credentials
- 'limani-integ'
- --region
- 'us-central1'
- --project
- '$PROJECT_ID'

- id: &CopyKubectlCredentials Copy kubectl Credentials
name: gcr.io/google-appengine/debian9
waitFor:
- Get Kubernetes Credentials
entrypoint: bash
args:
- -exc
- |
gcloud container clusters get-credentials 'limani-integ' --region 'us-central1' --project '$PROJECT_ID'
mkdir -p /workspace/.kube/
cp -r $$HOME/.kube/ /workspace/
- id: &CopyGcloudCredentials Copy gcloud Credentials
name: gcr.io/google-appengine/debian9
waitFor:
- Get Kubernetes Credentials
entrypoint: bash
args:
- -exc
- |
mkdir -p /workspace/.config/gcloud/
cp -r $$HOME/.config/gcloud/ /workspace/.config/
- id: Verify
name: gcr.io/$PROJECT_ID/k8s/dev:sha_$COMMIT_SHA
waitFor:
- *BuildDev
- *BuildEnvsubst
- *BuildHelm
- *BuildHelmTiller
- *CopyGcloudCredentials
- *CopyKubectlCredentials
- *InitializeCredentials
env:
- 'KUBE_CONFIG=/workspace/.kube'
- 'GCLOUD_CONFIG=/workspace/.config/gcloud'
# Use local Docker network named cloudbuild as described here:
# https://cloud.google.com/cloud-build/docs/overview#build_configuration_and_build_steps
- 'EXTRA_DOCKER_PARAMS=--net cloudbuild'
- MARKETPLACE_TOOLS_TAG=testing-sha_$COMMIT_SHA
args:
- make
- --file=testing.Makefile
- -j4
- testing/all

Expand Down
25 changes: 3 additions & 22 deletions common.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,19 @@ define print_error
printf "\n\033[93m\033[1m$(1)\033[0m\n"
endef

makefile_dir := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
include $(makefile_dir)/var.Makefile
include var.Makefile


# MARKETPLACE_TOOLS_PATH is the path to the root of the
# marketplace-k8s-app-tools submodule. We derive it here by taking the
# full path of the directory containing this common.Makefile. patsubst
# operation removes the trailing slash.
MARKETPLACE_TOOLS_PATH ?= $(patsubst %/,%,$(dir $(realpath $(lastword $(MAKEFILE_LIST)))))

$(info ---- MARKETPLACE_TOOLS_PATH = $(MARKETPLACE_TOOLS_PATH))

# MARKETPLACE_TOOLS_TAG is the tag of the container images published
# by marketplace-k8s-app-tools.
MARKETPLACE_TOOLS_TAG ?= $(shell cd $(MARKETPLACE_TOOLS_PATH) && $(MARKETPLACE_TOOLS_PATH)/scripts/derive_tag.sh)
MARKETPLACE_TOOLS_TAG ?= $(shell echo local-$(USER))
export MARKETPLACE_TOOLS_TAG

$(info ---- MARKETPLACE_TOOLS_TAG = $(MARKETPLACE_TOOLS_TAG))


.build: | tools_path_exists
.build:
mkdir -p "$@"


.build/tmp: | .build
mkdir -p "$@"

Expand All @@ -46,12 +35,4 @@ $(info ---- MARKETPLACE_TOOLS_TAG = $(MARKETPLACE_TOOLS_TAG))
clean::
rm -Rf .build


.PHONY: tools_path_exists
tools_path_exists:
ifeq ($(shell test -d "$(MARKETPLACE_TOOLS_PATH)" && echo "OK"),)
$(error '$(MARKETPLACE_TOOLS_PATH)' directory does not exist. Must set proper path for marketplace tools)
endif


endif
8 changes: 3 additions & 5 deletions crd.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@ ifndef __CRD_MAKEFILE__

__CRD_MAKEFILE__ := included


makefile_dir := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
include $(makefile_dir)/common.Makefile
include common.Makefile

# Installs the application CRD on the cluster.
.PHONY: crd/install
crd/install:
kubectl apply -f "$(MARKETPLACE_TOOLS_PATH)/crd/app-crd.yaml"
kubectl apply -f "crd/app-crd.yaml"

# Uninstalls the application CRD from the cluster.
.PHONY: crd/uninstall
crd/uninstall:
kubectl delete -f "$(MARKETPLACE_TOOLS_PATH)/crd/app-crd.yaml"
kubectl delete -f "crd/app-crd.yaml"


endif
40 changes: 17 additions & 23 deletions marketplace.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,21 @@ __MARKETPLACE_MAKEFILE__ := included

COMMIT ?= $(shell git rev-parse HEAD | fold -w 12 | head -n 1)

makefile_dir := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
include $(makefile_dir)/common.Makefile
include $(makefile_dir)/var.Makefile
include common.Makefile
include var.Makefile


.build/marketplace: | .build
mkdir -p "$@"


.build/marketplace/dev: $(MARKETPLACE_TOOLS_PATH)/marketplace/deployer_util/* \
$(MARKETPLACE_TOOLS_PATH)/marketplace/dev/* \
$(MARKETPLACE_TOOLS_PATH)/scripts/* \
$(MARKETPLACE_TOOLS_PATH)/marketplace.Makefile \
.build/marketplace/dev: marketplace/deployer_util/* \
marketplace/dev/* \
scripts/* \
marketplace.Makefile \
.build/var/MARKETPLACE_TOOLS_TAG \
| .build/marketplace
$(call print_target)
cd "$(MARKETPLACE_TOOLS_PATH)" ; \
docker build \
--tag "gcr.io/cloud-marketplace-tools/k8s/dev:$(MARKETPLACE_TOOLS_TAG)" \
-f marketplace/dev/Dockerfile \
Expand All @@ -32,29 +30,27 @@ include $(makefile_dir)/var.Makefile
mkdir -p "$@"


.build/marketplace/deployer/envsubst: $(MARKETPLACE_TOOLS_PATH)/marketplace/deployer_util/* \
$(MARKETPLACE_TOOLS_PATH)/marketplace/deployer_envsubst_base/* \
.build/marketplace/deployer/envsubst: marketplace/deployer_util/* \
marketplace/deployer_envsubst_base/* \
.build/marketplace/delete_deprecated \
.build/var/MARKETPLACE_TOOLS_TAG \
| .build/marketplace/deployer
$(call print_target)
cd "$(MARKETPLACE_TOOLS_PATH)"; \
docker build \
--tag "gcr.io/cloud-marketplace-tools/k8s/deployer_envsubst:$(MARKETPLACE_TOOLS_TAG)" \
-f marketplace/deployer_envsubst_base/Dockerfile \
.
@touch "$@"


.build/marketplace/deployer/helm: $(MARKETPLACE_TOOLS_PATH)/marketplace/deployer_util/* \
$(MARKETPLACE_TOOLS_PATH)/marketplace/deployer_helm_base/* \
.build/marketplace/deployer/helm: marketplace/deployer_util/* \
marketplace/deployer_helm_base/* \
.build/marketplace/delete_deprecated \
.build/var/COMMIT \
.build/var/MARKETPLACE_TOOLS_TAG \
| .build/marketplace/deployer
$(call print_target)
cd $(MARKETPLACE_TOOLS_PATH) \
&& docker build \
docker build \
--build-arg VERSION="$(COMMIT)" \
--tag "gcr.io/cloud-marketplace-tools/k8s/deployer_helm:$(MARKETPLACE_TOOLS_TAG)" \
-f marketplace/deployer_helm_base/Dockerfile \
Expand All @@ -64,12 +60,11 @@ include $(makefile_dir)/var.Makefile

.build/marketplace/deployer/helm_tiller: \
.build/var/MARKETPLACE_TOOLS_TAG \
$(MARKETPLACE_TOOLS_PATH)/marketplace/deployer_helm_tiller_base/* \
$(MARKETPLACE_TOOLS_PATH)/marketplace/deployer_util/* \
marketplace/deployer_helm_tiller_base/* \
marketplace/deployer_util/* \
| .build/marketplace/deployer
$(call print_target)
cd $(MARKETPLACE_TOOLS_PATH) \
&& docker build \
docker build \
--tag "gcr.io/cloud-marketplace-tools/k8s/deployer_helm_tiller:$(MARKETPLACE_TOOLS_TAG)" \
-f marketplace/deployer_helm_tiller_base/Dockerfile \
.
Expand All @@ -79,12 +74,11 @@ include $(makefile_dir)/var.Makefile
.build/marketplace/deployer/helm_tiller_onbuild: \
.build/marketplace/deployer/helm_tiller \
.build/var/MARKETPLACE_TOOLS_TAG \
$(MARKETPLACE_TOOLS_PATH)/marketplace/deployer_helm_tiller_base/onbuild/* \
$(MARKETPLACE_TOOLS_PATH)/marketplace/deployer_util/* \
marketplace/deployer_helm_tiller_base/onbuild/* \
marketplace/deployer_util/* \
| .build/marketplace/deployer
$(call print_target)
cd $(MARKETPLACE_TOOLS_PATH) \
&& docker build \
docker build \
--build-arg FROM="gcr.io/cloud-marketplace-tools/k8s/deployer_helm_tiller:$(MARKETPLACE_TOOLS_TAG)" \
--tag "gcr.io/cloud-marketplace-tools/k8s/deployer_helm_tiller/onbuild:$(MARKETPLACE_TOOLS_TAG)" \
-f marketplace/deployer_helm_tiller_base/onbuild/Dockerfile \
Expand Down
30 changes: 0 additions & 30 deletions scripts/derive_tag.sh

This file was deleted.

7 changes: 4 additions & 3 deletions testing.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ ifndef __TESTING_MAKEFILE__

__TESTING_MAKEFILE__ := included

include common.Makefile

# TODO: Move testing targets in top-level Makefile to here and include
# this file in top-level Makefile.

include common.Makefile
include gcloud.Makefile
include marketplace.Makefile

TEST_ID := $(shell cat /dev/urandom | tr -dc 'a-z0-9' | head -c 8)

.testing/marketplace/deployer/helm_tiller_onbuild:
mkdir -p $@
mkdir -p "$@"

.testing/marketplace/deployer/helm_tiller_onbuild/helm-dependency-build: \
.build/marketplace/deployer/helm_tiller_onbuild \
Expand Down Expand Up @@ -53,7 +54,7 @@ testing/marketplace/deployer/helm_tiller_onbuild: \


.testing/marketplace/deployer/envsubst:
mkdir -p $@
mkdir -p "$@"

.testing/marketplace/deployer/envsubst/standard: \
.build/marketplace/deployer/envsubst \
Expand Down
11 changes: 4 additions & 7 deletions testrunner.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@ ifndef __TESTRUNNER_MAKEFILE__

__TESTRUNNER_MAKEFILE__ := included


makefile_dir := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
include $(makefile_dir)/common.Makefile

include common.Makefile

.build/testrunner: | .build/tmp
$(call print_target)
cd $(MARKETPLACE_TOOLS_PATH)/testrunner \
cd testrunner \
&& bazel build //runner:main
rm -rf .build/tmp/testrunner
mkdir -p .build/tmp/testrunner
cp $(MARKETPLACE_TOOLS_PATH)/testrunner/bazel-bin/runner/main .build/tmp/testrunner/testrunner
docker build --tag=testrunner --file=$(MARKETPLACE_TOOLS_PATH)/testrunner/runner/Dockerfile .build/tmp/testrunner
cp testrunner/bazel-bin/runner/main .build/tmp/testrunner/testrunner
docker build --tag=testrunner --file=testrunner/runner/Dockerfile .build/tmp/testrunner
@touch "$@"

endif
2 changes: 1 addition & 1 deletion var.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ __VAR_MAKEFILE__ := included


.build/var:
mkdir -p .build/var
mkdir -p "$@"


# Since we can't make pattern targets phony, we make them
Expand Down

0 comments on commit c9c8870

Please sign in to comment.