Skip to content

Commit

Permalink
exit if it cant connect webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
KongZ committed Feb 7, 2022
1 parent 764b5ff commit b4bee63
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,26 @@ docker-piggy-multi: ## Build a piggy-env and piggy-webhooks Docker image in mult
--build-arg=BUILD_DATE=$(BUILD_DATE) \
-f piggy-webhooks/Dockerfile piggy-webhooks

.PHONY: docker-piggy-multi-push
docker-piggy-multi-push: BUILD_ARCH := $(strip $(BUILD_ARCH)),linux/arm64
docker-piggy-multi-push: ## Build a piggy-env and piggy-webhooks Docker image in multi-architect and push to GCR
@docker login ghcr.io -u USERNAME -p $(CR_PAT)
@echo "Building architecture ${BUILD_ARCH}"
docker buildx build -t ${PIGGY_ENV_DOCKER_IMAGE}:${DOCKER_TAG} \
--push \
--platform=$(BUILD_ARCH) \
--build-arg=VERSION=$(VERSION) \
--build-arg=COMMIT_HASH=$(COMMIT_HASH) \
--build-arg=BUILD_DATE=$(BUILD_DATE) \
-f piggy-env/Dockerfile piggy-env
docker buildx build -t ${PIGGY_WEBHOOK_DOCKER_IMAGE}:${DOCKER_TAG} \
--push \
--platform=$(BUILD_ARCH) \
--build-arg=VERSION=$(VERSION) \
--build-arg=COMMIT_HASH=$(COMMIT_HASH) \
--build-arg=BUILD_DATE=$(BUILD_DATE) \
-f piggy-webhooks/Dockerfile piggy-webhooks

release-%: ## Release a new version
git tag -m 'Release $*' $*

Expand Down
13 changes: 8 additions & 5 deletions piggy-env/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func install(src, dst string) error {
dst = dst + "/piggy-env"
}
}
destination, err := os.Create(dst)
destination, err := os.Create(filepath.Clean(dst))
if err != nil {
return err
}
Expand Down Expand Up @@ -369,6 +369,10 @@ func main() {
log.Info().Msgf("Sleeping for %s", initialDelay)
time.Sleep(initialDelay)
}
ignoreNoEnv := false
if os.Getenv("PIGGY_IGNORE_NO_ENV") != "" {
ignoreNoEnv, _ = strconv.ParseBool(os.Getenv("PIGGY_IGNORE_NO_ENV"))
}
retryResults := make([]string, numberOfRetry)
success := false
if standalone {
Expand Down Expand Up @@ -408,10 +412,9 @@ func main() {
for _, result := range retryResults {
log.Error().Msg(result)
}
}
ignoreNoEnv := false
if os.Getenv("PIGGY_IGNORE_NO_ENV") != "" {
ignoreNoEnv, _ = strconv.ParseBool(os.Getenv("PIGGY_IGNORE_NO_ENV"))
if !ignoreNoEnv {
log.Fatal().Msgf("Unable to communicate with %s", os.Getenv("PIGGY_ADDRESS"))
}
}
if !ignoreNoEnv {
for _, v := range sanitized.Env {
Expand Down

0 comments on commit b4bee63

Please sign in to comment.