Skip to content

Commit

Permalink
Merge pull request #5303 from antoooks/refactor/ci-tasks-improvement-new
Browse files Browse the repository at this point in the history
refactor/ci tasks improvement new
  • Loading branch information
k8s-ci-robot authored Oct 19, 2023
2 parents bde28b1 + d91ea65 commit 752bb2e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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
Expand Down
22 changes: 20 additions & 2 deletions Makefile-plugins.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions cmd/pluginator/internal/builtinplugin/builtinplugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(") {
Expand All @@ -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
Expand Down

0 comments on commit 752bb2e

Please sign in to comment.