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

Add check operation #66

Merged
merged 6 commits into from
Feb 23, 2023
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
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,21 @@ One of the following is required.
`metadata` which should contain the name of your new lock and the contents you
would like in the lock, respectively.

* `check`: If set, we will check for an existing claimed lock in the pool and
wait until it becomes unclaimed.

* If there is an existing lock in claimed state: wait until lock is unclaimed
* If there is an existing lock in unclaimed state: no-op
* If no lock exists: fail

The purpose is to simply block until a given lock in a pool is moved from a
claimed state to an unclaimed state. This functionality allows us to build
dependencies between disparate pipelines without the need to `acquire` locks.

Note: the lock must be present to perform a check. In other words, a `get`
step to fetch metadata about the lock is necessary before a `put` step can
check the existence of the lock.

## Example Concourse Configuration

The following example pipeline models acquiring, passing through, and releasing
Expand Down
8 changes: 8 additions & 0 deletions cmd/out/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ func main() {
}
}

if request.Params.Check != "" {
lockPath := filepath.Join(sourceDir, request.Params.Check)
lock, version, err = lockPool.CheckLock(lockPath)
if err != nil {
fatal("checking lock", err)
}
}

err = json.NewEncoder(os.Stdout).Encode(out.OutResponse{
Version: version,
Metadata: []out.MetadataPair{
Expand Down
Loading