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 force_absent parameter to ecs_ecr module #1316

Merged
merged 1 commit into from
Jul 6, 2022
Merged

Add force_absent parameter to ecs_ecr module #1316

merged 1 commit into from
Jul 6, 2022

Conversation

vranyes
Copy link
Contributor

@vranyes vranyes commented Jul 5, 2022

SUMMARY

Adds a force_absent parameter to the ecs_ecr module.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

ecs_ecr module

ADDITIONAL INFORMATION

It would be useful for the ecs_ecr module to have capability for removing repositories which still contain images.
This PR adds that ability by adding an additional parameter force_absent which has a default value of false and essentially just gets passed to the boto3 call for repo deletion.

The following was run against a repository with an image in it.

- name: Add ecr repos and sync with external sources.
  hosts: localhost
  connection: local
  gather_facts: false

  tasks:
  - name: test the changes
    register: state
    ecs_ecr:
      state: absent
      force_absent: true
      region: us-east-1
      name: myimage/test

  - debug:
      var: state

This was run with force_absent: true, force_absent: false and force_absent not defined.

The expected behavior was seen in all three scenarios.

I haven't added any new cases to the integration tests because there doesn't seem to be a great way to sync images into the repo that is created as part of the tests.

@ansibullbot
Copy link

@ansibullbot ansibullbot added community_review docs feature This issue/PR relates to a feature request module module needs_triage new_contributor Help guide this first time contributor plugins plugin (any type) labels Jul 5, 2022
@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

✔️ ansible-galaxy-importer SUCCESS in 5m 05s (non-voting)
✔️ build-ansible-collection SUCCESS in 5m 02s
ansible-test-sanity-docker-devel FAILURE in 16m 59s (non-voting)
ansible-test-sanity-docker-milestone FAILURE in 16m 40s
ansible-test-sanity-docker-stable-2.12 FAILURE in 17m 17s
ansible-test-sanity-docker-stable-2.13 FAILURE in 15m 21s
✔️ ansible-test-units-community-aws-python38 SUCCESS in 7m 16s
✔️ ansible-test-units-community-aws-python39 SUCCESS in 6m 05s
✔️ ansible-test-splitter SUCCESS in 2m 45s
✔️ integration-community.aws-1 SUCCESS in 6m 25s
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED

Copy link
Contributor

@tremble tremble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @vranyes,

Thanks for submitting this PR. I think this is a good addition to the module

A couple of things:

  • The documentation you updated is actually auto-generated from the docs at the top of the module
  • As well as the usual description/type definitions as a new parameter this will need version_added: 4.1.0

@github-actions
Copy link

github-actions bot commented Jul 6, 2022

Docs Build 📝

Thank you for contribution!✨

The docsite for this PR is available for download as an artifact from this run:
https://github.com/ansible-collections/community.aws/actions/runs/2623199002

File changes:

  • M collections/community/aws/ecs_ecr_module.html
Click to see the diff comparison.

NOTE: only file modifications are shown here. New and deleted files are excluded.
See the file list and check the published docs to see those files.

diff --git a/home/runner/work/community.aws/community.aws/docsbuild/base/collections/community/aws/ecs_ecr_module.html b/home/runner/work/community.aws/community.aws/docsbuild/head/collections/community/aws/ecs_ecr_module.html
index 8ef0b90..b2887b3 100644
--- a/home/runner/work/community.aws/community.aws/docsbuild/base/collections/community/aws/ecs_ecr_module.html
+++ b/home/runner/work/community.aws/community.aws/docsbuild/head/collections/community/aws/ecs_ecr_module.html
@@ -227,6 +227,19 @@ To check whether it is installed, run <code class="code docutils literal notrans
 </div></td>
 </tr>
 <tr class="row-even"><td><div class="ansible-option-cell">
+<div class="ansibleOptionAnchor" id="parameter-force_absent"></div><p class="ansible-option-title" id="ansible-collections-community-aws-ecs-ecr-module-parameter-force-absent"><strong>force_absent</strong></p>
+<a class="ansibleOptionLink" href="#parameter-force_absent" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
+<p><span class="ansible-option-versionadded">added in 4.1.0 of community.aws</span></p>
+</div></td>
+<td><div class="ansible-option-cell"><p>If <em>force_absent=true</em>, the repository will be removed, even if images are present.</p>
+<p class="ansible-option-line"><span class="ansible-option-choices">Choices:</span></p>
+<ul class="simple">
+<li><p><span class="ansible-option-default-bold">no</span> <span class="ansible-option-default">← (default)</span></p></li>
+<li><p><span class="ansible-option-choices-entry">yes</span></p></li>
+</ul>
+</div></td>
+</tr>
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-force_set_policy"></div><p class="ansible-option-title" id="ansible-collections-community-aws-ecs-ecr-module-parameter-force-set-policy"><strong>force_set_policy</strong></p>
 <a class="ansibleOptionLink" href="#parameter-force_set_policy" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
 </div></td>
