Skip to content

Commit

Permalink
Upgrade to v3 YAML package and Go 1.19
Browse files Browse the repository at this point in the history
* Updates to v3 of YAML package
* Updates Go version to 1.19 for builds
* Updates underlying Alpine Linux to latest

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
  • Loading branch information
alexellis committed Feb 23, 2023
1 parent 45c1d90 commit 600ae24
Show file tree
Hide file tree
Showing 167 changed files with 7,227 additions and 2,820 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ghcr.io/openfaas/license-check:0.4.1 as license-check

# Build stage
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.18 as builder
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.19 as builder

ARG TARGETPLATFORM
ARG BUILDPLATFORM
Expand Down Expand Up @@ -40,7 +40,7 @@ RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 \
-a -installsuffix cgo -o faas-cli

# CICD stage
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.16.2 as root
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.17.2 as root

ARG REPO_URL

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.redist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ghcr.io/openfaas/license-check:0.4.1 as license-check

# Build stage
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.18 as builder
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.19 as builder

ARG GIT_COMMIT
ARG VERSION
Expand Down Expand Up @@ -70,7 +70,7 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build --ldflags "-s -w \
-a -installsuffix cgo -o faas-cli-arm64

# Release stage
FROM alpine:3.16.2
FROM alpine:3.17.2

RUN apk --no-cache add ca-certificates git

Expand Down
2 changes: 1 addition & 1 deletion commands/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/openfaas/faas-cli/util"

"github.com/spf13/cobra"
yaml "gopkg.in/yaml.v2"
yaml "gopkg.in/yaml.v3"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions commands/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"

yaml "gopkg.in/yaml.v2"
yaml "gopkg.in/yaml.v3"
)

