@@ -11,16 +11,16 @@ import (
1111)
1212
1313const (
14- SlackUnknownResponse = "Incorrect usage, expected /gitops-commit [ command] [name] [tag] "
15- SlackUnknownCommandResponse = "Unknown command '%s' , expected /gitops-commit [command] [name] [tag]"
14+ SlackUnknownResponse = "Incorrect usage, unknown command"
15+ SlackDeployUnknownResponse = "Incorrect usage , expected /gitops-commit [command] [name] [tag]"
1616)
1717
1818func (s * server ) handleSlackCommand (registry * NamedRepositoryRegistry ) func (http.ResponseWriter , slack.SlashCommand ) {
1919 return func (w http.ResponseWriter , sl slack.SlashCommand ) {
2020 text := strings .Split (sl .Text , " " )
2121
22- if len (text ) < 3 || len ( text ) > 3 {
23- respondSlack (SlackUnknownResponse , slack .ResponseTypeEphemeral , w )
22+ if len (text ) < 1 {
23+ respondSlack (SlackDeployUnknownResponse , slack .ResponseTypeEphemeral , w )
2424
2525 return
2626 }
@@ -29,19 +29,33 @@ func (s *server) handleSlackCommand(registry *NamedRepositoryRegistry) func(http
2929
3030 switch command {
3131 case "deploy" :
32+ if len (text ) < 3 || len (text ) > 3 {
33+ respondSlack (SlackDeployUnknownResponse , slack .ResponseTypeEphemeral , w )
34+
35+ return
36+ }
37+
3238 deploy (s , w , registry , text [1 ], text [2 ])
3339
40+ return
41+ case "show" :
42+ show (w , registry )
43+
3444 return
3545 default :
3646 respondSlack (
37- fmt . Sprintf ( SlackUnknownCommandResponse , command ) ,
47+ SlackUnknownResponse ,
3848 slack .ResponseTypeEphemeral ,
3949 w ,
4050 )
4151 }
4252 }
4353}
4454
55+ func show (w http.ResponseWriter , registry * NamedRepositoryRegistry ) {
56+ respondSlack (fmt .Sprintf ("Manifest options: %s" , registry .getNamesFlattened ()), slack .ResponseTypeInChannel , w )
57+ }
58+
4559func deploy (s * server , w http.ResponseWriter , registry * NamedRepositoryRegistry , name string , version string ) {
4660 r , err := registry .findNamedRepository (name )
4761
0 commit comments