@@ -238,7 +251,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 </ul>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-image_tag_mutability"></div><p class="ansible-option-title" id="ansible-collections-community-aws-ecs-ecr-module-parameter-image-tag-mutability"><strong>image_tag_mutability</strong></p>
 <a class="ansibleOptionLink" href="#parameter-image_tag_mutability" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
@@ -250,28 +263,28 @@ To check whether it is installed, run <code class="code docutils literal notrans
 </ul>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-lifecycle_policy"></div><p class="ansible-option-title" id="ansible-collections-community-aws-ecs-ecr-module-parameter-lifecycle-policy"><strong>lifecycle_policy</strong></p>
 <a class="ansibleOptionLink" href="#parameter-lifecycle_policy" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">json</span></p>
 </div></td>
 <td><div class="ansible-option-cell"><p>JSON or dict that represents the new lifecycle policy.</p>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-name"></div><p class="ansible-option-title" id="ansible-collections-community-aws-ecs-ecr-module-parameter-name"><strong>name</strong></p>
 <a class="ansibleOptionLink" href="#parameter-name" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span> / <span class="ansible-option-required">required</span></p>
 </div></td>
 <td><div class="ansible-option-cell"><p>The name of the repository.</p>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-policy"></div><p class="ansible-option-title" id="ansible-collections-community-aws-ecs-ecr-module-parameter-policy"><strong>policy</strong></p>
 <a class="ansibleOptionLink" href="#parameter-policy" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">json</span></p>
 </div></td>
 <td><div class="ansible-option-cell"><p>JSON or dict that represents the new policy.</p>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-profile"></div>
 <div class="ansibleOptionAnchor" id="parameter-aws_profile"></div><p class="ansible-option-title" id="ansible-collections-community-aws-ecs-ecr-module-parameter-profile"><span id="ansible-collections-community-aws-ecs-ecr-module-parameter-aws-profile"></span><strong>profile</strong></p>
 <a class="ansibleOptionLink" href="#parameter-profile" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-aliases">aliases: aws_profile</span></p>
@@ -280,7 +293,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <td><div class="ansible-option-cell"><p>The <em>profile</em> option is mutually exclusive with the <em>aws_access_key</em>, <em>aws_secret_key</em> and <em>security_token</em> options.</p>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-purge_lifecycle_policy"></div><p class="ansible-option-title" id="ansible-collections-community-aws-ecs-ecr-module-parameter-purge-lifecycle-policy"><strong>purge_lifecycle_policy</strong></p>
 <a class="ansibleOptionLink" href="#parameter-purge_lifecycle_policy" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
 </div></td>
@@ -293,7 +306,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 </ul>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-purge_policy"></div><p class="ansible-option-title" id="ansible-collections-community-aws-ecs-ecr-module-parameter-purge-policy"><strong>purge_policy</strong></p>
 <a class="ansibleOptionLink" href="#parameter-purge_policy" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
 </div></td>
@@ -306,7 +319,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 </ul>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-region"></div>
 <div class="ansibleOptionAnchor" id="parameter-aws_region"></div>
 <div class="ansibleOptionAnchor" id="parameter-ec2_region"></div><p class="ansible-option-title" id="ansible-collections-community-aws-ecs-ecr-module-parameter-region"><span id="ansible-collections-community-aws-ecs-ecr-module-parameter-ec2-region"></span><span id="ansible-collections-community-aws-ecs-ecr-module-parameter-aws-region"></span><strong>region</strong></p>
@@ -316,7 +329,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <td><div class="ansible-option-cell"><p>The AWS region to use. If not specified then the value of the AWS_REGION or EC2_REGION environment variable, if any, is used. See <a class="reference external" href="http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region">http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region</a></p>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-registry_id"></div><p class="ansible-option-title" id="ansible-collections-community-aws-ecs-ecr-module-parameter-registry-id"><strong>registry_id</strong></p>
 <a class="ansibleOptionLink" href="#parameter-registry_id" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
@@ -324,7 +337,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <p>If not specified, the default registry is assumed.</p>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-scan_on_push"></div><p class="ansible-option-title" id="ansible-collections-community-aws-ecs-ecr-module-parameter-scan-on-push"><strong>scan_on_push</strong></p>
 <a class="ansibleOptionLink" href="#parameter-scan_on_push" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
 <p><span class="ansible-option-versionadded">added in 1.3.0 of community.aws</span></p>
@@ -337,7 +350,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 </ul>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-security_token"></div>
 <div class="ansibleOptionAnchor" id="parameter-aws_session_token"></div>
 <div class="ansibleOptionAnchor" id="parameter-session_token"></div>
@@ -351,7 +364,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <p>Aliases <em>aws_session_token</em> and <em>session_token</em> have been added in version 3.2.0.</p>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-state"></div><p class="ansible-option-title" id="ansible-collections-community-aws-ecs-ecr-module-parameter-state"><strong>state</strong></p>
 <a class="ansibleOptionLink" href="#parameter-state" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
