func ClientFromConfig() (client.Client, error) { c := client.Client{ Host: viper.GetString("host"), AccessKeyName: viper.GetString("access_key_name"), AccessKey: viper.GetString("access_key"), ShowRequests: viper.GetBool("show_requests"), Mailbox: viper.GetString("mailbox"), } if c.AccessKeyName == "" { c.AccessKeyName = viper.GetString("mailbox") } return c, nil }
func _respond(call otto.FunctionCall) otto.Value { response, _ := call.Argument(0).ToString() client := client.Client{ Host: viper.GetString("host"), AccessKey: viper.GetString("access_key"), AccessKeyName: viper.GetString("access_key_name"), ShowRequests: viper.GetBool("show_requests"), } if client.AccessKeyName == "" { client.AccessKeyName = viper.GetString("mailbox") } messageId := getConstant(call.Otto, "SCRIPT_ID") err := client.Respond(messageId, response, false) if err != nil { jsThrow(call, err) } var v otto.Value v, _ = otto.ToValue(true) return v }
var deployTimeout int // sendCmd represents the send command var deployCmd = &cobra.Command{ Use: "deploy [file] [client]", Aliases: []string{"send"}, Short: "Send a script to be executed", Long: `Send a script to be executed by a client. The file can either be a javascript file or a zip file containing a javascript file and other arbitrary files.`, Run: func(cmd *cobra.Command, args []string) { client := client.Client{ Host: viper.GetString("host"), Mailbox: viper.GetString("mailbox"), AccessKey: viper.GetString("access_key"), AccessKeyName: viper.GetString("access_key_name"), ShowRequests: viper.GetBool("show_requests"), } if len(args) == 0 { log.Fatal("No script specified.") } filename := args[0] mailboxes := args[1:] pattern := cmd.Flag("pattern").Value.String() if pattern == "" && len(mailboxes) == 0 { log.Fatal("Must provide either a list of mailboxes, a pattern, or both.") } data, err := ioutil.ReadFile(filename) if err != nil { log.Fatal(err.Error())