applications-download 0.7.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2020-2024, Camptocamp SA
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
17
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,121 @@
1
+ Metadata-Version: 2.1
2
+ Name: applications-download
3
+ Version: 0.7.1
4
+ Summary: Tools used to publish Python packages, Docker images and Helm charts for GitHub tag and branch
5
+ Home-page: https://github.com/camptocamp/applications-download
6
+ License: FreeBSD
7
+ Keywords: ci
8
+ Author: Camptocamp
9
+ Author-email: info@camptocamp.com
10
+ Requires-Python: >=3.9
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: License :: Other/Proprietary License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Typing :: Typed
25
+ Requires-Dist: PyYAML (>=6.0.0,<7.0.0)
26
+ Requires-Dist: jsonschema-validator-new (>=0.0.0,<1.0.0)
27
+ Requires-Dist: requests (>=2.0.0,<3.0.0)
28
+ Requires-Dist: ruamel.yaml (>=0.0.0,<1.0.0)
29
+ Project-URL: Repository, https://github.com/camptocamp/applications-download
30
+ Description-Content-Type: text/markdown
31
+
32
+ # Applications Download
33
+
34
+ This tool can be used to maintain a version file (eventually also an application file) for a given application.
35
+
36
+ The version file is a YAML file that contains the version number of the application.
37
+ The version file respect the schema describe in application.md and provided in applications_download/application-schema.json.
38
+
39
+ The application file is also a YAML file that contains how to download and install the application.
40
+ This is a simple key value file with the application as key and the version as value.
41
+
42
+ ## Install
43
+
44
+ ```bash
45
+ pip install applications-download
46
+ ```
47
+
48
+ ## Usage
49
+
50
+ ```bash
51
+ applications-download --help
52
+ ```
53
+
54
+ ## Applications configuration
55
+
56
+ In case some executables or applications from GitHub releases or any other URLs are required on the CI host
57
+ and are not handled by any dependency manager, we provide a set of tools to install them and manage upgrades
58
+ through Renovate.
59
+
60
+ Create an application file (e.-g. `applications.yaml`) with:
61
+
62
+ ```yaml
63
+ # yaml-language-server: $schema=https://raw.githubusercontent.com/camptocamp/c2cciutils/master/c2cciutils/schema-applications.json
64
+
65
+ # Application from GitHub release
66
+ <organization>/<project>:
67
+ get-file-name: <file name present in the release>
68
+ to-file-name: <The file name you want to create in ~/.local/bin>
69
+ finish-command: # The command you want to run after the file is downloaded
70
+ - - chmod # To be executable (usually required)
71
+ - +x
72
+ - <to-file-name>
73
+ - - <to-file-name> # Print the version of the application
74
+ - --version
75
+ # Application from GitHub release in a tar file (or tar.gz)
76
+ <organization>/<project>:
77
+ get-file-name: <file name present in the release>
78
+ type: tar
79
+ tar-file-name: <The file name available in the tar file>
80
+ to-file-name: <The file name you want to create in ~/.local/bin>
81
+ finish-command: [...] # The command you want to run after the file is downloaded
82
+ # Application from an URL
83
+ <application reference name>:
84
+ url-pattern: <The URL used to download the application>
85
+ to-file-name: <The file name you want to create in ~/.local/bin>
86
+ finish-command: [...] # The command you want to run after the file is downloaded
87
+ ```
88
+
89
+ In the attributes `url-pattern`, `get-file-name` you can use the following variables:
90
+
91
+ - `{version}`: The version of the application present in the version file.
92
+ - `{version_quote}`: The URL encoded version.
93
+ - `{short_version}`: The version without the `v` prefix.
94
+
95
+ The `applications-versions.yaml` file is a map of applications and their versions.
96
+
97
+ Add in your Renovate configuration:
98
+
99
+ ```json5
100
+ regexManagers: [
101
+ {
102
+ fileMatch: ['^applications-versions.yaml$'],
103
+ matchStrings: [
104
+ '(?<depName>[^\\s]+): (?<currentValue>[^\\s]+) # (?<datasource>[^\\s]+)',
105
+ ],
106
+ },
107
+ ],
108
+ ```
109
+
110
+ Now you need to call `c2cciutils-download-applications --applications-file=applications.yaml --versions-file=applications-version.yaml`
111
+ to install required applications on CI host before using them (an already installed application is installed only if needed).
112
+
113
+ ## Contributing
114
+
115
+ Install the pre-commit hooks:
116
+
117
+ ```bash
118
+ pip install pre-commit
119
+ pre-commit install --allow-missing-config
120
+ ```
121
+
@@ -0,0 +1,89 @@
1
+ # Applications Download
2
+
3
+ This tool can be used to maintain a version file (eventually also an application file) for a given application.
4
+
5
+ The version file is a YAML file that contains the version number of the application.
6
+ The version file respect the schema describe in application.md and provided in applications_download/application-schema.json.
7
+
8
+ The application file is also a YAML file that contains how to download and install the application.
9
+ This is a simple key value file with the application as key and the version as value.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ pip install applications-download
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```bash
20
+ applications-download --help
21
+ ```
22
+
23
+ ## Applications configuration
24
+
25
+ In case some executables or applications from GitHub releases or any other URLs are required on the CI host
26
+ and are not handled by any dependency manager, we provide a set of tools to install them and manage upgrades
27
+ through Renovate.
28
+
29
+ Create an application file (e.-g. `applications.yaml`) with:
30
+
31
+ ```yaml
32
+ # yaml-language-server: $schema=https://raw.githubusercontent.com/camptocamp/c2cciutils/master/c2cciutils/schema-applications.json
33
+
34
+ # Application from GitHub release
35
+ <organization>/<project>:
36
+ get-file-name: <file name present in the release>
37
+ to-file-name: <The file name you want to create in ~/.local/bin>
38
+ finish-command: # The command you want to run after the file is downloaded
39
+ - - chmod # To be executable (usually required)
40
+ - +x
41
+ - <to-file-name>
42
+ - - <to-file-name> # Print the version of the application
43
+ - --version
44
+ # Application from GitHub release in a tar file (or tar.gz)
45
+ <organization>/<project>:
46
+ get-file-name: <file name present in the release>
47
+ type: tar
48
+ tar-file-name: <The file name available in the tar file>
49
+ to-file-name: <The file name you want to create in ~/.local/bin>
50
+ finish-command: [...] # The command you want to run after the file is downloaded
51
+ # Application from an URL
52
+ <application reference name>:
53
+ url-pattern: <The URL used to download the application>
54
+ to-file-name: <The file name you want to create in ~/.local/bin>
55
+ finish-command: [...] # The command you want to run after the file is downloaded
56
+ ```
57
+
58
+ In the attributes `url-pattern`, `get-file-name` you can use the following variables:
59
+
60
+ - `{version}`: The version of the application present in the version file.
61
+ - `{version_quote}`: The URL encoded version.
62
+ - `{short_version}`: The version without the `v` prefix.
63
+
64
+ The `applications-versions.yaml` file is a map of applications and their versions.
65
+
66
+ Add in your Renovate configuration:
67
+
68
+ ```json5
69
+ regexManagers: [
70
+ {
71
+ fileMatch: ['^applications-versions.yaml$'],
72
+ matchStrings: [
73
+ '(?<depName>[^\\s]+): (?<currentValue>[^\\s]+) # (?<datasource>[^\\s]+)',
74
+ ],
75
+ },
76
+ ],
77
+ ```
78
+
79
+ Now you need to call `c2cciutils-download-applications --applications-file=applications.yaml --versions-file=applications-version.yaml`
80
+ to install required applications on CI host before using them (an already installed application is installed only if needed).
81
+
82
+ ## Contributing
83
+
84
+ Install the pre-commit hooks:
85
+
86
+ ```bash
87
+ pip install pre-commit
88
+ pre-commit install --allow-missing-config
89
+ ```
@@ -0,0 +1,208 @@
1
+ """
2
+ Application download main module.
3
+ """
4
+
5
+ import json
6
+ import os
7
+ import pkgutil
8
+ import subprocess # nosec
9
+ import sys
10
+ import tarfile
11
+ import urllib
12
+ import urllib.parse
13
+ from io import BytesIO
14
+ from typing import Optional, cast
15
+
16
+ import jsonschema_validator
17
+ import requests
18
+ import ruamel.yaml
19
+ import yaml
20
+
21
+ from applications_download import applications_definition
22
+
23
+ _CONFIG_FOLDER = os.path.join(
24
+ os.getenv("XDG_CONFIG_HOME") or os.path.expanduser(os.path.join("~", ".config")), "applications_download"
25
+ )
26
+ _SCHEMA = None
27
+
28
+
29
+ def _validate_applications(
30
+ applications_data: str, application_filename: str
31
+ ) -> applications_definition.ApplicationsConfiguration:
32
+ """Validate the applications configuration."""
33
+ global _SCHEMA # pylint: disable=global-statement
34
+
35
+ if _SCHEMA is None:
36
+ schema_data = pkgutil.get_data("applications_download", "applications-schema.json")
37
+ assert schema_data is not None
38
+ _SCHEMA = json.loads(schema_data)
39
+
40
+ ru_yaml = ruamel.yaml.YAML()
41
+ applications = ru_yaml.load(applications_data) # nosec
42
+
43
+ errors, _ = jsonschema_validator.validate(application_filename, applications, _SCHEMA)
44
+ if errors:
45
+ sys.stderr.write("\n".join(errors))
46
+ sys.stderr.write("\n")
47
+ sys.exit(1)
48
+
49
+ return cast(applications_definition.ApplicationsConfiguration, applications)
50
+
51
+
52
+ def load_applications_data(
53
+ applications_data: str, filename: str, applications: applications_definition.ApplicationsConfiguration
54
+ ) -> None:
55
+ """Load the applications from the file."""
56
+ applications.update(_validate_applications(applications_data, filename))
57
+
58
+
59
+ def load_applications_file(
60
+ applications_filename: str, applications: applications_definition.ApplicationsConfiguration
61
+ ) -> None:
62
+ """Load the applications from the file."""
63
+ with open(applications_filename, encoding="utf-8") as config_file:
64
+ applications_data = config_file.read()
65
+ load_applications_data(applications_data, applications_filename, applications)
66
+
67
+
68
+ def load_applications(applications_file: Optional[str]) -> applications_definition.ApplicationsConfiguration:
69
+ """Load the applications from the file."""
70
+ applications: applications_definition.ApplicationsConfiguration = {}
71
+
72
+ # Load the applications from the file provided by the package
73
+ package_applications_data = pkgutil.get_data("applications_download", "applications.yaml")
74
+ assert package_applications_data is not None
75
+ load_applications_data(
76
+ package_applications_data.decode(), "<applications_download>/applications.yaml", applications
77
+ )
78
+
79
+ # Load the applications from the file provided by the user
80
+ user_applications_file = os.path.join(_CONFIG_FOLDER, "applications.yaml")
81
+ if os.path.exists(user_applications_file):
82
+ load_applications_file(user_applications_file, applications)
83
+
84
+ if applications_file is None:
85
+ if os.path.exists("applications.yaml"):
86
+ load_applications_file("applications.yaml", applications)
87
+ else:
88
+ load_applications_file(applications_file, applications)
89
+
90
+ return applications
91
+
92
+
93
+ def load_versions(versions_filename: Optional[str] = None) -> dict[str, str]:
94
+ """Load the versions from the file."""
95
+ if versions_filename is not None:
96
+ with open(versions_filename, encoding="utf-8") as version_file:
97
+ return cast(dict[str, str], yaml.load(version_file, Loader=yaml.SafeLoader))
98
+
99
+ if os.path.exists("applications-versions.yaml"):
100
+ with open("applications-versions.yaml", encoding="utf-8") as version_file:
101
+ return cast(dict[str, str], yaml.load(version_file, Loader=yaml.SafeLoader))
102
+
103
+ config_filename = os.path.join(_CONFIG_FOLDER, "applications-versions.yaml")
104
+ if os.path.exists(config_filename):
105
+ with open(config_filename, encoding="utf-8") as version_file:
106
+ return cast(dict[str, str], yaml.load(version_file, Loader=yaml.SafeLoader))
107
+
108
+ versions_data = pkgutil.get_data("applications_download", "versions.yaml")
109
+ assert versions_data is not None
110
+ return cast(dict[str, str], yaml.load(versions_data, Loader=yaml.SafeLoader))
111
+
112
+
113
+ def download_all_applications() -> None:
114
+ """Download all the applications defined in the c2cciutils package."""
115
+ applications = load_applications(None)
116
+ versions = load_versions("applications-versions.yaml")
117
+ download_applications(applications, versions)
118
+
119
+
120
+ def download_application(
121
+ name: str, versions_filename: Optional[str] = None, application_filename: Optional[str] = None
122
+ ) -> None:
123
+ """Download the applications defined in the c2cciutils package."""
124
+ applications = load_applications(application_filename)
125
+ versions = load_versions(versions_filename)
126
+ download_applications(applications, {name: versions[name]})
127
+
128
+
129
+ def download_applications(
130
+ applications: applications_definition.ApplicationsConfiguration, versions: dict[str, str]
131
+ ) -> None:
132
+ """Download the versions of applications specified in the configuration."""
133
+ bin_path = os.path.join(os.environ["HOME"], ".local", "bin")
134
+ if not os.path.exists(bin_path):
135
+ os.makedirs(bin_path)
136
+
137
+ installed_applications = get_installed_applications()
138
+ dirty = False
139
+
140
+ for key, version in versions.items():
141
+ if key not in applications:
142
+ sys.stderr.write(f"Application {key} not found in the configuration\n")
143
+ sys.exit(1)
144
+ app = applications[key]
145
+
146
+ # If the package is already at the right version don't re-download
147
+ if key in installed_applications and installed_applications[key] == version:
148
+ continue
149
+
150
+ print(f"Download {key} version {version}")
151
+ version_quote = urllib.parse.quote_plus(version)
152
+ params = {
153
+ "version": version,
154
+ "version_quote": version_quote,
155
+ "short_version": version.lstrip("v"),
156
+ }
157
+ response = requests.get( # nosec
158
+ app.get(
159
+ "url-pattern",
160
+ f"https://github.com/{key}/releases/download/{version_quote}/"
161
+ f"{app.get('get-file-name', '')}",
162
+ ).format(**params),
163
+ timeout=int(os.environ.get("REQUESTS_TIMEOUT", "30")),
164
+ )
165
+ response.raise_for_status()
166
+
167
+ if app.get("type") == "tar":
168
+ with tarfile.open(fileobj=BytesIO(response.content)) as tar:
169
+ extracted_file = tar.extractfile(app["tar-file-name"])
170
+ assert extracted_file is not None
171
+ content = extracted_file.read()
172
+ else:
173
+ content = response.content
174
+
175
+ with open(os.path.join(bin_path, app["to-file-name"]), "wb") as destination_file:
176
+ destination_file.write(content)
177
+
178
+ for additional_filename, additional_content in app.get("additional-files", {}).items():
179
+ print(f"Create {additional_filename}")
180
+ with open(os.path.join(bin_path, additional_filename), "w", encoding="utf-8") as additional_file:
181
+ additional_file.write(additional_content)
182
+
183
+ for command in app.get("finish-commands", []):
184
+ subprocess.run(command, check=True, cwd=bin_path) # nosec
185
+
186
+ if "version-command" in app:
187
+ subprocess.run(app["version-command"], check=True, cwd=bin_path) # nosec
188
+
189
+ if app.get("remove-after-success", False):
190
+ os.remove(os.path.join(bin_path, app["to-file-name"]))
191
+
192
+ installed_applications[key] = version
193
+ dirty = True
194
+ if dirty:
195
+ if not os.path.exists(_CONFIG_FOLDER):
196
+ os.makedirs(_CONFIG_FOLDER)
197
+ with open(os.path.join(_CONFIG_FOLDER, "installed.yaml"), "w", encoding="utf-8") as installed_file:
198
+ yaml.dump(installed_applications, installed_file)
199
+
200
+
201
+ def get_installed_applications() -> dict[str, str]:
202
+ """List the installed applications."""
203
+ installed_applications_filename = os.path.join(_CONFIG_FOLDER, "installed.yaml")
204
+ if not os.path.exists(installed_applications_filename):
205
+ return {}
206
+
207
+ with open(installed_applications_filename, encoding="utf-8") as installed_file:
208
+ return cast(dict[str, str], yaml.load(installed_file, Loader=yaml.SafeLoader))
@@ -0,0 +1,71 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "https://raw.githubusercontent.com/camptocamp/tilecloud-chain/master/tilecloud_chain/schema.json",
4
+ "title": "Applications configuration",
5
+ "description": "All the applications configuration",
6
+ "type": "object",
7
+ "definitions": {},
8
+ "additionalProperties": {
9
+ "title": "Application configuration",
10
+ "description": "An application configuration",
11
+ "type": "object",
12
+ "properties": {
13
+ "description": {
14
+ "title": "Description",
15
+ "description": "The description of the application",
16
+ "type": "string"
17
+ },
18
+ "url-pattern": {
19
+ "title": "URL pattern",
20
+ "description": "URL pattern, to be used for files that didn't come from GitHub release, available arguments: {version}",
21
+ "type": "string"
22
+ },
23
+ "type": {
24
+ "title": "The type of file",
25
+ "description": "The type of file",
26
+ "type": "string",
27
+ "enum": ["tar"]
28
+ },
29
+ "get-file-name": {
30
+ "title": "The filename to get",
31
+ "description": "The name of the file to get in the GitHub release",
32
+ "type": "string"
33
+ },
34
+ "to-file-name": {
35
+ "title": "The created tile name",
36
+ "description": "The name of the final tile we will create",
37
+ "type": "string"
38
+ },
39
+ "tar-file-name": {
40
+ "title": "The tile name to get in the tar file",
41
+ "type": "string"
42
+ },
43
+ "additional-files": {
44
+ "title": "Additional files",
45
+ "description": "Additional files to be created",
46
+ "type": "object",
47
+ "additionalProperties": {
48
+ "type": "string"
49
+ }
50
+ },
51
+ "finish-commands": {
52
+ "title": "The commands to run after the tile creation",
53
+ "type": "array",
54
+ "items": {
55
+ "type": "array",
56
+ "items": {
57
+ "type": "string"
58
+ }
59
+ }
60
+ },
61
+ "version-command": {
62
+ "title": "The command to get the version",
63
+ "type": "array",
64
+ "items": {
65
+ "type": "string"
66
+ }
67
+ }
68
+ },
69
+ "required": ["description", "to-file-name"]
70
+ }
71
+ }
@@ -0,0 +1,255 @@
1
+ # yaml-language-server: $schema=https://raw.githubusercontent.com/camptocamp/c2cciutils/master/c2cciutils/schema-applications.json
2
+
3
+ k3d-io/k3d:
4
+ description: k3d is a lightweight wrapper to run k3s (Rancher Lab's minimal Kubernetes distribution) in Docker.
5
+ get-file-name: k3d-linux-amd64
6
+ to-file-name: k3d
7
+ finish-commands:
8
+ - - chmod
9
+ - +x
10
+ - k3d
11
+ - - k3d
12
+ - --version
13
+ k3s-io/k3s:
14
+ description: Lightweight Kubernetes
15
+ get-file-name: k3s
16
+ to-file-name: k3s
17
+ finish-commands:
18
+ - - chmod
19
+ - +x
20
+ - k3s
21
+ - - k3s
22
+ - --version
23
+ derailed/k9s:
24
+ description: K9s provides a terminal UI to interact with your Kubernetes clusters.
25
+ type: tar
26
+ get-file-name: k9s_Linux_amd64.tar.gz
27
+ tar-file-name: k9s
28
+ to-file-name: k9s
29
+ finish-commands:
30
+ - - chmod
31
+ - +x
32
+ - k9s
33
+ - - k9s
34
+ - version
35
+ kubernetes/kubernetes:
36
+ description: Kubernetes
37
+ url-pattern: https://dl.k8s.io/release/{version}/bin/linux/amd64/kubectl
38
+ to-file-name: kubectl
39
+ helm/helm:
40
+ description: Helm helps you manage Kubernetes applications
41
+ type: tar
42
+ url-pattern: https://get.helm.sh/helm-{version}-linux-amd64.tar.gz
43
+ tar-file-name: linux-amd64/helm
44
+ to-file-name: helm3
45
+ finish-commands:
46
+ - - chmod
47
+ - +x
48
+ - helm3
49
+ version-command:
50
+ - helm3
51
+ - version
52
+ snyk/cli:
53
+ description: Snyk helps you find, fix and monitor known vulnerabilities in your dependencies
54
+ get-file-name: snyk-linux
55
+ to-file-name: snyk
56
+ finish-commands:
57
+ - - chmod
58
+ - +x
59
+ - snyk
60
+ version-command:
61
+ - snyk
62
+ - --version
63
+ helm/chart-releaser:
64
+ description: Helm Chart Releaser
65
+ get-file-name: chart-releaser_{short_version}_linux_amd64.tar.gz
66
+ type: tar
67
+ tar-file-name: cr
68
+ to-file-name: cr
69
+ finish-commands:
70
+ - - chmod
71
+ - +x
72
+ - cr
73
+ version-command:
74
+ - cr
75
+ - version
76
+ mozilla/sops:
77
+ description: Sops is an editor of encrypted files
78
+ get-file-name: sops_{short_version}_amd64.deb
79
+ to-file-name: sops.deb
80
+ remove-after-success: true
81
+ finish-commands:
82
+ - - sudo
83
+ - dpkg
84
+ - --install
85
+ - sops.deb
86
+ version-command:
87
+ - sops
88
+ - --version
89
+ rclone/rclone:
90
+ description: Rclone is a command line program to manage files on cloud storage
91
+ get-file-name: rclone-{version}-linux-amd64.deb
92
+ to-file-name: rclone.deb
93
+ remove-after-success: true
94
+ finish-commands:
95
+ - - sudo
96
+ - dpkg
97
+ - --install
98
+ - rclone.deb
99
+ version-command:
100
+ - rclone
101
+ - --version
102
+ aquasecurity/trivy:
103
+ description: Trivy is a simple and comprehensive vulnerability scanner for containers
104
+ get-file-name: trivy_{short_version}_Linux-64bit.deb
105
+ to-file-name: trivy.deb
106
+ remove-after-success: true
107
+ finish-commands:
108
+ - - sudo
109
+ - dpkg
110
+ - --install
111
+ - trivy.deb
112
+ version-command:
113
+ - trivy
114
+ - --version
115
+ gopasspw/gopass:
116
+ description: Gopass is a password manager for teams
117
+ get-file-name: gopass_{short_version}_linux_amd64.deb
118
+ #get-file-name: gopass-{short_version}-linux-amd64.deb
119
+ to-file-name: gopass.deb
120
+ remove-after-success: true
121
+ finish-commands:
122
+ - - sudo
123
+ - dpkg
124
+ - --install
125
+ - gopass.deb
126
+ version-command:
127
+ - gopass
128
+ - --version
129
+ JOSM/josm:
130
+ description: JOSM is an extensible editor for OpenStreetMap (OSM)
131
+ url-pattern: https://josm.openstreetmap.de/josm-tested.jar
132
+ to-file-name: josm.jar
133
+ additional-files:
134
+ josm: |
135
+ #!/bin/bash -eux
136
+ java -jar josm.jar "$@"
137
+ finish-commands:
138
+ - - chmod
139
+ - +x
140
+ - josm
141
+ version-command:
142
+ - josm
143
+ - --version
144
+ hadolint/hadolint:
145
+ description: Hadolint is a Dockerfile linter
146
+ get-file-name: hadolint-Linux-x86_64
147
+ to-file-name: hadolint
148
+ finish-commands:
149
+ - - chmod
150
+ - +x
151
+ - hadolint
152
+ version-command:
153
+ - hadolint
154
+ - --version
155
+ cli/cli:
156
+ description: GitHub CLI
157
+ get-file-name: gh_{short_version}_linux_amd64.deb
158
+ to-file-name: gh.deb
159
+ remove-after-success: true
160
+ finish-commands:
161
+ - - sudo
162
+ - dpkg
163
+ - --install
164
+ - gh.deb
165
+ version-command:
166
+ - gh
167
+ - --version
168
+ Azure/kubelogin:
169
+ description: Azure Kubernetes Service (AKS) kubeconfig credential helper
170
+ get-file-name: kubelogin-linux-amd64.zip
171
+ to-file-name: kubelogin-linux-amd64.zip
172
+ remove-after-success: true
173
+ finish-commands:
174
+ - - unzip
175
+ - kubelogin-linux-amd64.zip
176
+ - - mv
177
+ - bin/linux_amd64/kubelogin
178
+ - kubelogin
179
+ - - rmdir
180
+ - bin/linux_amd64
181
+ - - rm
182
+ - -rf
183
+ - bin
184
+ - - chmod
185
+ - +x
186
+ - kubelogin
187
+ version-command:
188
+ - kubelogin
189
+ - --version
190
+ transifex/cli:
191
+ description: Transifex Command-line Client
192
+ get-file-name: tx-linux-amd64.tar.gz
193
+ tar-file-name: tx
194
+ to-file-name: tx
195
+ finish-commands:
196
+ - - chmod
197
+ - +x
198
+ - tx
199
+ # version-command:
200
+ # - tx
201
+ # - --version
202
+ google/google-java-format:
203
+ description: Google Java Format
204
+ get-file-name: google-java-format-{short_version}-all-deps.jar
205
+ to-file-name: google-java-format-all-deps.jar
206
+ additional-files:
207
+ google-java-format: |
208
+ #!/bin/bash -eux
209
+ java -jar google-java-format-all-deps.jar "$@"
210
+ finish-commands:
211
+ - - chmod
212
+ - +x
213
+ - google-java-format
214
+ version-command:
215
+ - google-java-format
216
+ - --version
217
+ docker/compose:
218
+ description: Docker Compose
219
+ get-file-name: docker-compose-linux-x86_64
220
+ to-file-name: docker-compose
221
+ finish-commands:
222
+ - - chmod
223
+ - +x
224
+ - docker-compose
225
+ - - mkdir
226
+ - --parents
227
+ - ../.docker/cli-plugins
228
+ - - cp
229
+ - docker-compose
230
+ - ../.docker/cli-plugins/docker-compose
231
+ - - docker-compose
232
+ - --version
233
+ version-command:
234
+ - docker
235
+ - compose
236
+ - version
237
+ kubescape/kubescape:
238
+ description: Kubescape is the first tool for testing if Kubernetes is deployed securely as defined in Kubernetes Hardening Guidance by to NSA and CISA
239
+ get-file-name: kubescape-ubuntu-latest
240
+ to-file-name: kubescape
241
+ finish-commands:
242
+ - - chmod
243
+ - +x
244
+ - kubescape
245
+ version-command:
246
+ - kubescape
247
+ - version
248
+ nvm-sh/nvm:
249
+ description: Node Version Manager
250
+ url-pattern: https://raw.githubusercontent.com/nvm-sh/nvm/{version}/install.sh
251
+ to-file-name: nvm-install.sh
252
+ remove-after-success: true
253
+ finish-commands:
254
+ - - bash
255
+ - nvm-install.sh
@@ -0,0 +1,69 @@
1
+ """
2
+ Automatically generated file from a JSON schema.
3
+ """
4
+
5
+ from typing import Dict, List, Literal, TypedDict, Union
6
+ from typing_extensions import Required
7
+
8
+
9
+ # | Application configuration.
10
+ # |
11
+ # | An application configuration
12
+ ApplicationConfiguration = TypedDict(
13
+ "ApplicationConfiguration",
14
+ {
15
+ # | Description.
16
+ # |
17
+ # | The description of the application
18
+ # |
19
+ # | Required property
20
+ "description": Required[str],
21
+ # | URL pattern.
22
+ # |
23
+ # | URL pattern, to be used for files that didn't come from GitHub release, available arguments: {version}
24
+ "url-pattern": str,
25
+ # | The type of file.
26
+ # |
27
+ # | The type of file
28
+ "type": "TheTypeOfFile",
29
+ # | The filename to get.
30
+ # |
31
+ # | The name of the file to get in the GitHub release
32
+ "get-file-name": str,
33
+ # | The created tile name.
34
+ # |
35
+ # | The name of the final tile we will create
36
+ # |
37
+ # | Required property
38
+ "to-file-name": Required[str],
39
+ # | The tile name to get in the tar file.
40
+ "tar-file-name": str,
41
+ # | Additional files.
42
+ # |
43
+ # | Additional files to be created
44
+ "additional-files": Dict[str, str],
45
+ # | The commands to run after the tile creation.
46
+ "finish-commands": List[List[str]],
47
+ # | The command to get the version.
48
+ "version-command": List[str],
49
+ },
50
+ total=False,
51
+ )
52
+
53
+
54
+ ApplicationsConfiguration = Dict[str, "ApplicationConfiguration"]
55
+ """
56
+ Applications configuration.
57
+
58
+ All the applications configuration
59
+ """
60
+
61
+
62
+ TheTypeOfFile = Union[Literal["tar"]]
63
+ """
64
+ The type of file.
65
+
66
+ The type of file
67
+ """
68
+ THETYPEOFFILE_TAR: Literal["tar"] = "tar"
69
+ """The values for the 'The type of file' enum"""
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import argparse
4
+ import sys
5
+
6
+ import applications_download
7
+
8
+
9
+ def main() -> None:
10
+ """Download applications from GitHub releases or any other URLs to the ~/.local/bin folder."""
11
+ argparser = argparse.ArgumentParser(
12
+ description="""Download applications from GitHub releases or any other URLs to the ~/.local/bin
13
+ folder.
14
+ Based on tow files, the first contains the information about from where to download the
15
+ applications,
16
+ how to extract the application from the archive, and the executable name.
17
+ The second file contains the versions of the applications to download,
18
+ this file is usually updated by Renovate."""
19
+ )
20
+ argparser.add_argument("--applications", help="The file containing the applications to download")
21
+ argparser.add_argument(
22
+ "--versions", help="The file containing the versions of the applications to download"
23
+ )
24
+ argparser.add_argument("--name", help="The name of the application to download")
25
+ argparser.add_argument(
26
+ "--version", help="The version of the application to download, to be used with --name"
27
+ )
28
+ argparser.add_argument("--list", action="store_true", help="List the applications to download")
29
+ argparser.add_argument(
30
+ "--installed", action="store_true", help="List the installed applications versions"
31
+ )
32
+
33
+ args = argparser.parse_args()
34
+
35
+ applications = applications_download.load_applications(args.applications)
36
+
37
+ if args.list:
38
+ versions = applications_download.load_versions(args.versions)
39
+ for key, app in applications.items():
40
+ if args.name is None or args.name == key:
41
+ version = f" ({versions[key]})" if key in versions else ""
42
+ print(f"{key}{version}: {app['description']}")
43
+ sys.exit(0)
44
+
45
+ if args.installed:
46
+ installed_applications = applications_download.get_installed_applications()
47
+ for application, version in installed_applications.items():
48
+ if args.name is None or args.name == application:
49
+ print(f"{application}: {version}")
50
+ sys.exit(0)
51
+
52
+ if args.version is not None:
53
+ assert args.name is not None
54
+ applications_download.download_applications(applications, {args.name: args.version})
55
+ sys.exit(0)
56
+
57
+ versions = applications_download.load_versions(args.versions)
58
+
59
+ if args.name is not None:
60
+ applications_download.download_applications(applications, {args.name: versions[args.name]})
61
+ sys.exit(0)
62
+
63
+ applications_download.download_applications(applications, versions)
64
+
65
+
66
+ if __name__ == "__main__":
67
+ main()
@@ -0,0 +1,21 @@
1
+ # https://docs.renovatebot.com/modules/datasource/#github-releases-datasource
2
+ k3d-io/k3d: v5.7.4 # github-releases
3
+ k3s-io/k3s: v1.31.1+k3s1 # github-releases
4
+ derailed/k9s: v0.32.5 # github-releases
5
+ helm/helm: v3.16.1 # github-releases
6
+ helm/chart-releaser: v1.6.1 # github-releases
7
+ snyk/cli: v1.1293.1 # github-releases
8
+ kubernetes/kubernetes: v1.31.1 # github-releases
9
+ mozilla/sops: v3.9.0 # github-releases
10
+ aquasecurity/trivy: v0.55.2 # github-releases
11
+ gopasspw/gopass: v1.15.14 # github-releases
12
+ JOSM/josm: 19207-tested # github-releases
13
+ hadolint/hadolint: v2.12.0 # github-releases
14
+ transifex/cli: v1.6.17 # github-releases
15
+ cli/cli: v2.58.0 # github-releases
16
+ Azure/kubelogin: v0.1.4 # github-releases
17
+ google/google-java-format: v1.23.0 # github-releases
18
+ rclone/rclone: v1.68.1 # github-releases
19
+ docker/compose: v2.29.7 # github-releases
20
+ kubescape/kubescape: v3.0.18 # github-releases
21
+ nvm-sh/nvm: v0.40.1 # github-releases
@@ -0,0 +1,100 @@
1
+ [tool.ruff]
2
+ line-length = 110
3
+ target-version = "py39"
4
+
5
+ [tool.ruff.lint]
6
+ fixable = ["ALL"]
7
+ extend-select = [
8
+ "UP", # pyupgrade
9
+ "F", # Pyflakes
10
+ "E", "W", # Pycodestyle
11
+ "I", # isort
12
+ "S", # flake8-bandit
13
+ "SIM", # flake8-simplify
14
+ "B", # flake8-bugbear
15
+ # pydocstyle
16
+ "D213", "D214", "D215", "D405", "D406", "D407", "D408", "D409", "D410", "D411", "D413", "D416", "D417",
17
+ ]
18
+ ignore= [
19
+ "S101", # Use of assert detected
20
+ "S607", # start-process-with-partial-path
21
+ "S603", # subprocess-without-shell-equals-true
22
+ ]
23
+ exclude = ["applications_download/applications_definition.py"]
24
+
25
+ [tool.mypy]
26
+ python_version = "3.9"
27
+ ignore_missing_imports = true
28
+ warn_redundant_casts = true
29
+ warn_unused_ignores = true
30
+ warn_return_any = true
31
+ strict = true
32
+
33
+ [tool.poetry]
34
+ name = "applications-download"
35
+ version = "0.7.1"
36
+ description = "Tools used to publish Python packages, Docker images and Helm charts for GitHub tag and branch"
37
+ readme = "README.md"
38
+ authors = ["Camptocamp <info@camptocamp.com>"]
39
+ keywords = ["ci"]
40
+ repository = "https://github.com/camptocamp/applications-download"
41
+ license = "FreeBSD"
42
+ packages = [{ include = "applications_download" }]
43
+ classifiers = [
44
+ "Development Status :: 5 - Production/Stable",
45
+ "Environment :: Console",
46
+ "Operating System :: OS Independent",
47
+ "Programming Language :: Python",
48
+ "Intended Audience :: Developers",
49
+ "License :: OSI Approved :: MIT License",
50
+ "Typing :: Typed",
51
+ ]
52
+ include = [
53
+ "applications_download/py.typed",
54
+ "applications_download/*.json",
55
+ "applications_download/*.yaml",
56
+ ]
57
+
58
+ [tool.poetry.scripts]
59
+ applications-download = "applications_download.cli:main"
60
+
61
+ [tool.poetry.dependencies]
62
+ python = ">=3.9,<4.0"
63
+ requests = "2.32.3"
64
+ PyYAML = "6.0.2"
65
+ "ruamel.yaml" = "0.18.6"
66
+ jsonschema-validator-new = "0.1.0"
67
+ #jsonschema-validator = "0.1.0"
68
+
69
+ [tool.poetry.group.dev.dependencies]
70
+ prospector = { version = "1.12.1", extras = ["with-bandit", "with-mypy", "with-pyroma"] }
71
+ prospector-profile-duplicated = "1.6.0"
72
+ prospector-profile-utils = "1.9.1"
73
+ types-requests = "2.32.0.20241016"
74
+ types-pyyaml = "6.0.12.20240917"
75
+
76
+ [build-system]
77
+ requires = [
78
+ "poetry-core>=1.0.0",
79
+ "poetry-dynamic-versioning[plugin]>=0.19.0",
80
+ "poetry-plugin-tweak-dependencies-version",
81
+ "poetry-plugin-drop-python-upper-constraint",
82
+ ]
83
+ build-backend = "poetry.core.masonry.api"
84
+
85
+ [tool.poetry-dynamic-versioning]
86
+ enable = false
87
+ vcs = "git"
88
+ pattern = "^(?P<base>\\d+(\\.\\d+)*)"
89
+ format-jinja = """
90
+ {%- if env.get("VERSION_TYPE") == "version_branch" -%}
91
+ {{serialize_pep440(bump_version(base, 1 if env.get("IS_MASTER") == "TRUE" else 2), dev=distance)}}
92
+ {%- elif distance == 0 -%}
93
+ {{serialize_pep440(base)}}
94
+ {%- else -%}
95
+ {{serialize_pep440(bump_version(base), dev=distance)}}
96
+ {%- endif -%}
97
+ """
98
+
99
+ [tool.poetry-plugin-tweak-dependencies-version]
100
+ default = "major"