Skip to content

Commit

Permalink
rename disable_repo_locking into repo_locking
Browse files Browse the repository at this point in the history
  • Loading branch information
krrrr38 committed Nov 21, 2022
1 parent 2447c74 commit 0c4240b
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 70 deletions.
6 changes: 3 additions & 3 deletions runatlantis.io/docs/repo-level-atlantis-yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ projects:
workspace: default
terraform_version: v0.11.0
delete_source_branch_on_merge: true
disable_repo_locking: true
repo_locking: true
autoplan:
when_modified: ["*.tf", "../modules/**/*.tf"]
enabled: true
Expand Down Expand Up @@ -265,7 +265,7 @@ dir: mydir
workspace: myworkspace
execution_order_group: 0
delete_source_branch_on_merge: false
disable_repo_locking: false
repo_locking: true
autoplan:
terraform_version: 0.11.0
apply_requirements: ["approved"]
Expand All @@ -280,7 +280,7 @@ workflow: myworkflow
| workspace | string | `"default"` | no | The [Terraform workspace](https://www.terraform.io/docs/state/workspaces.html) for this project. Atlantis will switch to this workplace when planning/applying and will create it if it doesn't exist. |
| execution_order_group | int | `0` | no | Index of execution order group. Projects will be sort by this field before planning/applying. |
| delete_source_branch_on_merge | bool | `false` | no | Automatically deletes the source branch on merge. |
| disable_repo_locking | bool | `false` | no | Disable repository lock in this project when plan. |
| repo_locking | bool | `true` | no | Get a repository lock in this project when plan. |
| autoplan | [Autoplan](#autoplan) | none | no | A custom autoplan configuration. If not specified, will use the autoplan config. See [Autoplanning](autoplanning.html). |
| terraform_version | string | none | no | A specific Terraform version to use when running commands for this project. Must be [Semver compatible](https://semver.org/), ex. `v0.11.0`, `0.12.0-beta1`. |
| apply_requirements<br />*(restricted)* | array[string] | none | no | Requirements that must be satisfied before `atlantis apply` can be run. Currently the only supported requirements are `approved`, `mergeable`, and `undiverged`. See [Apply Requirements](apply-requirements.html) for more details. |
Expand Down
12 changes: 6 additions & 6 deletions runatlantis.io/docs/server-side-repo-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ repos:

# allowed_overrides specifies which keys can be overridden by this repo in
# its atlantis.yaml file.
allowed_overrides: [apply_requirements, workflow, delete_source_branch_on_merge, disable_repo_locking]
allowed_overrides: [apply_requirements, workflow, delete_source_branch_on_merge, repo_locking]

# allowed_workflows specifies which workflows the repos that match
# are allowed to select.
Expand All @@ -59,9 +59,9 @@ repos:
# If false (default), the source branch won't be deleted on merge
delete_source_branch_on_merge: true

# disable_repo_locking defines whether lock repository when planning.
# If false (default), atlantis try to get a lock.
disable_repo_locking: true
# repo_locking defines whether lock repository when planning.
# If true (default), atlantis try to get a lock.
repo_locking: true

# pre_workflow_hooks defines arbitrary list of scripts to execute before workflow execution.
pre_workflow_hooks:
Expand Down Expand Up @@ -402,11 +402,11 @@ If you set a workflow with the key `default`, it will override this.
| branch | string | none | no | An regex matching pull requests by base branch (the branch the pull request is getting merged into). By default, all branches are matched |
| workflow | string | none | no | A custom workflow. |
| apply_requirements | []string | none | no | Requirements that must be satisfied before `atlantis apply` can be run. Currently the only supported requirements are `approved`, `mergeable`, and `undiverged`. See [Apply Requirements](apply-requirements.html) for more details. |
| allowed_overrides | []string | none | no | A list of restricted keys that `atlantis.yaml` files can override. The only supported keys are `apply_requirements`, `workflow`, `delete_source_branch_on_merge` and `disable_repo_locking` |
| allowed_overrides | []string | none | no | A list of restricted keys that `atlantis.yaml` files can override. The only supported keys are `apply_requirements`, `workflow`, `delete_source_branch_on_merge` and `repo_locking` |
| allowed_workflows | []string | none | no | A list of workflows that `atlantis.yaml` files can select from. |
| allow_custom_workflows | bool | false | no | Whether or not to allow [Custom Workflows](custom-workflows.html). |
| delete_source_branch_on_merge | bool | false | no | Whether or not to delete the source branch on merge (only AzureDevOps and GitLab support) |
| disable_repo_locking | bool | false | no | Whether or not to disable to get a lock |
| repo_locking | bool | false | no | Whether or not to get a lock |


:::tip Notes
Expand Down
4 changes: 2 additions & 2 deletions server/core/config/parser_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ func TestParseGlobalCfg(t *testing.T) {
input: `repos:
- id: /.*/
allowed_overrides: [invalid]`,
expErr: "repos: (0: (allowed_overrides: \"invalid\" is not a valid override, only \"apply_requirements\", \"workflow\", \"delete_source_branch_on_merge\" and \"disable_repo_locking\" are supported.).).",
expErr: "repos: (0: (allowed_overrides: \"invalid\" is not a valid override, only \"apply_requirements\", \"workflow\", \"delete_source_branch_on_merge\" and \"repo_locking\" are supported.).).",
},
"invalid apply_requirement": {
input: `repos:
Expand Down Expand Up @@ -1450,7 +1450,7 @@ workflows:
AllowedOverrides: []string{},
AllowCustomWorkflows: Bool(false),
DeleteSourceBranchOnMerge: Bool(false),
DisableRepoLocking: Bool(false),
RepoLocking: Bool(true),
},
},
Workflows: map[string]valid.Workflow{
Expand Down
8 changes: 4 additions & 4 deletions server/core/config/raw/global_cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Repo struct {
AllowedOverrides []string `yaml:"allowed_overrides" json:"allowed_overrides"`
AllowCustomWorkflows *bool `yaml:"allow_custom_workflows,omitempty" json:"allow_custom_workflows,omitempty"`
DeleteSourceBranchOnMerge *bool `yaml:"delete_source_branch_on_merge,omitempty" json:"delete_source_branch_on_merge,omitempty"`
DisableRepoLocking *bool `yaml:"disable_repo_locking,omitempty" json:"disable_repo_locking,omitempty"`
RepoLocking *bool `yaml:"repo_locking,omitempty" json:"repo_locking,omitempty"`
}

func (g GlobalCfg) Validate() error {
Expand Down Expand Up @@ -174,8 +174,8 @@ func (r Repo) Validate() error {
overridesValid := func(value interface{}) error {
overrides := value.([]string)
for _, o := range overrides {
if o != valid.ApplyRequirementsKey && o != valid.WorkflowKey && o != valid.DeleteSourceBranchOnMergeKey && o != valid.DisableRepoLockingKey {
return fmt.Errorf("%q is not a valid override, only %q, %q, %q and %q are supported", o, valid.ApplyRequirementsKey, valid.WorkflowKey, valid.DeleteSourceBranchOnMergeKey, valid.DisableRepoLockingKey)
if o != valid.ApplyRequirementsKey && o != valid.WorkflowKey && o != valid.DeleteSourceBranchOnMergeKey && o != valid.RepoLockingKey {
return fmt.Errorf("%q is not a valid override, only %q, %q, %q and %q are supported", o, valid.ApplyRequirementsKey, valid.WorkflowKey, valid.DeleteSourceBranchOnMergeKey, valid.RepoLockingKey)
}
}
return nil
Expand Down Expand Up @@ -269,6 +269,6 @@ OUTER:
AllowedOverrides: r.AllowedOverrides,
AllowCustomWorkflows: r.AllowCustomWorkflows,
DeleteSourceBranchOnMerge: r.DeleteSourceBranchOnMerge,
DisableRepoLocking: r.DisableRepoLocking,
RepoLocking: r.RepoLocking,
}
}
6 changes: 3 additions & 3 deletions server/core/config/raw/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Project struct {
Autoplan *Autoplan `yaml:"autoplan,omitempty"`
ApplyRequirements []string `yaml:"apply_requirements,omitempty"`
DeleteSourceBranchOnMerge *bool `yaml:"delete_source_branch_on_merge,omitempty"`
DisableRepoLocking *bool `yaml:"disable_repo_locking,omitempty"`
RepoLocking *bool `yaml:"repo_locking,omitempty"`
ExecutionOrderGroup *int `yaml:"execution_order_group,omitempty"`
}

Expand Down Expand Up @@ -119,8 +119,8 @@ func (p Project) ToValid() valid.Project {
v.DeleteSourceBranchOnMerge = p.DeleteSourceBranchOnMerge
}

if p.DisableRepoLocking != nil {
v.DisableRepoLocking = p.DisableRepoLocking
if p.RepoLocking != nil {
v.RepoLocking = p.RepoLocking
}

if p.ExecutionOrderGroup != nil {
Expand Down
44 changes: 22 additions & 22 deletions server/core/config/valid/global_cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const AllowedOverridesKey = "allowed_overrides"
const AllowCustomWorkflowsKey = "allow_custom_workflows"
const DefaultWorkflowName = "default"
const DeleteSourceBranchOnMergeKey = "delete_source_branch_on_merge"
const DisableRepoLockingKey = "disable_repo_locking"
const RepoLockingKey = "repo_locking"

// NonOverrideableApplyReqs will get applied across all "repos" in the server side config.
// If repo config is allowed overrides, they can override this.
Expand Down Expand Up @@ -70,7 +70,7 @@ type Repo struct {
AllowedOverrides []string
AllowCustomWorkflows *bool
DeleteSourceBranchOnMerge *bool
DisableRepoLocking *bool
RepoLocking *bool
}

type MergedProjectCfg struct {
Expand All @@ -87,7 +87,7 @@ type MergedProjectCfg struct {
PolicySets PolicySets
DeleteSourceBranchOnMerge bool
ExecutionOrderGroup int
DisableRepoLocking bool
RepoLocking bool
}

// WorkflowHook is a map of custom run commands to run before or after workflows.
Expand Down Expand Up @@ -194,9 +194,9 @@ func NewGlobalCfgFromArgs(args GlobalCfgArgs) GlobalCfg {

allowCustomWorkflows := false
deleteSourceBranchOnMerge := false
disableRepoLockingKey := false
repoLockingKey := true
if args.AllowRepoCfg {
allowedOverrides = []string{ApplyRequirementsKey, WorkflowKey, DeleteSourceBranchOnMergeKey, DisableRepoLockingKey}
allowedOverrides = []string{ApplyRequirementsKey, WorkflowKey, DeleteSourceBranchOnMergeKey, RepoLockingKey}
allowCustomWorkflows = true
}

Expand All @@ -213,7 +213,7 @@ func NewGlobalCfgFromArgs(args GlobalCfgArgs) GlobalCfg {
AllowedOverrides: allowedOverrides,
AllowCustomWorkflows: &allowCustomWorkflows,
DeleteSourceBranchOnMerge: &deleteSourceBranchOnMerge,
DisableRepoLocking: &disableRepoLockingKey,
RepoLocking: &repoLockingKey,
},
},
Workflows: map[string]Workflow{
Expand Down Expand Up @@ -250,7 +250,7 @@ func (r Repo) IDString() string {
// final config. It assumes that all configs have been validated.
func (g GlobalCfg) MergeProjectCfg(log logging.SimpleLogging, repoID string, proj Project, rCfg RepoCfg) MergedProjectCfg {
log.Debug("MergeProjectCfg started")
applyReqs, workflow, allowedOverrides, allowCustomWorkflows, deleteSourceBranchOnMerge, disableRepoLocking := g.getMatchingCfg(log, repoID)
applyReqs, workflow, allowedOverrides, allowCustomWorkflows, deleteSourceBranchOnMerge, repoLocking := g.getMatchingCfg(log, repoID)

// If repos are allowed to override certain keys then override them.
for _, key := range allowedOverrides {
Expand Down Expand Up @@ -296,10 +296,10 @@ func (g GlobalCfg) MergeProjectCfg(log logging.SimpleLogging, repoID string, pro
deleteSourceBranchOnMerge = *proj.DeleteSourceBranchOnMerge
}
log.Debug("merged deleteSourceBranchOnMerge: [%t]", deleteSourceBranchOnMerge)
case DisableRepoLockingKey:
if proj.DisableRepoLocking != nil {
log.Debug("overriding server-defined %s with repo settings: [%t]", DisableRepoLockingKey, *proj.DisableRepoLocking)
disableRepoLocking = *proj.DisableRepoLocking
case RepoLockingKey:
if proj.RepoLocking != nil {
log.Debug("overriding server-defined %s with repo settings: [%t]", RepoLockingKey, *proj.RepoLocking)
repoLocking = *proj.RepoLocking
}
}
log.Debug("MergeProjectCfg completed")
Expand All @@ -320,15 +320,15 @@ func (g GlobalCfg) MergeProjectCfg(log logging.SimpleLogging, repoID string, pro
PolicySets: g.PolicySets,
DeleteSourceBranchOnMerge: deleteSourceBranchOnMerge,
ExecutionOrderGroup: proj.ExecutionOrderGroup,
DisableRepoLocking: disableRepoLocking,
RepoLocking: repoLocking,
}
}

// DefaultProjCfg returns the default project config for all projects under the
// repo with id repoID. It is used when there is no repo config.
func (g GlobalCfg) DefaultProjCfg(log logging.SimpleLogging, repoID string, repoRelDir string, workspace string) MergedProjectCfg {
log.Debug("building config based on server-side config")
applyReqs, workflow, _, _, deleteSourceBranchOnMerge, disableRepoLocking := g.getMatchingCfg(log, repoID)
applyReqs, workflow, _, _, deleteSourceBranchOnMerge, repoLocking := g.getMatchingCfg(log, repoID)
return MergedProjectCfg{
ApplyRequirements: applyReqs,
Workflow: workflow,
Expand All @@ -339,7 +339,7 @@ func (g GlobalCfg) DefaultProjCfg(log logging.SimpleLogging, repoID string, repo
TerraformVersion: nil,
PolicySets: g.PolicySets,
DeleteSourceBranchOnMerge: deleteSourceBranchOnMerge,
DisableRepoLocking: disableRepoLocking,
RepoLocking: repoLocking,
}
}

Expand Down Expand Up @@ -383,8 +383,8 @@ func (g GlobalCfg) ValidateRepoCfg(rCfg RepoCfg, repoID string) error {
if p.DeleteSourceBranchOnMerge != nil && !sliceContainsF(allowedOverrides, DeleteSourceBranchOnMergeKey) {
return fmt.Errorf("repo config not allowed to set '%s' key: server-side config needs '%s: [%s]'", DeleteSourceBranchOnMergeKey, AllowedOverridesKey, DeleteSourceBranchOnMergeKey)
}
if p.DisableRepoLocking != nil && !sliceContainsF(allowedOverrides, DisableRepoLockingKey) {
return fmt.Errorf("repo config not allowed to set '%s' key: server-side config needs '%s: [%s]'", DisableRepoLockingKey, AllowedOverridesKey, DisableRepoLockingKey)
if p.RepoLocking != nil && !sliceContainsF(allowedOverrides, RepoLockingKey) {
return fmt.Errorf("repo config not allowed to set '%s' key: server-side config needs '%s: [%s]'", RepoLockingKey, AllowedOverridesKey, RepoLockingKey)
}
}

Expand Down Expand Up @@ -444,7 +444,7 @@ func (g GlobalCfg) ValidateRepoCfg(rCfg RepoCfg, repoID string) error {
}

// getMatchingCfg returns the key settings for repoID.
func (g GlobalCfg) getMatchingCfg(log logging.SimpleLogging, repoID string) (applyReqs []string, workflow Workflow, allowedOverrides []string, allowCustomWorkflows bool, deleteSourceBranchOnMerge bool, disableRepoLocking bool) {
func (g GlobalCfg) getMatchingCfg(log logging.SimpleLogging, repoID string) (applyReqs []string, workflow Workflow, allowedOverrides []string, allowCustomWorkflows bool, deleteSourceBranchOnMerge bool, repoLocking bool) {
toLog := make(map[string]string)
traceF := func(repoIdx int, repoID string, key string, val interface{}) string {
from := "default server config"
Expand All @@ -466,7 +466,7 @@ func (g GlobalCfg) getMatchingCfg(log logging.SimpleLogging, repoID string) (app
return fmt.Sprintf("setting %s: %s from %s", key, valStr, from)
}

for _, key := range []string{ApplyRequirementsKey, WorkflowKey, AllowedOverridesKey, AllowCustomWorkflowsKey, DeleteSourceBranchOnMergeKey, DisableRepoLockingKey} {
for _, key := range []string{ApplyRequirementsKey, WorkflowKey, AllowedOverridesKey, AllowCustomWorkflowsKey, DeleteSourceBranchOnMergeKey, RepoLockingKey} {
for i, repo := range g.Repos {
if repo.IDMatches(repoID) {
switch key {
Expand Down Expand Up @@ -495,10 +495,10 @@ func (g GlobalCfg) getMatchingCfg(log logging.SimpleLogging, repoID string) (app
toLog[DeleteSourceBranchOnMergeKey] = traceF(i, repo.IDString(), DeleteSourceBranchOnMergeKey, *repo.DeleteSourceBranchOnMerge)
deleteSourceBranchOnMerge = *repo.DeleteSourceBranchOnMerge
}
case DisableRepoLockingKey:
if repo.DisableRepoLocking != nil {
toLog[DisableRepoLockingKey] = traceF(i, repo.IDString(), DisableRepoLockingKey, *repo.DisableRepoLocking)
disableRepoLocking = *repo.DisableRepoLocking
case RepoLockingKey:
if repo.RepoLocking != nil {
toLog[RepoLockingKey] = traceF(i, repo.IDString(), RepoLockingKey, *repo.RepoLocking)
repoLocking = *repo.RepoLocking
}
}
}
Expand Down
Loading

0 comments on commit 0c4240b

Please sign in to comment.