From 81bc025b2e1b25ff85b6d4fddf8d3d59d6bbd75d Mon Sep 17 00:00:00 2001 From: HappyTobi Date: Sat, 28 Mar 2020 23:18:50 +0100 Subject: [PATCH 01/18] [UPDATE] version --- puppeteer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/puppeteer.go b/puppeteer.go index 9ec4daf..b78fcc7 100644 --- a/puppeteer.go +++ b/puppeteer.go @@ -217,7 +217,7 @@ func (CfPuppeteerPlugin) GetMetadata() plugin.PluginMetadata { Version: plugin.VersionType{ Major: 1, Minor: 2, - Build: 0, + Build: 1, }, Commands: []plugin.Command{ { From 3ea20aabc7f0d09e0cd5ad46b4a2ca32ab3b75ad Mon Sep 17 00:00:00 2001 From: HappyTobi Date: Sat, 28 Mar 2020 23:19:05 +0100 Subject: [PATCH 02/18] [UPDATE] routes logic --- cf/v2/domain.go | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/cf/v2/domain.go b/cf/v2/domain.go index b70b8ef..52f77bf 100644 --- a/cf/v2/domain.go +++ b/cf/v2/domain.go @@ -42,24 +42,25 @@ func (resource *LegacyResourcesData) GetDomain(domains []map[string]string) (*[] } domainGUID := make(map[string]Routes) + for _, domainRes := range response.Resources { for _, routes := range domains { - domain := routes["route"] - hostName := strings.ReplaceAll(domain, domainRes.Entity.Name, "") - - _, exists := domainGUID[domain] - if exists { - exists = len(domainGUID[domain].Host) < len(hostName) - } + for _, domain := range routes { + hostName := strings.ReplaceAll(domain, domainRes.Entity.Name, "") + _, exists := domainGUID[domain] + if exists { + exists = len(domainGUID[domain].Host) < len(hostName) + } - //question ist when route matches 2 time what kind of your we are using? - if strings.Contains(domain, domainRes.Entity.Name) && len(hostName) > 0 && !exists { - hostName = strings.TrimRight(hostName, ".") - newRoute := &Routes{ - Host: hostName, - Domain: domainRes.Entity.Name, + //question ist when route matches 2 time what kind of your we are using? + if strings.Contains(domain, domainRes.Entity.Name) && len(hostName) > 0 && !exists { + hostName = strings.TrimRight(hostName, ".") + newRoute := &Routes{ + Host: hostName, + Domain: domainRes.Entity.Name, + } + domainGUID[domain] = *newRoute } - domainGUID[domain] = *newRoute } } } @@ -74,9 +75,14 @@ func (resource *LegacyResourcesData) GetDomain(domains []map[string]string) (*[] for _, domainRes := range response.Resources { for _, routes := range domains { for _, domain := range routes { + hostName := strings.ReplaceAll(domain, domainRes.Entity.Name, "") _, exists := domainGUID[domain] - if strings.Contains(domain, domainRes.Entity.Name) && !exists { - hostName := strings.ReplaceAll(domain, domainRes.Entity.Name, "") + if exists { + exists = len(domainGUID[domain].Host) < len(hostName) + } + + //question ist when route matches 2 time what kind of your we are using? + if strings.Contains(domain, domainRes.Entity.Name) && len(hostName) > 0 && !exists { hostName = strings.TrimRight(hostName, ".") newRoute := &Routes{ Host: hostName, From 9a3812862066d96f5a7f4806a20afb740ede632a Mon Sep 17 00:00:00 2001 From: HappyTobi Date: Sat, 28 Mar 2020 23:21:06 +0100 Subject: [PATCH 03/18] [UPDATE] versions in readme and changelog --- CHANGELOG.md | 5 +++++ README.md | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cae859..f0ad4b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - check space quota before deployment (if user pass the option) - set timeout how long the deployment will wait for more / free space +## [1.2.1] - 2020-03-28 + +### Fixed +- route logic when using legacy push + ## [1.2.0] - 2020-02-24 ### Added diff --git a/README.md b/README.md index a4f17f4..ed19522 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ To get an overview of the changes between versions, read the [changelog](CHANGEL ## Version -The latest version of *CF-Puppeteer* is *1.2.0*. It works with and is based on Cloud Foundry CLI version 6.43.0. +The latest version of *CF-Puppeteer* is *1.2.1*. It works with and is based on Cloud Foundry CLI version 6.43.0. For more details on the most recent release, check out the [changelog](CHANGELOG.md). From 83a0816c1366e6bd5cbd11552d07943fb5a0f77c Mon Sep 17 00:00:00 2001 From: HappyTobi Date: Tue, 31 Mar 2020 14:36:45 +0200 Subject: [PATCH 04/18] [NEW] add manifes for vars file test --- test/integration/application/manifest-vars.yml | 15 +++++++++++++++ test/integration/application/vars.yml | 3 +++ 2 files changed, 18 insertions(+) create mode 100644 test/integration/application/manifest-vars.yml create mode 100644 test/integration/application/vars.yml diff --git a/test/integration/application/manifest-vars.yml b/test/integration/application/manifest-vars.yml new file mode 100644 index 0000000..06fea17 --- /dev/null +++ b/test/integration/application/manifest-vars.yml @@ -0,0 +1,15 @@ +--- +applications: + - name: ((appname)) + memory: ((memory)) + buildpacks: + - nginx_buildpack + instances: 1 + health-check-type: http + health-check-http-endpoint: /health + routes: + - route: ((route)).apps.internal + - route: ((route)).eu-gb.mybluemix.net + - route: ((route)).apic.eu-gb.mybluemix.net + env: + GITHUB: https://github.com/HappyTobi/cf-puppeteer \ No newline at end of file diff --git a/test/integration/application/vars.yml b/test/integration/application/vars.yml new file mode 100644 index 0000000..a301dfd --- /dev/null +++ b/test/integration/application/vars.yml @@ -0,0 +1,3 @@ +appname: puppeteer_var +memory: 64mb +route: puppeteer \ No newline at end of file From e1980e10283ab4f64d8b67a7b995587a613948ea Mon Sep 17 00:00:00 2001 From: HappyTobi Date: Tue, 31 Mar 2020 14:40:13 +0200 Subject: [PATCH 05/18] [NEW] test for vars file deployment --- .github/workflows/main.yml | 46 ++++++++++++++++++++++++++- test/integration/application/vars.yml | 2 +- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1259d3c..0f43896 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -75,9 +75,53 @@ jobs: cf delete-route -f apic.eu-gb.mybluemix.net --hostname puppeteer cf delete-route -f eu-gb.mybluemix.net --hostname puppeteer + int_var_test_job: + name: Run integration tests + runs-on: ubuntu-latest + needs: [unit_test_job] + steps: + - name: Add CF Cli to apt-get + run: | + wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add - + echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list + - name: Install CF CLI + run: | + sudo apt-get update + sudo apt-get install cf-cli + - name: Checkout + uses: actions/checkout@v2 + - name: Compile plugin + run: | + mkdir -p ./artifacts + CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -o ./artifacts/cf-puppeteer + - name: Install Puppeteer plugin + run: | + cf install-plugin -f ./artifacts/cf-puppeteer + cf plugins + - name: CF Login + run: | + cf login -a ${{ secrets.API_BM }} -u ${{secrets.USER_NAME_BM}} -p ${{secrets.PASSWORD_BM}} -o ${{secrets.ORG_BM}} -s dev + - name: Deploy test application without routes + run: | + cf zero-downtime-push -f test/integration/application/manifest-vars.yml -p test/integration/application/ --vars-file test/integration/application/vars.yml + - name: Check deployment 1 + run: | + status_code=$(curl --write-out %{http_code} --silent --output /dev/null puppeteer2.eu-gb.mybluemix.net) + if [[ "$status_code" -ne 200 ]] ; then + exit 1 + else + exit 0 + fi + - name: Delete application + run: | + cf delete -f puppeteer + cf delete-route -f apps.internal --hostname puppeteer2 + cf delete-route -f apic.eu-gb.mybluemix.net --hostname puppeteer2 + cf delete-route -f eu-gb.mybluemix.net --hostname puppeteer2 + release_job: name: Build binary - needs: [unit_test_job, int_test_job] + needs: [unit_test_job, int_test_job, int_var_test_job] runs-on: ubuntu-latest #if: github.ref == 'refs/heads/develop' steps: diff --git a/test/integration/application/vars.yml b/test/integration/application/vars.yml index a301dfd..cbff608 100644 --- a/test/integration/application/vars.yml +++ b/test/integration/application/vars.yml @@ -1,3 +1,3 @@ appname: puppeteer_var memory: 64mb -route: puppeteer \ No newline at end of file +route: puppeteer2 \ No newline at end of file From b6e202d8cfd82d7ebb0948b1ff8505f029fefeb1 Mon Sep 17 00:00:00 2001 From: HappyTobi Date: Tue, 31 Mar 2020 14:41:55 +0200 Subject: [PATCH 06/18] [UPDATE] fix yml error --- .github/workflows/main.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0f43896..4ede75e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -106,12 +106,12 @@ jobs: cf zero-downtime-push -f test/integration/application/manifest-vars.yml -p test/integration/application/ --vars-file test/integration/application/vars.yml - name: Check deployment 1 run: | - status_code=$(curl --write-out %{http_code} --silent --output /dev/null puppeteer2.eu-gb.mybluemix.net) - if [[ "$status_code" -ne 200 ]] ; then - exit 1 - else - exit 0 - fi + status_code=$(curl --write-out %{http_code} --silent --output /dev/null puppeteer2.eu-gb.mybluemix.net) + if [[ "$status_code" -ne 200 ]] ; then + exit 1 + else + exit 0 + fi - name: Delete application run: | cf delete -f puppeteer From 2de99a3c508a870bd632fbe9647225a301294ee0 Mon Sep 17 00:00:00 2001 From: HappyTobi Date: Tue, 31 Mar 2020 14:54:20 +0200 Subject: [PATCH 07/18] [UPDATE] add more tests --- .github/workflows/main.yml | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4ede75e..ca98138 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -76,9 +76,9 @@ jobs: cf delete-route -f eu-gb.mybluemix.net --hostname puppeteer int_var_test_job: - name: Run integration tests + name: Run integration with vars file runs-on: ubuntu-latest - needs: [unit_test_job] + needs: [unit_test_job, int_test_job] steps: - name: Add CF Cli to apt-get run: | @@ -101,10 +101,30 @@ jobs: - name: CF Login run: | cf login -a ${{ secrets.API_BM }} -u ${{secrets.USER_NAME_BM}} -p ${{secrets.PASSWORD_BM}} -o ${{secrets.ORG_BM}} -s dev - - name: Deploy test application without routes + - name: Deploy test application with vars file run: | cf zero-downtime-push -f test/integration/application/manifest-vars.yml -p test/integration/application/ --vars-file test/integration/application/vars.yml - - name: Check deployment 1 + - name: Check deployment with vars file (route) + run: | + status_code=$(curl --write-out %{http_code} --silent --output /dev/null puppeteer2.eu-gb.mybluemix.net) + if [[ "$status_code" -ne 200 ]] ; then + exit 1 + else + exit 0 + fi + - name: Show application + run: | + cf app puppeteer2 + - name: Delete application + run: | + cf delete -f puppeteer + cf delete-route -f apps.internal --hostname puppeteer2 + cf delete-route -f apic.eu-gb.mybluemix.net --hostname puppeteer2 + cf delete-route -f eu-gb.mybluemix.net --hostname puppeteer2 + - name: Deploy test application with vars file (legacy-push) + run: | + cf zero-downtime-push -f test/integration/application/manifest-vars.yml -p test/integration/application/ --vars-file test/integration/application/vars.yml --legacy-push + - name: Check legacy deployment with vars file (route) run: | status_code=$(curl --write-out %{http_code} --silent --output /dev/null puppeteer2.eu-gb.mybluemix.net) if [[ "$status_code" -ne 200 ]] ; then @@ -112,6 +132,9 @@ jobs: else exit 0 fi + - name: Show application + run: | + cf app puppeteer2 - name: Delete application run: | cf delete -f puppeteer From 71d964135a907d11a88245d517cae526cf2cef84 Mon Sep 17 00:00:00 2001 From: HappyTobi Date: Tue, 31 Mar 2020 14:54:57 +0200 Subject: [PATCH 08/18] [UPDATE] rename test --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ca98138..c87082e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -76,7 +76,7 @@ jobs: cf delete-route -f eu-gb.mybluemix.net --hostname puppeteer int_var_test_job: - name: Run integration with vars file + name: Run integration tests with vars file runs-on: ubuntu-latest needs: [unit_test_job, int_test_job] steps: From 43911bb29238b4f4e905b88c1f3e5a2b9acf0d2f Mon Sep 17 00:00:00 2001 From: HappyTobi Date: Tue, 31 Mar 2020 16:47:19 +0200 Subject: [PATCH 09/18] [UPDATE] change appname --- test/integration/application/vars.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/application/vars.yml b/test/integration/application/vars.yml index cbff608..1c70633 100644 --- a/test/integration/application/vars.yml +++ b/test/integration/application/vars.yml @@ -1,3 +1,3 @@ -appname: puppeteer_var +appname: puppeteer2 memory: 64mb route: puppeteer2 \ No newline at end of file From 46bfdfd11a0c0d00f5184c2704e9601f97904c07 Mon Sep 17 00:00:00 2001 From: HappyTobi Date: Tue, 31 Mar 2020 22:25:28 +0200 Subject: [PATCH 10/18] [UPDATE] add more output to test run --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c87082e..58e3944 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -107,6 +107,7 @@ jobs: - name: Check deployment with vars file (route) run: | status_code=$(curl --write-out %{http_code} --silent --output /dev/null puppeteer2.eu-gb.mybluemix.net) + echo "Curl response status code: $status_code" if [[ "$status_code" -ne 200 ]] ; then exit 1 else @@ -114,6 +115,7 @@ jobs: fi - name: Show application run: | + cf apps cf app puppeteer2 - name: Delete application run: | From 1d2ae254669b1668a3c746fdbc43faaa863d5374 Mon Sep 17 00:00:00 2001 From: HappyTobi Date: Tue, 31 Mar 2020 23:00:03 +0200 Subject: [PATCH 11/18] [FIX] add vars file to legacy push #22 --- cf/v2/push_application.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cf/v2/push_application.go b/cf/v2/push_application.go index 4b715ec..36ad878 100644 --- a/cf/v2/push_application.go +++ b/cf/v2/push_application.go @@ -1,13 +1,14 @@ package v2 import ( - "code.cloudfoundry.org/cli/plugin" "fmt" + "strconv" + + "code.cloudfoundry.org/cli/plugin" "github.com/happytobi/cf-puppeteer/arguments" "github.com/happytobi/cf-puppeteer/cf/cli" "github.com/happytobi/cf-puppeteer/ui" "github.com/pkg/errors" - "strconv" ) //Push interface with all v3 actions @@ -51,6 +52,10 @@ func (resource *LegacyResourcesData) PushApplication(parsedArguments *arguments. args = append(args, "--no-start") } + if parsedArguments.VarsFile != "" { + args = append(args, "--vars-file", parsedArguments.VarsFile) + } + ui.Say("start pushing application with arguments %s", args) err := resource.Executor.Execute(args) if err != nil { From 3e6df90ca18627a546362a62ba2c475ce3216347 Mon Sep 17 00:00:00 2001 From: HappyTobi Date: Wed, 22 Apr 2020 23:07:23 +0200 Subject: [PATCH 12/18] [UPDATE] debug messages, run trace --- .github/workflows/main.yml | 2 +- cf/v2/domain.go | 8 ++++++-- cf/v3/domain_test.go | 15 +++++++++------ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 58e3944..641b4e6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -52,7 +52,7 @@ jobs: cf login -a ${{ secrets.API_BM }} -u ${{secrets.USER_NAME_BM}} -p ${{secrets.PASSWORD_BM}} -o ${{secrets.ORG_BM}} -s dev - name: Deploy test application without routes run: | - cf zero-downtime-push -f test/integration/application/manifest.yml -p test/integration/application/ --no-route --no-start --env foo=bar --venerable-action stop + CF_TRACE=/dev/stdout cf zero-downtime-push -f test/integration/application/manifest.yml -p test/integration/application/ --no-route --no-start --env foo=bar --venerable-action stop - name: Check deployment 1 run: | echo "Add api tests to check the deployed settings" diff --git a/cf/v2/domain.go b/cf/v2/domain.go index 52f77bf..e854d37 100644 --- a/cf/v2/domain.go +++ b/cf/v2/domain.go @@ -5,6 +5,8 @@ import ( "fmt" "sort" "strings" + + "github.com/happytobi/cf-puppeteer/ui" ) type Routes struct { @@ -34,13 +36,13 @@ type DomainResponse struct { func (resource *LegacyResourcesData) GetDomain(domains []map[string]string) (*[]Routes, error) { //default order asc. + ui.DebugMessage("GetDomain called, try to find matching domains for all routes %v", domains) path := fmt.Sprintf(`/v2/domains`) - response, err := resource.getDomain(path) if err != nil { return nil, err } - + ui.DebugMessage("/v2/domain response was %v", path) domainGUID := make(map[string]Routes) for _, domainRes := range response.Resources { @@ -59,6 +61,7 @@ func (resource *LegacyResourcesData) GetDomain(domains []map[string]string) (*[] Host: hostName, Domain: domainRes.Entity.Name, } + ui.DebugMessage("add new route for later mapping %v", newRoute) domainGUID[domain] = *newRoute } } @@ -88,6 +91,7 @@ func (resource *LegacyResourcesData) GetDomain(domains []map[string]string) (*[] Host: hostName, Domain: domainRes.Entity.Name, } + ui.DebugMessage("add new route for later mapping (paged) %v", newRoute) domainGUID[domain] = *newRoute } } diff --git a/cf/v3/domain_test.go b/cf/v3/domain_test.go index c9973ef..e58b328 100644 --- a/cf/v3/domain_test.go +++ b/cf/v3/domain_test.go @@ -1,10 +1,11 @@ package v3_test import ( + "testing" + "code.cloudfoundry.org/cli/plugin/pluginfakes" "github.com/happytobi/cf-puppeteer/cf/cli" v3 "github.com/happytobi/cf-puppeteer/cf/v3" - "testing" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -103,13 +104,15 @@ var _ = Describe("cf-domain test", func() { Expect(cliConn.CliCommandWithoutTerminalOutputCallCount()).To(Equal(1)) - Expect((*domainResponse)[0].Host).To(Equal("foo")) - Expect((*domainResponse)[0].Domain).To(Equal("example.com")) + checkMap := make(map[string]string, len(*domainResponse)) + for _, value := range *domainResponse { + checkMap[value.Host] = value.Domain + } - Expect((*domainResponse)[1].Host).To(Equal("url")) - Expect((*domainResponse)[1].Domain).To(Equal("test-domain.com")) + Expect(checkMap["foo"]).To(Equal("example.com")) + Expect(checkMap["url"]).To(Equal("test-domain.com")) Expect(err).ToNot(HaveOccurred()) }) }) -}) \ No newline at end of file +}) From 4f1c7bfd3c2510a6b4b411c19772ae32206dc9c9 Mon Sep 17 00:00:00 2001 From: HappyTobi Date: Thu, 23 Apr 2020 08:51:27 +0200 Subject: [PATCH 13/18] [UPDATE] drop trace while test --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 641b4e6..58e3944 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -52,7 +52,7 @@ jobs: cf login -a ${{ secrets.API_BM }} -u ${{secrets.USER_NAME_BM}} -p ${{secrets.PASSWORD_BM}} -o ${{secrets.ORG_BM}} -s dev - name: Deploy test application without routes run: | - CF_TRACE=/dev/stdout cf zero-downtime-push -f test/integration/application/manifest.yml -p test/integration/application/ --no-route --no-start --env foo=bar --venerable-action stop + cf zero-downtime-push -f test/integration/application/manifest.yml -p test/integration/application/ --no-route --no-start --env foo=bar --venerable-action stop - name: Check deployment 1 run: | echo "Add api tests to check the deployed settings" From e1500b8dc5f28d17fd3dd3b4d432bcbbe7add68d Mon Sep 17 00:00:00 2001 From: HappyTobi Date: Mon, 27 Apr 2020 22:33:32 +0200 Subject: [PATCH 14/18] [FIX] routes without hostname --- cf/v2/domain.go | 4 ++-- cf/v2/domain_test.go | 53 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/cf/v2/domain.go b/cf/v2/domain.go index e854d37..cd7cf0b 100644 --- a/cf/v2/domain.go +++ b/cf/v2/domain.go @@ -55,7 +55,7 @@ func (resource *LegacyResourcesData) GetDomain(domains []map[string]string) (*[] } //question ist when route matches 2 time what kind of your we are using? - if strings.Contains(domain, domainRes.Entity.Name) && len(hostName) > 0 && !exists { + if strings.Contains(domain, domainRes.Entity.Name) && !exists { hostName = strings.TrimRight(hostName, ".") newRoute := &Routes{ Host: hostName, @@ -85,7 +85,7 @@ func (resource *LegacyResourcesData) GetDomain(domains []map[string]string) (*[] } //question ist when route matches 2 time what kind of your we are using? - if strings.Contains(domain, domainRes.Entity.Name) && len(hostName) > 0 && !exists { + if strings.Contains(domain, domainRes.Entity.Name) && !exists { hostName = strings.TrimRight(hostName, ".") newRoute := &Routes{ Host: hostName, diff --git a/cf/v2/domain_test.go b/cf/v2/domain_test.go index 2d733d1..e468217 100644 --- a/cf/v2/domain_test.go +++ b/cf/v2/domain_test.go @@ -98,17 +98,64 @@ var _ = Describe("cf-domain test", func() { Expect(cliConn.CliCommandWithoutTerminalOutputCallCount()).To(Equal(1)) - checkMap := make(map[string]string,len(*domainResponse)) - for _, value := range (*domainResponse) { + checkMap := make(map[string]string, len(*domainResponse)) + for _, value := range *domainResponse { checkMap[value.Host] = value.Domain } - Expect(checkMap["foo"]).To(Equal("example.com")) Expect(checkMap["my"]).To(Equal("foo.example.com")) Expect(checkMap["puppeteer"]).To(Equal("internal.emea.github.com")) Expect(checkMap["url"]).To(Equal("test-domain.com")) + Expect(err).ToNot(HaveOccurred()) + }) + + It("use v2 domain api with multiple subdomains ", func() { + response := []string{`{ + "total_results": 18, + "total_pages": 2, + "prev_url": null, + "next_url": "https://api.example.org/v2/domains?page=1&per_page=2", + "resources": [ + { + "metadata": { + "guid": "aa23b15e-dc54-437e-a651-a29415b66d9m", + "url": "/v2/shared_domains/aa23b15e-dc54-437e-a651-a29415b66d9m", + "created_at": "2016-10-20T07:40:24Z", + "updated_at": "2018-02-09T06:19:46Z" + }, + "entity": { + "name": "staging.product.com", + "internal": false, + "router_group_guid": null, + "router_group_type": null + } + }, + { + "metadata": { + "guid": "aa23b15e-dc54-437e-a651-5673241243", + "url": "/v2/shared_domains/aa23b15e-dc54-437e-a651-5673241243", + "created_at": "2016-10-20T07:40:24Z", + "updated_at": "2018-02-09T06:19:46Z" + }, + "entity": { + "name": "cfapp.io", + "internal": false, + "router_group_guid": null, + "router_group_type": null + } + } + ]} + `} + + cliConn.CliCommandWithoutTerminalOutputReturns(response, nil) + + var routes = []map[string]string{0: {"route": " staging-p.cfapp.io"}, 1: {"route": "staging-product.cfapp.io"}, 2: {"route": "staging.product.com"}} + domainResponse, err := resourcesData.GetDomain(routes) + + Expect(cliConn.CliCommandWithoutTerminalOutputCallCount()).To(Equal(1)) + Expect(3).To(Equal(len(*domainResponse))) Expect(err).ToNot(HaveOccurred()) }) From 9b026866fc4ddcc891889e2b38ac1d071d4c2318 Mon Sep 17 00:00:00 2001 From: HappyTobi Date: Mon, 27 Apr 2020 22:40:18 +0200 Subject: [PATCH 15/18] [FIX] test for domain / route mapping --- cf/v2/domain_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cf/v2/domain_test.go b/cf/v2/domain_test.go index e468217..8158356 100644 --- a/cf/v2/domain_test.go +++ b/cf/v2/domain_test.go @@ -97,13 +97,13 @@ var _ = Describe("cf-domain test", func() { domainResponse, err := resourcesData.GetDomain(routes) Expect(cliConn.CliCommandWithoutTerminalOutputCallCount()).To(Equal(1)) + Expect(4).To(Equal(len(*domainResponse))) checkMap := make(map[string]string, len(*domainResponse)) for _, value := range *domainResponse { checkMap[value.Host] = value.Domain } - Expect(checkMap["foo"]).To(Equal("example.com")) Expect(checkMap["my"]).To(Equal("foo.example.com")) Expect(checkMap["puppeteer"]).To(Equal("internal.emea.github.com")) Expect(checkMap["url"]).To(Equal("test-domain.com")) From 9294e3bd06faf236f143e736e1b7196de74d1bd9 Mon Sep 17 00:00:00 2001 From: HappyTobi Date: Thu, 30 Apr 2020 22:04:53 +0200 Subject: [PATCH 16/18] [UPDATE] changelog --- CHANGELOG.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0ad4b2..202b244 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,10 +14,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - check space quota before deployment (if user pass the option) - set timeout how long the deployment will wait for more / free space -## [1.2.1] - 2020-03-28 +## [1.2.1] - 2020-03-30 ### Fixed -- route logic when using legacy push +- find matching routes +- pss a vars file combined with 'legacy-push' + +### Changed +- add more trace logging ## [1.2.0] - 2020-02-24 From f9d16cfc9f48793e4243358d4c378bf9a77fbbc2 Mon Sep 17 00:00:00 2001 From: HappyTobi Date: Thu, 30 Apr 2020 22:05:29 +0200 Subject: [PATCH 17/18] [UPDATE] changed things --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 202b244..77478df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - add more trace logging +- make tests more stable ## [1.2.0] - 2020-02-24 From fcc8aa5c57da5a6259cd10cc43f48b45baa72bd6 Mon Sep 17 00:00:00 2001 From: HappyTobi Date: Thu, 30 Apr 2020 22:30:51 +0200 Subject: [PATCH 18/18] [UPDATE] release date --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77478df..d179f44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - check space quota before deployment (if user pass the option) - set timeout how long the deployment will wait for more / free space -## [1.2.1] - 2020-03-30 +## [1.2.1] - 2020-04-30 ### Fixed - find matching routes