-
Notifications
You must be signed in to change notification settings - Fork 13
CLOUDP-295785 - script to create release_info.json #307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
05029e9
wip: initial release_info.py function
MaciejKaras aeafcfb
wip: added tests + `get_version_for_environment` function
MaciejKaras 0994d18
Added CMD function to create release_info.json
MaciejKaras 2317dc5
Review fixes
MaciejKaras 285ba41
refactor of the code
MaciejKaras 790bbcd
add missing fixtures
MaciejKaras 50dce8b
test fixes
MaciejKaras 38a84a0
Test fixes
MaciejKaras cb41432
Test fixes
MaciejKaras 8a0f1d9
more changes
MaciejKaras eacace9
test fixes
MaciejKaras 2e55e29
fixes
MaciejKaras File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
{ | ||
"images": { | ||
"mongodbOperator": { | ||
"patch": { | ||
"repository": "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes", | ||
"platforms": [ | ||
"linux/amd64" | ||
] | ||
}, | ||
"staging": { | ||
"repository": "quay.io/mongodb/mongodb-kubernetes-stg", | ||
"platforms": [ | ||
"linux/arm64", | ||
"linux/amd64" | ||
] | ||
}, | ||
"release": { | ||
"repository": "quay.io/mongodb/mongodb-kubernetes", | ||
"platforms": [ | ||
"linux/arm64", | ||
"linux/amd64" | ||
] | ||
} | ||
}, | ||
"initDatabase": { | ||
"patch": { | ||
"repository": "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes-init-database", | ||
"platforms": [ | ||
"linux/amd64" | ||
] | ||
}, | ||
"staging": { | ||
"repository": "quay.io/mongodb/mongodb-kubernetes-init-database-stg", | ||
"platforms": [ | ||
"linux/arm64", | ||
"linux/amd64" | ||
] | ||
}, | ||
"release": { | ||
"repository": "quay.io/mongodb/mongodb-kubernetes-init-database", | ||
"platforms": [ | ||
"linux/arm64", | ||
"linux/amd64" | ||
] | ||
} | ||
}, | ||
"initAppDb": { | ||
"patch": { | ||
"repository": "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes-init-appdb", | ||
"platforms": [ | ||
"linux/amd64" | ||
] | ||
}, | ||
"staging": { | ||
"repository": "quay.io/mongodb/mongodb-kubernetes-init-appdb-stg", | ||
"platforms": [ | ||
"linux/arm64", | ||
"linux/amd64" | ||
] | ||
}, | ||
"release": { | ||
"repository": "quay.io/mongodb/mongodb-kubernetes-init-appdb", | ||
"platforms": [ | ||
"linux/arm64", | ||
"linux/amd64" | ||
] | ||
} | ||
}, | ||
"initOpsManager": { | ||
"patch": { | ||
"repository": "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes-init-ops-manager", | ||
"platforms": [ | ||
"linux/amd64" | ||
] | ||
}, | ||
"staging": { | ||
"repository": "quay.io/mongodb/mongodb-kubernetes-init-ops-manager-stg", | ||
"platforms": [ | ||
"linux/arm64", | ||
"linux/amd64" | ||
] | ||
}, | ||
"release": { | ||
"repository": "quay.io/mongodb/mongodb-kubernetes-init-ops-manager", | ||
"platforms": [ | ||
"linux/arm64", | ||
"linux/amd64" | ||
] | ||
} | ||
}, | ||
"database": { | ||
"patch": { | ||
"repository": "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes-database", | ||
"platforms": [ | ||
"linux/amd64" | ||
] | ||
}, | ||
"staging": { | ||
"repository": "quay.io/mongodb/mongodb-kubernetes-database-stg", | ||
"platforms": [ | ||
"linux/arm64", | ||
"linux/amd64" | ||
] | ||
}, | ||
"release": { | ||
"repository": "quay.io/mongodb/mongodb-kubernetes-database", | ||
"platforms": [ | ||
"linux/arm64", | ||
"linux/amd64" | ||
] | ||
} | ||
}, | ||
"readinessprobe": { | ||
"patch": { | ||
"repository": "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes-readinessprobe", | ||
"platforms": [ | ||
"linux/amd64" | ||
] | ||
}, | ||
"staging": { | ||
"repository": "quay.io/mongodb/mongodb-kubernetes-readinessprobe-stg", | ||
"platforms": [ | ||
"linux/arm64", | ||
"linux/amd64" | ||
] | ||
}, | ||
"release": { | ||
"version": "1.0.22", | ||
"repository": "quay.io/mongodb/mongodb-kubernetes-readinessprobe", | ||
"platforms": [ | ||
"linux/arm64", | ||
"linux/amd64" | ||
] | ||
} | ||
}, | ||
"operator-version-upgrade-post-start-hook": { | ||
"patch": { | ||
"repository": "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes-operator-version-upgrade-post-start-hook", | ||
"platforms": [ | ||
"linux/amd64" | ||
] | ||
}, | ||
"staging": { | ||
"repository": "quay.io/mongodb/mongodb-kubernetes-operator-version-upgrade-post-start-hook-stg", | ||
"platforms": [ | ||
"linux/arm64", | ||
"linux/amd64" | ||
] | ||
}, | ||
"release": { | ||
"version": "1.0.9", | ||
"repository": "quay.io/mongodb/mongodb-kubernetes-operator-version-upgrade-post-start-hook", | ||
"platforms": [ | ||
"linux/arm64", | ||
"linux/amd64" | ||
] | ||
} | ||
} | ||
}, | ||
"binaries": { | ||
"kubectl-mongodb": { | ||
"patch": { | ||
"s3-store": "s3://kubectl-mongodb/dev", | ||
"platforms": [ | ||
"linux/amd64" | ||
] | ||
}, | ||
"staging": { | ||
"s3-store": "s3://kubectl-mongodb/staging", | ||
"platforms": [ | ||
"darwin/amd64", | ||
"darwin/arm64", | ||
"linux/amd64", | ||
"linux/arm64" | ||
] | ||
}, | ||
"release": { | ||
"s3-store": "s3://kubectl-mongodb/prod", | ||
"platforms": [ | ||
"darwin/amd64", | ||
"darwin/arm64", | ||
"linux/amd64", | ||
"linux/arm64" | ||
] | ||
} | ||
} | ||
}, | ||
"helm-charts": { | ||
"mongodb-kubernetes": { | ||
"patch": { | ||
"repository": "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/helm-charts" | ||
}, | ||
"staging": { | ||
"repository": "quay.io/mongodb/helm-charts-stg" | ||
}, | ||
"release": { | ||
"repository": "quay.io/mongodb/helm-charts" | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import json | ||
from typing import Dict | ||
|
||
from scripts.release.build.build_scenario import BuildScenario | ||
from scripts.release.constants import DEFAULT_REPOSITORY_PATH, DEFAULT_CHANGELOG_PATH, RELEASE_INITIAL_VERSION_ENV_VAR, \ | ||
get_initial_version, get_initial_commit_sha | ||
|
||
|
||
class ImageInfo(dict): | ||
def __init__(self, repository: str, platforms: list[str], version: str): | ||
super().__init__() | ||
self.repository = repository | ||
self.platforms = platforms | ||
self.version = version | ||
|
||
def to_json(self): | ||
return {"repository": self.repository, "platforms": self.platforms, "version": self.version} | ||
|
||
|
||
class BinaryInfo(dict): | ||
def __init__(self, s3_store: str, platforms: list[str], version: str): | ||
super().__init__() | ||
self.s3_store = s3_store | ||
self.platforms = platforms | ||
self.version = version | ||
|
||
def to_json(self): | ||
return {"platforms": self.platforms, "version": self.version} | ||
|
||
|
||
class HelmChartInfo(dict): | ||
def __init__(self, repository: str, version: str): | ||
super().__init__() | ||
self.repository = repository | ||
self.version = version | ||
|
||
def to_json(self): | ||
return {"repository": self.repository, "version": self.version} | ||
|
||
|
||
class BuildInfo(dict): | ||
def __init__( | ||
self, images: Dict[str, ImageInfo], binaries: Dict[str, BinaryInfo], helm_charts: Dict[str, HelmChartInfo] | ||
): | ||
super().__init__() | ||
self.images = images | ||
self.binaries = binaries | ||
self.helm_charts = helm_charts | ||
|
||
def __dict__(self): | ||
return { | ||
"images": {name: images.__dict__ for name, images in self.images.items()}, | ||
"binaries": {name: bin.__dict__ for name, bin in self.binaries.items()}, | ||
"helm-charts": {name: chart.__dict__ for name, chart in self.helm_charts.items()}, | ||
} | ||
|
||
def to_json(self): | ||
return { | ||
"images": {name: images.to_json() for name, images in self.images.items()}, | ||
"binaries": {name: bin.to_json() for name, bin in self.binaries.items()}, | ||
"helm-charts": {name: chart.to_json() for name, chart in self.helm_charts.items()}, | ||
} | ||
|
||
|
||
def load_build_info(scenario: BuildScenario, | ||
repository_path: str = DEFAULT_REPOSITORY_PATH, | ||
changelog_sub_path: str = DEFAULT_CHANGELOG_PATH, | ||
initial_commit_sha: str = None, | ||
initial_version: str = None) -> BuildInfo: | ||
f""" | ||
Load build information based on the specified scenario. | ||
|
||
:param scenario: BuildScenario enum value indicating the build scenario (e.g., PATCH, STAGING, RELEASE). | ||
:param repository_path: Path to the Git repository. Default is the current directory `{DEFAULT_REPOSITORY_PATH}`. | ||
:param changelog_sub_path: Path to the changelog directory relative to the repository root. Default is '{DEFAULT_CHANGELOG_PATH}'. | ||
:param initial_commit_sha: SHA of the initial commit to start from if no previous version tag is found. If not provided, it will be determined based on `{RELEASE_INITIAL_VERSION_ENV_VAR} environment variable. | ||
:param initial_version: Initial version to use if no previous version tag is found. If not provided, it will be determined based on `{RELEASE_INITIAL_VERSION_ENV_VAR}` environment variable. | ||
:return: BuildInfo object containing images, binaries, and helm charts information for specified scenario. | ||
""" | ||
|
||
if not initial_commit_sha: | ||
initial_commit_sha = get_initial_commit_sha() | ||
if not initial_version: | ||
initial_version = get_initial_version() | ||
|
||
version = scenario.get_version(repository_path, changelog_sub_path, initial_commit_sha, initial_version) | ||
|
||
with open("build_info.json", "r") as f: | ||
build_info = json.load(f) | ||
|
||
images = {} | ||
for name, env_data in build_info["images"].items(): | ||
data = env_data[scenario] | ||
# Only update the image_version if it is not already set in the build_info.json file | ||
image_version = data.get("version") | ||
if not image_version: | ||
image_version = version | ||
|
||
images[name] = ImageInfo(repository=data["repository"], platforms=data["platforms"], version=image_version) | ||
|
||
binaries = {} | ||
for name, env_data in build_info["binaries"].items(): | ||
data = env_data[scenario] | ||
binaries[name] = BinaryInfo(s3_store=data["s3-store"], platforms=data["platforms"], version=version) | ||
|
||
helm_charts = {} | ||
for name, env_data in build_info["helm-charts"].items(): | ||
data = env_data[scenario] | ||
helm_charts[name] = HelmChartInfo(repository=data["repository"], version=version) | ||
|
||
return BuildInfo(images=images, binaries=binaries, helm_charts=helm_charts) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.