Files
atlantis/server/events/command/name.go
Sarvar Muminov 90e92e3a13 chore: move CommandContext and CommandResult to models (#193) (#2093)
* Moved CommandContext and CommandResult to models (#193)

* Moved CommandContext and CommandResult to models

* move from models to command

rename CommandContext -> Context
rename CommandResult -> Result

* moved command related helpers into command package

* move ProjectCommandContext and ProjectResult to command/project package

* move project command context and project result

* revert unrelated code

* move tests

* fix left over

* fix linting

* fix tests

* remove unused import

* fix project context dependencies

* fix depenedecies

* fix typo
2022-03-21 10:36:13 -07:00

50 lines
1.2 KiB
Go

package command
import "strings"
// Name is which command to run.
type Name int
const (
// Apply is a command to run terraform apply.
Apply Name = iota
// Plan is a command to run terraform plan.
Plan
// Unlock is a command to discard previous plans as well as the atlantis locks.
Unlock
// PolicyCheck is a command to run conftest test.
PolicyCheck
// ApprovePolicies is a command to approve policies with owner check
ApprovePolicies
// Autoplan is a command to run terrafor plan on PR open/update if autoplan is enabled
Autoplan
// Version is a command to run terraform version.
Version
// Adding more? Don't forget to update String() below
)
// TitleString returns the string representation in title form.
// ie. policy_check becomes Policy Check
func (c Name) TitleString() string {
return strings.Title(strings.ReplaceAll(strings.ToLower(c.String()), "_", " "))
}
// String returns the string representation of c.
func (c Name) String() string {
switch c {
case Apply:
return "apply"
case Plan, Autoplan:
return "plan"
case Unlock:
return "unlock"
case PolicyCheck:
return "policy_check"
case ApprovePolicies:
return "approve_policies"
case Version:
return "version"
}
return ""
}