Skip to content

Commit a683c74

Browse files
authored
airbyte-ci/metadata-lib: make dockerhub credentials optional (#37787)
1 parent 4886205 commit a683c74

File tree

10 files changed

+24
-42
lines changed

10 files changed

+24
-42
lines changed

airbyte-ci/connectors/connectors_qa/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ poe lint
107107
```
108108
## Changelog
109109

110+
### 1.3.1
111+
112+
Remove requirements on DockerHub credentials to run metadata validation.
113+
110114
### 1.3.0
111115

112116
Added `CheckConnectorMaxSecondsBetweenMessagesValue` check that verifies presence of `maxSecondsBetweenMessages` value in `metadata.yaml` file for all source certified connectors.

airbyte-ci/connectors/connectors_qa/pyproject.toml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "connectors-qa"
3-
version = "1.3.0"
3+
version = "1.3.1"
44
description = "A package to run QA checks on Airbyte connectors, generate reports and documentation."
55
authors = ["Airbyte <[email protected]>"]
66
readme = "README.md"
@@ -41,5 +41,4 @@ lint = "ruff check src"
4141

4242
[tool.airbyte_ci]
4343
optional_poetry_groups = ["dev"]
44-
poe_tasks = ["type_check", "lint", "test"]
45-
required_environment_variables = ["DOCKER_HUB_USERNAME", "DOCKER_HUB_PASSWORD"]
44+
poe_tasks = ["type_check", "test"]

airbyte-ci/connectors/connectors_qa/src/connectors_qa/checks/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
22
from .assets import ENABLED_CHECKS as ASSETS_CHECKS
3+
from .documentation import ENABLED_CHECKS as DOCUMENTATION_CHECKS
34
from .metadata import ENABLED_CHECKS as METADATA_CORRECTNESS_CHECKS
4-
from .security import ENABLED_CHECKS as SECURITY_CHECKS
55
from .packaging import ENABLED_CHECKS as PACKAGING_CHECKS
6-
from .documentation import ENABLED_CHECKS as DOCUMENTATION_CHECKS
6+
from .security import ENABLED_CHECKS as SECURITY_CHECKS
77

88
ENABLED_CHECKS = (
99
DOCUMENTATION_CHECKS

airbyte-ci/connectors/connectors_qa/src/connectors_qa/checks/metadata.py

-12
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,6 @@ class MetadataCheck(Check):
1818
class ValidateMetadata(MetadataCheck):
1919
name = f"Connectors must have valid {consts.METADATA_FILE_NAME} file"
2020
description = f"Connectors must have a `{consts.METADATA_FILE_NAME}` file at the root of their directory. This file is used to build our connector registry. Its structure must follow our metadata schema. Field values are also validated. This is to ensure that all connectors have the required metadata fields and that the metadata is valid. More details in this [documentation]({consts.METADATA_DOCUMENTATION_URL})."
21-
# Metadata lib required the following env var to be set
22-
# to check if the base image is on DockerHub
23-
required_env_vars = {
24-
consts.DOCKER_HUB_USERNAME_ENV_VAR_NAME,
25-
consts.DOCKER_HUB_PASSWORD_ENV_VAR_NAME,
26-
}
27-
28-
def __init__(self) -> None:
29-
for env_var in self.required_env_vars:
30-
if env_var not in os.environ:
31-
raise ValueError(f"Environment variable {env_var} is required for this check")
32-
super().__init__()
3321

3422
def _run(self, connector: Connector) -> CheckResult:
3523
if not connector.documentation_file_path or not connector.documentation_file_path.exists():

airbyte-ci/connectors/connectors_qa/tests/unit_tests/test_checks/test_metadata.py

-17
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,6 @@
99

1010

1111
class TestValidateMetadata:
12-
def test_fail_init_when_required_env_vars_are_not_set(self, random_string, mocker):
13-
# Arrange
14-
mocker.patch.object(metadata.ValidateMetadata, "required_env_vars", new={random_string})
15-
16-
# Act
17-
with pytest.raises(ValueError):
18-
metadata.ValidateMetadata()
19-
20-
def test_init_when_required_env_vars_are_set(self, random_string, mocker):
21-
# Arrange
22-
os.environ[random_string] = "test"
23-
mocker.patch.object(metadata.ValidateMetadata, "required_env_vars", new={random_string})
24-
25-
# Act
26-
metadata.ValidateMetadata()
27-
28-
os.environ.pop(random_string)
2912

3013
def test_fail_when_documentation_file_path_is_none(self, mocker):
3114
# Arrange

airbyte-ci/connectors/metadata_service/lib/metadata_service/docker_hub.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,14 @@ def is_image_on_docker_hub(image_name: str, version: str, digest: Optional[str]
4040
bool: True if the image and version exists on Docker Hub, False otherwise.
4141
"""
4242

43-
token = get_docker_hub_auth_token()
44-
headers = {"Authorization": f"JWT {token}"}
43+
if "DOCKER_HUB_USERNAME" not in os.environ or "DOCKER_HUB_PASSWORD" not in os.environ:
44+
# If the Docker Hub credentials are not provided, we can only anonymously call the Docker Hub API.
45+
# This will only work for public images and lead to a lower rate limit.
46+
headers = {}
47+
else:
48+
token = get_docker_hub_auth_token()
49+
headers = {"Authorization": f"JWT {token}"} if token else {}
50+
4551
tag_url = f"https://registry.hub.docker.com/v2/repositories/{image_name}/tags/{version}"
4652

4753
# Allow for retries as the DockerHub API is not always reliable with returning the latest publish.

airbyte-ci/connectors/metadata_service/lib/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "metadata-service"
3-
version = "0.3.4"
3+
version = "0.3.5"
44
description = ""
55
authors = ["Ben Church <[email protected]>"]
66
readme = "README.md"

airbyte-ci/connectors/pipelines/README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ options to the `airbyte-ci` command group.**
186186
| `--is-local/--is-ci` | `--is-local` | | Determines the environment in which the CLI runs: local environment or CI environment. |
187187
| `--git-branch` | The checked out git branch name | `CI_GIT_BRANCH` | The git branch on which the pipelines will run. |
188188
| `--git-revision` | The current branch head | `CI_GIT_REVISION` | The commit hash on which the pipelines will run. |
189-
| `--diffed-branch` | `master` | | Branch to which the git diff will happen to detect new or modified files. |
189+
| `--diffed-branch` | `master` | | Branch to which the git diff will happen to detect new or modified files. |
190190
| `--gha-workflow-run-id` | | | GHA CI only - The run id of the GitHub action workflow |
191191
| `--ci-context` | `manual` | | The current CI context: `manual` for manual run, `pull_request`, `nightly_builds`, `master` |
192192
| `--pipeline-start-timestamp` | Current epoch time | `CI_PIPELINE_START_TIMESTAMP` | Start time of the pipeline as epoch time. Used for pipeline run duration computation. |
@@ -744,7 +744,8 @@ E.G.: running Poe tasks on the modified internal packages of the current branch:
744744
## Changelog
745745

746746
| Version | PR | Description |
747-
|---------| ---------------------------------------------------------- |------------------------------------------------------------------------------------------------------------------------------|
747+
| ------- | ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
748+
| 4.12.7 | [#37787](https://github.com/airbytehq/airbyte/pull/37787) | Remove requirements on dockerhub credentials to run QA checks. |
748749
| 4.12.6 | [#36497](https://github.com/airbytehq/airbyte/pull/36497) | Add airbyte-cdk to list of poetry packages for testing |
749750
| 4.12.5 | [#37785](https://github.com/airbytehq/airbyte/pull/37785) | Set the `--yes-auto-update` flag to `True` by default. |
750751
| 4.12.4 | [#37786](https://github.com/airbytehq/airbyte/pull/37786) | (fixed 4.12.2): Do not upload dagger log to GCP when no credentials are available. |

airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/steps/docker.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(
1818
context: PipelineContext,
1919
paths_to_mount: List[MountPath] = [],
2020
internal_tools: List[MountPath] = [],
21-
secrets: dict[str, dagger.Secret] = {},
21+
secrets: dict[str, dagger.Secret | None] = {},
2222
env_variables: dict[str, str] = {},
2323
working_directory: str = "/",
2424
command: Optional[List[str]] = None,
@@ -78,7 +78,8 @@ def _set_env_variables(self, container: dagger.Container) -> dagger.Container:
7878

7979
def _set_secrets(self, container: dagger.Container) -> dagger.Container:
8080
for key, value in self.secrets.items():
81-
container = container.with_secret_variable(key, value)
81+
if value is not None:
82+
container = container.with_secret_variable(key, value)
8283
return container
8384

8485
async def init_container(self) -> dagger.Container:

airbyte-ci/connectors/pipelines/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "pipelines"
7-
version = "4.12.6"
7+
version = "4.12.7"
88
description = "Packaged maintained by the connector operations team to perform CI for connectors' pipelines"
99
authors = ["Airbyte <[email protected]>"]
1010

0 commit comments

Comments
 (0)