Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Commit def5200

Browse files
authored
Merge pull request #23 from HappyTobi/1.2.1
New release 1.2.1
2 parents 90ddef3 + fcc8aa5 commit def5200

File tree

10 files changed

+194
-32
lines changed

10 files changed

+194
-32
lines changed

.github/workflows/main.yml

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,78 @@ jobs:
7575
cf delete-route -f apic.eu-gb.mybluemix.net --hostname puppeteer
7676
cf delete-route -f eu-gb.mybluemix.net --hostname puppeteer
7777
78+
int_var_test_job:
79+
name: Run integration tests with vars file
80+
runs-on: ubuntu-latest
81+
needs: [unit_test_job, int_test_job]
82+
steps:
83+
- name: Add CF Cli to apt-get
84+
run: |
85+
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
86+
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
87+
- name: Install CF CLI
88+
run: |
89+
sudo apt-get update
90+
sudo apt-get install cf-cli
91+
- name: Checkout
92+
uses: actions/checkout@v2
93+
- name: Compile plugin
94+
run: |
95+
mkdir -p ./artifacts
96+
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -o ./artifacts/cf-puppeteer
97+
- name: Install Puppeteer plugin
98+
run: |
99+
cf install-plugin -f ./artifacts/cf-puppeteer
100+
cf plugins
101+
- name: CF Login
102+
run: |
103+
cf login -a ${{ secrets.API_BM }} -u ${{secrets.USER_NAME_BM}} -p ${{secrets.PASSWORD_BM}} -o ${{secrets.ORG_BM}} -s dev
104+
- name: Deploy test application with vars file
105+
run: |
106+
cf zero-downtime-push -f test/integration/application/manifest-vars.yml -p test/integration/application/ --vars-file test/integration/application/vars.yml
107+
- name: Check deployment with vars file (route)
108+
run: |
109+
status_code=$(curl --write-out %{http_code} --silent --output /dev/null puppeteer2.eu-gb.mybluemix.net)
110+
echo "Curl response status code: $status_code"
111+
if [[ "$status_code" -ne 200 ]] ; then
112+
exit 1
113+
else
114+
exit 0
115+
fi
116+
- name: Show application
117+
run: |
118+
cf apps
119+
cf app puppeteer2
120+
- name: Delete application
121+
run: |
122+
cf delete -f puppeteer
123+
cf delete-route -f apps.internal --hostname puppeteer2
124+
cf delete-route -f apic.eu-gb.mybluemix.net --hostname puppeteer2
125+
cf delete-route -f eu-gb.mybluemix.net --hostname puppeteer2
126+
- name: Deploy test application with vars file (legacy-push)
127+
run: |
128+
cf zero-downtime-push -f test/integration/application/manifest-vars.yml -p test/integration/application/ --vars-file test/integration/application/vars.yml --legacy-push
129+
- name: Check legacy deployment with vars file (route)
130+
run: |
131+
status_code=$(curl --write-out %{http_code} --silent --output /dev/null puppeteer2.eu-gb.mybluemix.net)
132+
if [[ "$status_code" -ne 200 ]] ; then
133+
exit 1
134+
else
135+
exit 0
136+
fi
137+
- name: Show application
138+
run: |
139+
cf app puppeteer2
140+
- name: Delete application
141+
run: |
142+
cf delete -f puppeteer
143+
cf delete-route -f apps.internal --hostname puppeteer2
144+
cf delete-route -f apic.eu-gb.mybluemix.net --hostname puppeteer2
145+
cf delete-route -f eu-gb.mybluemix.net --hostname puppeteer2
146+
78147
release_job:
79148
name: Build binary
80-
needs: [unit_test_job, int_test_job]
149+
needs: [unit_test_job, int_test_job, int_var_test_job]
81150
runs-on: ubuntu-latest
82151
#if: github.ref == 'refs/heads/develop'
83152
steps:

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- check space quota before deployment (if user pass the option)
1515
- set timeout how long the deployment will wait for more / free space
1616

17+
## [1.2.1] - 2020-04-30
18+
19+
### Fixed
20+
- find matching routes
21+
- pss a vars file combined with 'legacy-push'
22+
23+
### Changed
24+
- add more trace logging
25+
- make tests more stable
26+
1727
## [1.2.0] - 2020-02-24
1828

1929
### Added

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ To get an overview of the changes between versions, read the [changelog](CHANGEL
2626

2727
## Version
2828

29-
The latest version of *CF-Puppeteer* is *1.2.0*. It works with and is based on Cloud Foundry CLI version 6.43.0.
29+
The latest version of *CF-Puppeteer* is *1.2.1*. It works with and is based on Cloud Foundry CLI version 6.43.0.
3030

3131
For more details on the most recent release, check out the [changelog](CHANGELOG.md).
3232

cf/v2/domain.go

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"fmt"
66
"sort"
77
"strings"
8+
9+
"github.com/happytobi/cf-puppeteer/ui"
810
)
911

