Skip to content
This repository was archived by the owner on Mar 10, 2023. It is now read-only.

Commit 63a2f66

Browse files
committed
Add support for limited build-args
Support for go modules is now active in git-tar and of-builder. Tested on the community cluster with new images and the following sample repo: https://github.com/alexellis/gitops-webinar Fixes: #652 Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent daceb4d commit 63a2f66

File tree

15 files changed

+121
-65
lines changed

15 files changed

+121
-65
lines changed

git-tar/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
FROM openfaas/faas-cli:0.11.8 as faas-cli
2-
FROM openfaas/classic-watchdog:0.18.1 as watchdog
3-
FROM golang:1.13-alpine3.11 as build
1+
FROM openfaas/faas-cli:0.12.8 as faas-cli
2+
FROM openfaas/classic-watchdog:0.18.17 as watchdog
3+
FROM golang:1.13-alpine3.12 as build
44

55
ENV CGO_ENABLED=0
66
ENV GO111MODULE=off

git-tar/Gopkg.lock

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

git-tar/Gopkg.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[[constraint]]
22
name = "github.com/openfaas/faas-cli"
3-
version = "0.9.3"
3+
version = "0.12.8"
44

55
[[constraint]]
66
name = "github.com/openfaas/openfaas-cloud"
@@ -26,4 +26,3 @@
2626
go-tests = true
2727
unused-packages = true
2828

29-

git-tar/function/ops.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ type tarEntry struct {
3636
imageName string
3737
}
3838

39-
type cfg struct {
40-
Ref string `json:"ref"`
41-
Frontend *string `json:"frontend,omitempty"`
42-
}
43-
4439
func parseYAML(filePath string) (*stack.Services, error) {
4540
envVarSubst := false
4641
parsed, err := stack.ParseYAMLFile(path.Join(filePath, "stack.yml"), "", "", envVarSubst)
@@ -123,8 +118,13 @@ func makeTar(pushEvent sdk.PushEvent, filePath string, services *stack.Services)
123118
imageName := formatImageShaTag(pushRepositoryURL, &v, pushEvent.AfterCommitID,
124119
pushEvent.Repository.Owner.Login, pushEvent.Repository.Name)
125120

126-
config := cfg{
127-
Ref: imageName,
121+
allowedBuildArgs := []string{"GO111MODULE"}
122+
buildArgs := makeBuildArgs(v.BuildArgs, allowedBuildArgs)
123+
124+
// Write a config file for the Docker build
125+
config := buildConfig{
126+
Ref: imageName,
127+
BuildArgs: buildArgs,
128128
}
129129

130130
configBytes, _ := json.Marshal(config)
@@ -797,3 +797,16 @@ func invokeWithHMAC(uri string, payload []byte, payloadSecret string, headers ma
797797

798798
return res.StatusCode, resOut, nil
799799
}
800+
801+
func makeBuildArgs(inputArgs map[string]string, allowed []string) map[string]string {
802+
args := map[string]string{}
803+
for key, value := range inputArgs {
804+
for _, allow := range allowed {
805+
if key == allow {
806+
args[key] = value
807+
break
808+
}
809+
}
810+
}
811+
return args
812+
}

git-tar/function/types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package function
2+
3+
type buildConfig struct {
4+
Ref string `json:"ref"`
5+
Frontend string `json:"frontend,omitempty"`
6+
BuildArgs map[string]string `json:"buildArgs,omitempty"`
7+
}

git-tar/vendor/github.com/openfaas/faas-cli/schema/image.go

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

git-tar/vendor/github.com/openfaas/faas-cli/schema/metadata.go

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

git-tar/vendor/github.com/openfaas/faas-cli/schema/secret.go

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

git-tar/vendor/github.com/openfaas/faas-cli/stack/schema.go

Lines changed: 49 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

git-tar/vendor/github.com/openfaas/faas-cli/stack/stack.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)