Skip to content

Commit

Permalink
feat: container registry new features (#189)
Browse files Browse the repository at this point in the history
* feat: added new container registry modules

* feat: added vulnerability_scanning to registry

* doc: regenerated docs

* docs: added examples

* feat: change feature to bool from dict, updated tests

* test: fix registry test

* feat: changed registry added features argument

* fix: remove typo

* feat: wait for registry to be ready for repository query

* feat: added listing all artifact in a registry

* fix: removed trailing comma

* fix: removed test file

* updated examples and added wait in registry test

* feat: repalce registry when disabling vulnerability scanning

* fix: fixed error when features was not sent

* fix: retrieve registry after wait
  • Loading branch information
rmocanu-ionos authored Dec 21, 2023
1 parent 1e6e645 commit 31934f8
Show file tree
Hide file tree
Showing 18 changed files with 2,047 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,4 @@ ansible.cfg
*.retry

update_description_utils/swaggers
reset.sh
31 changes: 25 additions & 6 deletions docs/api/container-registry/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ This is a module that supports creating, updating or destroying Registries
```yaml
- name: Create Registry
registry:
name: test_registry
name: testregistry
location: de/fra
garbage_collection_schedule:
days:
- Wednesday
time: 04:17:00+00:00
features:
vulnerability_scanning:
enabled: false
register: registry_response

- name: Update Registry
registry:
registry: test_registry
registry: testregistry
name: test_registry_update
garbage_collection_schedule:
days:
Expand All @@ -28,7 +31,7 @@ This is a module that supports creating, updating or destroying Registries

- name: Delete Registry
registry:
registry: test_registry
registry: testregistry
wait: true
state: absent

Expand Down Expand Up @@ -82,18 +85,22 @@ This is a module that supports creating, updating or destroying Registries
## Parameters that can trigger a resource replacement:
* name
* location
* features (changing features.vulnerability_scanning.enabled from true to false will trigger a resource replacement)
 

# state: **present**
```yaml
- name: Create Registry
registry:
name: test_registry
name: testregistry
location: de/fra
garbage_collection_schedule:
days:
- Wednesday
time: 04:17:00+00:00
features:
vulnerability_scanning:
enabled: false
register: registry_response

```
Expand All @@ -118,6 +125,12 @@ This is a module that supports creating, updating or destroying Registries
<td>location<br/><mark style="color:blue;">str</mark></td>
<td align="center">True</td>
<td>The location of your registry</td>
</tr>
<tr>
<td>features<br/><mark style="color:blue;">dict</mark></td>
<td align="center">False</td>
<td>Optional registry features. Format: 'vulnerability_scanning' key having a dict for value containing the 'enabled' key with a boolean value
Note: Vulnerability scanning for images is enabled by default. This is a paid add-on, please make sure you specify if you do not want it enabled</td>
</tr>
<tr>
<td>name<br/><mark style="color:blue;">str</mark></td>
Expand Down Expand Up @@ -174,7 +187,7 @@ This is a module that supports creating, updating or destroying Registries
```yaml
- name: Delete Registry
registry:
registry: test_registry
registry: testregistry
wait: true
state: absent

Expand Down Expand Up @@ -241,7 +254,7 @@ This is a module that supports creating, updating or destroying Registries
```yaml
- name: Update Registry
registry:
registry: test_registry
registry: testregistry
name: test_registry_update
garbage_collection_schedule:
days:
Expand Down Expand Up @@ -271,6 +284,12 @@ This is a module that supports creating, updating or destroying Registries
<td>location<br/><mark style="color:blue;">str</mark></td>
<td align="center">False</td>
<td>The location of your registry</td>
</tr>
<tr>
<td>features<br/><mark style="color:blue;">dict</mark></td>
<td align="center">False</td>
<td>Optional registry features. Format: 'vulnerability_scanning' key having a dict for value containing the 'enabled' key with a boolean value
Note: Vulnerability scanning for images is enabled by default. This is a paid add-on, please make sure you specify if you do not want it enabled</td>
</tr>
<tr>
<td>name<br/><mark style="color:blue;">str</mark></td>
Expand Down
127 changes: 127 additions & 0 deletions docs/api/container-registry/registry_artifact_info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# registry_artifact_info

This is a simple module that supports listing existing Artifacts

## Example Syntax


```yaml

- name: List Artifacts
registry_artifact_info:
registry: "RegistryName"
repository: "repositoryName"
register: artifacts_response


- name: Show Artifacts
debug:
var: artifacts_response.result

```

&nbsp;

&nbsp;
## Returned object
```json
{
"href": "<base_url>/registries/0d6fd999-9bf9-462c-a148-951198ebca8f/artifacts",
"id": "artifacts",
"items": [
{
"href": "<base_url>/registries/0d6fd999-9bf9-462c-a148-951198ebca8f/repositories/image-test/artifacts/<digest>",
"id": "<digest>",
"metadata": {
"created_by": null,
"created_by_user_id": null,
"created_date": null,
"last_modified_by": null,
"last_modified_by_user_id": null,
"last_modified_date": null,
"last_pulled_at": null,
"last_pushed_at": "<datetime>",
"last_scanned_at": "<datetime>",
"pull_count": 0,
"push_count": 1,
"resource_urn": null,
"vuln_fixable_count": 45,
"vuln_max_severity": "critical",
"vuln_total_count": 57,
"vuln_total_score": 389.39993
},
"properties": {
"digest": "<digest>",
"media_type": "application/vnd.docker.distribution.manifest.v2+json",
"repository_name": "image-test",
"tags": [
"latest"
]
},
"type": "artifact"
}
],
"limit": 100,
"links": {
"next": null,
"prev": null,
"var_self": "<base_url>/registries/0d6fd999-9bf9-462c-a148-951198ebca8f/artifacts?limit=100&offset=100&orderBy=-pullCount"
},
"offset": 0,
"type": "collection"
}

```

&nbsp;

&nbsp;
### Available parameters:
&nbsp;

<table data-full-width="true">
<thead>
<tr>
<th width="22.8vw">Name</th>
<th width="10.8vw" align="center">Required</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>filters<br/><mark style="color:blue;">dict</mark></td>
<td align="center">False</td>
<td>Filter that can be used to list only objects which have a certain set of propeties. Filters should be a dict with a key containing keys and value pair in the following format:'properties.name': 'server_name'</td>
</tr>
<tr>
<td>registry<br/><mark style="color:blue;">str</mark></td>
<td align="center">True</td>
<td>The ID or name of an existing Registry.</td>
</tr>
<tr>
<td>repository<br/><mark style="color:blue;">str</mark></td>
<td align="center">False</td>
<td>The name of an existing Repository.</td>
</tr>
<tr>
<td>api_url<br/><mark style="color:blue;">str</mark></td>
<td align="center">False</td>
<td>The Ionos API base URL.</td>
</tr>
<tr>
<td>username<br/><mark style="color:blue;">str</mark></td>
<td align="center">False</td>
<td>The Ionos username. Overrides the IONOS_USERNAME environment variable.</td>
</tr>
<tr>
<td>password<br/><mark style="color:blue;">str</mark></td>
<td align="center">False</td>
<td>The Ionos password. Overrides the IONOS_PASSWORD environment variable.</td>
</tr>
<tr>
<td>token<br/><mark style="color:blue;">str</mark></td>
<td align="center">False</td>
<td>The Ionos token. Overrides the IONOS_TOKEN environment variable.</td>
</tr>
</tbody>
</table>
93 changes: 93 additions & 0 deletions docs/api/container-registry/registry_repository.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# registry_repository

This is a module that supports creating, updating or destroying Repositories

## Example Syntax


```yaml
- name: Delete Repository
registry_repository:
registry: RegistryName
repository: testRepository
state: absent

```


&nbsp;

&nbsp;

# state: **absent**
```yaml
- name: Delete Repository
registry_repository:
registry: RegistryName
repository: testRepository
state: absent

```
### Available parameters for state **absent**:
&nbsp;

<table data-full-width="true">
<thead>
<tr>
<th width="70">Name</th>
<th width="40" align="center">Required</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>repository<br/><mark style="color:blue;">str</mark></td>
<td align="center">True</td>
<td>The name of an existing repository.</td>
</tr>
<tr>
<td>registry<br/><mark style="color:blue;">str</mark></td>
<td align="center">True</td>
<td>The ID or name of an existing Registry.</td>
</tr>
<tr>
<td>api_url<br/><mark style="color:blue;">str</mark></td>
<td align="center">False</td>
<td>The Ionos API base URL.</td>
</tr>
<tr>
<td>username<br/><mark style="color:blue;">str</mark></td>
<td align="center">False</td>
<td>The Ionos username. Overrides the IONOS_USERNAME environment variable.</td>
</tr>
<tr>
<td>password<br/><mark style="color:blue;">str</mark></td>
<td align="center">False</td>
<td>The Ionos password. Overrides the IONOS_PASSWORD environment variable.</td>
</tr>
<tr>
<td>token<br/><mark style="color:blue;">str</mark></td>
<td align="center">False</td>
<td>The Ionos token. Overrides the IONOS_TOKEN environment variable.</td>
</tr>
<tr>
<td>wait<br/><mark style="color:blue;">bool</mark></td>
<td align="center">False</td>
<td>Wait for the resource to be created before returning.<br />Default: True<br />Options: [True, False]</td>
</tr>
<tr>
<td>wait_timeout<br/><mark style="color:blue;">int</mark></td>
<td align="center">False</td>
<td>How long before wait gives up, in seconds.<br />Default: 600</td>
</tr>
<tr>
<td>state<br/><mark style="color:blue;">str</mark></td>
<td align="center">False</td>
<td>Indicate desired state of the resource.<br />Default: present<br />Options: ['absent']</td>
</tr>
</tbody>
</table>

&nbsp;

&nbsp;
Loading

0 comments on commit 31934f8

Please sign in to comment.