Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Updated vendoring for new gocomposeapi and added set scale, set note …
Browse files Browse the repository at this point in the history
…and set code commands.
  • Loading branch information
codepope committed Jun 29, 2017
1 parent 3a7e3ad commit a42e9ee
Show file tree
Hide file tree
Showing 166 changed files with 11,470 additions and 11,808 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Available Commands:
recipe Show details of a recipe
recipes Show Recipes related to deployment
scale Show scale information for a deployment
set Commands for setting parameters and values
user Show user information
versions Show versions for deployment database
watch Watch a recipe status
Expand Down
22 changes: 14 additions & 8 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var clusterid string
var version string
var ssl bool
var wiredtiger bool
var notes string
var billingcode string

// createCmd represents the deployment command
var createCmd = &cobra.Command{
Expand Down Expand Up @@ -54,14 +56,16 @@ var createCmd = &cobra.Command{

params :=
composeAPI.DeploymentParams{
Name: deploymentname,
AccountID: account.ID,
DatabaseType: dbtype,
Datacenter: datacenterid,
ClusterID: clusterid,
Version: version,
SSL: ssl,
WiredTiger: wiredtiger,
Name: deploymentname,
AccountID: account.ID,
DatabaseType: dbtype,
Datacenter: datacenterid,
ClusterID: clusterid,
Version: version,
SSL: ssl,
WiredTiger: wiredtiger,
Notes: notes,
CustomerBillingCode: billingcode,
}

deployment, errs := c.CreateDeployment(params)
Expand All @@ -86,4 +90,6 @@ func init() {
createCmd.Flags().StringVar(&version, "version", "", "Database version required")
createCmd.Flags().BoolVar(&ssl, "ssl", false, "SSL required (where supported)")
createCmd.Flags().BoolVar(&wiredtiger, "wiredtiger", false, "Use WiredTiger storage (MongoDB only)")
createCmd.Flags().StringVar(&notes, "notes", "", "Customer notes")
createCmd.Flags().StringVar(&billingcode, "code", "", "Customer billing code")
}
43 changes: 5 additions & 38 deletions cmd/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,49 +15,16 @@
package cmd

import (
"fmt"
"log"
"strconv"

composeAPI "github.com/compose/gocomposeapi"
"github.com/spf13/cobra"
)

// setCmd represents the set command
// RootCmd represents the base command when called without any subcommands
var setCmd = &cobra.Command{
Use: "set [deployment id] [scale in integer units]",
Short: "Set scale for a deployment",
Long: `Sets the number of resource units (storage/memory) that should be available.`,

Run: func(cmd *cobra.Command, args []string) {
if len(args) != 2 {
log.Fatal("Need a deployment id and new units value")
}
c := getComposeAPI()

params := composeAPI.ScalingsParams{}
params.DeploymentID = args[0]
scaleval, err := strconv.Atoi(args[1])
if err != nil {
log.Fatal("Scale units must be integer")
}

params.Units = scaleval
recipe, errs := c.SetScalings(params)
bailOnErrs(errs)
if !outputJSON {
printRecipe(*recipe)
fmt.Println()
} else {
printAsJSON(*recipe)
}

if recipewatch {
watchRecipeTillComplete(c, recipe.ID)
}
},
Use: "set",
Short: "Commands for setting parameters and values",
Long: `A selection of subcommands are available for setting parameters and values`,
}

func init() {
scaleCmd.AddCommand(setCmd)
RootCmd.AddCommand(setCmd)
}
54 changes: 54 additions & 0 deletions cmd/setcode.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright © 2017 Compose, an IBM company
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cmd

import (
"fmt"
"log"

composeAPI "github.com/compose/gocomposeapi"
"github.com/spf13/cobra"
)

// setNotesCmd represents the set command
var setCodeCmd = &cobra.Command{
Use: "code [deployment id] [notcodee]",
Short: "Set customer billing code for a deployment",
Long: `Sets the customer billing code for a deployment.`,

Run: func(cmd *cobra.Command, args []string) {
if len(args) != 2 {
log.Fatal("Need a deployment id and new billing code value")
}
c := getComposeAPI()

params := composeAPI.PatchDeploymentParams{}
params.DeploymentID = args[0]
params.CustomerBillingCode = args[1]
deployment, errs := c.PatchDeployment(params)

bailOnErrs(errs)
if !outputJSON {
printDeployment(*deployment)
fmt.Println()
} else {
printAsJSON(*deployment)
}
},
}

func init() {
setCmd.AddCommand(setCodeCmd)
}
54 changes: 54 additions & 0 deletions cmd/setnotes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright © 2017 Compose, an IBM company
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cmd

import (
"fmt"
"log"

composeAPI "github.com/compose/gocomposeapi"
"github.com/spf13/cobra"
)

// setNotesCmd represents the set command
var setNotesCmd = &cobra.Command{
Use: "notes [deployment id] [note]",
Short: "Set notes for a deployment",
Long: `Sets the customer notes for a deployment.`,

Run: func(cmd *cobra.Command, args []string) {
if len(args) != 2 {
log.Fatal("Need a deployment id and new notes value")
}
c := getComposeAPI()

params := composeAPI.PatchDeploymentParams{}
params.DeploymentID = args[0]
params.Notes = args[1]
deployment, errs := c.PatchDeployment(params)

bailOnErrs(errs)
if !outputJSON {
printDeployment(*deployment)
fmt.Println()
} else {
printAsJSON(*deployment)
}
},
}

func init() {
setCmd.AddCommand(setNotesCmd)
}
63 changes: 63 additions & 0 deletions cmd/setscale.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright © 2017 Compose, an IBM company
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cmd

import (
"fmt"
"log"
"strconv"

composeAPI "github.com/compose/gocomposeapi"
"github.com/spf13/cobra"
)

// setScaleCmd represents the set command
var setScaleCmd = &cobra.Command{
Use: "scale [deployment id] [scale in integer units]",
Short: "Set scale for a deployment",
Long: `Sets the number of resource units (storage/memory) that should be available.`,

Run: func(cmd *cobra.Command, args []string) {
if len(args) != 2 {
log.Fatal("Need a deployment id and new units value")
}
c := getComposeAPI()

params := composeAPI.ScalingsParams{}
params.DeploymentID = args[0]
scaleval, err := strconv.Atoi(args[1])
if err != nil {
log.Fatal("Scale units must be integer")
}

params.Units = scaleval
recipe, errs := c.SetScalings(params)
bailOnErrs(errs)
if !outputJSON {
printRecipe(*recipe)
fmt.Println()
} else {
printAsJSON(*recipe)
}

if recipewatch {
watchRecipeTillComplete(c, recipe.ID)
}
},
}

func init() {
setCmd.AddCommand(setScaleCmd)
}
18 changes: 8 additions & 10 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion glide.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package: github.com/compose/bach
import:
- package: github.com/compose/gocomposeapi
version: master
version: 0.1
- package: github.com/spf13/cobra
- package: github.com/spf13/viper
36 changes: 36 additions & 0 deletions vendor/github.com/compose/gocomposeapi/cluster.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a42e9ee

Please sign in to comment.