Upgrade to Go 1.18 and introduce timeout for deploy
* Go is upgraded to 1.18 for builds * Alpine Linux is upgraded for the runtime container * The deploy command gains a timeout for use with faaasd which is synchronous and would time-out otherwise. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
committed by
Alex Ellis
parent
3534df7157
commit
fcf50cef7b
@@ -1,7 +1,7 @@
|
||||
FROM teamserverless/license-check:0.3.9 as license-check
|
||||
FROM ghcr.io/openfaas/license-check:0.4.1 as license-check
|
||||
|
||||
# Build stage
|
||||
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.17 as builder
|
||||
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.18 as builder
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
ARG BUILDPLATFORM
|
||||
@@ -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.13 as root
|
||||
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.16.2 as root
|
||||
|
||||
ARG REPO_URL
|
||||
|
||||
@@ -57,7 +57,7 @@ ENV PATH=$PATH:/usr/bin/
|
||||
ENTRYPOINT [ "faas-cli" ]
|
||||
|
||||
# Release stage
|
||||
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.13 as release
|
||||
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.16.2 as release
|
||||
|
||||
ARG REPO_URL
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
FROM teamserverless/license-check:0.3.6 as license-check
|
||||
FROM ghcr.io/openfaas/license-check:0.4.1 as license-check
|
||||
|
||||
# Build stage
|
||||
FROM golang:1.17 as builder
|
||||
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.18 as builder
|
||||
|
||||
ARG GIT_COMMIT
|
||||
ARG VERSION
|
||||
@@ -62,7 +62,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.13
|
||||
FROM alpine:3.16.2
|
||||
|
||||
RUN apk --no-cache add ca-certificates git
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/openfaas/faas-cli/builder"
|
||||
"github.com/openfaas/faas-cli/proxy"
|
||||
@@ -21,7 +22,8 @@ import (
|
||||
|
||||
var (
|
||||
// readTemplate controls whether we should read the function's template when deploying.
|
||||
readTemplate bool
|
||||
readTemplate bool
|
||||
timeoutOverride time.Duration
|
||||
)
|
||||
|
||||
// DeployFlags holds flags that are to be added to commands.
|
||||
@@ -72,6 +74,8 @@ func init() {
|
||||
_ = deployCmd.Flags().SetAnnotation("handler", cobra.BashCompSubdirsInDir, []string{})
|
||||
deployCmd.Flags().BoolVar(&readTemplate, "read-template", true, "Read the function's template")
|
||||
|
||||
deployCmd.Flags().DurationVar(&timeoutOverride, "timeout", commandTimeout, "Timeout for any HTTP calls made to the OpenFaaS API.")
|
||||
|
||||
faasCmd.AddCommand(deployCmd)
|
||||
}
|
||||
|
||||
@@ -147,14 +151,13 @@ func runDeployCommand(args []string, image string, fprocess string, functionName
|
||||
return err
|
||||
}
|
||||
|
||||
parsedServices.Provider.GatewayURL = getGatewayURL(gateway, defaultGateway, parsedServices.Provider.GatewayURL, os.Getenv(openFaaSURLEnvironment))
|
||||
|
||||
if parsedServices != nil {
|
||||
parsedServices.Provider.GatewayURL = getGatewayURL(gateway, defaultGateway, parsedServices.Provider.GatewayURL, os.Getenv(openFaaSURLEnvironment))
|
||||
services = *parsedServices
|
||||
}
|
||||
}
|
||||
|
||||
transport := GetDefaultCLITransport(tlsInsecure, &commandTimeout)
|
||||
transport := GetDefaultCLITransport(tlsInsecure, &timeoutOverride)
|
||||
ctx := context.Background()
|
||||
|
||||
var failedStatusCodes = make(map[string]int)
|
||||
@@ -164,7 +167,8 @@ func runDeployCommand(args []string, image string, fprocess string, functionName
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
proxyClient, err := proxy.NewClient(cliAuth, services.Provider.GatewayURL, transport, &commandTimeout)
|
||||
|
||||
proxyClient, err := proxy.NewClient(cliAuth, services.Provider.GatewayURL, transport, &timeoutOverride)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -283,7 +287,7 @@ Error: %s`, fprocessErr.Error())
|
||||
}
|
||||
} else {
|
||||
if len(image) == 0 || len(functionName) == 0 {
|
||||
return fmt.Errorf("To deploy a function give --yaml/-f or a --image and --name flag")
|
||||
return fmt.Errorf("to deploy a function give --yaml/-f or a --image and --name flag")
|
||||
}
|
||||
gateway = getGatewayURL(gateway, defaultGateway, "", os.Getenv(openFaaSURLEnvironment))
|
||||
cliAuth, err := proxy.NewCLIAuth(token, gateway)
|
||||
@@ -389,7 +393,7 @@ func mergeSlice(values []string, overlay []string) []string {
|
||||
}
|
||||
|
||||
for _, value := range values {
|
||||
if exists := added[value]; exists == false {
|
||||
if exists := added[value]; !exists {
|
||||
results = append(results, value)
|
||||
}
|
||||
}
|
||||
@@ -490,26 +494,6 @@ func languageExistsNotDockerfile(language string) bool {
|
||||
return len(language) > 0 && strings.ToLower(language) != "dockerfile"
|
||||
}
|
||||
|
||||
type authConfig struct {
|
||||
Auth string `json:"auth,omitempty"`
|
||||
}
|
||||
|
||||
type configFile struct {
|
||||
AuthConfigs map[string]authConfig `json:"auths"`
|
||||
CredentialsStore string `json:"credsStore,omitempty"`
|
||||
}
|
||||
|
||||
const (
|
||||
// docker default settings
|
||||
configFileName = "config.json"
|
||||
configFileDir = ".docker"
|
||||
defaultDockerRegistry = "https://index.docker.io/v1/"
|
||||
)
|
||||
|
||||
var (
|
||||
configDir = os.Getenv("DOCKER_CONFIG")
|
||||
)
|
||||
|
||||
func deployFailed(status map[string]int) error {
|
||||
if len(status) == 0 {
|
||||
return nil
|
||||
@@ -517,7 +501,7 @@ func deployFailed(status map[string]int) error {
|
||||
|
||||
var allErrors []string
|
||||
for funcName, funcStatus := range status {
|
||||
err := fmt.Errorf("Function '%s' failed to deploy with status code: %d", funcName, funcStatus)
|
||||
err := fmt.Errorf("function '%s' failed to deploy with status code: %d", funcName, funcStatus)
|
||||
allErrors = append(allErrors, err.Error())
|
||||
}
|
||||
return fmt.Errorf(strings.Join(allErrors, "\n"))
|
||||
|
||||
@@ -28,6 +28,7 @@ func init() {
|
||||
storeDeployCmd.Flags().StringArrayVarP(&storeDeployFlags.annotationOpts, "annotation", "", []string{}, "Set one or more annotation (ANNOTATION=VALUE)")
|
||||
storeDeployCmd.Flags().BoolVar(&tlsInsecure, "tls-no-verify", false, "Disable TLS validation")
|
||||
storeDeployCmd.Flags().StringVarP(&token, "token", "k", "", "Pass a JWT token to use instead of basic auth")
|
||||
storeDeployCmd.Flags().DurationVar(&timeoutOverride, "timeout", commandTimeout, "Timeout for any HTTP calls made to the OpenFaaS API.")
|
||||
|
||||
// Set bash-completion.
|
||||
_ = storeDeployCmd.Flags().SetAnnotation("handler", cobra.BashCompSubdirsInDir, []string{})
|
||||
@@ -119,8 +120,8 @@ func runStoreDeploy(cmd *cobra.Command, args []string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
transport := GetDefaultCLITransport(tlsInsecure, &commandTimeout)
|
||||
proxyClient, err := proxy.NewClient(cliAuth, gateway, transport, &commandTimeout)
|
||||
transport := GetDefaultCLITransport(tlsInsecure, &timeoutOverride)
|
||||
proxyClient, err := proxy.NewClient(cliAuth, gateway, transport, &timeoutOverride)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM alpine:3.13
|
||||
FROM alpine:3.16.2
|
||||
|
||||
# Alternatively use ADD https:// (which will not be cached by Docker builder)
|
||||
RUN apk --no-cache add curl ca-certificates imagemagick \
|
||||
|
||||
Reference in New Issue
Block a user