Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Update the builder plugin to make version flag optional and add new 'build-plugin-local' make target #3289

Merged
merged 1 commit into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ endif
# Package tooling related variables
PACKAGE_VERSION ?= ${BUILD_VERSION}
REPO_BUNDLE_VERSION ?= ${BUILD_VERSION}
PLUGIN_PATH ?= ./cmd/cli/plugin

DOCKER_DIR := /app
SWAGGER=docker run --rm -v ${PWD}:${DOCKER_DIR}:$(DOCKER_VOL_OPTS) quay.io/goswagger/swagger:v0.21.0
Expand Down Expand Up @@ -240,6 +241,20 @@ build-plugin-admin-with-oci-discovery: ${CLI_ADMIN_JOBS_OCI_DISCOVERY} publish-a
.PHONY: build-plugin-admin-with-local-discovery
build-plugin-admin-with-local-discovery: ${CLI_ADMIN_JOBS_LOCAL_DISCOVERY} publish-admin-plugins-all-local ## Build Tanzu CLI admin plugins with Local standalone discovery

.PHONY: build-plugin-local
build-plugin-local: prepare-builder ## Build given CLI Plugin locally, needs PLUGIN_NAME
@if [ "${PLUGIN_NAME}" = "" ] || [ ! -d ${PLUGIN_PATH}/${PLUGIN_NAME} ]; then \
echo "The PLUGIN_NAME: '${PLUGIN_NAME}' is not valid or not exists or empty, please provide valid PLUGIN_NAME." ; \
else \
$(BUILDER) cli compile --match "$(PLUGIN_NAME)" --version $(BUILD_VERSION) --ldflags "$(LD_FLAGS)" --path $(PLUGIN_PATH) --target local --artifacts artifacts/${GOHOSTOS}/${GOHOSTARCH}/cli ; \
fi

.PHONY: install-plugin-local
install-plugin-local: build-plugin-local ## Build and Install given CLI Plugin locally, needs PLUGIN_NAME
@if [ "${PLUGIN_NAME}" != "" ] && [ -d ${PLUGIN_PATH}/${PLUGIN_NAME} ]; then \
tanzu plugin install ${PLUGIN_NAME} --local $(ARTIFACTS_DIR)/$(GOHOSTOS)/$(GOHOSTARCH)/cli ; \
fi

.PHONY: build-plugin-admin-%
build-plugin-admin-%: prepare-builder
$(eval ARCH = $(word 3,$(subst -, ,$*)))
Expand Down
4 changes: 1 addition & 3 deletions cmd/cli/plugin-admin/builder/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func newCompileCmd() *cobra.Command {
},
}

cmd.Flags().StringVar(&compileArgs.Version, "version", "", "Version of the root cli (required)")
cmd.Flags().StringVar(&compileArgs.Version, "version", "", "Version of the core tanzu cli")
cmd.Flags().StringVar(&compileArgs.LDFlags, "ldflags", "", "ldflags to set on build")
cmd.Flags().StringVar(&compileArgs.Tags, "tags", "", "Tags to set on build")
cmd.Flags().StringVar(&compileArgs.Match, "match", compileArgs.Match, "Match a plugin name to build, supports globbing")
Expand All @@ -55,8 +55,6 @@ func newCompileCmd() *cobra.Command {
cmd.Flags().StringVar(&compileArgs.CorePath, "corepath", "", "Path for core binary")
cmd.Flags().StringVar(&compileArgs.GoPrivate, "goprivate", "", "Comma-separated list of glob patterns of module path prefixes to set as GOPRIVATE on build")

_ = cmd.MarkFlagRequired("version")

return cmd
}

Expand Down
4 changes: 0 additions & 4 deletions cmd/cli/plugin-admin/builder/command/cli_compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ type errInfo struct {
// setGlobals initializes a set of global variables used throughout the compile
// process, based on the arguments passed in.
func setGlobals(compileArgs *PluginCompileArgs) {
if compileArgs.Version == "" {
log.Fatal("version value must be set")
}

version = compileArgs.Version
artifactsDir = compileArgs.ArtifactsDir
ldflags = compileArgs.LDFlags
Expand Down