diff --git a/pkg/webhook/commands.go b/pkg/webhook/commands.go index 60c73b6a..b9b9172e 100644 --- a/pkg/webhook/commands.go +++ b/pkg/webhook/commands.go @@ -125,7 +125,7 @@ func NewCommandParser() *CommandParser { mentionRegex: regexp.MustCompile(`(?im)^ {0,3}schemabot(?:[ \t]+|$)`), helpRegex: regexp.MustCompile(`(?im)^ {0,3}schemabot[ \t]+help\b`), applyIDRegex: regexp.MustCompile(`(?i)\b(apply[_-][a-f0-9]+)\b`), - environmentRegex: regexp.MustCompile(`(?i)-e\s+(staging|production)`), + environmentRegex: regexp.MustCompile(`(?i)-e\s+([a-z0-9][a-z0-9_-]*)`), databaseRegex: regexp.MustCompile(`(?i)-d\s+([a-zA-Z0-9_-]+)`), tenantRegex: regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9_-]*$`), tenantFlagRegex: regexp.MustCompile(`(?i)(?:^|\s)(?:--tenant|-t)(?:[ \t]+([^\s]+))?`), diff --git a/pkg/webhook/commands_test.go b/pkg/webhook/commands_test.go index e032ad9e..6e833b96 100644 --- a/pkg/webhook/commands_test.go +++ b/pkg/webhook/commands_test.go @@ -278,6 +278,36 @@ func TestParseCommand(t *testing.T) { IsMention: true, }, }, + { + name: "apply with custom environment (qa)", + body: "schemabot apply -e qa", + expected: CommandResult{ + Action: "apply", + Environment: "qa", + Found: true, + IsMention: true, + }, + }, + { + name: "apply with custom environment (load)", + body: "schemabot apply -e load", + expected: CommandResult{ + Action: "apply", + Environment: "load", + Found: true, + IsMention: true, + }, + }, + { + name: "env flag does not consume a following flag", + body: "schemabot apply -e --tenant alpha", + expected: CommandResult{ + Action: "apply", + Tenant: "alpha", + MissingEnv: true, + IsMention: true, + }, + }, { name: "plan with database flag", body: "schemabot plan -e staging -d my-database",