Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix build for pr_locks and deprecate disable-locking flag in docs #1586

Merged
merged 3 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ inputs:
required: false
default: '3.2.22'
disable-locking:
description: Disable locking
description: Disable locking (deprecated, use pr_locks on digger.yml instead)
required: false
default: 'false'
digger-filename:
Expand Down
2 changes: 0 additions & 2 deletions backend/controllers/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ func handlePullRequestEvent(gh utils.GithubClientProvider, payload *github.PullR
if config.PrLocks {
for _, project := range impactedProjects {
prLock := dg_locking.PullRequestLock{
Enable: config.PrLocks,
InternalLock: locking.BackendDBLock{
OrgId: organisationId,
},
Expand Down Expand Up @@ -794,7 +793,6 @@ func handleIssueCommentEvent(gh utils.GithubClientProvider, payload *github.Issu
if config.PrLocks {
for _, project := range impactedProjects {
prLock := dg_locking.PullRequestLock{
Enable: config.PrLocks,
InternalLock: locking.BackendDBLock{
OrgId: orgId,
},
Expand Down
2 changes: 1 addition & 1 deletion cli/pkg/digger/digger.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package digger
import (
"errors"
"fmt"
comment_updater "github.com/diggerhq/digger/libs/comment_utils/summary"
coreutils "github.com/diggerhq/digger/libs/comment_utils/utils"
locking2 "github.com/diggerhq/digger/libs/locking"
"log"
Expand Down Expand Up @@ -204,7 +205,6 @@ func run(command string, job orchestrator.Job, policyChecker policy.Checker, org
}

projectLock := &locking2.PullRequestLock{
Enable: config.PrLocks,
InternalLock: lock,
Reporter: reporter,
CIService: prService,
Expand Down
5 changes: 5 additions & 0 deletions cli/pkg/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ func GitHubCI(lock core_locking.Lock, policyChecker core_policy.Checker, backend
}
log.Printf("Digger digger_config read successfully\n")

if diggerConfig.PrLocks == false {
log.Printf("info: Using noop lock as configured in digger.yml")
lock = core_locking.NoOpLock{}
}

yamlData, err := yaml.Marshal(diggerConfigYaml)
if err != nil {
log.Fatalf("error: %v", err)
Expand Down
1 change: 0 additions & 1 deletion docs/getting-started/github-actions-+-aws.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ jobs:
setup-aws: true
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
disable-locking: true
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
1 change: 0 additions & 1 deletion docs/getting-started/github-actions-and-gcp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ jobs:
uses: diggerhq/digger@vLatest
with:
setup-aws: false
disable-locking: true
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
13 changes: 13 additions & 0 deletions docs/howto/disable-locking.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: "Disable locking"
---

In order to disable locking repo wide you can add a top-level flag to your digger.yml:

```
pr_locks: false

projects:
- name: dev
dir: dev/
```
1 change: 0 additions & 1 deletion docs/howto/multiacc-aws.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ jobs:
setup-aws: true
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
disable-locking: true
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 2 additions & 1 deletion docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@
"howto/using-infracost",
"howto/using-opa-conftest",
"howto/using-terragrunt",
"howto/versioning"
"howto/versioning",
"howto/disable-locking"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/action-inputs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ inputs:
required: false
default: '3.2.22'
disable-locking:
description: Disable locking
description: Disable locking (deprecated, use pr_locks on digger.yml instead)
required: false
default: 'false'
digger-filename:
Expand Down
4 changes: 0 additions & 4 deletions libs/locking/locking.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
)

type PullRequestLock struct {
Enable bool
InternalLock Lock
CIService orchestrator.PullRequestService
Reporter reporting.Reporter
Expand Down Expand Up @@ -64,9 +63,6 @@ func (projectLock *PullRequestLock) Lock() (bool, error) {
}

var existingLockTransactionId *int
if projectLock.Enable {
existingLockTransactionId, err = projectLock.InternalLock.GetLock(lockId)
}

if err != nil {
log.Printf("failed to get lock: %v\n", err)
Expand Down
Loading