Skip to content

Commit

Permalink
Merge pull request #56 from caliban0/createServerWithStorage
Browse files Browse the repository at this point in the history
feat: add storage attachment functionality to server creation
  • Loading branch information
zalmarge authored Oct 29, 2024
2 parents 95d1fa2 + c461b0d commit d5340b7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/cherryctl_server_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Create a server.
Create a server in specified project.

```
cherryctl server create -p <project_id> --plan <plan_slug> --region <region_slug> [--hostname <hostname>] [--image <image_slug>] [--ssh-keys <ssh_key_ids>] [--ip-addresses <ip_addresses_ids>] [--os-partition-size <size>] [--userdata-file <filepath>] [--tags] [--spot-instance] [flags]
cherryctl server create -p <project_id> --plan <plan_slug> --region <region_slug> [--hostname <hostname>] [--image <image_slug>] [--ssh-keys <ssh_key_ids>] [--ip-addresses <ip_addresses_ids>] [--os-partition-size <size>] [--userdata-file <filepath>] [--tags] [--spot-instance] [--storage-id <storage_id>] [flags]
```

### Examples
Expand All @@ -30,6 +30,7 @@ cherryctl server create -p <project_id> --plan <plan_slug> --region <region_slug
--region string Slug of the region where server will be provisioned.
--spot-instance Provisions the server as a spot instance.
--ssh-keys strings Comma separated list of SSH key ID's to be embed in the Server.
--storage-id int ID of the storage that will be attached to server.
--tags strings Tag or list of tags for the server: --tags="key=value,env=prod".
--userdata-file string Path to a userdata file for server initialization.
```
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/cherryservers/cherryctl
go 1.21

require (
github.com/cherryservers/cherrygo/v3 v3.4.0
github.com/cherryservers/cherrygo/v3 v3.5.0
github.com/google/uuid v1.3.0
github.com/manifoldco/promptui v0.9.0
github.com/olekukonko/tablewriter v0.0.5
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cherryservers/cherrygo/v3 v3.4.0 h1:Za1wwky0Rc9uEpxrgULYrxGmaFnfxtwVXYAsitTb2+0=
github.com/cherryservers/cherrygo/v3 v3.4.0/go.mod h1:ubyz7yqr8CaC6k7RSzkI2P6tNXk094BOADodGejEcLQ=
github.com/cherryservers/cherrygo/v3 v3.5.0 h1:aqqKIQvOPadLi8PyRLN6GNQfCxyNMbKukz4ACov5zMs=
github.com/cherryservers/cherrygo/v3 v3.5.0/go.mod h1:ubyz7yqr8CaC6k7RSzkI2P6tNXk094BOADodGejEcLQ=
github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8=
Expand Down
5 changes: 4 additions & 1 deletion internal/servers/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ func (c *Client) Create() *cobra.Command {
tags []string
spotInstance bool
ipAddresses []string
storageID int
)

createServerCmd := &cobra.Command{
Use: `create -p <project_id> --plan <plan_slug> --region <region_slug> [--hostname <hostname>] [--image <image_slug>] [--ssh-keys <ssh_key_ids>] [--ip-addresses <ip_addresses_ids>] [--os-partition-size <size>] [--userdata-file <filepath>] [--tags] [--spot-instance]`,
Use: `create -p <project_id> --plan <plan_slug> --region <region_slug> [--hostname <hostname>] [--image <image_slug>] [--ssh-keys <ssh_key_ids>] [--ip-addresses <ip_addresses_ids>] [--os-partition-size <size>] [--userdata-file <filepath>] [--tags] [--spot-instance] [--storage-id <storage_id>]`,
Short: "Create a server.",
Long: "Create a server in specified project.",
Example: ` # Provisions a E5-1620v4 server in EU-Nord-1 location running on a Ubuntu 20.04:
Expand Down Expand Up @@ -69,6 +70,7 @@ func (c *Client) Create() *cobra.Command {
OSPartitionSize: osPartitionSize,
UserData: userdata,
Tags: &tagsArr,
StorageID: storageID,
}

s, _, err := c.Service.Create(request)
Expand All @@ -95,6 +97,7 @@ func (c *Client) Create() *cobra.Command {
createServerCmd.Flags().BoolVarP(&spotInstance, "spot-instance", "", false, "Provisions the server as a spot instance.")
createServerCmd.Flags().StringSliceVarP(&tags, "tags", "", []string{}, `Tag or list of tags for the server: --tags="key=value,env=prod".`)
createServerCmd.Flags().StringSliceVarP(&ipAddresses, "ip-addresses", "", []string{}, "Comma separated list of IP addresses ID's to be embed in the Server.")
createServerCmd.Flags().IntVarP(&storageID, "storage-id", "", 0, "ID of the storage that will be attached to server.")

_ = createServerCmd.MarkFlagRequired("project-id")
_ = createServerCmd.MarkFlagRequired("plan")
Expand Down

0 comments on commit d5340b7

Please sign in to comment.