File tree Expand file tree Collapse file tree 3 files changed +32
-5
lines changed
cmd/pluginator/internal/builtinplugin Expand file tree Collapse file tree 3 files changed +32
-5
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,9 @@ verify-kustomize-repo: \
108108.PHONY : prow-presubmit-check
109109prow-presubmit-check : \
110110 install-tools \
111+ workspace-sync \
112+ generate-kustomize-builtin-plugins \
113+ builtin-plugins-diff \
111114 test-unit-kustomize-plugins \
112115 test-go-mod \
113116 build-non-plugin-all \
@@ -181,7 +184,12 @@ test-examples-kustomize-against-HEAD: $(MYGOBIN)/kustomize $(MYGOBIN)/mdrip
181184test-examples-kustomize-against-latest-release : $(MYGOBIN ) /mdrip
182185 ./hack/testExamplesAgainstKustomize.sh v5@$(LATEST_RELEASE )
183186
184-
187+ # Pushes dependencies in the go.work file back to go.mod files of each workspace module.
188+ .PHONY : workspace-sync
189+ workspace-sync :
190+ go work sync
191+ ./hack/doGoMod.sh tidy
192+
185193# --- Cleanup targets ---
186194.PHONY : clean
187195clean : clean-kustomize-external-go-plugin uninstall-tools
Original file line number Diff line number Diff line change @@ -89,9 +89,27 @@ $(pGen)/%.go: $(MYGOBIN)/pluginator $(MYGOBIN)/goimports
8989 $(MYGOBIN ) /goimports -w $* .go \
9090 )
9191
92- # Target is for debugging.
92+ # Generate builtin plugins
9393.PHONY : generate-kustomize-builtin-plugins
94- generate-kustomize-builtin-plugins : $(builtinplugins )
94+ generate-kustomize-builtin-plugins : $(builtplugins )
95+ for plugin in $( abspath $( wildcard $( pSrc) /* ) ) ; do \
96+ echo " generating $$ {plugin} ..." ; \
97+ set -e; \
98+ cd $$ {plugin}; \
99+ go generate pluginator . ; \
100+ done
101+
102+ # Check for diff by comparing current revision of generated plugins on HEAD and newly generated plugins on local branch,
103+ # If diff is found, throw error code 1
104+ .PHONY : builtin-plugins-diff
105+ builtin-plugins-diff : $(builtplugins )
106+ for file in $( abspath $( builtinplugins) ) ; do \
107+ echo " Checking for diff... $$ {file}" ; \
108+ set -e ; \
109+ if [ " ` git diff $$ {file} | wc -c` " -gt 0 ]; then\
110+ echo " Error(1): diff found on $$ {file}" ; exit 1; \
111+ fi \
112+ done
95113
96114.PHONY : build-kustomize-external-go-plugin
97115build-kustomize-external-go-plugin :
Original file line number Diff line number Diff line change @@ -62,7 +62,6 @@ func ConvertToBuiltInPlugin() (retErr error) {
6262 w .write (
6363 fmt .Sprintf (
6464 "// pluginator %s\n " , provenance .GetProvenance ().Short ()))
65- w .write ("\n " )
6665 w .write ("package " + packageForGeneratedCode )
6766
6867 pType := unknown
@@ -73,6 +72,8 @@ func ConvertToBuiltInPlugin() (retErr error) {
7372 continue
7473 }
7574 if strings .HasPrefix (l , "var " + konfig .PluginSymbol + " plugin" ) {
75+ // Hack to skip leading new line
76+ scanner .Scan ()
7677 continue
7778 }
7879 if strings .Contains (l , " Transform(" ) {
@@ -93,7 +94,7 @@ func ConvertToBuiltInPlugin() (retErr error) {
9394 }
9495 w .write ("" )
9596 w .write ("func New" + root + "Plugin() resmap." + pType .String () + "Plugin {" )
96- w .write (" return &" + root + "Plugin{}" )
97+ w .write (" return &" + root + "Plugin{}" )
9798 w .write ("}" )
9899
99100 return nil
You can’t perform that action at this time.
0 commit comments