{"id":19806015,"url":"https://github.com/cycloidio/approval-resource","last_synced_at":"2025-02-28T12:19:45.020Z","repository":{"id":83786333,"uuid":"74557210","full_name":"cycloidio/approval-resource","owner":"cycloidio","description":null,"archived":false,"fork":false,"pushed_at":"2017-02-14T11:52:33.000Z","size":28,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-01-11T06:13:21.930Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cycloidio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-23T08:38:56.000Z","updated_at":"2016-12-06T16:25:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"db7eda1d-17ec-4d01-b924-acac222faa43","html_url":"https://github.com/cycloidio/approval-resource","commit_stats":{"total_commits":17,"total_committers":3,"mean_commits":5.666666666666667,"dds":"0.11764705882352944","last_synced_commit":"80b29b98295412b7916ad2ff411b171dd4a29f2b"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cycloidio%2Fapproval-resource","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cycloidio%2Fapproval-resource/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cycloidio%2Fapproval-resource/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cycloidio%2Fapproval-resource/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cycloidio","download_url":"https://codeload.github.com/cycloidio/approval-resource/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241150243,"owners_count":19918334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T09:06:10.103Z","updated_at":"2025-02-28T12:19:45.013Z","avatar_url":"https://github.com/cycloidio.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# approval-resource\n\nThe approval resource copies the pool-resource but is backed by dynamodb on AWS.\nThere is no \"pool\" of random lock to acquire like the pool-resource does, but the resource creates on the fly a lock with a lockname until this one is released.\n\nThis resource adds a feature to let an external user approve or reject a step. For example, if you want a user validation between the job `test1` and `test2`, then you should use this resource.\n\n## IAM configuration\n\nTo work with dynamodb, you will need a dedicated IAM user with this policy :\n\n```\n{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Sid\": \"ConcourseApproval\",\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"dynamodb:*\"\n            ],\n            \"Resource\": \"arn:aws:dynamodb:eu-west-1:\u003cACCOUNT-NUMBER\u003e:table/concourse-approval*\"\n        },\n        {\n            \"Sid\": \"ListAllTables\",\n            \"Effect\": \"Allow\",\n            \"Action\": \"dynamodb:ListTables\",\n            \"Resource\": \"*\"\n        }\n    ]\n}\n```\n\n## Source Configuration\n\n* `AWS_ACCESS_KEY_ID`: *Required.* The access key used to query dynamodb.\n\n* `AWS_SECRET_ACCESS_KEY`: *Required.* The secret key used to query dynamodb.\n\n* `AWS_DEFAULT_REGION`: *Required.* The region where is located dynamodb.\n\n* `pool`: *Required.* This parameter sets the pool which the lock will belong too. It's useful to avoid lockname collisions.\n\n* `wait_lock`: *Optional.* This parameter controls the time to wait between two checks of the `approved` field.\n\n* `debug`: *Optional.* This parameter will increase the verbosity of logs output.\n\n## Behavior\n\n### `check`: Check for changes to the pool.\n\nThe check command will query the dynamodb table and retrieve all locks of a pool with a timestamp greater than the last version checked.\n\n\n### `in`: Fetch an acquired lock or wait until it's approved.\n\nOutputs 2 files:\n\n* `metadata`: Contains the content of whatever was in your lock file. This is\n  useful for environment configuration settings.\n\n* `name`: Contains the name of lock that was acquired.\n\nIf the lock is waiting for an approval, the get will wait that the field `approved` goes to `True` or `False`.\nIf the `approved` field is `False`, it will exit with a `1` status and then, fail the job.\n\n#### Parameters\n\n* `lock_name`: *Optional.* This field is optional but goes with the `need_approval` field. It specifies which lock to fetch from the dynamodb.\n  \n* `need_approval`: *Optional.* If set, the `get` will wait indefinitely for a change on the `approved` field.\n\n* `timeout`: *Optional.* If set, the `get` will not wait indefinitely for a change on the `approved` field but will fail once the timeout is reached.\n\n### `out`: Claim or release a lock.\n\nPerforms one of the following actions to change the state of the pool.\n\n#### Parameters\n\n* `action`: *Required.* This field has two possible values : `claim` and `release`.\n  The `claim` will create/acquire a lock and the `release` will release the lock\n\n* `lock_name`: *Required.* This field contains the name of the lock to acquire/release\n\n* `need_approval`: *Optional.* If set, the `put` will add a field to tell the `get` that it should wait for an approval.\n\n* `override_approval`: *Optional.* If set, the `put` will fail the previous approval to be able to claim the lock.\n\n## Example Concourse Configuration\n\nThe following example pipeline models: acquiring, passing through, and releasing\na lock based on the example git repository structure:\n\n```\nresource_types:\n- name: approval\n  type: docker-image\n  source:\n    # use tag `latest` for stable release\n    repository: cycloid/approval-resource\n    tag: test\n\nresources:\n- name: approval\n  type: approval\n  source:\n    #debug: true\n    AWS_ACCESS_KEY_ID: {{ec2_access_key}}\n    AWS_SECRET_ACCESS_KEY: {{ec2_secret_key}}\n    AWS_DEFAULT_REGION: eu-west-1\n    pool: cycloid-approval\n    \njobs:\n  - name: lock\n    plan:\n      - get: resource-src\n        trigger: true\n      - put: approval\n        params:\n          lock_name: mylock\n          action: claim\n          need_approval: true\n          override_approval: true\n\n  - name: release-if-approved\n    plan:\n      - get: approval\n        trigger: true\n        passed: [lock]\n        params:\n          lock_name: mylock\n          need_approval: true\n      - get: resource-src\n        trigger: true\n        passed: [lock]\n      - put: approval\n        params:\n          lock_name: mylock\n          action: release\n\n```\n\n## CLI\n\nTo manage the lock, there's a little CLI script to interact with dynamodb.\nYou can of course write your own tool.\n\n### List\n```\n# python3 cli.py list\napproved    claimed    description    id                                    lockname    need_approval    pipeline           pool              team    timestamp\n----------  ---------  -------------  ------------------------------------  ----------  ---------------  -----------------  ----------------  ------  --------------------------------\n            True                      f47f5864-a1b4-4bc0-8899-784ae3b768a4  test1       True             approval-resource  cycloid-approval  main    2016-11-30 13:55:05.079579+00:00\n```\n\n### Approve\n```\n# python3 cli.py approve --id f47f5864-a1b4-4bc0-8899-784ae3b768a4\nINFO: The lock f47f5864-a1b4-4bc0-8899-784ae3b768a4 has been approved\n```\n\n### Reject\n```\n# python3 cli.py reject --id f47f5864-a1b4-4bc0-8899-784ae3b768a4\nINFO: The lock f47f5864-a1b4-4bc0-8899-784ae3b768a4 has been rejected\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcycloidio%2Fapproval-resource","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcycloidio%2Fapproval-resource","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcycloidio%2Fapproval-resource/lists"}