Skip to content

Commit

Permalink
Merge pull request #3 from apecloud/support/rename_to_dbctl
Browse files Browse the repository at this point in the history
chore: rename lorry to dbctl
  • Loading branch information
xuriwuyun authored Aug 15, 2024
2 parents 6ba4d15 + 15cede3 commit 5164668
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 33 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
################################################################################
# Variables #
################################################################################
APP_NAME = lorry
APP_NAME = dbctl
VERSION ?= 0.1.0-alpha.0
GITHUB_PROXY ?=
INIT_ENV ?= false
Expand Down Expand Up @@ -108,7 +108,7 @@ help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\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

Expand Down Expand Up @@ -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.
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion ctl/createuser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
20 changes: 11 additions & 9 deletions ctl/ctr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion ctl/deleteuser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion ctl/describeuser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion ctl/getrole.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion ctl/grantrole.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion ctl/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion ctl/leave.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion ctl/listsystemaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion ctl/listusers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion ctl/revokerole.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions ctl/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion ctl/switchover.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
8 changes: 4 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -35,14 +35,14 @@ 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
ARG APK_MIRROR

# copy files
COPY config/ /config/
COPY --from=builder /out/lorry /bin
COPY --from=builder /out/dbctl /bin

USER 65532:65532

0 comments on commit 5164668

Please sign in to comment.