mirror of
https://github.com/ansible-collections/hetzner.hcloud
synced 2024-12-13 14:02:31 +00:00
feat: replace ansible version with collection version in hcloud user agent (#291)
* feat: use collection version in hcloud user-agent * chore: add version sync pre-commit hook * chore: add changelog fragment
This commit is contained in:
parent
59fe4339d4
commit
dd5ee78386
6 changed files with 22 additions and 3 deletions
|
@ -87,3 +87,11 @@ repos:
|
|||
entry: scripts/integration-test-files.sh
|
||||
pass_filenames: false
|
||||
files: ^(scripts/integration-test-files.sh$|tests/integration)
|
||||
|
||||
- id: check-version-variables
|
||||
name: check version variables
|
||||
description: Ensure the version variables are in sync
|
||||
language: system
|
||||
entry: scripts/version-sync.sh
|
||||
pass_filenames: false
|
||||
files: ^(scripts/version-sync.sh$|galaxy.yml|plugins/module_utils/version.py)
|
||||
|
|
|
@ -77,7 +77,8 @@ ansible-test integration --color --local -vvv hcloud_server // Executed all int
|
|||
5. Update the `version` in the ansible galaxy metadata file:
|
||||
```sh
|
||||
sed -i "s/^version: .*/version: $HCLOUD_VERSION/" galaxy.yml
|
||||
git add galaxy.yml
|
||||
scripts/version-sync.sh
|
||||
git add galaxy.yml plugins/module_utils/version.py
|
||||
```
|
||||
6. Commit the changes:
|
||||
```sh
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- Use the collection version in the hcloud user-agent instead of the ansible-core version.
|
|
@ -5,11 +5,11 @@
|
|||
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.ansible_release import __version__
|
||||
from ansible.module_utils.basic import env_fallback, missing_required_lib
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
|
||||
from ..module_utils.vendor import hcloud
|
||||
from .version import version
|
||||
|
||||
HAS_REQUESTS = True
|
||||
HAS_DATEUTIL = True
|
||||
|
@ -65,7 +65,7 @@ class AnsibleHCloud:
|
|||
token=self.module.params["api_token"],
|
||||
api_endpoint=self.module.params["endpoint"],
|
||||
application_name="ansible-module",
|
||||
application_version=__version__,
|
||||
application_version=version,
|
||||
)
|
||||
|
||||
def _mark_as_changed(self):
|
||||
|
|
1
plugins/module_utils/version.py
Normal file
1
plugins/module_utils/version.py
Normal file
|
@ -0,0 +1 @@
|
|||
version = "2.0.0"
|
7
scripts/version-sync.sh
Executable file
7
scripts/version-sync.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Sync the collection version variable based on the version in the galaxy.yml file.
|
||||
|
||||
galaxy_version="$(grep '^version:' galaxy.yml | cut -d ' ' -f 2)"
|
||||
|
||||
sed --in-place "s|version = .*|version = \"$galaxy_version\"|" plugins/module_utils/version.py
|
Loading…
Reference in a new issue