Skip to content

Commit

Permalink
Merge pull request #109 from cybozu-go/applyconfiggen-aqua
Browse files Browse the repository at this point in the history
Setup applyconfiguration-gen with aqua
  • Loading branch information
ymmt2005 authored Nov 17, 2023
2 parents b30b46b + c666d48 commit 6bbd4ec
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
12 changes: 3 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ GO_MODULE = $(shell go list -m)
API_DIRS = $(shell find api -mindepth 2 -type d | sed "s|^|$(shell go list -m)/|" | paste -sd ",")
AC_PKG = internal/applyconfigurations
.PHONY: generate-applyconfigurations
generate-applyconfigurations: applyconfiguration-gen ## Generate applyconfigurations to support typesafe SSA.
generate-applyconfigurations: setup ## Generate applyconfigurations to support typesafe SSA.
rm -rf $(AC_PKG)
@echo ">> generating $(AC_PKG)..."
$(APPLYCONFIGURATION_GEN) \
applyconfiguration-gen \
--go-header-file hack/boilerplate.go.txt \
--input-dirs "$(API_DIRS)" \
--output-package "$(GO_MODULE)/$(AC_PKG)" \
Expand Down Expand Up @@ -114,6 +114,7 @@ release-build: setup
##@ Tools

setup:
aqua policy allow ./aqua-policy.yaml
aqua i -l

SETUP_ENVTEST := $(shell pwd)/bin/setup-envtest
Expand All @@ -123,13 +124,6 @@ $(SETUP_ENVTEST):
# see https://github.com/kubernetes-sigs/controller-runtime/tree/master/tools/setup-envtest
GOBIN=$(shell pwd)/bin go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

APPLYCONFIGURATION_GEN := $(shell pwd)/bin/applyconfiguration-gen
.PHONY: applyconfiguration-gen
applyconfiguration-gen: $(APPLYCONFIGURATION_GEN) ## Download applyconfiguration-gen locally if necessary
$(APPLYCONFIGURATION_GEN):
# see https://github.com/kubernetes/code-generator/tree/master/cmd/applyconfiguration-gen
GOBIN=$(shell pwd)/bin go install k8s.io/code-generator/cmd/[email protected]

# go-get-tool will 'go get' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
define go-get-tool
Expand Down
12 changes: 12 additions & 0 deletions aqua-policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
# aqua Policy
# https://aquaproj.github.io/
registries:
- name: local
type: local
path: registry.yaml
- type: standard
ref: semver(">= 3.0.0")
packages:
- registry: local # allow all packages in the Registry
- registry: standard
5 changes: 5 additions & 0 deletions aqua.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
registries:
- type: standard
ref: v4.23.0 # renovate: depName=aquaproj/aqua-registry
- name: local
type: local
path: registry.yaml
packages:
- name: kubernetes/[email protected]
- name: kubernetes-sigs/[email protected]
Expand All @@ -15,3 +18,5 @@ packages:
- name: helm/[email protected]
- name: bitnami-labs/[email protected]
- name: goreleaser/[email protected]
- name: kubernetes/code-generator/[email protected]
registry: local
9 changes: 9 additions & 0 deletions registry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
packages:
- type: go_install
name: kubernetes/code-generator/applyconfiguration-gen
path: k8s.io/code-generator/cmd/applyconfiguration-gen
repo_owner: kubernetes
repo_name: code-generator
description: applyconfiguration-gen is a tool for auto-generating apply configuration functions.
files:
- name: applyconfiguration-gen

0 comments on commit 6bbd4ec

Please sign in to comment.