Skip to content

Commit

Permalink
s/node/segment/ for the interface only
Browse files Browse the repository at this point in the history
  • Loading branch information
Everett Toews committed Jan 8, 2016
1 parent e15df21 commit 4b278d8
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@ type CreateCommand struct {
*WaitClusterCommand

// Options passed along to Carina's API
Segments int
Nodes int
AutoScale bool

// TODO: See if setting flavor or image makes sense, even if the API takes it
// Flavor string
// Image string
}

// GrowCommand keeps context about the number of segments to scale by
// GrowCommand keeps context about the number of nodes to scale by
type GrowCommand struct {
*ClusterCommand
Segments int
Nodes int
}

// UserNameEnvKey is the name of the env var accepted for the username
Expand Down Expand Up @@ -142,7 +142,7 @@ func New() *Application {

createCommand := new(CreateCommand)
createCommand.WaitClusterCommand = cap.NewWaitClusterCommand(ctx, "create", "Create a swarm cluster")
createCommand.Flag("segments", "number of segments for the initial cluster").Default("1").IntVar(&createCommand.Segments)
createCommand.Flag("segments", "number of segments for the initial cluster").Default("1").IntVar(&createCommand.Nodes)
createCommand.Flag("autoscale", "whether autoscale is on or off").BoolVar(&createCommand.AutoScale)
createCommand.Action(createCommand.Create)

Expand All @@ -160,7 +160,7 @@ func New() *Application {

growCommand := new(GrowCommand)
growCommand.ClusterCommand = cap.NewClusterCommand(ctx, "grow", "Grow a cluster by the requested number of segments")
growCommand.Flag("by", "number of segments to increase the cluster by").Required().IntVar(&growCommand.Segments)
growCommand.Flag("by", "number of segments to increase the cluster by").Required().IntVar(&growCommand.Nodes)
growCommand.Action(growCommand.Grow)

credentialsCommand := cap.NewCredentialsCommand(ctx, "credentials", "download credentials")
Expand Down Expand Up @@ -543,7 +543,7 @@ func (carina *CredentialsCommand) Delete(pc *kingpin.ParseContext) (err error) {
// Grow increases the size of the given cluster
func (carina *GrowCommand) Grow(pc *kingpin.ParseContext) (err error) {
return carina.clusterApply(func(clusterName string) (*libcarina.Cluster, error) {
return carina.ClusterClient.Grow(clusterName, carina.Segments)
return carina.ClusterClient.Grow(clusterName, carina.Nodes)
})
}

Expand Down Expand Up @@ -621,14 +621,14 @@ const CarinaHomeDirEnvVar = "CARINA_HOME"
// Create a cluster
func (carina *CreateCommand) Create(pc *kingpin.ParseContext) (err error) {
return carina.clusterApplyWait(func(clusterName string) (*libcarina.Cluster, error) {
if carina.Segments < 1 {
if carina.Nodes < 1 {
return nil, errors.New("segments must be >= 1")
}
segments := libcarina.Number(carina.Segments)
nodes := libcarina.Number(carina.Nodes)

c := libcarina.Cluster{
ClusterName: carina.ClusterName,
Segments: segments,
Nodes: nodes,
AutoScale: carina.AutoScale,
}
cluster, err := carina.ClusterClient.Create(c)
Expand Down Expand Up @@ -800,7 +800,7 @@ func writeCluster(w *tabwriter.Writer, cluster *libcarina.Cluster) (err error) {
s := strings.Join([]string{
cluster.ClusterName,
cluster.Flavor,
strconv.FormatInt(cluster.Segments.Int64(), 10),
strconv.FormatInt(cluster.Nodes.Int64(), 10),
strconv.FormatBool(cluster.AutoScale),
cluster.Status,
}, "\t")
Expand Down

0 comments on commit 4b278d8

Please sign in to comment.