Skip to content

Commit

Permalink
metadata-service[lib]: validate that release candidate have rc suffix…
Browse files Browse the repository at this point in the history
… in their version (#46573)
  • Loading branch information
alafanechere authored Oct 10, 2024
1 parent 655daf9 commit 6256948
Show file tree
Hide file tree
Showing 8 changed files with 1,487 additions and 1,239 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,34 @@ def validate_docker_image_tag_is_not_decremented(
return True, None


def validate_release_candidate_has_rc_suffix_in_version(
metadata_definition: ConnectorMetadataDefinitionV0, _validator_opts: ValidatorOptions
) -> ValidationResult:
# Bypass validation for pre-releases
if _validator_opts and _validator_opts.prerelease_tag:
return True, None

is_release_candidate = get(metadata_definition, "data.releases.isReleaseCandidate")
if not is_release_candidate:
return True, None

docker_image_tag = get(metadata_definition, "data.dockerImageTag")
if docker_image_tag is None:
return False, "The dockerImageTag field is not set."
try:
parsed_version = semver.VersionInfo.parse(docker_image_tag)
has_rc_suffix = parsed_version.prerelease and "rc" in parsed_version.prerelease
if not has_rc_suffix:
return (
False,
"The dockerImageTag field should have an -rc.<RC #> suffix as the connector is marked as a release candidate (releases.isReleaseCandidate). Example: 2.1.0-rc.1",
)
except ValueError:
return False, f"The dockerImageTag field is not a valid semver version: {docker_image_tag}."

return True, None


PRE_UPLOAD_VALIDATORS = [
validate_all_tags_are_keyvalue_pairs,
validate_at_least_one_language_tag,
Expand All @@ -214,6 +242,7 @@ def validate_docker_image_tag_is_not_decremented(
validate_metadata_base_images_in_dockerhub,
validate_pypi_only_for_python,
validate_docker_image_tag_is_not_decremented,
validate_release_candidate_has_rc_suffix_in_version,
]

POST_UPLOAD_VALIDATORS = PRE_UPLOAD_VALIDATORS + [
Expand Down
4 changes: 2 additions & 2 deletions airbyte-ci/connectors/metadata_service/lib/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[tool.poetry]
name = "metadata-service"
version = "0.17.0"
version = "0.18.0"
description = ""
authors = ["Ben Church <ben@airbyte.io>"]
readme = "README.md"
packages = [{ include = "metadata_service" }]

[tool.poetry.dependencies]
python = "~3.10"
python = "^3.10"
pydantic = "^1.10.6"
click = "^8.1.3"
google = "^3.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ data:
connectorType: source
dockerRepository: airbyte/image-exists-1
githubIssueLabel: source-alloydb-strict-encrypt
dockerImageTag: 2.1.0
dockerImageTag: 2.1.0-rc.1
documentationUrl: https://docs.airbyte.com/integrations/sources/existingsource
connectorSubtype: database
releaseStage: generally_available
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
metadataSpecVersion: 1.0
data:
name: AlloyDB for PostgreSQL
definitionId: 1fa90628-2b9e-11ed-a261-0242ac120002
connectorType: source
dockerRepository: airbyte/image-exists-1
githubIssueLabel: source-alloydb-strict-encrypt
dockerImageTag: 2.0.1
documentationUrl: https://docs.airbyte.com/integrations/sources/existingsource
connectorSubtype: database
releaseStage: generally_available
license: MIT
releases:
isReleaseCandidate: true
breakingChanges:
2.0.0:
upgradeDeadline: 2023-08-22
message: "This version changes the connector’s authentication method from `ApiKey` to `oAuth`, per the [API guide](https://amazon-sqs.com/api/someguide)."

tags:
- language:java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
metadataSpecVersion: 1.0
data:
name: AlloyDB for PostgreSQL
definitionId: 1fa90628-2b9e-11ed-a261-0242ac120002
connectorType: source
dockerRepository: airbyte/image-exists-1
githubIssueLabel: source-alloydb-strict-encrypt
dockerImageTag: 2.0.1-rc.1
documentationUrl: https://docs.airbyte.com/integrations/sources/existingsource
connectorSubtype: database
releaseStage: generally_available
license: MIT
releases:
isReleaseCandidate: true
breakingChanges:
2.0.0:
upgradeDeadline: 2023-08-22
message: "This version changes the connector’s authentication method from `ApiKey` to `oAuth`, per the [API guide](https://amazon-sqs.com/api/someguide)."

tags:
- language:java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

import pandas as pd
from dagster import OpExecutionContext
from metadata_service.constants import METADATA_FILE_NAME
from metadata_service.gcs_upload import get_metadata_remote_file_path
from metadata_service.constants import METADATA_FILE_NAME, METADATA_FOLDER
from metadata_service.models.generated.ConnectorRegistryDestinationDefinition import ConnectorRegistryDestinationDefinition
from metadata_service.models.generated.ConnectorRegistrySourceDefinition import ConnectorRegistrySourceDefinition

Expand All @@ -16,10 +15,10 @@

def _get_version_specific_registry_entry_file_path(registry_entry, registry_name):
"""Get the file path for the version specific registry entry file."""
docker_reposiory = registry_entry.dockerRepository
docker_repository = registry_entry.dockerRepository
docker_version = registry_entry.dockerImageTag

assumed_metadata_file_path = get_metadata_remote_file_path(docker_reposiory, docker_version)
assumed_metadata_file_path = f"{METADATA_FOLDER}/{docker_repository}/{docker_version}/{METADATA_FILE_NAME}"
registry_entry_file_path = assumed_metadata_file_path.replace(METADATA_FILE_NAME, registry_name)
return registry_entry_file_path

Expand Down
Loading

0 comments on commit 6256948

Please sign in to comment.