Skip to content

Commit 18c02ea

Browse files
author
Aaron Schlesinger
committed
fix(build.go,controller.go): get the app config differently
and fetch the build pack url
1 parent 8daa2a3 commit 18c02ea

2 files changed

Lines changed: 19 additions & 21 deletions

File tree

pkg/gitreceive/build.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ func build(conf *Config, builderKey, gitSha string) error {
8989
tarURL := fmt.Sprintf("%s://%s:%s/git/home/%s/tar", storage.schema(), storage.host(), storage.port(), slugName)
9090
pushURL := fmt.Sprintf("%s://%s:%s/git/home/%s/push", storage.schema(), storage.host(), storage.port(), slugName)
9191

92+
// Ensure that the app config can be gotten from workflow. We don't do anything with this information
93+
appConf, err := getAppConfig(conf, builderKey, conf.Username, appName)
94+
if err != nil {
95+
return fmt.Errorf("getting app config for %s (%s)", appName, err)
96+
}
97+
log.Debug("got the following config back for app %s: %+v", appName, *appConf)
98+
buildPackURLInterface, ok := appConf.Values["BUILDPACK_URL"]
99+
if !ok {
100+
return fmt.Errorf("BUILDPACK_URL not found in returned app config")
101+
}
102+
buildPackURL, ok := buildPackURLInterface.(string)
103+
if !ok {
104+
return fmt.Errorf("BUILDPACK_URL not returned as a string")
105+
}
106+
92107
// build a tarball from the new objects
93108
gitArchiveCmd := repoCmd(repoDir, "git", "archive", "--format=tar.gz", fmt.Sprintf("--output=%s.tar.gz", appName), gitSha)
94109
gitArchiveCmd.Stdout = os.Stdout
@@ -154,6 +169,7 @@ func build(conf *Config, builderKey, gitSha string) error {
154169
finalManifest = strings.Replace(string(fileBytes), "repo_name", buildPodName, -1)
155170
finalManifest = strings.Replace(finalManifest, "puturl", pushURL, -1)
156171
finalManifest = strings.Replace(finalManifest, "tar-url", tarURL, -1)
172+
finalManifest = strings.Replace(finalManifest, "buildurl", buildPackURL, -1)
157173
}
158174

159175
log.Debug("writing builder manifest to %s", finalManifestFileLocation)
@@ -240,12 +256,6 @@ func build(conf *Config, builderKey, gitSha string) error {
240256
}
241257

242258
log.Info("Build complete.")
243-
log.Info("Launching app.")
244-
245-
// Ensure that the app config can be gotten from workflow. We don't do anything with this information
246-
if _, err := getAppConfig(conf, builderKey, conf.Username, appName); err != nil {
247-
return fmt.Errorf("getting app config for %s (%s)", appName, err)
248-
}
249259

250260
log.Info("Launching...")
251261

pkg/gitreceive/controller.go

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,14 @@ func setReqHeaders(builderKey string, req *http.Request) {
4242
}
4343

4444
func getAppConfig(conf *Config, builderKey, userName, appName string) (*pkg.Config, error) {
45-
data, err := json.Marshal(&pkg.ConfigHook{
46-
ReceiveUser: userName,
47-
ReceiveRepo: appName,
48-
})
49-
45+
url := controllerURLStr(conf, "v2", "apps", appName, "config")
46+
req, err := http.NewRequest("GET", url, nil)
5047
if err != nil {
5148
return nil, err
5249
}
53-
54-
b := bytes.NewReader(data)
55-
url := controllerURLStr(conf, "v2", "hooks", "config")
56-
req, err := http.NewRequest("POST", url, b)
57-
58-
if err != nil {
59-
return nil, err
60-
}
61-
6250
setReqHeaders(builderKey, req)
6351

64-
log.Debug("Workflow request POST /v2/hooks/config\n%s", string(data))
52+
log.Debug("Workflow request GET /v2/apps/%s/config", appName)
6553
res, err := http.DefaultClient.Do(req)
6654
if err != nil {
6755
return nil, err

0 commit comments

Comments
 (0)