diff --git a/Makefile b/Makefile index 691c3fe1..15779bfe 100644 --- a/Makefile +++ b/Makefile @@ -122,7 +122,10 @@ api-tests: gen # upstream CI_BUILD_TAG ?= lagoon-cli CORE_REPO=https://github.com/uselagoon/lagoon.git -CORE_TREEISH=main +CORE_TREEISH=make-export-refactoring + +LAGOON_CORE_IMAGE_REPO=testlagoon +LAGOON_CORE_IMAGE_TAG=main TEMP_CONFIG_FILE := temp_config.yaml @@ -133,23 +136,33 @@ generate-config: clean-config: @rm -f $(TEMP_CONFIG_FILE) -# TODO - Update with UI-PR#266 -.PHONY: test-with-api -test-with-api: +.PHONY: cli-tests-with-development-api +cli-tests-with-development-api: development-api + TOKEN=$$(docker run -e JWTSECRET=super-secret-string \ + -e JWTAUDIENCE=api.dev \ + -e JWTUSER=localadmin \ + uselagoon/tests \ + python3 /ansible/tasks/api/admin_token.py) \ + && $(MAKE) generate-config TOKEN=$$TOKEN \ + && $(MAKE) api-tests \ + && $(MAKE) clean-config \ + && $(MAKE) CI_BUILD_TAG=$(CI_BUILD_TAG) development-api-down + +.PHONY: development-api +development-api: export LAGOON_CORE=$$(mktemp -d ./lagoon-core.XXX) \ - && git clone $(CORE_REPO) "$$LAGOON_CORE" \ - && cd "$$LAGOON_CORE" \ - && git checkout $(CORE_TREEISH) \ - && TOKEN=$$(docker run -e JWTSECRET=super-secret-string \ - -e JWTAUDIENCE=api.dev \ - -e JWTUSER=localadmin \ - uselagoon/tests \ - python3 /ansible/tasks/api/admin_token.py) \ - && IMAGE_REPO=uselagoon docker compose -p $(CI_BUILD_TAG) --compatibility up -d api api-db actions-handler local-api-data-watcher-pusher keycloak keycloak-db broker api-redis logs2notifications local-minio mailhog \ - && $(MAKE) CI_BUILD_TAG=$(CI_BUILD_TAG) wait-for-keycloak \ - && cd .. \ - && $(MAKE) generate-config TOKEN=$$TOKEN \ - && $(MAKE) api-tests \ - && $(MAKE) clean-config \ - && cd "$$LAGOON_CORE" \ - && $(MAKE) CI_BUILD_TAG=$(CI_BUILD_TAG) down + && git clone $(CORE_REPO) "$$LAGOON_CORE" \ + && cd "$$LAGOON_CORE" \ + && git checkout $(CORE_TREEISH) \ + && IMAGE_REPO=$(LAGOON_CORE_IMAGE_REPO) IMAGE_REPO_TAG=$(LAGOON_CORE_IMAGE_TAG) COMPOSE_STACK_NAME=core-$(CI_BUILD_TAG) docker compose -p core-$(CI_BUILD_TAG) pull \ + && IMAGE_REPO=$(LAGOON_CORE_IMAGE_REPO) IMAGE_REPO_TAG=$(LAGOON_CORE_IMAGE_TAG) COMPOSE_STACK_NAME=core-$(CI_BUILD_TAG) $(MAKE) compose-api-logs-development + +.PHONY: development-api-down +development-api-down: + cd lagoon-core* && \ + docker-compose -p core-$(CI_BUILD_TAG) --compatibility down -v --remove-orphans + +.PHONY: down +down: + $(MAKE) development-api-down + docker-compose -p $(CI_BUILD_TAG) --compatibility down -v --remove-orphans diff --git a/cmd/deploy.go b/cmd/deploy.go index ed6126b9..c3b99d5b 100644 --- a/cmd/deploy.go +++ b/cmd/deploy.go @@ -82,7 +82,8 @@ use 'lagoon deploy latest' instead`, return err } resultData := output.Result{Result: result.DeployEnvironmentBranch} - output.RenderResult(resultData, outputOptions, cmd) + r := output.RenderResult(resultData, outputOptions) + fmt.Fprintf(cmd.OutOrStdout(), "%s", r) } return nil }, @@ -146,7 +147,8 @@ var deployPromoteCmd = &cobra.Command{ return err } resultData := output.Result{Result: result.DeployEnvironmentPromote} - output.RenderResult(resultData, outputOptions, cmd) + r := output.RenderResult(resultData, outputOptions) + fmt.Fprintf(cmd.OutOrStdout(), "%s", r) } return nil }, @@ -208,7 +210,8 @@ This environment should already exist in lagoon. It is analogous with the 'Deplo return err } resultData := output.Result{Result: result.DeployEnvironmentLatest} - output.RenderResult(resultData, outputOptions, cmd) + r := output.RenderResult(resultData, outputOptions) + fmt.Fprintf(cmd.OutOrStdout(), "%s", r) } return nil }, @@ -296,7 +299,8 @@ This pullrequest may not already exist as an environment in lagoon.`, return err } resultData := output.Result{Result: result.DeployEnvironmentPullrequest} - output.RenderResult(resultData, outputOptions, cmd) + r := output.RenderResult(resultData, outputOptions) + fmt.Fprintf(cmd.OutOrStdout(), "%s", r) } return nil }, diff --git a/cmd/project_test.go b/cmd/project_test.go index 2863fc4b..cfa46dad 100644 --- a/cmd/project_test.go +++ b/cmd/project_test.go @@ -21,7 +21,7 @@ func TestAPIProjectCommands(t *testing.T) { }{ { name: "Add Project", - cmdArgs: []string{"add", "project", "--project=test-project", "--production-environment=main", "--openshift=4", "--git-url=https://github.com/lagoon-examples/drupal10-base"}, + cmdArgs: []string{"add", "project", "--project=test-project", "--production-environment=main", "--deploytarget=4", "--git-url=https://github.com/lagoon-examples/drupal10-base"}, setupCmd: func(cmd *cobra.Command, flags pflag.FlagSet) { cmd.AddCommand(addCmd) addCmd.AddCommand(addProjectCmd) @@ -31,7 +31,7 @@ func TestAPIProjectCommands(t *testing.T) { }, { name: "Add Project to an Organization", - cmdArgs: []string{"add", "project", "--project=test-organization-project", "--organization-name=lagoon-demo-organization", "--production-environment=main", "--openshift=4", "--git-url=https://github.com/lagoon-examples/drupal10-base"}, + cmdArgs: []string{"add", "project", "--project=test-organization-project", "--organization-name=lagoon-demo-organization", "--production-environment=main", "--deploytarget=4", "--git-url=https://github.com/lagoon-examples/drupal10-base"}, setupCmd: func(cmd *cobra.Command, flags pflag.FlagSet) { cmd.AddCommand(addCmd) addCmd.AddCommand(addProjectCmd) diff --git a/local-dev/config.tpl b/local-dev/config.tpl index 0e1a6efa..8276512d 100644 --- a/local-dev/config.tpl +++ b/local-dev/config.tpl @@ -6,3 +6,4 @@ lagoons: hostname: "localhost" port: "2020" token: ${TOKEN} + version: v1.9.0