Skip to content

Commit 5b10c9d

Browse files
committed
working deployment platform classes
1 parent b2214ae commit 5b10c9d

File tree

15 files changed

+1615
-16
lines changed

15 files changed

+1615
-16
lines changed

src/gardenlinux/github/__main__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import argparse
22

3+
from gardenlinux.constants import GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME
34
from gardenlinux.logger import LoggerSetup
45

56
from .release import create_github_release, upload_to_github_release_page, write_to_release_id_file
@@ -30,7 +31,7 @@ def main():
3031
args = parser.parse_args()
3132

3233
if args.command == "create":
33-
body = create_github_release_notes(args.tag, args.commit)
34+
body = create_github_release_notes(args.tag, args.commit, GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME)
3435
if args.dry_run:
3536
print("Dry Run ...")
3637
print("This release would be created:")

src/gardenlinux/github/release_notes/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
)
88

99

10-
def create_github_release_notes(gardenlinux_version, commitish):
10+
def create_github_release_notes(gardenlinux_version, commitish, releases_s3_bucket_name):
1111
package_list = get_package_list(gardenlinux_version)
1212

1313
output = ""
@@ -20,7 +20,7 @@ def create_github_release_notes(gardenlinux_version, commitish):
2020
gardenlinux_version, package_list
2121
)
2222

23-
metadata_files = download_all_metadata_files(gardenlinux_version, commitish)
23+
metadata_files = download_all_metadata_files(gardenlinux_version, commitish, releases_s3_bucket_name)
2424

2525
output += release_notes_image_ids_section(metadata_files)
2626

src/gardenlinux/github/release_notes/deployment_platform/__init__.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
class DeploymentPlatform():
55
artifacts_bucket_name = GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME
66

7+
def short_name(self):
8+
return "generic"
9+
710
def full_name(self):
811
return "Generic Deployment Platform"
912

@@ -21,19 +24,22 @@ def published_images_by_regions(self, image_metadata):
2124
def image_extension(self):
2225
return "raw"
2326

24-
def artifact_for_flavor(self, flavor):
27+
def artifact_for_flavor(self, flavor, markdown_format=True):
2528
base_url = f"https://{self.__class__.artifacts_bucket_name}.s3.amazonaws.com/objects"
2629
filename = f"{flavor}.{self.image_extension()}"
2730
download_url = f"{base_url}/{flavor}/{filename}"
28-
return f"[{filename}]({download_url})"
31+
if markdown_format:
32+
return f"[{filename}]({download_url})"
33+
else:
34+
return download_url
2935

30-
def region_details(self):
36+
def region_details(self, image_metadata):
3137
"""
3238
Generate the detailed region information for the collapsible section
3339
"""
3440
details = ""
3541

36-
match self.published_images_by_regions():
42+
match self.published_images_by_regions(image_metadata):
3743
case {"regions": regions}:
3844
for region in regions:
3945
match region:
@@ -71,11 +77,11 @@ def region_details(self):
7177

7278
return details
7379

74-
def summary_text(self):
80+
def summary_text(self, image_metadata):
7581
"""
7682
Generate the summary text for the collapsible section
7783
"""
78-
match self.published_images_by_regions():
84+
match self.published_images_by_regions(image_metadata):
7985
case {"regions": regions}:
8086
count = len(regions)
8187
return f"{count} regions"

src/gardenlinux/github/release_notes/deployment_platform/ali_cloud.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33

44
class AliCloud(DeploymentPlatform):
5+
def short_name(self):
6+
return "ali"
7+
58
def full_name(self):
69
return "Alibaba Cloud"
710

src/gardenlinux/github/release_notes/deployment_platform/amazon_web_services.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,19 @@
22

33

44
class AmazonWebServices(DeploymentPlatform):
5+
def short_name(self):
6+
return "aws"
7+
58
def full_name(self):
69
return "Amazon Web Services"
10+
11+
def published_images_by_regions(self, image_metadata):
12+
published_image_metadata = image_metadata["published_image_metadata"]
13+
flavor_name = image_metadata["s3_key"].split("/")[-1]
14+
15+
regions = []
16+
for pset in published_image_metadata:
17+
for p in published_image_metadata[pset]:
18+
regions.append({"region": p["aws_region_id"], "image_id": p["ami_id"]})
19+
20+
return {"flavor": flavor_name, "regions": regions}

src/gardenlinux/github/release_notes/deployment_platform/azure.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33

44
class Azure(DeploymentPlatform):
5+
def short_name(self):
6+
return "azure"
7+
58
def full_name(self):
69
return "Microsoft Azure"
710

src/gardenlinux/github/release_notes/deployment_platform/google_cloud.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33

44
class GoogleCloud(DeploymentPlatform):
5+
def short_name(self):
6+
return "gcp"
7+
58
def full_name(self):
69
return "Google Cloud Platform"
710

src/gardenlinux/github/release_notes/deployment_platform/openstack.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33

44
class OpenStack(DeploymentPlatform):
5+
def short_name(self):
6+
return "openstack"
7+
58
def full_name(self):
69
return "OpenStack"
710

src/gardenlinux/github/release_notes/deployment_platform/openstack_baremetal.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22

33

44
class OpenStackBareMetal(OpenStack):
5+
def short_name(self):
6+
return "openstackbaremetal"
7+
58
def full_name(self):
69
return "OpenStack Baremetal"

src/gardenlinux/github/release_notes/helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def compare_apt_repo_versions(previous_version, current_version):
4949
return output
5050

5151

52-
def download_all_metadata_files(version, commitish):
52+
def download_all_metadata_files(version, commitish, s3_bucket_name):
5353
repo = Repo(".")
5454
commit = repo.commit(commitish)
5555
flavors_data = commit.tree["flavors.yaml"].data_stream.read().decode("utf-8")
@@ -60,7 +60,7 @@ def download_all_metadata_files(version, commitish):
6060
shutil.rmtree(local_dest_path)
6161
local_dest_path.mkdir(mode=0o755, exist_ok=False)
6262

63-
s3_artifacts = S3Artifacts(GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME)
63+
s3_artifacts = S3Artifacts(s3_bucket_name)
6464

6565
commitish_short = commitish[:8]
6666

0 commit comments

Comments
 (0)