diff --git a/README.md b/README.md index daef857..85e9bd8 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ your-lex-workspace ├──bots └──monobot ``` +When using the provision command for a mono bot, the `--name` flag is optional. If it is not present `lexbelt` will use the `lexBotName` in the monobot specification file. You can take a look at examples/yaml/monobot/OrderFlowersMono.yaml to see an example monobot yaml file like so: ``` diff --git a/bot.go b/bot.go index ee5d65c..a0f7957 100644 --- a/bot.go +++ b/bot.go @@ -13,7 +13,7 @@ type botYaml struct { LexBot *lexmodelbuildingservice.PutBotInput `locationName:"lexBot" type:"structure"` } -func putBot(svc *lexmodelbuildingservice.LexModelBuildingService, file string, poll int) { +func putBot(svc *lexmodelbuildingservice.LexModelBuildingService, file string, name string, poll int) { var myBot botYaml readAndUnmarshal(file, &myBot) @@ -22,8 +22,8 @@ func putBot(svc *lexmodelbuildingservice.LexModelBuildingService, file string, p log.Fatal("Yaml file is not as expected, please check your syntax.") } - if *putBotCommandName != "" { - myBot.LexBot.Name = putBotCommandName + if name != "" { + myBot.LexBot.Name = &name } getResult, err := svc.GetBot(&lexmodelbuildingservice.GetBotInput{ diff --git a/examples/yaml/config.yaml b/examples/yaml/config.yaml deleted file mode 100644 index 711d61e..0000000 --- a/examples/yaml/config.yaml +++ /dev/null @@ -1,2 +0,0 @@ -region: ap-southeast-2 -profile: versent \ No newline at end of file diff --git a/lexbelt.go b/lexbelt.go index 8722963..d58cdcb 100644 --- a/lexbelt.go +++ b/lexbelt.go @@ -88,9 +88,9 @@ func main() { case putIntentCommand.FullCommand(): putIntent(svc, (*putIntentCommandFile).Name()) case putBotCommand.FullCommand(): - putBot(svc, (*putBotCommandFile).Name(), *putBotCommandPoll) + putBot(svc, (*putBotCommandFile).Name(), *putBotCommandName, *putBotCommandPoll) case provisionCommand.FullCommand(): - provision(svc, (*provisionCommandFile).Name(), *provisionCommandPoll) + provision(svc, (*provisionCommandFile).Name(), *provisionCommandName, *provisionCommandPoll) } } diff --git a/provisioner.go b/provisioner.go index 56fa93f..0beaae0 100644 --- a/provisioner.go +++ b/provisioner.go @@ -24,7 +24,7 @@ type provisionerSpecification struct { } `locationName:"lexBotProvisioner" type:"structure"` } -func provision(svc *lexmodelbuildingservice.LexModelBuildingService, file string, poll int) { +func provision(svc *lexmodelbuildingservice.LexModelBuildingService, file string, name string, poll int) { var myProvisionerSpecification provisionerSpecification readAndUnmarshal(file, &myProvisionerSpecification) @@ -34,11 +34,11 @@ func provision(svc *lexmodelbuildingservice.LexModelBuildingService, file string } var myProvisioner provisioner - if *provisionCommandName != "" { - myProvisioner.LexBot.Name = putIntentCommandName - } else { - myProvisioner.LexBot.Name = myProvisionerSpecification.LexBotProvisioner.LexBotName + + if name == "" { + name = *myProvisionerSpecification.LexBotProvisioner.LexBotName } + myProvisioner.LexBot.Name = &name //based on the mono bot yaml, load slots, intents and the bot and provision in the correct order @@ -59,6 +59,6 @@ func provision(svc *lexmodelbuildingservice.LexModelBuildingService, file string //lastly the bot fmt.Println("Adding the bot and building it") - putBot(svc, basePath+"bots"+separator+*myProvisionerSpecification.LexBotProvisioner.LexBot, poll) + putBot(svc, basePath+"bots"+separator+*myProvisionerSpecification.LexBotProvisioner.LexBot, name, poll) }