1012
type Routes struct {
@@ -34,32 +36,34 @@ type DomainResponse struct {
3436

3537
func (resource *LegacyResourcesData) GetDomain(domains []map[string]string) (*[]Routes, error) {
3638
//default order asc.
39+
ui.DebugMessage("GetDomain called, try to find matching domains for all routes %v", domains)
3740
path := fmt.Sprintf(`/v2/domains`)
38-
3941
response, err := resource.getDomain(path)
4042
if err != nil {
4143
return nil, err
4244
}
43-
45+
ui.DebugMessage("/v2/domain response was %v", path)
4446
domainGUID := make(map[string]Routes)
47+
4548
for _, domainRes := range response.Resources {
4649
for _, routes := range domains {
47-
domain := routes["route"]
48-
hostName := strings.ReplaceAll(domain, domainRes.Entity.Name, "")
49-
50-
_, exists := domainGUID[domain]
51-
if exists {
52-
exists = len(domainGUID[domain].Host) < len(hostName)
53-
}
50+
for _, domain := range routes {
51+
hostName := strings.ReplaceAll(domain, domainRes.Entity.Name, "")
52+
_, exists := domainGUID[domain]
53+
if exists {
54+
exists = len(domainGUID[domain].Host) < len(hostName)
55+
}
5456

55-
//question ist when route matches 2 time what kind of your we are using?
56-
if strings.Contains(domain, domainRes.Entity.Name) && len(hostName) > 0 && !exists {
57-
hostName = strings.TrimRight(hostName, ".")
58-
newRoute := &Routes{
59-
Host: hostName,
60-
Domain: domainRes.Entity.Name,
57+
//question ist when route matches 2 time what kind of your we are using?
58+
if strings.Contains(domain, domainRes.Entity.Name) && !exists {
59+
hostName = strings.TrimRight(hostName, ".")
60+
newRoute := &Routes{
61+
Host: hostName,
62+
Domain: domainRes.Entity.Name,
63+
}
64+
ui.DebugMessage("add new route for later mapping %v", newRoute)
65+
domainGUID[domain] = *newRoute
6166
}
62-
domainGUID[domain] = *newRoute
6367
}
6468
}
6569
}
@@ -74,14 +78,20 @@ func (resource *LegacyResourcesData) GetDomain(domains []map[string]string) (*[]
7478
for _, domainRes := range response.Resources {
7579
for _, routes := range domains {
7680
for _, domain := range routes {
81+
hostName := strings.ReplaceAll(domain, domainRes.Entity.Name, "")
7782
_, exists := domainGUID[domain]
83+
if exists {
84+
exists = len(domainGUID[domain].Host) < len(hostName)
85+
}
86+
87+
//question ist when route matches 2 time what kind of your we are using?
7888
if strings.Contains(domain, domainRes.Entity.Name) && !exists {
79-
hostName := strings.ReplaceAll(domain, domainRes.Entity.Name, "")
8089
hostName = strings.TrimRight(hostName, ".")
8190
newRoute := &Routes{
8291
Host: hostName,
8392
Domain: domainRes.Entity.Name,
8493
}
94+
ui.DebugMessage("add new route for later mapping (paged) %v", newRoute)
8595
domainGUID[domain] = *newRoute
8696
}
8797
}

cf/v2/domain_test.go

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,65 @@ var _ = Describe("cf-domain test", func() {
9797
domainResponse, err := resourcesData.GetDomain(routes)
9898

9999
Expect(cliConn.CliCommandWithoutTerminalOutputCallCount()).To(Equal(1))
100+
Expect(4).To(Equal(len(*domainResponse)))
100101

101-
checkMap := make(map[string]string,len(*domainResponse))
102-
for _, value := range (*domainResponse) {
102+
checkMap := make(map[string]string, len(*domainResponse))
103+
for _, value := range *domainResponse {
103104
checkMap[value.Host] = value.Domain
104105
}
105106

106-
107-
Expect(checkMap["foo"]).To(Equal("example.com"))
108107
Expect(checkMap["my"]).To(Equal("foo.example.com"))
109108
Expect(checkMap["puppeteer"]).To(Equal("internal.emea.github.com"))
110109
Expect(checkMap["url"]).To(Equal("test-domain.com"))
111110

111+
Expect(err).ToNot(HaveOccurred())
112+
})
113+
114+
It("use v2 domain api with multiple subdomains ", func() {
115+
response := []string{`{
116+
"total_results": 18,
117+
"total_pages": 2,
118+
"prev_url": null,
119+
"next_url": "https://api.example.org/v2/domains?page=1&per_page=2",
120+
"resources": [
121+
{
122+
"metadata": {
123+
"guid": "aa23b15e-dc54-437e-a651-a29415b66d9m",
124+
"url": "/v2/shared_domains/aa23b15e-dc54-437e-a651-a29415b66d9m",
125+
"created_at": "2016-10-20T07:40:24Z",
126+
"updated_at": "2018-02-09T06:19:46Z"
127+
},
128+
"entity": {
129+
"name": "staging.product.com",
130+
"internal": false,
131+
"router_group_guid": null,
132+
"router_group_type": null
133+
}
134+
},
135+
{
136+
"metadata": {
137+
"guid": "aa23b15e-dc54-437e-a651-5673241243",
138+
"url": "/v2/shared_domains/aa23b15e-dc54-437e-a651-5673241243",
139+
"created_at": "2016-10-20T07:40:24Z",
140+
"updated_at": "2018-02-09T06:19:46Z"
141+
},
142+
"entity": {
143+
"name": "cfapp.io",
144+
"internal": false,
145+
"router_group_guid": null,
146+
"router_group_type": null
147+
}
148+
}
149+
]}
150+
`}
151+
152+
cliConn.CliCommandWithoutTerminalOutputReturns(response, nil)
153+
154+
var routes = []map[string]string{0: {"route": " staging-p.cfapp.io"}, 1: {"route": "staging-product.cfapp.io"}, 2: {"route": "staging.product.com"}}
155+
domainResponse, err := resourcesData.GetDomain(routes)
156+
157+
Expect(cliConn.CliCommandWithoutTerminalOutputCallCount()).To(Equal(1))
158+
Expect(3).To(Equal(len(*domainResponse)))
112159

113160
Expect(err).ToNot(HaveOccurred())
114161
})

cf/v2/push_application.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package v2
22

33
import (
4-
"code.cloudfoundry.org/cli/plugin"
54
"fmt"
5+
"strconv"
6+
7+
"code.cloudfoundry.org/cli/plugin"
68
"github.com/happytobi/cf-puppeteer/arguments"
79
"github.com/happytobi/cf-puppeteer/cf/cli"
810
"github.com/happytobi/cf-puppeteer/ui"
911
"github.com/pkg/errors"
10-
"strconv"
1112
)
1213

1314
//Push interface with all v3 actions
@@ -51,6 +52,10 @@ func (resource *LegacyResourcesData) PushApplication(parsedArguments *arguments.
5152
args = append(args, "--no-start")
5253
}
5354

55+
if parsedArguments.VarsFile != "" {
56+
args = append(args, "--vars-file", parsedArguments.VarsFile)
57+
}
58+
5459
ui.Say("start pushing application with arguments %s", args)
5560
err := resource.Executor.Execute(args)
5661
if err != nil {

cf/v3/domain_test.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package v3_test
22

33
import (
4+
"testing"
5+
46
"code.cloudfoundry.org/cli/plugin/pluginfakes"
57
"github.com/happytobi/cf-puppeteer/cf/cli"
68
v3 "github.com/happytobi/cf-puppeteer/cf/v3"
7-
"testing"
89

910
. "github.com/onsi/ginkgo"
1011
. "github.com/onsi/gomega"
@@ -103,13 +104,15 @@ var _ = Describe("cf-domain test", func() {
103104

104105
Expect(cliConn.CliCommandWithoutTerminalOutputCallCount()).To(Equal(1))
105106

106-
Expect((*domainResponse)[0].Host).To(Equal("foo"))
107-
Expect((*domainResponse)[0].Domain).To(Equal("example.com"))
107+
checkMap := make(map[string]string, len(*domainResponse))
108+
for _, value := range *domainResponse {
109+
checkMap[value.Host] = value.Domain
110+
}
108111

109-
Expect((*domainResponse)[1].Host).To(Equal("url"))
110-
Expect((*domainResponse)[1].Domain).To(Equal("test-domain.com"))
112+
Expect(checkMap["foo"]).To(Equal("example.com"))
113+
Expect(checkMap["url"]).To(Equal("test-domain.com"))
111114

112115
Expect(err).ToNot(HaveOccurred())
113116
})
114117
})
115-
})
118+
})

puppeteer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func (CfPuppeteerPlugin) GetMetadata() plugin.PluginMetadata {
217217
Version: plugin.VersionType{
218218
Major: 1,
219219
Minor: 2,
220-
Build: 0,
220+
Build: 1,
221221
},
222222
Commands: []plugin.Command{
223223
{
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
applications:
3+
- name: ((appname))
4+
memory: ((memory))
5+
buildpacks:
6+
- nginx_buildpack
7+
instances: 1
8+
health-check-type: http
9+
health-check-http-endpoint: /health
10+
routes:
11+
- route: ((route)).apps.internal
12+
- route: ((route)).eu-gb.mybluemix.net
13+
- route: ((route)).apic.eu-gb.mybluemix.net
14+
env:
15+
GITHUB: https://github.com/HappyTobi/cf-puppeteer

test/integration/application/vars.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
appname: puppeteer2
2+
memory: 64mb
3+
route: puppeteer2

0 commit comments

Comments
 (0)