@@ -363,7 +376,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 </ul>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-validate_certs"></div><p class="ansible-option-title" id="ansible-collections-community-aws-ecs-ecr-module-parameter-validate-certs"><strong>validate_certs</strong></p>
 <a class="ansibleOptionLink" href="#parameter-validate_certs" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
 </div></td>

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

✔️ ansible-galaxy-importer SUCCESS in 3m 54s (non-voting)
✔️ build-ansible-collection SUCCESS in 5m 05s
✔️ ansible-test-sanity-docker-devel SUCCESS in 10m 27s (non-voting)
✔️ ansible-test-sanity-docker-milestone SUCCESS in 10m 42s
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 10m 03s
✔️ ansible-test-sanity-docker-stable-2.13 SUCCESS in 10m 51s
✔️ ansible-test-units-community-aws-python38 SUCCESS in 6m 00s
✔️ ansible-test-units-community-aws-python39 SUCCESS in 6m 12s
✔️ ansible-test-splitter SUCCESS in 2m 32s
✔️ integration-community.aws-1 SUCCESS in 5m 11s
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED

@tremble tremble added the backport-4 PR should be backported to the stable-4 branch label Jul 6, 2022
@tremble tremble added the mergeit Merge the PR (SoftwareFactory) label Jul 6, 2022
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).

✔️ ansible-galaxy-importer SUCCESS in 3m 57s (non-voting)
✔️ build-ansible-collection SUCCESS in 6m 10s
✔️ ansible-test-sanity-docker-devel SUCCESS in 10m 44s (non-voting)
✔️ ansible-test-sanity-docker-milestone SUCCESS in 9m 14s
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 10m 57s
✔️ ansible-test-sanity-docker-stable-2.13 SUCCESS in 10m 14s
✔️ ansible-test-units-community-aws-python38 SUCCESS in 5m 14s
✔️ ansible-test-units-community-aws-python39 SUCCESS in 5m 33s
✔️ ansible-test-splitter SUCCESS in 3m 07s
✔️ integration-community.aws-1 SUCCESS in 5m 09s
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit 5592372 into ansible-collections:main Jul 6, 2022
@patchback
Copy link

patchback bot commented Jul 6, 2022

Backport to stable-4: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-4/55923724d4f140bf2dd42ff152cb6f0436c75da8/pr-1316

Backported as #1320

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Jul 6, 2022
Add force_absent parameter to ecs_ecr module

SUMMARY
Adds a force_absent parameter to the ecs_ecr module.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
ecs_ecr module
ADDITIONAL INFORMATION
It would be useful for the ecs_ecr module to have capability for removing repositories which still contain images.
This PR adds that ability by adding an additional parameter force_absent which has a default value of false and essentially just gets passed to the boto3 call for repo deletion.
The following was run against a repository with an image in it.
- name: Add ecr repos and sync with external sources.
  hosts: localhost
  connection: local
  gather_facts: false

  tasks:
  - name: test the changes
    register: state
    ecs_ecr:
      state: absent
      force_absent: true
      region: us-east-1
      name: myimage/test

  - debug:
      var: state
This was run with force_absent: true, force_absent: false and force_absent not defined.
The expected behavior was seen in all three scenarios.
I haven't added any new cases to the integration tests because there doesn't seem to be a great way to sync images into the repo that is created as part of the tests.

Reviewed-by: Mark Chappell <None>
Reviewed-by: Josiah Vranyes <None>
(cherry picked from commit 5592372)
softwarefactory-project-zuul bot pushed a commit that referenced this pull request Jul 6, 2022
[PR #1316/55923724 backport][stable-4] Add force_absent parameter to ecs_ecr module

This is a backport of PR #1316 as merged into main (5592372).
SUMMARY
Adds a force_absent parameter to the ecs_ecr module.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
ecs_ecr module
ADDITIONAL INFORMATION
It would be useful for the ecs_ecr module to have capability for removing repositories which still contain images.
This PR adds that ability by adding an additional parameter force_absent which has a default value of false and essentially just gets passed to the boto3 call for repo deletion.
The following was run against a repository with an image in it.
- name: Add ecr repos and sync with external sources.
  hosts: localhost
  connection: local
  gather_facts: false

  tasks:
  - name: test the changes
    register: state
    ecs_ecr:
      state: absent
      force_absent: true
      region: us-east-1
      name: myimage/test

  - debug:
      var: state
This was run with force_absent: true, force_absent: false and force_absent not defined.
The expected behavior was seen in all three scenarios.
I haven't added any new cases to the integration tests because there doesn't seem to be a great way to sync images into the repo that is created as part of the tests.

Reviewed-by: Mark Chappell <None>
@vranyes vranyes deleted the feature/ecs_ecr/force_absent branch July 6, 2022 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-4 PR should be backported to the stable-4 branch community_review docs feature This issue/PR relates to a feature request mergeit Merge the PR (SoftwareFactory) module module new_contributor Help guide this first time contributor plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants