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

Commit

Permalink
Add make targets - install-plugin-local (#3289)
Browse files Browse the repository at this point in the history
As part of this changes:
-The command 'tanzu builder cli compile --match package --version v0.27.0-dev' is updated to make "--version" flag as optional
-New make target 'build-plugin-local' has added, to build the given plugin locally.
-New make target 'install-plugin-local' has added, to build and install the given plugin locally.

Co-authored-by: Chandra Pamuluri <cpamuluri@cpamuluri-a01.vmware.com>
  • Loading branch information
chandrareddyp and Chandra Pamuluri authored Sep 21, 2022
1 parent 432ae78 commit ed3014a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,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 @@ -244,6 +245,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

0 comments on commit ed3014a

Please sign in to comment.