mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
* api: Add new types for customizeable resource ordering Signed-off-by: Yannis Zarkadas <yanniszark@arrikto.com> * plugins: Implement SortOrderTransformer plugin Implement the SortOrderTransformer plugin. This plugin allows the user to customize the order that kustomize will output resources in. The API for the plugin is the following: sortOptions: order: legacy | fifo legacySortOptions: orderFirst: - {GVK} orderLast: - {GVK} Signed-off-by: Yannis Zarkadas <yanniszark@arrikto.com> * plugins: Add boilerplate and generate code for new SortOrderTransformer Signed-off-by: Yannis Zarkadas <yanniszark@arrikto.com> * build: Add option to denote if the reorder flag was set by the user We want to take different actions if the reorder flag was set by the user or filled by the default value. Thus, we propagate this information from build to the krusty options. Signed-off-by: Yannis Zarkadas <yanniszark@gmail.com> * api/krusty: Ensure sort ordering works with CLI flag and kustomization Sort order can be defined in two places: - (new) kustomization file - (old) CLI flag We want the kustomization file to take precedence over the CLI flag. Eventually, we may want to move away from having a CLI flag altogether: https://github.com/kubernetes-sigs/kustomize/issues/3947 Case 1: Sort order set in kustomization file AND in CLI flag. Print a warning and let the kustomization file take precedence. Case 2: Sort order set in CLI flag only or not at all. Follow the CLI flag (defaults to legacy) and reorder at the end. Case 3: Sort order set in kustomization file only. Simply build the kustomization. Signed-off-by: Yannis Zarkadas <yanniszark@gmail.com> * krusty: Add e2e test for SortOrderTransformer Signed-off-by: Yannis Zarkadas <yanniszark@arrikto.com> * plugins: Purge LegacyOrderTransformer Signed-off-by: Yannis Zarkadas <yanniszark@gmail.com> * Update go.work.sum Signed-off-by: Yannis Zarkadas <yanniszark@gmail.com> * review: Make review changes Signed-off-by: Yannis Zarkadas <yanniszark@gmail.com> Signed-off-by: Yannis Zarkadas <yanniszark@arrikto.com> Signed-off-by: Yannis Zarkadas <yanniszark@gmail.com>
103 lines
4.3 KiB
Makefile
103 lines
4.3 KiB
Makefile
# Copyright 2022 The Kubernetes Authors.
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
### Kustomize plugin rules.
|
|
#
|
|
# The rules to deal with builtin plugins are a bit
|
|
# complicated because
|
|
#
|
|
# - Every builtin plugin is a Go plugin -
|
|
# meaning it gets its own module directory
|
|
# (outside of the api module) with Go
|
|
# code in a 'main' package per Go plugin rules.
|
|
# - kustomize locates plugins using the
|
|
# 'apiVersion' and 'kind' fields from the
|
|
# plugin config file.
|
|
# - k8s wants CamelCase in 'kind' fields.
|
|
# - The module name (the last name in the path)
|
|
# must be the lowercased 'kind' of the
|
|
# plugin because Go and related tools
|
|
# demand lowercase in import paths, but
|
|
# allow CamelCase in file names.
|
|
# - the generated code must live in the api
|
|
# module (it's linked into the api).
|
|
|
|
# Where all generated builtin plugin code should go.
|
|
pGen=api/internal/builtins
|
|
# Where the builtin Go plugin modules live.
|
|
pSrc=plugin/builtin
|
|
|
|
_builtinplugins = \
|
|
AnnotationsTransformer.go \
|
|
ConfigMapGenerator.go \
|
|
IAMPolicyGenerator.go \
|
|
HashTransformer.go \
|
|
ImageTagTransformer.go \
|
|
LabelTransformer.go \
|
|
SortOrderTransformer.go \
|
|
NamespaceTransformer.go \
|
|
PatchJson6902Transformer.go \
|
|
PatchStrategicMergeTransformer.go \
|
|
PatchTransformer.go \
|
|
PrefixTransformer.go \
|
|
SuffixTransformer.go \
|
|
ReplacementTransformer.go \
|
|
ReplicaCountTransformer.go \
|
|
SecretGenerator.go \
|
|
ValueAddTransformer.go \
|
|
HelmChartInflationGenerator.go
|
|
|
|
# Maintaining this explicit list of generated files, and
|
|
# adding it as a dependency to a few targets, to assure
|
|
# they get recreated if deleted. The rules below on how
|
|
# to make them don't, by themselves, assure they will be
|
|
# recreated if deleted.
|
|
builtinplugins = $(patsubst %,$(pGen)/%,$(_builtinplugins))
|
|
|
|
# These rules are verbose, but assure that if a source file
|
|
# is modified, the corresponding generated file, and only
|
|
# that file, will be recreated.
|
|
$(pGen)/AnnotationsTransformer.go: $(pSrc)/annotationstransformer/AnnotationsTransformer.go
|
|
$(pGen)/ConfigMapGenerator.go: $(pSrc)/configmapgenerator/ConfigMapGenerator.go
|
|
$(pGen)/GkeSaGenerator.go: $(pSrc)/gkesagenerator/GkeSaGenerator.go
|
|
$(pGen)/HashTransformer.go: $(pSrc)/hashtransformer/HashTransformer.go
|
|
$(pGen)/ImageTagTransformer.go: $(pSrc)/imagetagtransformer/ImageTagTransformer.go
|
|
$(pGen)/LabelTransformer.go: $(pSrc)/labeltransformer/LabelTransformer.go
|
|
$(pGen)/SortOrderTransformer.go: $(pSrc)/sortordertransformer/SortOrderTransformer.go
|
|
$(pGen)/NamespaceTransformer.go: $(pSrc)/namespacetransformer/NamespaceTransformer.go
|
|
$(pGen)/PatchJson6902Transformer.go: $(pSrc)/patchjson6902transformer/PatchJson6902Transformer.go
|
|
$(pGen)/PatchStrategicMergeTransformer.go: $(pSrc)/patchstrategicmergetransformer/PatchStrategicMergeTransformer.go
|
|
$(pGen)/PatchTransformer.go: $(pSrc)/patchtransformer/PatchTransformer.go
|
|
$(pGen)/PrefixTransformer.go: $(pSrc)/prefixtransformer/PrefixTransformer.go
|
|
$(pGen)/SuffixTransformer.go: $(pSrc)/suffixtransformer/SuffixTransformer.go
|
|
$(pGen)/ReplacementTransformer.go: $(pSrc)/replacementtransformer/ReplacementTransformer.go
|
|
$(pGen)/ReplicaCountTransformer.go: $(pSrc)/replicacounttransformer/ReplicaCountTransformer.go
|
|
$(pGen)/SecretGenerator.go: $(pSrc)/secretgenerator/SecretGenerator.go
|
|
$(pGen)/ValueAddTransformer.go: $(pSrc)/valueaddtransformer/ValueAddTransformer.go
|
|
$(pGen)/HelmChartInflationGenerator.go: $(pSrc)/helmchartinflationgenerator/HelmChartInflationGenerator.go
|
|
|
|
# The (verbose but portable) Makefile way to convert to lowercase.
|
|
toLowerCase = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1))))))))))))))))))))))))))
|
|
|
|
$(pGen)/%.go: $(MYGOBIN)/pluginator
|
|
@echo "generating $*"
|
|
( \
|
|
set -e; \
|
|
cd $(pSrc)/$(call toLowerCase,$*); \
|
|
go generate .; \
|
|
cd ../../../$(pGen); \
|
|
$(MYGOBIN)/goimports -w $*.go \
|
|
)
|
|
|
|
# Target is for debugging.
|
|
.PHONY: generate-kustomize-builtin-plugins
|
|
generate-kustomize-builtin-plugins: $(builtinplugins)
|
|
|
|
.PHONY: build-kustomize-external-go-plugin
|
|
build-kustomize-external-go-plugin:
|
|
./hack/buildExternalGoPlugins.sh ./plugin
|
|
|
|
.PHONY: clean-kustomize-external-go-plugin
|
|
clean-kustomize-external-go-plugin:
|
|
./hack/buildExternalGoPlugins.sh ./plugin clean
|