Skip to content

Commit

Permalink
add code for config validation
Browse files Browse the repository at this point in the history
  • Loading branch information
MrBatschner committed Jan 17, 2024
1 parent c65bfdd commit 3466133
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .cicd-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,8 @@ def end_phase(name):
)
else:
raise ValueError(on_absent) # programming error
else:
publish.validate_publishing_configuration(manifest, cfg)

phase_logger.info('publishing-cfg was found to be okay - starting publishing now')

Expand Down
13 changes: 12 additions & 1 deletion glci/az.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,9 +873,10 @@ def delete_from_azure_community_gallery(
for public_name in configured_gallery.sharing_profile.community_gallery_info.public_names:
if public_name == image_community_gallery_name:
image_gallery_is_configured_gallery = True
break

if not image_gallery_is_configured_gallery:
raise RuntimeError(f"The community gallery of image {community_gallery_image_id} is not from the configured community gallery.")
raise RuntimeError(f"The community gallery of image {community_gallery_image_id} is not from the configured community gallery {shared_gallery_cfg.gallery_name}.")

gallery_image_version = cclient.gallery_image_versions.get(
resource_group_name=shared_gallery_cfg.resource_group_name,
Expand Down Expand Up @@ -938,3 +939,13 @@ def delete_from_azure_community_gallery(
result = result.result()
else:
logger.warning(f"{image_definition=} still contains {image_version_count} image versions - keeping definition")


def validate_azure_publishing_config(
release: glci.model.OnlineReleaseManifest,
publishing_cfg: glci.model.PublishingCfg,
):
azure_publishing_cfg: glci.model.PublishingTargetAzure = publishing_cfg.target(platform=release.platform)

if azure_publishing_cfg.publish_to_marketplace and not azure_publishing_cfg.marketplace_cfg:
raise RuntimeError(f"Expected to publish to Azure Marketplace but no marketplace config in publishing config.")
25 changes: 25 additions & 0 deletions publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,31 @@ def publish_image(
raise


def validate_publishing_configuration(
release: gm.OnlineReleaseManifest,
cfg: gm.PublishingCfg
):
if release.platform == 'azure':
validation_function = glci.az.validate_azure_publishing_config
elif release.platform == 'ali':
validation_function = None
elif release.platform == 'aws':
validation_function = None
elif release.platform == 'gcp':
validation_function = None
elif release.platform == 'openstack':
validation_function = None
elif release.platform == 'openstackbaremetal':
validation_function = None
elif release.platform == 'oci':
validation_function = None
else:
validation_function = None

if validation_function:
validation_function(release=release, publishing_cfg=cfg)


def _publish_alicloud_image(
release: gm.OnlineReleaseManifest,
publishing_cfg: gm.PublishingCfg,
Expand Down

0 comments on commit 3466133

Please sign in to comment.