This is an automated email from the ASF dual-hosted git repository. dubeejw pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-cli.git
commit eca5dde8aaeebab8dd6ba8ab52c5fd8c1dfa3762 Author: Jesus Alva <ja...@us.ibm.com> AuthorDate: Fri Sep 22 12:43:43 2017 -0500 Added changes for classes and variables casing to be get exported and can be used in other places (#2675) * Updating classes and variables so that they are exported and usable by other modules * Updating missed debug statements to have case of client -> Client --- commands/action.go | 64 +++++++++++++++++----------------- commands/activation.go | 54 ++++++++++++++--------------- commands/api.go | 54 ++++++++++++++--------------- commands/commands.go | 6 ++-- commands/namespace.go | 18 +++++----- commands/package.go | 84 ++++++++++++++++++++++---------------------- commands/property.go | 51 ++++++++++++++------------- commands/qualified_name.go | 8 ++--- commands/rule.go | 86 +++++++++++++++++++++++----------------------- commands/sdk.go | 6 ++-- commands/trigger.go | 72 +++++++++++++++++++------------------- commands/util.go | 4 +-- commands/wsk.go | 2 +- wski18n/i18n_resources.go | 20 +++++------ 14 files changed, 264 insertions(+), 265 deletions(-) diff --git a/commands/action.go b/commands/action.go index be56dda..b80bfb0 100644 --- a/commands/action.go +++ b/commands/action.go @@ -51,12 +51,12 @@ var actionCreateCmd = &cobra.Command{ Short: wski18n.T("create a new action"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var action *whisk.Action var err error - if whiskErr := checkArgs( + if whiskErr := CheckArgs( args, 1, 2, @@ -69,7 +69,7 @@ var actionCreateCmd = &cobra.Command{ return actionParseError(cmd, args, err) } - if _, _, err = client.Actions.Insert(action, false); err != nil { + if _, _, err = Client.Actions.Insert(action, false); err != nil { return actionInsertError(action, err) } @@ -84,12 +84,12 @@ var actionUpdateCmd = &cobra.Command{ Short: wski18n.T("update an existing action, or create an action if it does not exist"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var action *whisk.Action var err error - if whiskErr := checkArgs( + if whiskErr := CheckArgs( args, 1, 2, @@ -102,7 +102,7 @@ var actionUpdateCmd = &cobra.Command{ return actionParseError(cmd, args, err) } - if _, _, err = client.Actions.Insert(action, true); err != nil { + if _, _, err = Client.Actions.Insert(action, true); err != nil { return actionInsertError(action, err) } @@ -117,14 +117,14 @@ var actionInvokeCmd = &cobra.Command{ Short: wski18n.T("invoke action"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var parameters interface{} var qualifiedName = new(QualifiedName) var paramArgs []string - if whiskErr := checkArgs( + if whiskErr := CheckArgs( args, 1, 1, @@ -137,7 +137,7 @@ var actionInvokeCmd = &cobra.Command{ return NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() paramArgs = Flags.common.param if len(paramArgs) > 0 { @@ -148,7 +148,7 @@ var actionInvokeCmd = &cobra.Command{ if Flags.action.result { Flags.common.blocking = true} - res, _, err := client.Actions.Invoke( + res, _, err := Client.Actions.Invoke( qualifiedName.GetEntityName(), parameters, Flags.common.blocking, @@ -200,14 +200,14 @@ var actionGetCmd = &cobra.Command{ Short: wski18n.T("get action"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var field string var action *whisk.Action var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 1, 2, "Action get", wski18n.T("An action name is required.")); whiskErr != nil { + if whiskErr := CheckArgs(args, 1, 2, "Action get", wski18n.T("An action name is required.")); whiskErr != nil { return whiskErr } @@ -223,9 +223,9 @@ var actionGetCmd = &cobra.Command{ return NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() - if action, _, err = client.Actions.Get(qualifiedName.GetEntityName()); err != nil { + if action, _, err = Client.Actions.Get(qualifiedName.GetEntityName()); err != nil { return actionGetError(qualifiedName.GetEntityName(), err) } @@ -260,12 +260,12 @@ var actionDeleteCmd = &cobra.Command{ Short: wski18n.T("delete action"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var qualifiedName = new(QualifiedName) var err error - if whiskErr := checkArgs( + if whiskErr := CheckArgs( args, 1, 1, @@ -278,9 +278,9 @@ var actionDeleteCmd = &cobra.Command{ return NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() - if _, err = client.Actions.Delete(qualifiedName.GetEntityName()); err != nil { + if _, err = Client.Actions.Delete(qualifiedName.GetEntityName()); err != nil { return actionDeleteError(qualifiedName.GetEntityName(), err) } @@ -295,13 +295,13 @@ var actionListCmd = &cobra.Command{ Short: wski18n.T("list all actions in a namespace or actions contained in a package"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var qualifiedName = new(QualifiedName) var actions []whisk.Action var err error - if whiskErr := checkArgs( + if whiskErr := CheckArgs( args, 0, 1, @@ -315,7 +315,7 @@ var actionListCmd = &cobra.Command{ return NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() } options := &whisk.ActionListOptions{ @@ -323,7 +323,7 @@ var actionListCmd = &cobra.Command{ Limit: Flags.common.limit, } - if actions, _, err = client.Actions.List(qualifiedName.GetEntityName(), options); err != nil { + if actions, _, err = Client.Actions.List(qualifiedName.GetEntityName(), options); err != nil { return actionListError(qualifiedName.GetEntityName(), options, err) } @@ -348,7 +348,7 @@ func parseAction(cmd *cobra.Command, args []string, update bool) (*whisk.Action, return nil, NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() action := new(whisk.Action) action.Name = qualifiedName.GetEntityName() action.Namespace = qualifiedName.GetNamespace() @@ -386,13 +386,13 @@ func parseAction(cmd *cobra.Command, args []string, update bool) (*whisk.Action, return nil, NewQualifiedNameError(args[1], err) } - client.Namespace = copiedQualifiedName.GetNamespace() + Client.Namespace = copiedQualifiedName.GetNamespace() - if existingAction, _, err = client.Actions.Get(copiedQualifiedName.GetEntityName()); err != nil { + if existingAction, _, err = Client.Actions.Get(copiedQualifiedName.GetEntityName()); err != nil { return nil, actionGetError(copiedQualifiedName.GetEntityName(), err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() action.Exec = existingAction.Exec action.Parameters = append(action.Parameters, existingAction.Parameters...) action.Annotations = append(action.Annotations, existingAction.Annotations...) @@ -524,7 +524,7 @@ func webActionAnnotations( var err error if preserveAnnotations { - if action, _, err = client.Actions.Get(entityName); err != nil { + if action, _, err = Client.Actions.Get(entityName); err != nil { whiskErr, isWhiskError := err.(*whisk.WskError) if (isWhiskError && whiskErr.ExitCode != whisk.EXIT_CODE_NOT_FOUND) || !isWhiskError { @@ -627,7 +627,7 @@ func actionParseError(cmd *cobra.Command, args []string, err error) (error) { } func actionInsertError(action *whisk.Action, err error) (error) { - whisk.Debug(whisk.DbgError, "client.Actions.Insert(%#v, false) error: %s\n", action, err) + whisk.Debug(whisk.DbgError, "Client.Actions.Insert(%#v, false) error: %s\n", action, err) errMsg := wski18n.T( "Unable to create action '{{.name}}': {{.err}}", @@ -676,7 +676,7 @@ func invalidFieldFilterError(field string) (error) { } func actionDeleteError(entityName string, err error) (error) { - whisk.Debug(whisk.DbgError, "client.Actions.Delete(%s) error: %s\n", entityName, err) + whisk.Debug(whisk.DbgError, "Client.Actions.Delete(%s) error: %s\n", entityName, err) errMsg := wski18n.T( "Unable to delete action '{{.name}}': {{.err}}", @@ -689,7 +689,7 @@ func actionDeleteError(entityName string, err error) (error) { } func actionGetError(entityName string, err error) (error) { - whisk.Debug(whisk.DbgError, "client.Actions.Get(%s) error: %s\n", entityName, err) + whisk.Debug(whisk.DbgError, "Client.Actions.Get(%s) error: %s\n", entityName, err) errMsg := wski18n.T( "Unable to get action '{{.name}}': {{.err}}", @@ -704,7 +704,7 @@ func actionGetError(entityName string, err error) (error) { func handleInvocationError(err error, entityName string, parameters interface{}) (error) { whisk.Debug( whisk.DbgError, - "client.Actions.Invoke(%s, %s, %t) error: %s\n", + "Client.Actions.Invoke(%s, %s, %t) error: %s\n", entityName, parameters, Flags.common.blocking, err) @@ -720,7 +720,7 @@ func handleInvocationError(err error, entityName string, parameters interface{}) } func actionListError(entityName string, options *whisk.ActionListOptions, err error) (error) { - whisk.Debug(whisk.DbgError, "client.Actions.List(%s, %#v) error: %s\n", entityName, options, err) + whisk.Debug(whisk.DbgError, "Client.Actions.List(%s, %#v) error: %s\n", entityName, options, err) errMsg := wski18n.T( "Unable to obtain the list of actions for namespace '{{.name}}': {{.err}}", diff --git a/commands/activation.go b/commands/activation.go index 1a2bd33..22713b7 100644 --- a/commands/activation.go +++ b/commands/activation.go @@ -49,12 +49,12 @@ var activationListCmd = &cobra.Command{ Short: wski18n.T("list activations"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 0, 1, "Activation list", + if whiskErr := CheckArgs(args, 0, 1, "Activation list", wski18n.T("An optional namespace is the only valid argument.")); whiskErr != nil { return whiskErr } @@ -67,7 +67,7 @@ var activationListCmd = &cobra.Command{ return NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() } options := &whisk.ActivationListOptions{ @@ -79,9 +79,9 @@ var activationListCmd = &cobra.Command{ Docs: Flags.common.full, } - activations, _, err := client.Activations.List(options) + activations, _, err := Client.Activations.List(options) if err != nil { - whisk.Debug(whisk.DbgError, "client.Activations.List() error: %s\n", err) + whisk.Debug(whisk.DbgError, "Client.Activations.List() error: %s\n", err) errStr := wski18n.T("Unable to obtain the list of activations for namespace '{{.name}}': {{.err}}", map[string]interface{}{"name": getClientNamespace(), "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, @@ -105,7 +105,7 @@ var activationGetCmd = &cobra.Command{ Short: wski18n.T("get activation"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var field string var err error @@ -117,7 +117,7 @@ var activationGetCmd = &cobra.Command{ werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) return werr } - if whiskErr := checkArgs(args, 1, 2, "Activation get", + if whiskErr := CheckArgs(args, 1, 2, "Activation get", wski18n.T("An activation ID is required.")); whiskErr != nil { return whiskErr } @@ -134,9 +134,9 @@ var activationGetCmd = &cobra.Command{ } id := args[0] - activation, _, err := client.Activations.Get(id) + activation, _, err := Client.Activations.Get(id) if err != nil { - whisk.Debug(whisk.DbgError, "client.Activations.Get(%s) failed: %s\n", id, err) + whisk.Debug(whisk.DbgError, "Client.Activations.Get(%s) failed: %s\n", id, err) errStr := wski18n.T("Unable to get activation '{{.id}}': {{.err}}", map[string]interface{}{"id": id, "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) @@ -176,7 +176,7 @@ var activationLogsCmd = &cobra.Command{ Short: wski18n.T("get the logs of an activation"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error @@ -187,15 +187,15 @@ var activationLogsCmd = &cobra.Command{ werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) return werr } - if whiskErr := checkArgs(args, 1, 1, "Activation logs", + if whiskErr := CheckArgs(args, 1, 1, "Activation logs", wski18n.T("An activation ID is required.")); whiskErr != nil { return whiskErr } id := args[0] - activation, _, err := client.Activations.Logs(id) + activation, _, err := Client.Activations.Logs(id) if err != nil { - whisk.Debug(whisk.DbgError, "client.Activations.Logs(%s) failed: %s\n", id, err) + whisk.Debug(whisk.DbgError, "Client.Activations.Logs(%s) failed: %s\n", id, err) errStr := wski18n.T("Unable to get logs for activation '{{.id}}': {{.err}}", map[string]interface{}{"id": id, "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) @@ -212,7 +212,7 @@ var activationResultCmd = &cobra.Command{ Short: "get the result of an activation", SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error @@ -223,15 +223,15 @@ var activationResultCmd = &cobra.Command{ werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) return werr } - if whiskErr := checkArgs(args, 1, 1, "Activation result", + if whiskErr := CheckArgs(args, 1, 1, "Activation result", wski18n.T("An activation ID is required.")); whiskErr != nil { return whiskErr } id := args[0] - result, _, err := client.Activations.Result(id) + result, _, err := Client.Activations.Result(id) if err != nil { - whisk.Debug(whisk.DbgError, "client.Activations.result(%s) failed: %s\n", id, err) + whisk.Debug(whisk.DbgError, "Client.Activations.result(%s) failed: %s\n", id, err) errStr := wski18n.T("Unable to get result for activation '{{.id}}': {{.err}}", map[string]interface{}{"id": id, "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) @@ -252,9 +252,9 @@ func lastFlag(args []string) ([]string, error) { Limit: 1, Skip: 0, } - activations,_, err := client.Activations.List(options) + activations,_, err := Client.Activations.List(options) if err != nil { // Checks Activations.List for errors when retrieving latest activaiton - whisk.Debug(whisk.DbgError, "client.Activations.List(%#v) error during lastFlag: %s\n", options, err) + whisk.Debug(whisk.DbgError, "Client.Activations.List(%#v) error during lastFlag: %s\n", options, err) return args, err } if len(activations) == 0 { // Checks to to see if there are activations available @@ -281,14 +281,14 @@ var activationPollCmd = &cobra.Command{ Short: wski18n.T("poll continuously for log messages from currently running actions"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var name string var pollSince int64 // Represents an instant in time (in milliseconds since Jan 1 1970) if len(args) == 1 { name = args[0] - } else if whiskErr := checkArgs(args, 0, 1, "Activation poll", + } else if whiskErr := CheckArgs(args, 0, 1, "Activation poll", wski18n.T("An optional namespace is the only valid argument.")); whiskErr != nil { return whiskErr } @@ -315,10 +315,10 @@ var activationPollCmd = &cobra.Command{ Limit: 1, Docs: true, } - activationList, _, err := client.Activations.List(options) + activationList, _, err := Client.Activations.List(options) if err != nil { - whisk.Debug(whisk.DbgWarn, "client.Activations.List() error: %s\n", err) - whisk.Debug(whisk.DbgWarn, "Ignoring client.Activations.List failure; polling for activations since 'now'\n") + whisk.Debug(whisk.DbgWarn, "Client.Activations.List() error: %s\n", err) + whisk.Debug(whisk.DbgWarn, "Ignoring Client.Activations.List failure; polling for activations since 'now'\n") pollSince = time.Now().Unix() * 1000 // Convert to milliseconds } else { if len(activationList) > 0 { @@ -365,10 +365,10 @@ var activationPollCmd = &cobra.Command{ Skip: 0, } - activations, _, err := client.Activations.List(options) + activations, _, err := Client.Activations.List(options) if err != nil { - whisk.Debug(whisk.DbgWarn, "client.Activations.List() error: %s\n", err) - whisk.Debug(whisk.DbgWarn, "Ignoring client.Activations.List failure; continuing to poll for activations\n") + whisk.Debug(whisk.DbgWarn, "Client.Activations.List() error: %s\n", err) + whisk.Debug(whisk.DbgWarn, "Ignoring Client.Activations.List failure; continuing to poll for activations\n") continue } diff --git a/commands/api.go b/commands/api.go index 9c83941..f4bc225 100644 --- a/commands/api.go +++ b/commands/api.go @@ -123,7 +123,7 @@ var apiCreateCmd = &cobra.Command{ Short: wski18n.T("create a new API"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var api *whisk.Api var err error @@ -145,7 +145,7 @@ var apiCreateCmd = &cobra.Command{ return whiskErr } } else { - if whiskErr := checkArgs(args, 3, 4, "Api create", + if whiskErr := CheckArgs(args, 3, 4, "Api create", wski18n.T("Specify a swagger file or specify an API base path with an API path, an API verb, and an action name.")); whiskErr != nil { return whiskErr } @@ -160,7 +160,7 @@ var apiCreateCmd = &cobra.Command{ } // Confirm that the specified action is a web-action - err = isWebAction(client, *qname) + err = isWebAction(Client, *qname) if err != nil { whisk.Debug(whisk.DbgError, "isWebAction(%v) is false: %s\n", qname, err) whiskErr := whisk.MakeWskError(err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE) @@ -182,9 +182,9 @@ var apiCreateCmd = &cobra.Command{ whisk.Debug(whisk.DbgInfo, "AccessToken: %s\nSpaceGuid: %s\nResponsType: %s", apiCreateReqOptions.AccessToken, apiCreateReqOptions.SpaceGuid, apiCreateReqOptions.ResponseType) - retApi, _, err := client.Apis.Insert(apiCreateReq, apiCreateReqOptions, whisk.DoNotOverwrite) + retApi, _, err := Client.Apis.Insert(apiCreateReq, apiCreateReqOptions, whisk.DoNotOverwrite) if err != nil { - whisk.Debug(whisk.DbgError, "client.Apis.Insert(%#v, false) error: %s\n", api, err) + whisk.Debug(whisk.DbgError, "Client.Apis.Insert(%#v, false) error: %s\n", api, err) errMsg := wski18n.T("Unable to create API: {{.err}}", map[string]interface{}{"err": err}) whiskErr := whisk.MakeWskError(errors.New(errMsg), whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) @@ -254,12 +254,12 @@ var apiGetCmd = &cobra.Command{ Short: wski18n.T("get API details"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var isBasePathArg bool = true - if whiskErr := checkArgs(args, 1, 1, "Api get", + if whiskErr := CheckArgs(args, 1, 1, "Api get", wski18n.T("An API base path or API name is required.")); whiskErr != nil { return whiskErr } @@ -283,15 +283,15 @@ var apiGetCmd = &cobra.Command{ return err } - retApi, _, err := client.Apis.Get(apiGetReq, apiGetReqOptions) + retApi, _, err := Client.Apis.Get(apiGetReq, apiGetReqOptions) if err != nil { - whisk.Debug(whisk.DbgError, "client.Apis.Get(%#v, %#v) error: %s\n", apiGetReq, apiGetReqOptions, err) + whisk.Debug(whisk.DbgError, "Client.Apis.Get(%#v, %#v) error: %s\n", apiGetReq, apiGetReqOptions, err) errMsg := wski18n.T("Unable to get API '{{.name}}': {{.err}}", map[string]interface{}{"name": args[0], "err": err}) whiskErr := whisk.MakeWskError(errors.New(errMsg), whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) return whiskErr } - whisk.Debug(whisk.DbgInfo, "client.Apis.Get returned: %#v\n", retApi) + whisk.Debug(whisk.DbgInfo, "Client.Apis.Get returned: %#v\n", retApi) var displayResult interface{} = nil if (Flags.common.detail) { @@ -352,11 +352,11 @@ var apiDeleteCmd = &cobra.Command{ Short: wski18n.T("delete an API"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error - if whiskErr := checkArgs(args, 1, 3, "Api delete", + if whiskErr := CheckArgs(args, 1, 3, "Api delete", wski18n.T("An API base path or API name is required. An optional API relative path and operation may also be provided.")); whiskErr != nil { return whiskErr } @@ -393,9 +393,9 @@ var apiDeleteCmd = &cobra.Command{ apiDeleteReqOptions.ApiVerb = strings.ToUpper(args[2]) } - _, err = client.Apis.Delete(apiDeleteReq, apiDeleteReqOptions) + _, err = Client.Apis.Delete(apiDeleteReq, apiDeleteReqOptions) if err != nil { - whisk.Debug(whisk.DbgError, "client.Apis.Delete(%#v, %#v) error: %s\n", apiDeleteReq, apiDeleteReqOptions, err) + whisk.Debug(whisk.DbgError, "Client.Apis.Delete(%#v, %#v) error: %s\n", apiDeleteReq, apiDeleteReqOptions, err) errMsg := wski18n.T("Unable to delete API: {{.err}}", map[string]interface{}{"err": err}) whiskErr := whisk.MakeWskError(errors.New(errMsg), whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) @@ -437,7 +437,7 @@ var apiListCmd = &cobra.Command{ Short: wski18n.T("list APIs"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var retApiList *whisk.ApiListResponse @@ -448,7 +448,7 @@ var apiListCmd = &cobra.Command{ var orderFilteredList []whisk.ApiFilteredList var orderFilteredRow []whisk.ApiFilteredRow - if whiskErr := checkArgs(args, 0, 3, "Api list", + if whiskErr := CheckArgs(args, 0, 3, "Api list", wski18n.T("Optional parameters are: API base path (or API name), API relative path and operation.")); whiskErr != nil { return whiskErr } @@ -465,21 +465,21 @@ var apiListCmd = &cobra.Command{ return err } - retApiList, _, err = client.Apis.List(apiListReqOptions) + retApiList, _, err = Client.Apis.List(apiListReqOptions) if err != nil { - whisk.Debug(whisk.DbgError, "client.Apis.List(%#v) error: %s\n", apiListReqOptions, err) + whisk.Debug(whisk.DbgError, "Client.Apis.List(%#v) error: %s\n", apiListReqOptions, err) errMsg := wski18n.T("Unable to obtain the API list: {{.err}}", map[string]interface{}{"err": err}) whiskErr := whisk.MakeWskError(errors.New(errMsg), whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) return whiskErr } - whisk.Debug(whisk.DbgInfo, "client.Apis.List returned: %#v (%+v)\n", retApiList, retApiList) + whisk.Debug(whisk.DbgInfo, "Client.Apis.List returned: %#v (%+v)\n", retApiList, retApiList) // Cast to a common type to allow for code to print out apilist response or apiget response retApiArray = (*whisk.RetApiArray)(retApiList) } else { // Get API request body apiGetReq := new(whisk.ApiGetRequest) - apiGetReq.Namespace = client.Config.Namespace + apiGetReq.Namespace = Client.Config.Namespace // Get API request options apiGetReqOptions := new(whisk.ApiGetRequestOptions) if apiGetReqOptions.SpaceGuid, err = getUserContextId(); err != nil { @@ -508,15 +508,15 @@ var apiListCmd = &cobra.Command{ apiGetReqOptions.ApiVerb = apiVerb } - retApi, _, err = client.Apis.Get(apiGetReq, apiGetReqOptions) + retApi, _, err = Client.Apis.Get(apiGetReq, apiGetReqOptions) if err != nil { - whisk.Debug(whisk.DbgError, "client.Apis.Get(%#v, %#v) error: %s\n", apiGetReq, apiGetReqOptions, err) + whisk.Debug(whisk.DbgError, "Client.Apis.Get(%#v, %#v) error: %s\n", apiGetReq, apiGetReqOptions, err) errMsg := wski18n.T("Unable to obtain the API list: {{.err}}", map[string]interface{}{"err": err}) whiskErr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) return whiskErr } - whisk.Debug(whisk.DbgInfo, "client.Apis.Get returned: %#v\n", retApi) + whisk.Debug(whisk.DbgInfo, "Client.Apis.Get returned: %#v\n", retApi) // Cast to a common type to allow for code to print out apilist response or apiget response retApiArray = (*whisk.RetApiArray)(retApi) } @@ -810,7 +810,7 @@ func parseApi(cmd *cobra.Command, args []string) (*whisk.Api, *QualifiedName, er apiname = Flags.api.apiname } - api.Namespace = client.Config.Namespace + api.Namespace = Client.Config.Namespace api.Action = new(whisk.ApiAction) var urlActionPackage string if (len(qName.GetPackageName()) > 0) { @@ -818,11 +818,11 @@ func parseApi(cmd *cobra.Command, args []string) (*whisk.Api, *QualifiedName, er } else { urlActionPackage = "default" } - api.Action.BackendUrl = "https://" + client.Config.Host + "/api/v1/web/" + qName.GetNamespace() + "/" + urlActionPackage + "/" + qName.GetEntity() + ".http" + api.Action.BackendUrl = "https://" + Client.Config.Host + "/api/v1/web/" + qName.GetNamespace() + "/" + urlActionPackage + "/" + qName.GetEntity() + ".http" api.Action.BackendMethod = api.GatewayMethod api.Action.Name = qName.GetEntityName() api.Action.Namespace = qName.GetNamespace() - api.Action.Auth = client.Config.AuthToken + api.Action.Auth = Client.Config.AuthToken api.ApiName = apiname api.GatewayBasePath = basepath if (!basepathArgIsApiName) { api.Id = "API:"+api.Namespace+":"+api.GatewayBasePath } @@ -893,7 +893,7 @@ func parseSwaggerApi() (*whisk.Api, error) { } api := new(whisk.Api) - api.Namespace = client.Config.Namespace + api.Namespace = Client.Config.Namespace api.Swagger = swagger return api, nil diff --git a/commands/commands.go b/commands/commands.go index 9d79ad0..fcb5757 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -28,11 +28,11 @@ import ( "github.com/spf13/cobra" ) -var client *whisk.Client +var Client *whisk.Client const DefaultOpenWhiskApiPath string = "/api" var UserAgent string = "OpenWhisk-CLI" -func setupClientConfig(cmd *cobra.Command, args []string) (error){ +func SetupClientConfig(cmd *cobra.Command, args []string) (error){ baseURL, err := whisk.GetURLBase(Properties.APIHost, DefaultOpenWhiskApiPath) // Determine if the parent command will require the API host to be set @@ -73,7 +73,7 @@ func setupClientConfig(cmd *cobra.Command, args []string) (error){ } // Setup client - client, err = whisk.NewClient(http.DefaultClient, clientConfig) + Client, err = whisk.NewClient(http.DefaultClient, clientConfig) if err != nil { whisk.Debug(whisk.DbgError, "whisk.NewClient(%#v, %#v) error: %s\n", http.DefaultClient, clientConfig, err) diff --git a/commands/namespace.go b/commands/namespace.go index 688cb2e..35240ca 100644 --- a/commands/namespace.go +++ b/commands/namespace.go @@ -39,17 +39,17 @@ var namespaceListCmd = &cobra.Command{ Short: wski18n.T("list available namespaces"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { // add "TYPE" --> public / private - if whiskErr := checkArgs(args, 0, 0, "Namespace list", wski18n.T("No arguments are required.")); whiskErr != nil { + if whiskErr := CheckArgs(args, 0, 0, "Namespace list", wski18n.T("No arguments are required.")); whiskErr != nil { return whiskErr } - namespaces, _, err := client.Namespaces.List() + namespaces, _, err := Client.Namespaces.List() if err != nil { - whisk.Debug(whisk.DbgError, "client.Namespaces.List() error: %s\n", err) + whisk.Debug(whisk.DbgError, "Client.Namespaces.List() error: %s\n", err) errStr := wski18n.T("Unable to obtain the list of available namespaces: {{.err}}", map[string]interface{}{"err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_NETWORK, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) @@ -65,12 +65,12 @@ var namespaceGetCmd = &cobra.Command{ Short: wski18n.T("get triggers, actions, and rules in the registry for a namespace"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var qualifiedName = new(QualifiedName) var err error - if whiskErr := checkArgs(args, 0, 1, "Namespace get", + if whiskErr := CheckArgs(args, 0, 1, "Namespace get", wski18n.T("An optional namespace is the only valid argument.")); whiskErr != nil { return whiskErr } @@ -86,10 +86,10 @@ var namespaceGetCmd = &cobra.Command{ } } - namespace, _, err := client.Namespaces.Get(qualifiedName.GetNamespace()) + namespace, _, err := Client.Namespaces.Get(qualifiedName.GetNamespace()) if err != nil { - whisk.Debug(whisk.DbgError, "client.Namespaces.Get(%s) error: %s\n", getClientNamespace(), err) + whisk.Debug(whisk.DbgError, "Client.Namespaces.Get(%s) error: %s\n", getClientNamespace(), err) errStr := wski18n.T("Unable to obtain the list of entities for namespace '{{.namespace}}': {{.err}}", map[string]interface{}{"namespace": getClientNamespace(), "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_NETWORK, @@ -105,7 +105,7 @@ var namespaceGetCmd = &cobra.Command{ printList(namespace.Contents.Triggers, sortByName) //No errors, lets attempt to retrieve the status of each rule #312 for index, rule := range namespace.Contents.Rules { - ruleStatus, _, err := client.Rules.Get(rule.Name) + ruleStatus, _, err := Client.Rules.Get(rule.Name) if err != nil { errStr := wski18n.T("Unable to get status of rule '{{.name}}': {{.err}}", map[string]interface{}{"name": rule.Name, "err": err}) diff --git a/commands/package.go b/commands/package.go index abec693..c83ee53 100644 --- a/commands/package.go +++ b/commands/package.go @@ -39,13 +39,13 @@ var packageBindCmd = &cobra.Command{ Short: wski18n.T("bind parameters to a package"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var pkgQualifiedName = new(QualifiedName) var bindQualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 2, 2, "Package bind", + if whiskErr := CheckArgs(args, 2, 2, "Package bind", wski18n.T("A package name and binding name are required.")); whiskErr != nil { return whiskErr } @@ -60,7 +60,7 @@ var packageBindCmd = &cobra.Command{ return NewQualifiedNameError(bindingName, err) } - client.Namespace = bindQualifiedName.GetNamespace() + Client.Namespace = bindQualifiedName.GetNamespace() // Convert the binding's list of default parameters from a string into []KeyValue // The 1 or more --param arguments have all been combined into a single []string @@ -103,9 +103,9 @@ var packageBindCmd = &cobra.Command{ Binding: binding, } - _, _, err = client.Packages.Insert(p, false) + _, _, err = Client.Packages.Insert(p, false) if err != nil { - whisk.Debug(whisk.DbgError, "client.Packages.Insert(%#v, false) failed: %s\n", p, err) + whisk.Debug(whisk.DbgError, "Client.Packages.Insert(%#v, false) failed: %s\n", p, err) errStr := wski18n.T("Binding creation failed: {{.err}}", map[string]interface{}{"err":err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) return werr @@ -122,13 +122,13 @@ var packageCreateCmd = &cobra.Command{ Short: wski18n.T("create a new package"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var shared, sharedSet bool var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 1, 1, "Package create", wski18n.T("A package name is required.")); whiskErr != nil { + if whiskErr := CheckArgs(args, 1, 1, "Package create", wski18n.T("A package name is required.")); whiskErr != nil { return whiskErr } @@ -136,7 +136,7 @@ var packageCreateCmd = &cobra.Command{ return NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() if shared, sharedSet, err = parseShared(Flags.common.shared); err != nil { whisk.Debug(whisk.DbgError, "parseShared(%s) failed: %s\n", Flags.common.shared, err) @@ -176,9 +176,9 @@ var packageCreateCmd = &cobra.Command{ p.Publish = &shared } - p, _, err = client.Packages.Insert(p, false) + p, _, err = Client.Packages.Insert(p, false) if err != nil { - whisk.Debug(whisk.DbgError, "client.Packages.Insert(%#v, false) failed: %s\n", p, err) + whisk.Debug(whisk.DbgError, "Client.Packages.Insert(%#v, false) failed: %s\n", p, err) errStr := wski18n.T( "Unable to create package '{{.name}}': {{.err}}", map[string]interface{}{ @@ -200,13 +200,13 @@ var packageUpdateCmd = &cobra.Command{ Short: wski18n.T("update an existing package, or create a package if it does not exist"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var shared, sharedSet bool var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 1, 1, "Package update", wski18n.T("A package name is required.")); whiskErr != nil { + if whiskErr := CheckArgs(args, 1, 1, "Package update", wski18n.T("A package name is required.")); whiskErr != nil { return whiskErr } @@ -214,7 +214,7 @@ var packageUpdateCmd = &cobra.Command{ return NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() if shared, sharedSet, err = parseShared(Flags.common.shared); err != nil { whisk.Debug(whisk.DbgError, "parseShared(%s) failed: %s\n", Flags.common.shared, err) @@ -253,9 +253,9 @@ var packageUpdateCmd = &cobra.Command{ p.Publish = &shared } - p, _, err = client.Packages.Insert(p, true) + p, _, err = Client.Packages.Insert(p, true) if err != nil { - whisk.Debug(whisk.DbgError, "client.Packages.Insert(%#v, true) failed: %s\n", p, err) + whisk.Debug(whisk.DbgError, "Client.Packages.Insert(%#v, true) failed: %s\n", p, err) errStr := wski18n.T("Package update failed: {{.err}}", map[string]interface{}{"err":err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) return werr @@ -272,13 +272,13 @@ var packageGetCmd = &cobra.Command{ Short: wski18n.T("get package"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var field string var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 1, 2, "Package get", wski18n.T("A package name is required.")); whiskErr != nil { + if whiskErr := CheckArgs(args, 1, 2, "Package get", wski18n.T("A package name is required.")); whiskErr != nil { return whiskErr } @@ -296,11 +296,11 @@ var packageGetCmd = &cobra.Command{ if qualifiedName, err = NewQualifiedName(args[0]); err != nil { return NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() - xPackage, _, err := client.Packages.Get(qualifiedName.GetEntityName()) + xPackage, _, err := Client.Packages.Get(qualifiedName.GetEntityName()) if err != nil { - whisk.Debug(whisk.DbgError, "client.Packages.Get(%s) failed: %s\n", qualifiedName.GetEntityName(), err) + whisk.Debug(whisk.DbgError, "Client.Packages.Get(%s) failed: %s\n", qualifiedName.GetEntityName(), err) errStr := wski18n.T( "Unable to get package '{{.name}}': {{.err}}", map[string]interface{}{ @@ -336,12 +336,12 @@ var packageDeleteCmd = &cobra.Command{ Short: wski18n.T("delete package"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 1, 1, "Package delete", wski18n.T("A package name is required.")); whiskErr != nil { + if whiskErr := CheckArgs(args, 1, 1, "Package delete", wski18n.T("A package name is required.")); whiskErr != nil { return whiskErr } @@ -349,11 +349,11 @@ var packageDeleteCmd = &cobra.Command{ return NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() - _, err = client.Packages.Delete(qualifiedName.GetEntityName()) + _, err = Client.Packages.Delete(qualifiedName.GetEntityName()) if err != nil { - whisk.Debug(whisk.DbgError, "client.Packages.Delete(%s) failed: %s\n", qualifiedName.GetEntityName(), err) + whisk.Debug(whisk.DbgError, "Client.Packages.Delete(%s) failed: %s\n", qualifiedName.GetEntityName(), err) errStr := wski18n.T( "Unable to delete package '{{.name}}': {{.err}}", map[string]interface{}{ @@ -376,12 +376,12 @@ var packageListCmd = &cobra.Command{ Short: wski18n.T("list all packages"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 0, 1, "Package list", + if whiskErr := CheckArgs(args, 0, 1, "Package list", wski18n.T("An optional namespace is the only valid argument.")); whiskErr != nil { return whiskErr } @@ -395,7 +395,7 @@ var packageListCmd = &cobra.Command{ return entityNameError(qualifiedName.GetEntityName()) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() } options := &whisk.PackageListOptions{ @@ -403,9 +403,9 @@ var packageListCmd = &cobra.Command{ Limit: Flags.common.limit, } - packages, _, err := client.Packages.List(options) + packages, _, err := Client.Packages.List(options) if err != nil { - whisk.Debug(whisk.DbgError, "client.Packages.List(%+v) failed: %s\n", options, err) + whisk.Debug(whisk.DbgError, "Client.Packages.List(%+v) failed: %s\n", options, err) errStr := wski18n.T("Unable to obtain the list of packages for namespace '{{.name}}': {{.err}}", map[string]interface{}{"name": getClientNamespace(), "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) @@ -424,12 +424,12 @@ var packageRefreshCmd = &cobra.Command{ Short: wski18n.T("refresh package bindings"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 0, 1, "Package refresh", + if whiskErr := CheckArgs(args, 0, 1, "Package refresh", wski18n.T("An optional namespace is the only valid argument.")); whiskErr != nil { return whiskErr } @@ -446,18 +446,18 @@ var packageRefreshCmd = &cobra.Command{ } } - currentNamespace := client.Config.Namespace - client.Config.Namespace = qualifiedName.GetNamespace() + currentNamespace := Client.Config.Namespace + Client.Config.Namespace = qualifiedName.GetNamespace() defer func() { - client.Config.Namespace = currentNamespace + Client.Config.Namespace = currentNamespace }() - updates, resp, err := client.Packages.Refresh() + updates, resp, err := Client.Packages.Refresh() if err != nil { - whisk.Debug(whisk.DbgError, "client.Packages.Refresh() of namespace '%s' failed: %s\n", client.Config.Namespace, err) + whisk.Debug(whisk.DbgError, "Client.Packages.Refresh() of namespace '%s' failed: %s\n", Client.Config.Namespace, err) errStr := wski18n.T("Package refresh for namespace '{{.name}}' failed: {{.err}}", - map[string]interface{}{"name": client.Config.Namespace, "err": err}) + map[string]interface{}{"name": Client.Config.Namespace, "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) return werr } @@ -466,7 +466,7 @@ var packageRefreshCmd = &cobra.Command{ switch resp.StatusCode { case http.StatusOK: fmt.Printf(wski18n.T("'{{.name}}' refreshed successfully\n", - map[string]interface{}{"name": client.Config.Namespace})) + map[string]interface{}{"name": Client.Config.Namespace})) fmt.Println(wski18n.T("created bindings:")) @@ -487,14 +487,14 @@ var packageRefreshCmd = &cobra.Command{ } case http.StatusNotImplemented: - whisk.Debug(whisk.DbgError, "client.Packages.Refresh() for namespace '%s' returned 'Not Implemented' HTTP status code: %d\n", client.Config.Namespace, resp.StatusCode) + whisk.Debug(whisk.DbgError, "Client.Packages.Refresh() for namespace '%s' returned 'Not Implemented' HTTP status code: %d\n", Client.Config.Namespace, resp.StatusCode) errStr := wski18n.T("The package refresh feature is not implemented in the target deployment") werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_NETWORK, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) return werr default: - whisk.Debug(whisk.DbgError, "client.Packages.Refresh() for namespace '%s' returned an unexpected HTTP status code: %d\n", client.Config.Namespace, resp.StatusCode) + whisk.Debug(whisk.DbgError, "Client.Packages.Refresh() for namespace '%s' returned an unexpected HTTP status code: %d\n", Client.Config.Namespace, resp.StatusCode) errStr := wski18n.T("Package refresh for namespace '{{.name}}' failed due to unexpected HTTP status code: {{.code}}", - map[string]interface{}{"name": client.Config.Namespace, "code": resp.StatusCode}) + map[string]interface{}{"name": Client.Config.Namespace, "code": resp.StatusCode}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_NETWORK, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) return werr } diff --git a/commands/property.go b/commands/property.go index 5153e18..38afa43 100644 --- a/commands/property.go +++ b/commands/property.go @@ -66,7 +66,7 @@ var propertySetCmd = &cobra.Command{ Short: wski18n.T("set property"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var okMsg string = "" var werr *whisk.WskError = nil @@ -83,7 +83,7 @@ var propertySetCmd = &cobra.Command{ // read in each flag, update if necessary if cert := Flags.Global.Cert; len(cert) > 0 { props["CERT"] = cert - client.Config.Cert = cert + Client.Config.Cert = cert okMsg += fmt.Sprintf( wski18n.T("{{.ok}} client cert set. Run 'wsk property get --cert' to see the new value.\n", map[string]interface{}{"ok": color.GreenString("ok:")})) @@ -91,7 +91,7 @@ var propertySetCmd = &cobra.Command{ if key := Flags.Global.Key; len(key) > 0 { props["KEY"] = key - client.Config.Key = key + Client.Config.Key = key okMsg += fmt.Sprintf( wski18n.T("{{.ok}} client key set. Run 'wsk property get --key' to see the new value.\n", map[string]interface{}{"ok": color.GreenString("ok:")})) @@ -99,7 +99,7 @@ var propertySetCmd = &cobra.Command{ if auth := Flags.Global.Auth; len(auth) > 0 { props["AUTH"] = auth - client.Config.AuthToken = auth + Client.Config.AuthToken = auth okMsg += fmt.Sprintf( wski18n.T("{{.ok}} whisk auth set. Run 'wsk property get --auth' to see the new value.\n", map[string]interface{}{"ok": color.GreenString("ok:")})) @@ -118,7 +118,7 @@ var propertySetCmd = &cobra.Command{ whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE) } else { props["APIHOST"] = apiHost - client.Config.BaseURL = baseURL + Client.Config.BaseURL = baseURL okMsg += fmt.Sprintf( wski18n.T("{{.ok}} whisk API host set to {{.host}}\n", map[string]interface{}{"ok": color.GreenString("ok:"), "host": boldString(apiHost)})) @@ -127,16 +127,16 @@ var propertySetCmd = &cobra.Command{ if apiVersion := Flags.property.apiversionSet; len(apiVersion) > 0 { props["APIVERSION"] = apiVersion - client.Config.Version = apiVersion + Client.Config.Version = apiVersion okMsg += fmt.Sprintf( wski18n.T("{{.ok}} whisk API version set to {{.version}}\n", map[string]interface{}{"ok": color.GreenString("ok:"), "version": boldString(apiVersion)})) } if namespace := Flags.property.namespaceSet; len(namespace) > 0 { - namespaces, _, err := client.Namespaces.List() + namespaces, _, err := Client.Namespaces.List() if err != nil { - whisk.Debug(whisk.DbgError, "client.Namespaces.List() failed: %s\n", err) + whisk.Debug(whisk.DbgError, "Client.Namespaces.List() failed: %s\n", err) errStr := fmt.Sprintf( wski18n.T("Authenticated user does not have namespace '{{.name}}'; set command failed: {{.err}}", map[string]interface{}{"name": namespace, "err": err})) @@ -284,7 +284,7 @@ var propertyGetCmd = &cobra.Command{ Short: wski18n.T("get property"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { // If no property is explicitly specified, default to all properties @@ -301,7 +301,7 @@ var propertyGetCmd = &cobra.Command{ } if Flags.property.all || Flags.property.key { - fmt.Fprintf(color.Output, "%s\t\t%s\n", wski18n.T("client key"), boldString(Properties.Key)) + fmt.Fprintf(color.Output, "%s\t\t%s\n", wski18n.T("Client key"), boldString(Properties.Key)) } if Flags.property.all || Flags.property.auth { @@ -325,9 +325,9 @@ var propertyGetCmd = &cobra.Command{ } if Flags.property.all || Flags.property.apibuild || Flags.property.apibuildno { - info, _, err := client.Info.Get() + info, _, err := Client.Info.Get() if err != nil { - whisk.Debug(whisk.DbgError, "client.Info.Get() failed: %s\n", err) + whisk.Debug(whisk.DbgError, "Client.Info.Get() failed: %s\n", err) info = &whisk.Info{} info.Build = wski18n.T("Unknown") info.BuildNo = wski18n.T("Unknown") @@ -499,44 +499,43 @@ func parseConfigFlags(cmd *cobra.Command, args []string) error { if cert := Flags.Global.Cert; len(cert) > 0 { Properties.Cert = cert - if client != nil { - client.Config.Cert = cert + if Client != nil { + Client.Config.Cert = cert } } if key := Flags.Global.Key; len(key) > 0 { Properties.Key = key - if client != nil { - client.Config.Key = key + if Client != nil { + Client.Config.Key = key } } if auth := Flags.Global.Auth; len(auth) > 0 { Properties.Auth = auth - if client != nil { - client.Config.AuthToken = auth + if Client != nil { + Client.Config.AuthToken = auth } } if namespace := Flags.property.namespaceSet; len(namespace) > 0 { Properties.Namespace = namespace - if client != nil { - client.Config.Namespace = namespace + if Client != nil { + Client.Config.Namespace = namespace } } if apiVersion := Flags.Global.Apiversion; len(apiVersion) > 0 { Properties.APIVersion = apiVersion - if client != nil { - client.Config.Version = apiVersion + if Client != nil { + Client.Config.Version = apiVersion } } if apiHost := Flags.Global.Apihost; len(apiHost) > 0 { Properties.APIHost = apiHost - - if client != nil { - client.Config.Host = apiHost + if Client != nil { + Client.Config.Host = apiHost baseURL, err := whisk.GetURLBase(apiHost, DefaultOpenWhiskApiPath) if err != nil { @@ -546,7 +545,7 @@ func parseConfigFlags(cmd *cobra.Command, args []string) error { werr := whisk.MakeWskError(errors.New(errStr), whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) return werr } - client.Config.BaseURL = baseURL + Client.Config.BaseURL = baseURL } } diff --git a/commands/qualified_name.go b/commands/qualified_name.go index e94aa9a..e3391cf 100644 --- a/commands/qualified_name.go +++ b/commands/qualified_name.go @@ -28,7 +28,7 @@ type QualifiedName struct { namespace string // namespace. does not include leading '/'. may be "" (i.e. default namespace) packageName string // package. may be "". does not include leading/trailing '/' entity string // entity. should not be "" - entityName string // pkg+entity + EntityName string // pkg+entity } /////////////////////////// @@ -61,7 +61,7 @@ func (qualifiedName *QualifiedName) GetPackageName() string { // GetEntityName() returns the entity name ([package/]entity) of qualifiedName // without a leading '/' func (qualifiedName *QualifiedName) GetEntityName() string { - return qualifiedName.entityName + return qualifiedName.EntityName } // GetEntity() returns the name of entity in qualifiedName without a leading '/' @@ -110,7 +110,7 @@ func NewQualifiedName(name string) (*QualifiedName, error) { } } - qualifiedName.entityName = strings.Join(parts[2:], "/") + qualifiedName.EntityName = strings.Join(parts[2:], "/") if len(parts) == 4 { qualifiedName.packageName = parts[2] } @@ -124,7 +124,7 @@ func NewQualifiedName(name string) (*QualifiedName, error) { if len(parts) == 2 { qualifiedName.packageName = parts[0] } - qualifiedName.entityName = name + qualifiedName.EntityName = name qualifiedName.namespace = getNamespaceFromProp() } diff --git a/commands/rule.go b/commands/rule.go index f88a2dd..dddbc3b 100644 --- a/commands/rule.go +++ b/commands/rule.go @@ -39,12 +39,12 @@ var ruleEnableCmd = &cobra.Command{ Short: wski18n.T("enable rule"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 1, 1, "Rule enable", wski18n.T("A rule name is required.")); whiskErr != nil { + if whiskErr := CheckArgs(args, 1, 1, "Rule enable", wski18n.T("A rule name is required.")); whiskErr != nil { return whiskErr } @@ -52,12 +52,12 @@ var ruleEnableCmd = &cobra.Command{ return NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() ruleName := qualifiedName.GetEntityName() - _, _, err = client.Rules.SetState(ruleName, "active") + _, _, err = Client.Rules.SetState(ruleName, "active") if err != nil { - whisk.Debug(whisk.DbgError, "client.Rules.SetState(%s, active) failed: %s\n", ruleName, err) + whisk.Debug(whisk.DbgError, "Client.Rules.SetState(%s, active) failed: %s\n", ruleName, err) errStr := wski18n.T("Unable to enable rule '{{.name}}': {{.err}}", map[string]interface{}{"name": ruleName, "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) @@ -76,12 +76,12 @@ var ruleDisableCmd = &cobra.Command{ Short: wski18n.T("disable rule"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 1, 1, "Rule disable", wski18n.T("A rule name is required.")); whiskErr != nil { + if whiskErr := CheckArgs(args, 1, 1, "Rule disable", wski18n.T("A rule name is required.")); whiskErr != nil { return whiskErr } @@ -89,12 +89,12 @@ var ruleDisableCmd = &cobra.Command{ return NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() ruleName := qualifiedName.GetEntityName() - _, _, err = client.Rules.SetState(ruleName, "inactive") + _, _, err = Client.Rules.SetState(ruleName, "inactive") if err != nil { - whisk.Debug(whisk.DbgError, "client.Rules.SetState(%s, inactive) failed: %s\n", ruleName, err) + whisk.Debug(whisk.DbgError, "Client.Rules.SetState(%s, inactive) failed: %s\n", ruleName, err) errStr := wski18n.T("Unable to disable rule '{{.name}}': {{.err}}", map[string]interface{}{"name": ruleName, "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) @@ -113,12 +113,12 @@ var ruleStatusCmd = &cobra.Command{ Short: wski18n.T("get rule status"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 1, 1, "Rule status", wski18n.T("A rule name is required.")); whiskErr != nil { + if whiskErr := CheckArgs(args, 1, 1, "Rule status", wski18n.T("A rule name is required.")); whiskErr != nil { return whiskErr } @@ -126,12 +126,12 @@ var ruleStatusCmd = &cobra.Command{ return NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() ruleName := qualifiedName.GetEntityName() - rule, _, err := client.Rules.Get(ruleName) + rule, _, err := Client.Rules.Get(ruleName) if err != nil { - whisk.Debug(whisk.DbgError, "client.Rules.Get(%s) failed: %s\n", ruleName, err) + whisk.Debug(whisk.DbgError, "Client.Rules.Get(%s) failed: %s\n", ruleName, err) errStr := wski18n.T("Unable to get status of rule '{{.name}}': {{.err}}", map[string]interface{}{"name": ruleName, "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE) @@ -150,12 +150,12 @@ var ruleCreateCmd = &cobra.Command{ Short: wski18n.T("create new rule"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 3, 3, "Rule create", + if whiskErr := CheckArgs(args, 3, 3, "Rule create", wski18n.T("A rule, trigger and action name are required.")); whiskErr != nil { return whiskErr } @@ -164,7 +164,7 @@ var ruleCreateCmd = &cobra.Command{ return NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() ruleName := qualifiedName.GetEntityName() triggerName := getQualifiedName(args[1], Properties.Namespace) actionName := getQualifiedName(args[2], Properties.Namespace) @@ -177,9 +177,9 @@ var ruleCreateCmd = &cobra.Command{ whisk.Debug(whisk.DbgInfo, "Inserting rule:\n%+v\n", rule) var retRule *whisk.Rule - retRule, _, err = client.Rules.Insert(rule, false) + retRule, _, err = Client.Rules.Insert(rule, false) if err != nil { - whisk.Debug(whisk.DbgError, "client.Rules.Insert(%#v) failed: %s\n", rule, err) + whisk.Debug(whisk.DbgError, "Client.Rules.Insert(%#v) failed: %s\n", rule, err) errStr := wski18n.T("Unable to create rule '{{.name}}': {{.err}}", map[string]interface{}{"name": ruleName, "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) @@ -199,12 +199,12 @@ var ruleUpdateCmd = &cobra.Command{ Short: wski18n.T("update an existing rule, or create a rule if it does not exist"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 3, 3, "Rule update", + if whiskErr := CheckArgs(args, 3, 3, "Rule update", wski18n.T("A rule, trigger and action name are required.")); whiskErr != nil { return whiskErr } @@ -213,7 +213,7 @@ var ruleUpdateCmd = &cobra.Command{ return NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() ruleName := qualifiedName.GetEntityName() triggerName := getQualifiedName(args[1], Properties.Namespace) actionName := getQualifiedName(args[2], Properties.Namespace) @@ -224,9 +224,9 @@ var ruleUpdateCmd = &cobra.Command{ Action: actionName, } - _, _, err = client.Rules.Insert(rule, true) + _, _, err = Client.Rules.Insert(rule, true) if err != nil { - whisk.Debug(whisk.DbgError, "client.Rules.Insert(%#v) failed: %s\n", rule, err) + whisk.Debug(whisk.DbgError, "Client.Rules.Insert(%#v) failed: %s\n", rule, err) errStr := wski18n.T("Unable to update rule '{{.name}}': {{.err}}", map[string]interface{}{"name": rule.Name, "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) @@ -245,13 +245,13 @@ var ruleGetCmd = &cobra.Command{ Short: wski18n.T("get rule"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var field string var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 1, 2, "Rule get", wski18n.T("A rule name is required.")); whiskErr != nil { + if whiskErr := CheckArgs(args, 1, 2, "Rule get", wski18n.T("A rule name is required.")); whiskErr != nil { return whiskErr } @@ -270,12 +270,12 @@ var ruleGetCmd = &cobra.Command{ return NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() ruleName := qualifiedName.GetEntityName() - rule, _, err := client.Rules.Get(ruleName) + rule, _, err := Client.Rules.Get(ruleName) if err != nil { - whisk.Debug(whisk.DbgError, "client.Rules.Get(%s) failed: %s\n", ruleName, err) + whisk.Debug(whisk.DbgError, "Client.Rules.Get(%s) failed: %s\n", ruleName, err) errStr := wski18n.T("Unable to get rule '{{.name}}': {{.err}}", map[string]interface{}{"name": ruleName, "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE) @@ -306,12 +306,12 @@ var ruleDeleteCmd = &cobra.Command{ Short: wski18n.T("delete rule"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 1, 1, "Rule delete", wski18n.T("A rule name is required.")); whiskErr != nil { + if whiskErr := CheckArgs(args, 1, 1, "Rule delete", wski18n.T("A rule name is required.")); whiskErr != nil { return whiskErr } @@ -319,13 +319,13 @@ var ruleDeleteCmd = &cobra.Command{ return NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() ruleName := qualifiedName.GetEntityName() if Flags.rule.disable { - _, _, err := client.Rules.SetState(ruleName, "inactive") + _, _, err := Client.Rules.SetState(ruleName, "inactive") if err != nil { - whisk.Debug(whisk.DbgError, "client.Rules.SetState(%s, inactive) failed: %s\n", ruleName, err) + whisk.Debug(whisk.DbgError, "Client.Rules.SetState(%s, inactive) failed: %s\n", ruleName, err) errStr := wski18n.T("Unable to disable rule '{{.name}}': {{.err}}", map[string]interface{}{"name": ruleName, "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) @@ -333,9 +333,9 @@ var ruleDeleteCmd = &cobra.Command{ } } - _, err = client.Rules.Delete(ruleName) + _, err = Client.Rules.Delete(ruleName) if err != nil { - whisk.Debug(whisk.DbgError, "client.Rules.Delete(%s) error: %s\n", ruleName, err) + whisk.Debug(whisk.DbgError, "Client.Rules.Delete(%s) error: %s\n", ruleName, err) errStr := wski18n.T("Unable to delete rule '{{.name}}': {{.err}}", map[string]interface{}{"name": ruleName, "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) @@ -354,12 +354,12 @@ var ruleListCmd = &cobra.Command{ Short: wski18n.T("list all rules"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 0, 1, "Rule list", + if whiskErr := CheckArgs(args, 0, 1, "Rule list", wski18n.T("An optional namespace is the only valid argument.")); whiskErr != nil { return whiskErr } @@ -373,7 +373,7 @@ var ruleListCmd = &cobra.Command{ return entityNameError(qualifiedName.GetEntityName()) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() } ruleListOptions := &whisk.RuleListOptions{ @@ -381,9 +381,9 @@ var ruleListCmd = &cobra.Command{ Limit: Flags.common.limit, } - rules, _, err := client.Rules.List(ruleListOptions) + rules, _, err := Client.Rules.List(ruleListOptions) if err != nil { - whisk.Debug(whisk.DbgError, "client.Rules.List(%#v) error: %s\n", ruleListOptions, err) + whisk.Debug(whisk.DbgError, "Client.Rules.List(%#v) error: %s\n", ruleListOptions, err) errStr := wski18n.T("Unable to obtain the list of rules for namespace '{{.name}}': {{.err}}", map[string]interface{}{"name": getClientNamespace(), "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) @@ -391,7 +391,7 @@ var ruleListCmd = &cobra.Command{ } else { //No errors, lets attempt to retrieve the status of each rule #312 for index, rule := range rules { - ruleStatus, _, err := client.Rules.Get(rule.Name) + ruleStatus, _, err := Client.Rules.Get(rule.Name) if err != nil { errStr := wski18n.T("Unable to get status of rule '{{.name}}': {{.err}}", map[string]interface{}{"name": rule.Name, "err": err}) diff --git a/commands/sdk.go b/commands/sdk.go index 145839a..3dbb1fe 100644 --- a/commands/sdk.go +++ b/commands/sdk.go @@ -58,7 +58,7 @@ var sdkInstallCmd = &cobra.Command{ Long: wski18n.T("install SDK artifacts, where valid COMPONENT values are docker, ios, and bashauto"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error if len(args) != 1 { @@ -160,9 +160,9 @@ func sdkInstall(componentName string) error { return werr } - resp, err := client.Sdks.Install(sdkMap[componentName].UrlPath) + resp, err := Client.Sdks.Install(sdkMap[componentName].UrlPath) if err != nil { - whisk.Debug(whisk.DbgError, "client.Sdks.Install(%s) failed: %s\n", sdkMap[componentName].UrlPath, err) + whisk.Debug(whisk.DbgError, "Client.Sdks.Install(%s) failed: %s\n", sdkMap[componentName].UrlPath, err) errStr := wski18n.T("Unable to retrieve '{{.urlpath}}' SDK: {{.err}}", map[string]interface{}{"urlpath": sdkMap[componentName].UrlPath, "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) diff --git a/commands/trigger.go b/commands/trigger.go index 92ae09c..2e53acd 100644 --- a/commands/trigger.go +++ b/commands/trigger.go @@ -45,13 +45,13 @@ var triggerFireCmd = &cobra.Command{ Short: wski18n.T("fire trigger event"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var parameters interface{} var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 1, 2, "Trigger fire", + if whiskErr := CheckArgs(args, 1, 2, "Trigger fire", wski18n.T("A trigger name is required. A payload is optional.")); whiskErr != nil { return whiskErr } @@ -60,7 +60,7 @@ var triggerFireCmd = &cobra.Command{ return NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() // Add payload to parameters if len(args) == 2 { @@ -80,9 +80,9 @@ var triggerFireCmd = &cobra.Command{ } } - trigResp, _, err := client.Triggers.Fire(qualifiedName.GetEntityName(), parameters) + trigResp, _, err := Client.Triggers.Fire(qualifiedName.GetEntityName(), parameters) if err != nil { - whisk.Debug(whisk.DbgError, "client.Triggers.Fire(%s, %#v) failed: %s\n", qualifiedName.GetEntityName(), parameters, err) + whisk.Debug(whisk.DbgError, "Client.Triggers.Fire(%s, %#v) failed: %s\n", qualifiedName.GetEntityName(), parameters, err) errStr := wski18n.T("Unable to fire trigger '{{.name}}': {{.err}}", map[string]interface{}{"name": qualifiedName.GetEntityName(), "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, @@ -106,14 +106,14 @@ var triggerCreateCmd = &cobra.Command{ Short: wski18n.T("create new trigger"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var annotations interface{} var feedArgPassed bool = (Flags.common.feed != "") var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 1, 1, "Trigger create", + if whiskErr := CheckArgs(args, 1, 1, "Trigger create", wski18n.T("A trigger name is required.")); whiskErr != nil { return whiskErr } @@ -122,7 +122,7 @@ var triggerCreateCmd = &cobra.Command{ return NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() var fullTriggerName string var fullFeedName string @@ -138,7 +138,7 @@ var triggerCreateCmd = &cobra.Command{ fullTriggerName = fmt.Sprintf("/%s/%s", qualifiedName.GetNamespace(), qualifiedName.GetEntityName()) Flags.common.param = append(Flags.common.param, getFormattedJSON(FEED_LIFECYCLE_EVENT, FEED_CREATE)) Flags.common.param = append(Flags.common.param, getFormattedJSON(FEED_TRIGGER_NAME, fullTriggerName)) - Flags.common.param = append(Flags.common.param, getFormattedJSON(FEED_AUTH_KEY, client.Config.AuthToken)) + Flags.common.param = append(Flags.common.param, getFormattedJSON(FEED_AUTH_KEY, Client.Config.AuthToken)) } @@ -181,9 +181,9 @@ var triggerCreateCmd = &cobra.Command{ trigger.Parameters = parameters.(whisk.KeyValueArr) } - _, _, err = client.Triggers.Insert(trigger, false) + _, _, err = Client.Triggers.Insert(trigger, false) if err != nil { - whisk.Debug(whisk.DbgError, "client.Triggers.Insert(%+v,false) failed: %s\n", trigger, err) + whisk.Debug(whisk.DbgError, "Client.Triggers.Insert(%+v,false) failed: %s\n", trigger, err) errStr := wski18n.T("Unable to create trigger '{{.name}}': {{.err}}", map[string]interface{}{"name": trigger.Name, "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) @@ -221,12 +221,12 @@ var triggerUpdateCmd = &cobra.Command{ Short: wski18n.T("update an existing trigger, or create a trigger if it does not exist"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 1, 1, "Trigger update", + if whiskErr := CheckArgs(args, 1, 1, "Trigger update", wski18n.T("A trigger name is required.")); whiskErr != nil { return whiskErr } @@ -235,7 +235,7 @@ var triggerUpdateCmd = &cobra.Command{ return NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() // Convert the trigger's list of default parameters from a string into []KeyValue // The 1 or more --param arguments have all been combined into a single []string @@ -269,9 +269,9 @@ var triggerUpdateCmd = &cobra.Command{ Annotations: annotations.(whisk.KeyValueArr), } - _, _, err = client.Triggers.Insert(trigger, true) + _, _, err = Client.Triggers.Insert(trigger, true) if err != nil { - whisk.Debug(whisk.DbgError, "client.Triggers.Insert(%+v,true) failed: %s\n", trigger, err) + whisk.Debug(whisk.DbgError, "Client.Triggers.Insert(%+v,true) failed: %s\n", trigger, err) errStr := wski18n.T("Unable to update trigger '{{.name}}': {{.err}}", map[string]interface{}{"name": trigger.Name, "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) @@ -290,13 +290,13 @@ var triggerGetCmd = &cobra.Command{ Short: wski18n.T("get trigger"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var field string var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 1, 2, "Trigger get", wski18n.T("A trigger name is required.")); whiskErr != nil { + if whiskErr := CheckArgs(args, 1, 2, "Trigger get", wski18n.T("A trigger name is required.")); whiskErr != nil { return whiskErr } @@ -315,11 +315,11 @@ var triggerGetCmd = &cobra.Command{ return NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() - retTrigger, _, err := client.Triggers.Get(qualifiedName.GetEntityName()) + retTrigger, _, err := Client.Triggers.Get(qualifiedName.GetEntityName()) if err != nil { - whisk.Debug(whisk.DbgError, "client.Triggers.Get(%s) failed: %s\n", qualifiedName.GetEntityName(), err) + whisk.Debug(whisk.DbgError, "Client.Triggers.Get(%s) failed: %s\n", qualifiedName.GetEntityName(), err) errStr := wski18n.T("Unable to get trigger '{{.name}}': {{.err}}", map[string]interface{}{"name": qualifiedName.GetEntityName(), "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) @@ -350,7 +350,7 @@ var triggerDeleteCmd = &cobra.Command{ Short: wski18n.T("delete trigger"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var retTrigger *whisk.Trigger @@ -358,7 +358,7 @@ var triggerDeleteCmd = &cobra.Command{ var origParams []string var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 1, 1, "Trigger delete", + if whiskErr := CheckArgs(args, 1, 1, "Trigger delete", wski18n.T("A trigger name is required.")); whiskErr != nil { return whiskErr } @@ -367,11 +367,11 @@ var triggerDeleteCmd = &cobra.Command{ return NewQualifiedNameError(args[0], err) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() - retTrigger, _, err = client.Triggers.Get(qualifiedName.GetEntityName()) + retTrigger, _, err = Client.Triggers.Get(qualifiedName.GetEntityName()) if err != nil { - whisk.Debug(whisk.DbgError, "client.Triggers.Get(%s) failed: %s\n", qualifiedName.GetEntityName(), err) + whisk.Debug(whisk.DbgError, "Client.Triggers.Get(%s) failed: %s\n", qualifiedName.GetEntityName(), err) errStr := wski18n.T("Unable to get trigger '{{.name}}': {{.err}}", map[string]interface{}{"name": qualifiedName.GetEntityName(), "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) @@ -387,7 +387,7 @@ var triggerDeleteCmd = &cobra.Command{ fullTriggerName := fmt.Sprintf("/%s/%s", qualifiedName.GetNamespace(), qualifiedName.GetEntityName()) Flags.common.param = append(Flags.common.param, getFormattedJSON(FEED_LIFECYCLE_EVENT, FEED_DELETE)) Flags.common.param = append(Flags.common.param, getFormattedJSON(FEED_TRIGGER_NAME, fullTriggerName)) - Flags.common.param = append(Flags.common.param, getFormattedJSON(FEED_AUTH_KEY, client.Config.AuthToken)) + Flags.common.param = append(Flags.common.param, getFormattedJSON(FEED_AUTH_KEY, Client.Config.AuthToken)) err = configureFeed(qualifiedName.GetEntityName(), fullFeedName) if err != nil { @@ -395,14 +395,14 @@ var triggerDeleteCmd = &cobra.Command{ } Flags.common.param = origParams - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() } } - retTrigger, _, err = client.Triggers.Delete(qualifiedName.GetEntityName()) + retTrigger, _, err = Client.Triggers.Delete(qualifiedName.GetEntityName()) if err != nil { - whisk.Debug(whisk.DbgError, "client.Triggers.Delete(%s) failed: %s\n", qualifiedName.GetEntityName(), err) + whisk.Debug(whisk.DbgError, "Client.Triggers.Delete(%s) failed: %s\n", qualifiedName.GetEntityName(), err) errStr := wski18n.T("Unable to delete trigger '{{.name}}': {{.err}}", map[string]interface{}{"name": qualifiedName.GetEntityName(), "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) @@ -422,12 +422,12 @@ var triggerListCmd = &cobra.Command{ Short: wski18n.T("list all triggers"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: func(cmd *cobra.Command, args []string) error { var err error var qualifiedName = new(QualifiedName) - if whiskErr := checkArgs(args, 0, 1, "Trigger list", + if whiskErr := CheckArgs(args, 0, 1, "Trigger list", wski18n.T("An optional namespace is the only valid argument.")); whiskErr != nil { return whiskErr } @@ -441,17 +441,17 @@ var triggerListCmd = &cobra.Command{ return entityNameError(qualifiedName.GetEntityName()) } - client.Namespace = qualifiedName.GetNamespace() + Client.Namespace = qualifiedName.GetNamespace() } options := &whisk.TriggerListOptions{ Skip: Flags.common.skip, Limit: Flags.common.limit, } - triggers, _, err := client.Triggers.List(options) + triggers, _, err := Client.Triggers.List(options) if err != nil { - whisk.Debug(whisk.DbgError, "client.Triggers.List(%#v) for namespace '%s' failed: %s\n", options, - client.Namespace, err) + whisk.Debug(whisk.DbgError, "Client.Triggers.List(%#v) for namespace '%s' failed: %s\n", options, + Client.Namespace, err) errStr := wski18n.T("Unable to obtain the list of triggers for namespace '{{.name}}': {{.err}}", map[string]interface{}{"name": getClientNamespace(), "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) diff --git a/commands/util.go b/commands/util.go index 95b8291..a4056ad 100644 --- a/commands/util.go +++ b/commands/util.go @@ -785,7 +785,7 @@ func unpackTar(inpath string) error { return nil } -func checkArgs(args []string, minimumArgNumber int, maximumArgNumber int, commandName string, +func CheckArgs(args []string, minimumArgNumber int, maximumArgNumber int, commandName string, requiredArgMsg string) (*whisk.WskError) { exactlyOrAtLeast := wski18n.T("exactly") exactlyOrNoMoreThan := wski18n.T("exactly") @@ -824,7 +824,7 @@ func normalizeNamespace(namespace string) (string) { } func getClientNamespace() (string) { - return normalizeNamespace(client.Config.Namespace) + return normalizeNamespace(Client.Config.Namespace) } func ReadFile(filename string) (string, error) { diff --git a/commands/wsk.go b/commands/wsk.go index b95a898..d81826d 100644 --- a/commands/wsk.go +++ b/commands/wsk.go @@ -36,7 +36,7 @@ var listCmd = &cobra.Command{ Short: wski18n.T("list entities in the current namespace"), SilenceUsage: true, SilenceErrors: true, - PreRunE: setupClientConfig, + PreRunE: SetupClientConfig, RunE: namespaceGetCmd.RunE, } diff --git a/wski18n/i18n_resources.go b/wski18n/i18n_resources.go index b331ec6..26f85a3 100644 --- a/wski18n/i18n_resources.go +++ b/wski18n/i18n_resources.go @@ -109,7 +109,7 @@ func wski18nResourcesDe_deAllJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "wski18n/resources/de_DE.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1506089398, 0)} + info := bindataFileInfo{name: "wski18n/resources/de_DE.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1506363546, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -129,7 +129,7 @@ func wski18nResourcesEn_usAllJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "wski18n/resources/en_US.all.json", size: 50999, mode: os.FileMode(420), modTime: time.Unix(1506089759, 0)} + info := bindataFileInfo{name: "wski18n/resources/en_US.all.json", size: 50999, mode: os.FileMode(420), modTime: time.Unix(1506363546, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -149,7 +149,7 @@ func wski18nResourcesEs_esAllJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "wski18n/resources/es_ES.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1506089398, 0)} + info := bindataFileInfo{name: "wski18n/resources/es_ES.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1506363546, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -169,7 +169,7 @@ func wski18nResourcesFr_frAllJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "wski18n/resources/fr_FR.all.json", size: 101, mode: os.FileMode(420), modTime: time.Unix(1506089398, 0)} + info := bindataFileInfo{name: "wski18n/resources/fr_FR.all.json", size: 101, mode: os.FileMode(420), modTime: time.Unix(1506363546, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -189,7 +189,7 @@ func wski18nResourcesIt_itAllJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "wski18n/resources/it_IT.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1506089398, 0)} + info := bindataFileInfo{name: "wski18n/resources/it_IT.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1506363546, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -209,7 +209,7 @@ func wski18nResourcesJa_jaAllJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "wski18n/resources/ja_JA.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1506089398, 0)} + info := bindataFileInfo{name: "wski18n/resources/ja_JA.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1506363546, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -229,7 +229,7 @@ func wski18nResourcesKo_krAllJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "wski18n/resources/ko_KR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1506089398, 0)} + info := bindataFileInfo{name: "wski18n/resources/ko_KR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1506363546, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -249,7 +249,7 @@ func wski18nResourcesPt_brAllJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "wski18n/resources/pt_BR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1506089398, 0)} + info := bindataFileInfo{name: "wski18n/resources/pt_BR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1506363546, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -269,7 +269,7 @@ func wski18nResourcesZh_hansAllJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "wski18n/resources/zh_Hans.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1506089398, 0)} + info := bindataFileInfo{name: "wski18n/resources/zh_Hans.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1506363546, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -289,7 +289,7 @@ func wski18nResourcesZh_hantAllJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "wski18n/resources/zh_Hant.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1506089398, 0)} + info := bindataFileInfo{name: "wski18n/resources/zh_Hant.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1506363546, 0)} a := &asset{bytes: bytes, info: info} return a, nil } -- To stop receiving notification emails like this one, please contact "commits@openwhisk.apache.org" <commits@openwhisk.apache.org>.