const (
Expand Down Expand Up @@ -172,7 +172,7 @@ Use "--yaml" to pass a file or "--from-store" to generate using function store.`
return nil
}

//generateCRDYAML generates CRD YAML for functions
// generateCRDYAML generates CRD YAML for functions
func generateCRDYAML(services stack.Services, format schema.BuildFormat, apiVersion, namespace, branch, version string) (string, error) {

var objectsString string
Expand Down
173 changes: 86 additions & 87 deletions commands/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ var generateTestcases = []struct {
Name: "Specified Namespace and API Version",
Input: `
provider:
name: openfaas
gateway: http://127.0.0.1:8080
network: "func_functions"
name: openfaas
gateway: http://127.0.0.1:8080
network: "func_functions"
functions:
url-ping:
lang: python
handler: ./sample/url-ping
image: alexellis/faas-url-ping:0.2`,
lang: python
handler: ./sample/url-ping
image: alexellis/faas-url-ping:0.2`,
Output: []string{`---
apiVersion: openfaas.com/v1
kind: Function
metadata:
name: url-ping
namespace: openfaas-fn
name: url-ping
namespace: openfaas-fn
spec:
name: url-ping
image: alexellis/faas-url-ping:0.2
name: url-ping
image: alexellis/faas-url-ping:0.2
`},
Format: schema.DefaultFormat,
APIVersion: "openfaas.com/v1",
Expand All @@ -54,27 +54,27 @@ spec:
Name: "Annotation present",
Input: `
provider:
name: openfaas
gateway: http://127.0.0.1:8080
name: openfaas
gateway: http://127.0.0.1:8080
functions:
url-ping:
lang: python
handler: ./sample/url-ping
image: alexellis/faas-url-ping:0.2
annotations:
com.scale.zero: 1
lang: python
handler: ./sample/url-ping
image: alexellis/faas-url-ping:0.2
annotations:
com.scale.zero: 1
`,
Output: []string{`---
apiVersion: openfaas.com/v1
kind: Function
metadata:
name: url-ping
namespace: openfaas-fn
name: url-ping
namespace: openfaas-fn
spec:
name: url-ping
image: alexellis/faas-url-ping:0.2
annotations:
com.scale.zero: "1"
name: url-ping
image: alexellis/faas-url-ping:0.2
annotations:
com.scale.zero: "1"
`},
Format: schema.DefaultFormat,
APIVersion: "openfaas.com/v1",
Expand All @@ -86,22 +86,22 @@ spec:
Name: "Blank namespace",
Input: `
provider:
name: openfaas
gateway: http://127.0.0.1:8080
network: "func_functions"
name: openfaas
gateway: http://127.0.0.1:8080
network: "func_functions"
functions:
url-ping:
lang: python
handler: ./sample/url-ping
image: alexellis/faas-url-ping:0.2`,
lang: python
handler: ./sample/url-ping
image: alexellis/faas-url-ping:0.2`,
Output: []string{`---
apiVersion: openfaas.com/v1
kind: Function
metadata:
name: url-ping
name: url-ping
spec:
name: url-ping
image: alexellis/faas-url-ping:0.2
name: url-ping
image: alexellis/faas-url-ping:0.2
`},
Format: schema.DefaultFormat,
APIVersion: "openfaas.com/v1",
Expand All @@ -113,23 +113,23 @@ spec:
Name: "BranchAndSHA Image format",
Input: `
provider:
name: openfaas
gateway: http://127.0.0.1:8080
network: "func_functions"
name: openfaas
gateway: http://127.0.0.1:8080
network: "func_functions"
functions:
url-ping:
lang: python
handler: ./sample/url-ping
image: alexellis/faas-url-ping:0.2`,
lang: python
handler: ./sample/url-ping
image: alexellis/faas-url-ping:0.2`,
Output: []string{`---
apiVersion: openfaas.com/v1
kind: Function
metadata:
name: url-ping
namespace: openfaas-function
name: url-ping
namespace: openfaas-function
spec:
name: url-ping
image: alexellis/faas-url-ping:0.2-master-6bgf36qd
name: url-ping
image: alexellis/faas-url-ping:0.2-master-6bgf36qd
`},
Format: schema.BranchAndSHAFormat,
APIVersion: "openfaas.com/v1",
Expand All @@ -141,60 +141,60 @@ spec:
Name: "Multiple functions",
Input: `
provider:
name: openfaas
gateway: http://127.0.0.1:8080
network: "func_functions"
name: openfaas
gateway: http://127.0.0.1:8080
network: "func_functions"
functions:
url-ping:
lang: python
handler: ./sample/url-ping
image: alexellis/faas-url-ping:0.2
lang: python
handler: ./sample/url-ping
image: alexellis/faas-url-ping:0.2
astronaut-finder:
lang: python3
handler: ./astronaut-finder
image: astronaut-finder
environment:
write_debug: true`,
lang: python3
handler: ./astronaut-finder
image: astronaut-finder
environment:
write_debug: true`,
Output: []string{`---
apiVersion: openfaas.com/v2alpha2
kind: Function
metadata:
name: url-ping
namespace: openfaas-fn
name: url-ping
namespace: openfaas-fn
spec:
name: url-ping
image: alexellis/faas-url-ping:0.2
name: url-ping
image: alexellis/faas-url-ping:0.2
---
apiVersion: openfaas.com/v2alpha2
kind: Function
metadata:
name: astronaut-finder
namespace: openfaas-fn
name: astronaut-finder
namespace: openfaas-fn
spec:
name: astronaut-finder
image: astronaut-finder:latest
environment:
write_debug: "true"
name: astronaut-finder
image: astronaut-finder:latest
environment:
write_debug: "true"
`, `---
apiVersion: openfaas.com/v2alpha2
kind: Function
metadata:
name: astronaut-finder
namespace: openfaas-fn
name: astronaut-finder
namespace: openfaas-fn
spec:
name: astronaut-finder
image: astronaut-finder:latest
environment:
write_debug: "true"
name: astronaut-finder
image: astronaut-finder:latest
environment:
write_debug: "true"
---
apiVersion: openfaas.com/v2alpha2
kind: Function
metadata:
name: url-ping
namespace: openfaas-fn
name: url-ping
namespace: openfaas-fn
spec:
name: url-ping
image: alexellis/faas-url-ping:0.2
name: url-ping
image: alexellis/faas-url-ping:0.2
`},
Format: schema.DefaultFormat,
APIVersion: "openfaas.com/v2alpha2",
Expand All @@ -206,24 +206,24 @@ spec:
Name: "Read-only root filesystem",
Input: `
provider:
name: openfaas
gateway: http://127.0.0.1:8080
name: openfaas
gateway: http://127.0.0.1:8080
functions:
url-ping:
lang: python
handler: ./sample/url-ping
image: alexellis/faas-url-ping:0.2
readonly_root_filesystem: true`,
lang: python
handler: ./sample/url-ping
image: alexellis/faas-url-ping:0.2
readonly_root_filesystem: true`,
Output: []string{`---
apiVersion: openfaas.com/v1
kind: Function
metadata:
name: url-ping
namespace: openfaas-fn
name: url-ping
namespace: openfaas-fn
spec:
name: url-ping
image: alexellis/faas-url-ping:0.2
readOnlyRootFilesystem: true
name: url-ping
image: alexellis/faas-url-ping:0.2
readOnlyRootFilesystem: true
`},
Format: schema.DefaultFormat,
APIVersion: "openfaas.com/v1",
Expand Down Expand Up @@ -256,7 +256,6 @@ func Test_generateCRDYAML(t *testing.T) {
t.Fatalf("%s failed: want:\n%q, but got:\n%q", testcase.Name, testcase.Output, generatedYAML)
}
}

}

func stringInSlice(a string, list []string) bool {
Expand All @@ -271,7 +270,7 @@ func stringInSlice(a string, list []string) bool {
func Test_filterStoreItem_Found(t *testing.T) {

items := []v2.StoreFunction{
v2.StoreFunction{
{
Name: "figlet",
},
}
Expand All @@ -293,7 +292,7 @@ func Test_filterStoreItem_Found(t *testing.T) {
func Test_filterStoreItem_NotFound(t *testing.T) {

items := []v2.StoreFunction{
v2.StoreFunction{
{
Name: "figlets",
},
}
Expand Down
2 changes: 1 addition & 1 deletion commands/template_pull_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io/ioutil"
"os"

"gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"

"github.com/openfaas/faas-cli/stack"
"github.com/spf13/cobra"
Expand Down
4 changes: 2 additions & 2 deletions config/config_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import (
"strings"

"github.com/mitchellh/go-homedir"
"gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"
)

//AuthType auth type
// AuthType auth type
type AuthType string

const (
Expand Down
Loading

0 comments on commit 600ae24

Please sign in to comment.