diff --git a/Makefile b/Makefile index e50ebf4450..20749393be 100644 --- a/Makefile +++ b/Makefile @@ -108,6 +108,9 @@ verify-kustomize-repo: \ .PHONY: prow-presubmit-check prow-presubmit-check: \ install-tools \ + workspace-sync \ + generate-kustomize-builtin-plugins \ + builtin-plugins-diff \ test-unit-kustomize-plugins \ test-go-mod \ build-non-plugin-all \ @@ -181,7 +184,12 @@ test-examples-kustomize-against-HEAD: $(MYGOBIN)/kustomize $(MYGOBIN)/mdrip test-examples-kustomize-against-latest-release: $(MYGOBIN)/mdrip ./hack/testExamplesAgainstKustomize.sh v5@$(LATEST_RELEASE) - +# Pushes dependencies in the go.work file back to go.mod files of each workspace module. +.PHONY: workspace-sync +workspace-sync: + go work sync + ./hack/doGoMod.sh tidy + # --- Cleanup targets --- .PHONY: clean clean: clean-kustomize-external-go-plugin uninstall-tools diff --git a/Makefile-plugins.mk b/Makefile-plugins.mk index 6cc49b3880..a1edf91bdc 100644 --- a/Makefile-plugins.mk +++ b/Makefile-plugins.mk @@ -89,9 +89,27 @@ $(pGen)/%.go: $(MYGOBIN)/pluginator $(MYGOBIN)/goimports $(MYGOBIN)/goimports -w $*.go \ ) -# Target is for debugging. +# Generate builtin plugins .PHONY: generate-kustomize-builtin-plugins -generate-kustomize-builtin-plugins: $(builtinplugins) +generate-kustomize-builtin-plugins: $(builtplugins) + for plugin in $(abspath $(wildcard $(pSrc)/*)); do \ + echo "generating $${plugin} ..."; \ + set -e; \ + cd $${plugin}; \ + go generate pluginator .; \ + done + +# Check for diff by comparing current revision of generated plugins on HEAD and newly generated plugins on local branch, +# If diff is found, throw error code 1 +.PHONY: builtin-plugins-diff +builtin-plugins-diff: $(builtplugins) + for file in $(abspath $(builtinplugins)); do \ + echo "Checking for diff... $${file}" ; \ + set -e ; \ + if [ "`git diff $${file} | wc -c`" -gt 0 ]; then\ + echo "Error(1): diff found on $${file}"; exit 1; \ + fi \ + done .PHONY: build-kustomize-external-go-plugin build-kustomize-external-go-plugin: diff --git a/cmd/pluginator/internal/builtinplugin/builtinplugin.go b/cmd/pluginator/internal/builtinplugin/builtinplugin.go index e6d66b8b0f..af97000d28 100644 --- a/cmd/pluginator/internal/builtinplugin/builtinplugin.go +++ b/cmd/pluginator/internal/builtinplugin/builtinplugin.go @@ -62,7 +62,6 @@ func ConvertToBuiltInPlugin() (retErr error) { w.write( fmt.Sprintf( "// pluginator %s\n", provenance.GetProvenance().Short())) - w.write("\n") w.write("package " + packageForGeneratedCode) pType := unknown @@ -73,6 +72,8 @@ func ConvertToBuiltInPlugin() (retErr error) { continue } if strings.HasPrefix(l, "var "+konfig.PluginSymbol+" plugin") { + // Hack to skip leading new line + scanner.Scan() continue } if strings.Contains(l, " Transform(") { @@ -93,7 +94,7 @@ func ConvertToBuiltInPlugin() (retErr error) { } w.write("") w.write("func New" + root + "Plugin() resmap." + pType.String() + "Plugin {") - w.write(" return &" + root + "Plugin{}") + w.write(" return &" + root + "Plugin{}") w.write("}") return nil