Skip to content

Commit

Permalink
update build scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Hector Fernandez <[email protected]>
  • Loading branch information
hectorj2f committed Jun 14, 2023
1 parent 32c9ffc commit b46a2ee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 35 deletions.
14 changes: 0 additions & 14 deletions .ko.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,3 @@ builds:
- -extldflags "-static"
- "{{ .Env.LDFLAGS }}"

- id: policy_webhook
dir: .
main: ./cmd/policy_webhook
env:
- CGO_ENABLED=0
flags:
- -trimpath
- --tags
- "{{ .Env.GIT_HASH }}"
- --tags
- "{{ .Env.GIT_VERSION }}"
ldflags:
- -extldflags "-static"
- "{{ .Env.LDFLAGS }}"
24 changes: 3 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,9 @@ fmt: ## Format all go files

## Build policy-controller binary
.PHONY: policy-controller
policy-controller: policy-webhook
policy-controller:
CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o $@ ./cmd/webhook

.PHONY: policy-webhook
policy-webhook: ## Build the policy webhook binary
CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o $@ ./cmd/policy_webhook

## Build policy-tester binary
.PHONY: policy-tester
policy-tester:
Expand All @@ -114,7 +110,6 @@ test:

clean:
rm -rf policy-controller
rm -rf policy-webhook

KOCACHE_PATH=/tmp/ko
ARTIFACT_HUB_LABELS=--image-label io.artifacthub.package.readme-url="https://raw.githubusercontent.com/sigstore/policy-controller/main/README.md" \
Expand All @@ -133,23 +128,16 @@ endef
# ko build
##########
.PHONY: ko
ko: ko-policy-controller ko-policy-webhook
ko: ko-policy-controller

.PHONY: ko-policy-controller
ko-policy-controller: kustomize-policy-controller ko-policy-webhook
ko-policy-controller: kustomize-policy-controller
# policy-controller
LDFLAGS="$(LDFLAGS)" GIT_HASH=$(GIT_HASH) GIT_VERSION=$(GIT_VERSION) \
KOCACHE=$(KOCACHE_PATH) KO_DOCKER_REPO=$(KO_PREFIX)/policy-controller ko resolve --bare \
--platform=$(POLICY_CONTROLLER_ARCHS) --tags $(GIT_VERSION) --tags $(GIT_HASH)$(LATEST_TAG) \
--image-refs policyControllerImagerefs --filename config/webhook.yaml >> $(POLICY_CONTROLLER_YAML)

ko-policy-webhook:
# policy_webhook
LDFLAGS="$(LDFLAGS)" GIT_HASH=$(GIT_HASH) GIT_VERSION=$(GIT_VERSION) \
KOCACHE=$(KOCACHE_PATH) KO_DOCKER_REPO=$(KO_PREFIX)/policy-webhook ko resolve --bare \
--platform=$(POLICY_CONTROLLER_ARCHS) --tags $(GIT_VERSION) --tags $(GIT_HASH)$(LATEST_TAG) \
--image-refs policyImagerefs --filename config/policy-webhook.yaml >> $(POLICY_CONTROLLER_YAML)

.PHONY: ko-local
ko-local:
LDFLAGS="$(LDFLAGS)" GIT_HASH=$(GIT_HASH) GIT_VERSION=$(GIT_VERSION) \
Expand All @@ -158,12 +146,6 @@ ko-local:
$(ARTIFACT_HUB_LABELS) \
github.com/sigstore/policy-controller/cmd/webhook

LDFLAGS="$(LDFLAGS)" GIT_HASH=$(GIT_HASH) GIT_VERSION=$(GIT_VERSION) \
KOCACHE=$(KOCACHE_PATH) KO_DOCKER_REPO=ko.local ko build --base-import-paths \
--tags $(GIT_VERSION) --tags $(GIT_HASH) \
$(ARTIFACT_HUB_LABELS) \
github.com/sigstore/policy-controller/cmd/policy_webhook

.PHONY: ko-apply
ko-apply:
LDFLAGS="$(LDFLAGS)" GIT_HASH=$(GIT_HASH) GIT_VERSION=$(GIT_VERSION) ko apply -Bf config/
Expand Down

0 comments on commit b46a2ee

Please sign in to comment.