diff --git a/Makefile b/Makefile index 61386ff..0ac156e 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ ################################################################################ # Variables # ################################################################################ -APP_NAME = lorry +APP_NAME = dbctl VERSION ?= 0.1.0-alpha.0 GITHUB_PROXY ?= INIT_ENV ?= false @@ -108,7 +108,7 @@ help: ## Display this help. @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) .PHONY: all -all: lorry ## Make all cmd binaries. +all: dbctl ## Make all cmd binaries. ##@ Development @@ -180,17 +180,17 @@ goimports: goimportstool ## Run goimports against code. $(GOIMPORTS) -local github.com/apecloud/lorry -w $$(git ls-files|grep "\.go$$") -.PHONY: lorry -lorry: build-checks ## Build lorry binary. - $(GO) build -tags $(BUILD_TAGS) -ldflags=${LD_FLAGS} -o bin/lorry ./cmd/lorry/main.go +.PHONY: dbctl +dbctl: build-checks ## Build dbctl binary. + $(GO) build -tags $(BUILD_TAGS) -ldflags=${LD_FLAGS} -o bin/dbctl ./cmd/dbctl/main.go .PHONY: run run: fmt vet - $(GO) run ./cmd/lorry/main.go --config-path ./config/components service + $(GO) run ./cmd/dbctl/main.go --config-path ./config/components service # Run with Delve for development purposes # Delve is a debugger for the Go programming language. More info: https://github.com/go-delve/delve -GO_PACKAGE=./cmd/lorry/main.go +GO_PACKAGE=./cmd/dbctl/main.go ARGUMENTS= DEBUG_PORT=2345 run-delve: manifests fmt vet ## Run Delve debugger. diff --git a/cmd/lorry/main.go b/cmd/dbctl/main.go similarity index 100% rename from cmd/lorry/main.go rename to cmd/dbctl/main.go diff --git a/ctl/createuser.go b/ctl/createuser.go index 2a9596d..e32784c 100644 --- a/ctl/createuser.go +++ b/ctl/createuser.go @@ -76,7 +76,7 @@ var CreateUserCmd = &cobra.Command{ Use: "createuser", Short: "create user.", Example: ` -lorry createuser --username xxx --password xxx +dbctl createuser --username xxx --password xxx `, Args: cobra.MinimumNArgs(0), Run: CmdRunner(createUserOptions), diff --git a/ctl/ctr.go b/ctl/ctr.go index c19827e..264f270 100644 --- a/ctl/ctr.go +++ b/ctl/ctr.go @@ -50,17 +50,19 @@ var opts = kzap.Options{ } var RootCmd = &cobra.Command{ - Use: "lorry", - Short: "Lorry command line interface", + Use: "dbctl", + Short: "dbctl command line interface", Long: ` - _ ____ _____ _______ __ - | | / __ \| __ \| __ \ \ / / - | | | | | | |__) | |__) \ \_/ / - | | | | | | _ /| _ / \ / - | |___| |__| | | \ \| | \ \ | | - |______\____/|_| \_\_| \_\ |_| +_ ______ _______ ______ _ _______ _______ _ _______ ______ ______ _______ _________ _ +| \ /\|\ /|( ___ \ ( ____ \( ___ \ ( \ ( ___ )( ____ \| \ /\( ____ \ ( __ \ ( ___ \ ( ____ \\__ __/( \ +| \ / /| ) ( || ( ) )| ( \/| ( ) )| ( | ( ) || ( \/| \ / /| ( \/ | ( \ )| ( ) )| ( \/ ) ( | ( +| (_/ / | | | || (__/ / | (__ | (__/ / | | | | | || | | (_/ / | (_____ | | ) || (__/ / | | | | | | +| _ ( | | | || __ ( | __) | __ ( | | | | | || | | _ ( (_____ ) | | | || __ ( | | | | | | +| ( \ \ | | | || ( \ \ | ( | ( \ \ | | | | | || | | ( \ \ ) | | | ) || ( \ \ | | | | | | +| / \ \| (___) || )___) )| (____/\| )___) )| (____/\| (___) || (____/\| / \ \/\____) | | (__/ )| )___) )| (____/\ | | | (____/\ +|_/ \/(_______)|/ \___/ (_______/|/ \___/ (_______/(_______)(_______/|_/ \/\_______) (______/ |/ \___/ (_______/ )_( (_______/ =============================== -Lorry command line interface`, +dbctl command line interface`, PersistentPreRunE: func(cmd *cobra.Command, _ []string) error { err := viper.BindPFlags(pflag.CommandLine) if err != nil { diff --git a/ctl/deleteuser.go b/ctl/deleteuser.go index 3282b9a..1d68104 100644 --- a/ctl/deleteuser.go +++ b/ctl/deleteuser.go @@ -69,7 +69,7 @@ var DeleteUserCmd = &cobra.Command{ Use: "deleteuser", Short: "delete user.", Example: ` -lorry deleteuser --username xxx +dbctl deleteuser --username xxx `, Args: cobra.MinimumNArgs(0), Run: CmdRunner(deleteUserOptions), diff --git a/ctl/describeuser.go b/ctl/describeuser.go index b73fe2f..77ac0bf 100644 --- a/ctl/describeuser.go +++ b/ctl/describeuser.go @@ -70,7 +70,7 @@ var DescribeUserCmd = &cobra.Command{ Use: "describeuser", Short: "describe user.", Example: ` -lorry describeuser --username xxx +dbctl describeuser --username xxx `, Args: cobra.MinimumNArgs(0), Run: CmdRunner(describeUserOptions), diff --git a/ctl/getrole.go b/ctl/getrole.go index 8ed32e0..d7d0c57 100644 --- a/ctl/getrole.go +++ b/ctl/getrole.go @@ -63,7 +63,7 @@ var GetRoleCmd = &cobra.Command{ Use: "getrole", Short: "get role of the replica.", Example: ` -lorry getrole +dbctl getrole `, Args: cobra.MinimumNArgs(0), Run: CmdRunner(getRoleOptions), diff --git a/ctl/grantrole.go b/ctl/grantrole.go index 68b8f42..8d3c898 100644 --- a/ctl/grantrole.go +++ b/ctl/grantrole.go @@ -72,7 +72,7 @@ var GrantUserRoleCmd = &cobra.Command{ Use: "grant-role", Short: "grant user role.", Example: ` -lorry grant-role --username xxx --rolename xxx +dbctl grant-role --username xxx --rolename xxx `, Args: cobra.MinimumNArgs(0), Run: CmdRunner(grantUserRoleOptions), diff --git a/ctl/join.go b/ctl/join.go index 2a3d11c..6137735 100644 --- a/ctl/join.go +++ b/ctl/join.go @@ -56,7 +56,7 @@ var JoinCmd = &cobra.Command{ Use: "joinmember", Short: "execute a join member request.", Example: ` -lorry joinmember +dbctl joinmember `, Args: cobra.MinimumNArgs(0), Run: CmdRunner(joinOptions), diff --git a/ctl/leave.go b/ctl/leave.go index 6576f7d..adbbd41 100644 --- a/ctl/leave.go +++ b/ctl/leave.go @@ -56,7 +56,7 @@ var LeaveCmd = &cobra.Command{ Use: "leavemember", Short: "execute a leave member request.", Example: ` -lorry leavemember +dbctl leavemember `, Args: cobra.MinimumNArgs(0), Run: CmdRunner(leaveOptions), diff --git a/ctl/listsystemaccounts.go b/ctl/listsystemaccounts.go index b61c423..f69fdb8 100644 --- a/ctl/listsystemaccounts.go +++ b/ctl/listsystemaccounts.go @@ -67,7 +67,7 @@ var ListSystemAccountsCmd = &cobra.Command{ Use: "listsystemaccounts", Short: "list system accounts.", Example: ` -lorry listsystemaccounts +dbctl listsystemaccounts `, Args: cobra.MinimumNArgs(0), Run: CmdRunner(listSystemAccountsOptions), diff --git a/ctl/listusers.go b/ctl/listusers.go index 4bf5979..0bc9b73 100644 --- a/ctl/listusers.go +++ b/ctl/listusers.go @@ -71,7 +71,7 @@ var ListUsersCmd = &cobra.Command{ Use: "listusers", Short: "list normal users.", Example: ` -lorry listusers +dbctl listusers `, Args: cobra.MinimumNArgs(0), Run: CmdRunner(listUsersOptions), diff --git a/ctl/revokerole.go b/ctl/revokerole.go index 1d76006..8a86298 100644 --- a/ctl/revokerole.go +++ b/ctl/revokerole.go @@ -62,7 +62,7 @@ var RevokeUserRoleCmd = &cobra.Command{ Use: "revoke-role", Short: "revoke user role.", Example: ` -lorry revoke-role --username xxx --rolename xxx +dbctl revoke-role --username xxx --rolename xxx `, Args: cobra.MinimumNArgs(0), Run: CmdRunner(revokeUserRoleOptions), diff --git a/ctl/service.go b/ctl/service.go index 0b1a968..a05da40 100644 --- a/ctl/service.go +++ b/ctl/service.go @@ -33,9 +33,9 @@ import ( var ServiceCmd = &cobra.Command{ Use: "service", - Short: "Run Lorry as a daemon and provide api service.", + Short: "Run dbctl as a daemon and provide api service.", Example: ` -lorry service +dbctl service `, Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { diff --git a/ctl/switchover.go b/ctl/switchover.go index ee81aef..c2e4d28 100644 --- a/ctl/switchover.go +++ b/ctl/switchover.go @@ -75,7 +75,7 @@ var SwitchCmd = &cobra.Command{ Use: "switchover", Short: "execute a switchover request.", Example: ` -lorry switchover --primary xxx --candidate xxx +dbctl switchover --primary xxx --candidate xxx `, Args: cobra.MinimumNArgs(0), Run: CmdRunner(switchoverOptions), diff --git a/docker/Dockerfile b/docker/Dockerfile index 5a7e364..8a49eca 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,5 @@ -# Build the lorry image -# includes lorry and configurations. +# Build the dbctl image +# includes dbctl and configurations. ## docker buildx build injected build-args: #BUILDPLATFORM — matches the current machine. (e.g. linux/amd64) @@ -35,7 +35,7 @@ RUN --mount=type=bind,target=. \ RUN --mount=type=bind,target=. \ --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg/mod \ - CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="${LD_FLAGS}" -a -o /out/lorry cmd/lorry/main.go + CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="${LD_FLAGS}" -a -o /out/dbctl cmd/dbctl/main.go # Use alpine with tag 20230329 is corresponding to "edge" tag (latest release to date is 3.18) as of 20230625 FROM docker.io/alpine:edge as dist @@ -43,6 +43,6 @@ ARG APK_MIRROR # copy files COPY config/ /config/ -COPY --from=builder /out/lorry /bin +COPY --from=builder /out/dbctl /bin USER 65532:65532