Skip to content

Commit

Permalink
Remove unused organization logic
Browse files Browse the repository at this point in the history
  • Loading branch information
sagikazarmark authored and orymate committed Dec 20, 2018
1 parent 37e49f7 commit 52fad75
Showing 1 changed file with 1 addition and 77 deletions.
78 changes: 1 addition & 77 deletions cmd/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,12 @@ import (
"context"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
survey "gopkg.in/AlecAivazis/survey.v1"
"gopkg.in/AlecAivazis/survey.v1"
)

const orgIdKey = "organization.id"

// organizationCmd represents the organization command
var organizationCmd = &cobra.Command{
Use: "organization",
Aliases: []string{"org", "orgs"},
Short: "List and select organizations.",
Run: OrganizationList,
}

var organizationSelectCmd = &cobra.Command{
Use: "select",
Short: "Select organization.",
Run: OrganizationSelect,
Args: cobra.MaximumNArgs(1),
}

var organizationListCmd = &cobra.Command{
Use: "list",
Short: "List organizations.",
Run: OrganizationList,
Args: cobra.NoArgs,
}

func OrganizationList(cmd *cobra.Command, args []string) {
pipeline := InitPipeline()
orgs, _, err := pipeline.OrganizationsApi.ListOrgs(context.Background())
if err != nil {
log.Fatalf("could not list organizations: %v", err)
}
Out(orgs, []string{"Id", "Name"})
id := GetOrgId(false)
for _, org := range orgs {
if org.Id == id {
log.Infof("Organization %q (%d) is selected.", org.Name, org.Id)
}
}
}

func searchOrganizationId(name string) int32 {
pipeline := InitPipeline()
orgs, _, err := pipeline.OrganizationsApi.ListOrgs(context.Background())
Expand All @@ -78,29 +40,6 @@ func searchOrganizationId(name string) int32 {
return 0
}

func searchOrganizationName(id int32) string {
pipeline := InitPipeline()
org, _, err := pipeline.OrganizationsApi.GetOrg(context.Background(), id)
if err != nil {
logAPIError("get organization", err, id)
return ""
}
return org.Name
}

func OrganizationSelect(cmd *cobra.Command, args []string) {
if len(args) == 1 {
id := searchOrganizationId(args[0])
if id > 0 {
viper.Set(orgIdKey, id)
}
} else {
viper.Set(orgIdKey, 0)
GetOrgId(true)
}
WriteConfig()
}

func GetOrgId(ask bool) int32 {
id := viper.GetInt32(orgIdKey)
if id != 0 {
Expand All @@ -126,18 +65,3 @@ func GetOrgId(ask bool) int32 {
}
return id
}

func init() {
//rootCmd.AddCommand(organizationCmd)
//organizationCmd.AddCommand(organizationListCmd)
//organizationCmd.AddCommand(organizationSelectCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// organizationCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}

0 comments on commit 52fad75

Please sign in to comment.