From d340721b31faf51d76fb787d784ffc9c043222c1 Mon Sep 17 00:00:00 2001 From: "Jonathan A. Sternberg" Date: Wed, 30 May 2018 16:52:43 -0500 Subject: [PATCH] fix(cmd/transpilerd): fix transpilerd to use only --org-id This removes the `--org` parameter because we can't properly decode the name into an organization id without access to the idp daemon. We will either have to open access to that or not have that feature. --- cmd/transpilerd/main.go | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/cmd/transpilerd/main.go b/cmd/transpilerd/main.go index 5f71f8e70c..e3f51027bd 100644 --- a/cmd/transpilerd/main.go +++ b/cmd/transpilerd/main.go @@ -49,11 +49,8 @@ func init() { viper.BindEnv("IFQLD_HOSTS") viper.BindPFlag("IFQLD_HOSTS", transpileCmd.PersistentFlags().Lookup("ifqld-hosts")) - transpileCmd.PersistentFlags().StringP("org", "o", "", "name of the organization that owns the bucket") - viper.BindEnv("ORG") - viper.BindPFlag("ORG", transpileCmd.PersistentFlags().Lookup("org")) - - transpileCmd.PersistentFlags().StringP("org-id", "", "", "id of the organization that owns the bucket") + // TODO(jsternberg): Determine how we are going to identify the organization id in open source. + transpileCmd.PersistentFlags().StringP("org-id", "", "0000000000000000", "id of the organization that owns the bucket") viper.BindEnv("ORG_ID") viper.BindPFlag("ORG_ID", transpileCmd.PersistentFlags().Lookup("org-id")) } @@ -67,14 +64,14 @@ func transpileF(cmd *cobra.Command, logger *zap.Logger, args []string) error { } // Retrieve the organization that we are using. - id, err := getOrganization(cmd) + id, err := getOrganization() if err != nil { return err } // TODO(nathanielc): Allow QueryService to use multiple hosts. - logger.Info("Using ifqld service", zap.Strings("hosts", hosts)) + logger.Info("Using ifqld service", zap.Strings("hosts", hosts), zap.Stringer("org-id", id)) transpileHandler := http.NewTranspilerQueryHandler(id) transpileHandler.QueryService = &http.QueryService{ Addr: hosts[0], @@ -106,21 +103,18 @@ func getStrList(key string) ([]string, error) { return strings.Split(valStr, ","), nil } -func getOrganization(cmd *cobra.Command) (platform.ID, error) { +func getOrganization() (platform.ID, error) { v := viper.GetViper() - orgName := v.GetString("ORG") orgID := v.GetString("ORG_ID") - if (orgName != "" && orgID != "") || (orgName == "" && orgID == "") { - return nil, errors.New("must specify exactly one of org or org-id") + if orgID == "" { + return nil, errors.New("must specify org-id") } - if orgID != "" { - var id platform.ID - if err := id.DecodeFromString(orgID); err != nil { - return nil, fmt.Errorf("unable to decode organization id: %s", err) - } + var id platform.ID + if err := id.DecodeFromString(orgID); err != nil { + return nil, fmt.Errorf("unable to decode organization id: %s", err) } - return platform.ID(orgName), nil + return id, nil } func discoverHosts() ([]string, error) {