diff --git a/Documentation/getting-started.md b/Documentation/getting-started.md index c6f17a6c3..dc17aa51e 100644 --- a/Documentation/getting-started.md +++ b/Documentation/getting-started.md @@ -73,7 +73,7 @@ TODO: show how castle can be configured from cloud-init and started At this point the storage cluster is up and running. -### 3) Using castlectl +### 3) Using castle Now that the cluster is up and running, you can communicate with it using castletctl. First you need export an environment variable for the cluster url: @@ -91,7 +91,7 @@ export CASTLE_DISCOVERY_DNS=mycluster.acme.com Let's list the nodes that are part of the cluster: ``` -castlectl node ls +castle node ls ``` the output shows the nodes that are part of the cluster @@ -108,7 +108,7 @@ ADDRESS STATE CLUSTER SIZE LOCATION To create a volume run the following: ``` -castlectl volume create myvolume 100GiB +castle volume create myvolume 100GiB ``` This creates a volume that can be used as a block device from client nodes. diff --git a/Makefile b/Makefile index 3f5eabf82..2b91ca639 100644 --- a/Makefile +++ b/Makefile @@ -77,6 +77,8 @@ CLIENT_SERVER_PLATFORMS ?= linux_amd64 linux_arm64 CLIENT_ONLY_PLATFORMS ?= darwin_amd64 windows_amd64 ALL_PLATFORMS ?= $(CLIENT_SERVER_PLATFORMS) $(CLIENT_ONLY_PLATFORMS) +GO_PROJECT=github.com/quantum/castle + # ==================================================================================== # Setup Castled @@ -103,7 +105,7 @@ CEPHD_PLATFORM = $(GOOS)_$(GOARCH) # to force go to rebuild cephd CEPHD_TOUCH_ON_BUILD = pkg/cephmgr/cephd/dummy.cc -GO_CGO_PACKAGES=cmd/castled +GO_CGO_PACKAGES=$(GO_PROJECT)/cmd/castled CGO_LDFLAGS = -L$(abspath $(CEPHD_BUILD_DIR)/$(CEPHD_PLATFORM)/lib) CGO_PREREQS = cephd.build @@ -116,14 +118,13 @@ endif # ==================================================================================== # Setup Go projects -GO_PROJECT=github.com/quantum/castle GO_WORK_DIR = $(WORKDIR) GO_BIN_DIR = $(BIN_DIR) ifeq ($(STATIC),1) -GO_STATIC_PACKAGES=cmd/castlectl +GO_STATIC_PACKAGES=$(GO_PROJECT) else -GO_NONSTATIC_PACKAGES=cmd/castlectl +GO_NONSTATIC_PACKAGES=$(GO_PROJECT) endif GO_TOOL_FLAGS=$(BUILDFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' diff --git a/build/makelib/golang.mk b/build/makelib/golang.mk index 12015a43b..fa9eea2ab 100644 --- a/build/makelib/golang.mk +++ b/build/makelib/golang.mk @@ -101,15 +101,15 @@ endif .PHONY: go.build go.build: go.vet go.fmt $(CGO_PREREQS) - $(foreach p,$(GO_NONSTATIC_PACKAGES),@CGO_ENABLED=1 $(GO) build -v -i $(GO_PKG_FLAGS) -o $(GO_OUT_DIR)/$(lastword $(subst /, ,$(p))) $(GO_TOOL_FLAGS) $(GO_PROJECT)/$(p)/...) - $(foreach p,$(GO_CGO_PACKAGES),@CGO_ENABLED=1 $(GO) build -v -i $(GO_PKG_FLAGS) -o $(GO_OUT_DIR)/$(lastword $(subst /, ,$(p))) $(GO_TOOL_FLAGS) $(GO_PROJECT)/$(p)/...) - $(foreach p,$(GO_STATIC_PACKAGES),@CGO_ENABLED=0 $(GO) build -v -i $(GO_PKG_STATIC_FLAGS) -o $(GO_OUT_DIR)/$(lastword $(subst /, ,$(p))) $(GO_TOOL_FLAGS) $(GO_PROJECT)/$(p)/...) + $(foreach p,$(GO_NONSTATIC_PACKAGES),@CGO_ENABLED=1 $(GO) build -v -i $(GO_PKG_FLAGS) -o $(GO_OUT_DIR)/$(lastword $(subst /, ,$(p))) $(GO_TOOL_FLAGS) $(p)) + $(foreach p,$(GO_CGO_PACKAGES),@CGO_ENABLED=1 $(GO) build -v -i $(GO_PKG_FLAGS) -o $(GO_OUT_DIR)/$(lastword $(subst /, ,$(p))) $(GO_TOOL_FLAGS) $(p)) + $(foreach p,$(GO_STATIC_PACKAGES),@CGO_ENABLED=0 $(GO) build -v -i $(GO_PKG_STATIC_FLAGS) -o $(GO_OUT_DIR)/$(lastword $(subst /, ,$(p))) $(GO_TOOL_FLAGS) $(p)) .PHONY: go.install go.install: go.vet go.fmt $(CGO_PREREQS) - $(foreach p,$(GO_NONSTATIC_PACKAGES),@CGO_ENABLED=1 $(GO) install -v $(GO_PKG_FLAGS) $(GO_TOOL_FLAGS) $(GO_PROJECT)/$(p)/...) - $(foreach p,$(GO_CGO_PACKAGES),@CGO_ENABLED=1 $(GO) install -v $(GO_PKG_FLAGS) $(GO_TOOL_FLAGS) $(GO_PROJECT)/$(p)/...) - $(foreach p,$(GO_STATIC_PACKAGES),@CGO_ENABLED=0 $(GO) install -v $(GO_PKG_STATIC_FLAGS) $(GO_TOOL_FLAGS) $(GO_PROJECT)/$(p)/...) + $(foreach p,$(GO_NONSTATIC_PACKAGES),@CGO_ENABLED=1 $(GO) install -v $(GO_PKG_FLAGS) $(GO_TOOL_FLAGS) $(p)) + $(foreach p,$(GO_CGO_PACKAGES),@CGO_ENABLED=1 $(GO) install -v $(GO_PKG_FLAGS) $(GO_TOOL_FLAGS) $(p)) + $(foreach p,$(GO_STATIC_PACKAGES),@CGO_ENABLED=0 $(GO) install -v $(GO_PKG_STATIC_FLAGS) $(GO_TOOL_FLAGS) $(p)) .PHONY: go.test go.test: go.vet go.fmt $(CGO_PREREQS) diff --git a/build/release/binaries.sh b/build/release/binaries.sh index 9be8ac32d..5a02674cd 100755 --- a/build/release/binaries.sh +++ b/build/release/binaries.sh @@ -14,7 +14,7 @@ build() { local ext=".exe" fi - local files=( castlectl${ext} ) + local files=( castle${ext} ) if [[ ${type} == "both" ]]; then files+=( castled${ext} ) diff --git a/build/release/common.sh b/build/release/common.sh index 35919f7ff..b995e6b64 100644 --- a/build/release/common.sh +++ b/build/release/common.sh @@ -22,7 +22,7 @@ layout_root() { mkdir -p $dir/root/etc/ssl/certs cp $bindir/castled $dir/root/usr/bin - cp $bindir/castlectl $dir/root/usr/bin + cp $bindir/castle $dir/root/usr/bin cp /etc/ssl/certs/ca-certificates.crt $dir/root/etc/ssl/certs } diff --git a/cmd/castlectl/block-create.go b/cmd/castle/block-create.go similarity index 96% rename from cmd/castlectl/block-create.go rename to cmd/castle/block-create.go index 7e1fa6be0..6aba08b0f 100644 --- a/cmd/castlectl/block-create.go +++ b/cmd/castle/block-create.go @@ -1,10 +1,10 @@ -package main +package castle import ( "fmt" "net/http" - "github.com/quantum/castle/pkg/castlectl/client" + "github.com/quantum/castle/pkg/castle/client" "github.com/quantum/castle/pkg/model" "github.com/quantum/castle/pkg/util/flags" "github.com/spf13/cobra" diff --git a/cmd/castlectl/block-create_test.go b/cmd/castle/block-create_test.go similarity index 93% rename from cmd/castlectl/block-create_test.go rename to cmd/castle/block-create_test.go index d61e2fa56..b1b9dfa0b 100644 --- a/cmd/castlectl/block-create_test.go +++ b/cmd/castle/block-create_test.go @@ -1,10 +1,10 @@ -package main +package castle import ( "fmt" "testing" - "github.com/quantum/castle/pkg/castlectl/test" + "github.com/quantum/castle/pkg/castle/test" "github.com/quantum/castle/pkg/model" "github.com/stretchr/testify/assert" ) diff --git a/cmd/castlectl/block-list.go b/cmd/castle/block-list.go similarity index 96% rename from cmd/castlectl/block-list.go rename to cmd/castle/block-list.go index f474ad9a3..5e8cd736a 100644 --- a/cmd/castlectl/block-list.go +++ b/cmd/castle/block-list.go @@ -1,4 +1,4 @@ -package main +package castle import ( "bytes" @@ -6,7 +6,7 @@ import ( "net/http" "strings" - "github.com/quantum/castle/pkg/castlectl/client" + "github.com/quantum/castle/pkg/castle/client" "github.com/quantum/castle/pkg/util/display" "github.com/quantum/castle/pkg/util/exec" "github.com/quantum/castle/pkg/util/flags" diff --git a/cmd/castlectl/block-list_test.go b/cmd/castle/block-list_test.go similarity index 97% rename from cmd/castlectl/block-list_test.go rename to cmd/castle/block-list_test.go index 1f2f5704d..d395fa95b 100644 --- a/cmd/castlectl/block-list_test.go +++ b/cmd/castle/block-list_test.go @@ -1,4 +1,4 @@ -package main +package castle import ( "fmt" @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/quantum/castle/pkg/castlectl/test" + "github.com/quantum/castle/pkg/castle/test" "github.com/quantum/castle/pkg/model" exectest "github.com/quantum/castle/pkg/util/exec/test" ) diff --git a/cmd/castlectl/block-mount.go b/cmd/castle/block-mount.go similarity index 99% rename from cmd/castlectl/block-mount.go rename to cmd/castle/block-mount.go index 55e0b5750..353c6dfbe 100644 --- a/cmd/castlectl/block-mount.go +++ b/cmd/castle/block-mount.go @@ -1,4 +1,4 @@ -package main +package castle import ( "fmt" @@ -10,7 +10,7 @@ import ( "strings" "time" - "github.com/quantum/castle/pkg/castlectl/client" + "github.com/quantum/castle/pkg/castle/client" "github.com/quantum/castle/pkg/model" "github.com/quantum/castle/pkg/util/exec" "github.com/quantum/castle/pkg/util/flags" diff --git a/cmd/castlectl/block-mount_test.go b/cmd/castle/block-mount_test.go similarity index 97% rename from cmd/castlectl/block-mount_test.go rename to cmd/castle/block-mount_test.go index b824867f6..a7693fc61 100644 --- a/cmd/castlectl/block-mount_test.go +++ b/cmd/castle/block-mount_test.go @@ -1,4 +1,4 @@ -package main +package castle import ( "fmt" @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/quantum/castle/pkg/castlectl/test" + "github.com/quantum/castle/pkg/castle/test" "github.com/quantum/castle/pkg/model" exectest "github.com/quantum/castle/pkg/util/exec/test" ) diff --git a/cmd/castlectl/block-unmount.go b/cmd/castle/block-unmount.go similarity index 99% rename from cmd/castlectl/block-unmount.go rename to cmd/castle/block-unmount.go index 2ba8919c0..5df33f989 100644 --- a/cmd/castlectl/block-unmount.go +++ b/cmd/castle/block-unmount.go @@ -1,4 +1,4 @@ -package main +package castle import ( "fmt" diff --git a/cmd/castlectl/block-unmount_test.go b/cmd/castle/block-unmount_test.go similarity index 99% rename from cmd/castlectl/block-unmount_test.go rename to cmd/castle/block-unmount_test.go index a79e8af85..dfd865010 100644 --- a/cmd/castlectl/block-unmount_test.go +++ b/cmd/castle/block-unmount_test.go @@ -1,4 +1,4 @@ -package main +package castle import ( "fmt" diff --git a/cmd/castlectl/block.go b/cmd/castle/block.go similarity index 95% rename from cmd/castlectl/block.go rename to cmd/castle/block.go index 3434d5a81..2518f5d3d 100644 --- a/cmd/castlectl/block.go +++ b/cmd/castle/block.go @@ -1,4 +1,4 @@ -package main +package castle import "github.com/spf13/cobra" diff --git a/cmd/castlectl/castlectl.go b/cmd/castle/castle.go similarity index 92% rename from cmd/castlectl/castlectl.go rename to cmd/castle/castle.go index be8001d49..04734d50e 100644 --- a/cmd/castlectl/castlectl.go +++ b/cmd/castle/castle.go @@ -1,4 +1,4 @@ -package main +package castle import ( "fmt" @@ -21,16 +21,16 @@ const ( outputTabWidth = 0 outputPadChar = ' ' logFileDir = "/tmp/castle/log" - logFileName = "castlectl.log" + logFileName = "castle.log" ) var rootCmd = &cobra.Command{ - Use: "castlectl", + Use: "castle", Short: "A command line client for working with a castle cluster", Long: `https://github.com/quantum/castle`, } -func main() { +func Main() { // set up logging to a log file instead of stdout (only command output and errors should go to stdout/stderr) if err := os.MkdirAll(logFileDir, 0744); err != nil { log.Fatalf("failed to create logging dir '%s': %+v", logFileDir, err) @@ -45,7 +45,7 @@ func main() { addCommands() if err := rootCmd.Execute(); err != nil { - fmt.Printf("castlectl error: %+v\n", err) + fmt.Printf("castle error: %+v\n", err) } } diff --git a/cmd/castlectl/node-list.go b/cmd/castle/node-list.go similarity index 95% rename from cmd/castlectl/node-list.go rename to cmd/castle/node-list.go index bb4879f86..153f12a26 100644 --- a/cmd/castlectl/node-list.go +++ b/cmd/castle/node-list.go @@ -1,11 +1,11 @@ -package main +package castle import ( "bytes" "fmt" "net/http" - "github.com/quantum/castle/pkg/castlectl/client" + "github.com/quantum/castle/pkg/castle/client" "github.com/quantum/castle/pkg/model" "github.com/quantum/castle/pkg/util/display" "github.com/spf13/cobra" diff --git a/cmd/castlectl/node-list_test.go b/cmd/castle/node-list_test.go similarity index 94% rename from cmd/castlectl/node-list_test.go rename to cmd/castle/node-list_test.go index bb999089a..2b5d51716 100644 --- a/cmd/castlectl/node-list_test.go +++ b/cmd/castle/node-list_test.go @@ -1,4 +1,4 @@ -package main +package castle import ( "fmt" @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/quantum/castle/pkg/castlectl/test" + "github.com/quantum/castle/pkg/castle/test" "github.com/quantum/castle/pkg/model" ) diff --git a/cmd/castlectl/node.go b/cmd/castle/node.go similarity index 93% rename from cmd/castlectl/node.go rename to cmd/castle/node.go index bcabf10d0..a2b52151e 100644 --- a/cmd/castlectl/node.go +++ b/cmd/castle/node.go @@ -1,4 +1,4 @@ -package main +package castle import "github.com/spf13/cobra" diff --git a/cmd/castlectl/pool-create.go b/cmd/castle/pool-create.go similarity index 98% rename from cmd/castlectl/pool-create.go rename to cmd/castle/pool-create.go index b7c4da56b..ed42c54d3 100644 --- a/cmd/castlectl/pool-create.go +++ b/cmd/castle/pool-create.go @@ -1,10 +1,10 @@ -package main +package castle import ( "fmt" "net/http" - "github.com/quantum/castle/pkg/castlectl/client" + "github.com/quantum/castle/pkg/castle/client" "github.com/quantum/castle/pkg/model" "github.com/quantum/castle/pkg/util/flags" "github.com/spf13/cobra" diff --git a/cmd/castlectl/pool-create_test.go b/cmd/castle/pool-create_test.go similarity index 98% rename from cmd/castlectl/pool-create_test.go rename to cmd/castle/pool-create_test.go index 5c1db070b..145e9a65f 100644 --- a/cmd/castlectl/pool-create_test.go +++ b/cmd/castle/pool-create_test.go @@ -1,10 +1,10 @@ -package main +package castle import ( "fmt" "testing" - "github.com/quantum/castle/pkg/castlectl/test" + "github.com/quantum/castle/pkg/castle/test" "github.com/quantum/castle/pkg/model" "github.com/stretchr/testify/assert" ) diff --git a/cmd/castlectl/pool-list.go b/cmd/castle/pool-list.go similarity index 95% rename from cmd/castlectl/pool-list.go rename to cmd/castle/pool-list.go index 4c777b7b7..0e969a428 100644 --- a/cmd/castlectl/pool-list.go +++ b/cmd/castle/pool-list.go @@ -1,11 +1,11 @@ -package main +package castle import ( "bytes" "fmt" "net/http" - "github.com/quantum/castle/pkg/castlectl/client" + "github.com/quantum/castle/pkg/castle/client" "github.com/quantum/castle/pkg/model" "github.com/quantum/castle/pkg/util/display" "github.com/quantum/castle/pkg/util/flags" diff --git a/cmd/castlectl/pool-list_test.go b/cmd/castle/pool-list_test.go similarity index 95% rename from cmd/castlectl/pool-list_test.go rename to cmd/castle/pool-list_test.go index ac0200aaf..2cb5fb6cb 100644 --- a/cmd/castlectl/pool-list_test.go +++ b/cmd/castle/pool-list_test.go @@ -1,4 +1,4 @@ -package main +package castle import ( "fmt" @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/quantum/castle/pkg/castlectl/test" + "github.com/quantum/castle/pkg/castle/test" "github.com/quantum/castle/pkg/model" ) diff --git a/cmd/castlectl/pool.go b/cmd/castle/pool.go similarity index 94% rename from cmd/castlectl/pool.go rename to cmd/castle/pool.go index f95968c31..bff51a277 100644 --- a/cmd/castlectl/pool.go +++ b/cmd/castle/pool.go @@ -1,4 +1,4 @@ -package main +package castle import "github.com/spf13/cobra" diff --git a/cmd/castled/castled.go b/cmd/castled/main.go similarity index 100% rename from cmd/castled/castled.go rename to cmd/castled/main.go diff --git a/main.go b/main.go new file mode 100644 index 000000000..d4f208a79 --- /dev/null +++ b/main.go @@ -0,0 +1,7 @@ +package main + +import "github.com/quantum/castle/cmd/castle" + +func main() { + castle.Main() +} diff --git a/pkg/castlectl/client/block.go b/pkg/castle/client/block.go similarity index 100% rename from pkg/castlectl/client/block.go rename to pkg/castle/client/block.go diff --git a/pkg/castlectl/client/client.go b/pkg/castle/client/client.go similarity index 100% rename from pkg/castlectl/client/client.go rename to pkg/castle/client/client.go diff --git a/pkg/castlectl/client/client_test.go b/pkg/castle/client/client_test.go similarity index 100% rename from pkg/castlectl/client/client_test.go rename to pkg/castle/client/client_test.go diff --git a/pkg/castlectl/client/node.go b/pkg/castle/client/node.go similarity index 100% rename from pkg/castlectl/client/node.go rename to pkg/castle/client/node.go diff --git a/pkg/castlectl/client/pool.go b/pkg/castle/client/pool.go similarity index 100% rename from pkg/castlectl/client/pool.go rename to pkg/castle/client/pool.go diff --git a/pkg/castlectl/test/mockclient.go b/pkg/castle/test/mockclient.go similarity index 97% rename from pkg/castlectl/test/mockclient.go rename to pkg/castle/test/mockclient.go index d6b3081b8..38ee6a24f 100644 --- a/pkg/castlectl/test/mockclient.go +++ b/pkg/castle/test/mockclient.go @@ -3,7 +3,7 @@ package test import ( "net/http" - "github.com/quantum/castle/pkg/castlectl/client" + "github.com/quantum/castle/pkg/castle/client" "github.com/quantum/castle/pkg/model" )