Skip to content

Commit

Permalink
metadata-service[lib]: Forbid release candidate for major version (#4…
Browse files Browse the repository at this point in the history
  • Loading branch information
alafanechere authored Oct 16, 2024
1 parent b8b2bfa commit 0bae1e6
Show file tree
Hide file tree
Showing 5 changed files with 276 additions and 231 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,24 @@ def check_is_release_candidate_version(version: str) -> bool:
return parsed_version.prerelease is not None and "rc" in parsed_version.prerelease


def check_is_major_release_candidate_version(version: str) -> bool:
"""Check whether the version is a major release candidate version.
Example: 2.0.0-rc.1
"""

if not check_is_release_candidate_version(version):
return False

# The version is a release candidate version
parsed_version = semver.VersionInfo.parse(version)
# No major version exists.
if parsed_version.major == 0:
return False
# The current release candidate is for a major version
if parsed_version.minor == 0 and parsed_version.patch == 0:
return True


def validate_rc_suffix_and_rollout_configuration(
metadata_definition: ConnectorMetadataDefinitionV0, _validator_opts: ValidatorOptions
) -> ValidationResult:
Expand All @@ -229,15 +247,28 @@ def validate_rc_suffix_and_rollout_configuration(
if docker_image_tag is None:
return False, "The dockerImageTag field is not set."
try:

is_major_release_candidate_version = check_is_major_release_candidate_version(docker_image_tag)
is_dev_version = check_is_dev_version(docker_image_tag)
is_rc_version = check_is_release_candidate_version(docker_image_tag)
is_prerelease = is_dev_version or is_rc_version
enabled_progressive_rollout = get(metadata_definition, "data.releases.rolloutConfiguration.enableProgressiveRollout", None)

# Major release candidate versions are not allowed
if is_major_release_candidate_version:
return (
False,
"The dockerImageTag has an -rc.<RC #> suffix for a major version. Release candidates for major version (with breaking changes) are not allowed.",
)

# Release candidates must have progressive rollout set to True or False
if is_rc_version and enabled_progressive_rollout is None:
return (
False,
"The dockerImageTag field has an -rc suffix but the connector is not set to use progressive rollout (releases.rolloutConfiguration.enableProgressiveRollout).",
"The dockerImageTag field has an -rc.<RC #> suffix but the connector is not set to use progressive rollout (releases.rolloutConfiguration.enableProgressiveRollout).",
)

# Progressive rollout can be enabled only for release candidates
if enabled_progressive_rollout is True and not is_prerelease:
return (
False,
Expand Down
2 changes: 1 addition & 1 deletion airbyte-ci/connectors/metadata_service/lib/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "metadata-service"
version = "0.21.0"
version = "0.22.0"
description = ""
authors = ["Ben Church <[email protected]>"]
readme = "README.md"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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: 3.0.0-rc.1
documentationUrl: https://docs.airbyte.com/integrations/sources/existingsource
connectorSubtype: database
releaseStage: generally_available
license: MIT
releases:
rolloutConfiguration:
enableProgressiveRollout: 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
Loading

0 comments on commit 0bae1e6

Please sign in to comment.