-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improves output for connector invocations with duration * Updates connector-sdk, and Go to 1.18 Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
- Loading branch information
Showing
8 changed files
with
180 additions
and
615 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,24 @@ | ||
.PHONY: build push manifest test verify-codegen charts | ||
TAG?=latest | ||
IMG_NAME?=cron-connector | ||
|
||
# docker manifest command will work with Docker CLI 18.03 or newer | ||
# but for now it's still experimental feature so we need to enable that | ||
export DOCKER_CLI_EXPERIMENTAL=enabled | ||
|
||
build: | ||
docker build -t openfaas/cron-connector:$(TAG)-amd64 . -f Dockerfile | ||
docker build --build-arg OPTS="GOARCH=arm64" -t openfaas/cron-connector:$(TAG)-arm64 . -f Dockerfile | ||
docker build --build-arg OPTS="GOARCH=arm GOARM=6" -t openfaas/cron-connector:$(TAG)-armhf . -f Dockerfile | ||
TAG?=dev | ||
PLATFORMS?=linux/amd64,linux/arm/v7,linux/arm64 | ||
OWNER?=alexellis2 | ||
SERVER?=docker.io | ||
|
||
push: | ||
docker push openfaas/cron-connector:$(TAG)-amd64 | ||
docker push openfaas/cron-connector:$(TAG)-arm64 | ||
docker push openfaas/cron-connector:$(TAG)-armhf | ||
VERSION := $(shell git describe --tags --dirty) | ||
GIT_COMMIT := $(shell git rev-parse HEAD) | ||
|
||
manifest: | ||
docker manifest create --amend openfaas/cron-connector:$(TAG) \ | ||
openfaas/cron-connector:$(TAG)-amd64 \ | ||
openfaas/cron-connector:$(TAG)-arm64 \ | ||
openfaas/cron-connector:$(TAG)-armhf | ||
docker manifest annotate openfaas/cron-connector:$(TAG) openfaas/cron-connector:$(TAG)-arm64 --os linux --arch arm64 | ||
docker manifest annotate openfaas/cron-connector:$(TAG) openfaas/cron-connector:$(TAG)-armhf --os linux --arch arm --variant v6 | ||
docker manifest push -p openfaas/cron-connector:$(TAG) | ||
export DOCKER_CLI_EXPERIMENTAL=enabled | ||
export DOCKER_BUILDKIT=1 | ||
|
||
test: | ||
go test ./... | ||
.PHONY: publish-buildx-all | ||
publish-buildx-all: | ||
@echo $(SERVER)/$(OWNER)/$(IMG_NAME):$(TAG) && \ | ||
docker buildx create --use --name=multiarch --node=multiarch && \ | ||
docker buildx build \ | ||
--platform $(PLATFORMS) \ | ||
--push=true \ | ||
--build-arg GIT_COMMIT=$(GIT_COMMIT) \ | ||
--build-arg VERSION=$(VERSION) \ | ||
--tag $(SERVER)/$(OWNER)/$(IMG_NAME):$(TAG) \ | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"time" | ||
|
||
"github.com/openfaas/connector-sdk/types" | ||
) | ||
|
||
func getControllerConfig() (*types.ControllerConfig, error) { | ||
gURL, ok := os.LookupEnv("gateway_url") | ||
|
||
if !ok { | ||
return nil, fmt.Errorf("gateway_url environment variable not set") | ||
} | ||
|
||
asynchronousInvocation := false | ||
if val, exists := os.LookupEnv("asynchronous_invocation"); exists { | ||
asynchronousInvocation = (val == "1" || val == "true") | ||
} | ||
|
||
contentType := "text/plain" | ||
if v, exists := os.LookupEnv("content_type"); exists && len(v) > 0 { | ||
contentType = v | ||
} | ||
|
||
var printResponseBody bool | ||
if val, exists := os.LookupEnv("print_response_body"); exists { | ||
printResponseBody = (val == "1" || val == "true") | ||
} | ||
|
||
rebuildInterval := time.Second * 10 | ||
|
||
if val, exists := os.LookupEnv("rebuild_interval"); exists { | ||
d, err := time.ParseDuration(val) | ||
if err != nil { | ||
return nil, err | ||
} | ||
rebuildInterval = d | ||
} | ||
|
||
return &types.ControllerConfig{ | ||
RebuildInterval: rebuildInterval, | ||
GatewayURL: gURL, | ||
AsyncFunctionInvocation: asynchronousInvocation, | ||
ContentType: contentType, | ||
PrintResponse: true, | ||
PrintResponseBody: printResponseBody, | ||
PrintRequestBody: false, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
module github.com/openfaas/cron-connector | ||
|
||
go 1.16 | ||
go 1.18 | ||
|
||
require ( | ||
github.com/openfaas/connector-sdk v0.6.1 | ||
github.com/openfaas/faas-cli v0.0.0-20210617112918-72816d486cf7 | ||
github.com/openfaas/faas-provider v0.18.5 | ||
github.com/pkg/errors v0.9.1 | ||
github.com/openfaas/connector-sdk v0.6.7 | ||
github.com/openfaas/faas-cli v0.0.0-20220806094027-3534df71572f | ||
github.com/openfaas/faas-provider v0.19.0 | ||
github.com/robfig/cron/v3 v3.0.1 | ||
) | ||
|
||
require ( | ||
github.com/drone/envsubst v1.0.3 // indirect | ||
github.com/kr/text v0.2.0 // indirect | ||
github.com/mitchellh/go-homedir v1.1.0 // indirect | ||
github.com/openfaas/faas/gateway v0.0.0-20220805080331-b87b96ae456e // indirect | ||
github.com/ryanuber/go-glob v1.0.0 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
) |
Oops, something went wrong.