Skip to content

Commit

Permalink
fix ocm call
Browse files Browse the repository at this point in the history
gci.compomentmodel was deprecated in gardener-cc-utils, replacing
all calls to it with respective calls to ocm
  • Loading branch information
MrBatschner committed Oct 2, 2024
1 parent 2442377 commit 08c1b98
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .cicd-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,13 +904,13 @@ def end_phase(name):
if parsed.print_component_descriptor:
pprint.pprint(component_descriptor)

repository_context = component_descriptor.component.current_repository_ctx().baseUrl
oci_repo = component_descriptor.component.current_ocm_repo().baseUrl
component_name = component_descriptor.component.name
component_version = component_descriptor.component.version

phase_logger.info('publishing component-descriptor')
on_exist=cnudie.upload.UploadMode.OVERWRITE if cfg.ocm.overwrite_component_descriptor else cnudie.upload.UploadMode.SKIP
phase_logger.info(f'{repository_context=} {component_name=} {component_version=} {on_exist=}')
phase_logger.info(f'{oci_repo=} {component_name=} {component_version=} {on_exist=}')

cnudie.upload.upload_component_descriptor(
component_descriptor=component_descriptor,
Expand Down
60 changes: 29 additions & 31 deletions component_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import glci.util

import ccc.aws
import gci.componentmodel as cm

import cnudie.retrieve
import ocm

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -51,37 +49,37 @@ def component_descriptor(
commit: str,
publishing_cfg: glci.model.PublishingCfg,
release_manifests: list[glci.model.OnlineReleaseManifest]
) -> cm.ComponentDescriptor:
) -> ocm.ComponentDescriptor:
ocm_repository = publishing_cfg.ocm.ocm_repository

s3_session = ccc.aws.session(publishing_cfg.origin_buildresult_bucket.aws_cfg_name)
s3_client = s3_session.client('s3')

component_descriptor = cm.ComponentDescriptor(
meta=cm.Metadata(schemaVersion=cm.SchemaVersion.V2),
component=cm.Component(
component_descriptor = ocm.ComponentDescriptor(
meta=ocm.Metadata(schemaVersion=ocm.SchemaVersion.V2),
component=ocm.Component(
name='github.com/gardenlinux/gardenlinux',
version=version,
repositoryContexts=[
cm.OciRepositoryContext(
ocm.OciOcmRepository(
baseUrl=ocm_repository,
type=cm.AccessType.OCI_REGISTRY,
type=ocm.AccessType.OCI_REGISTRY,
)
],
provider='sap-se',
sources=[
cm.ComponentSource(
ocm.Source(
name='gardenlinux',
type=cm.SourceType.GIT,
access=cm.GithubAccess(
type=cm.AccessType.GITHUB,
type=ocm.ArtefactType.GIT,
access=ocm.GithubAccess(
type=ocm.AccessType.GITHUB,
repoUrl='https://github.com/gardenlinux/gardenlinux',
ref='refs/heads/main', # TODO: determine release-tag
commit=commit,
),
version=version,
labels=[
cm.Label(
ocm.Label(
name='cloud.gardener.cnudie/dso/scanning-hints/source_analysis/v1',
value={
'policy': 'skip',
Expand Down Expand Up @@ -112,7 +110,7 @@ def virtual_machine_image_resource(
s3_client,
):
labels = [
cm.Label(
ocm.Label(
name='gardener.cloud/gardenlinux/ci/build-metadata',
value={
'modifiers': release_manifest.modifiers,
Expand Down Expand Up @@ -145,29 +143,29 @@ def virtual_machine_image_resource(

if package_versions:
labels.append(
cm.Label(
ocm.Label(
name='cloud.cnudie/dso/scanning-hints/package-versions',
value=package_versions,
)
)

if (published_image_metadata := release_manifest.published_image_metadata):
labels.append(
cm.Label(
ocm.Label(
name='gardener.cloud/gardenlinux/ci/published-image-metadata',
value=published_image_metadata,
),
)

image_file_suffix = glci.util.vm_image_artefact_for_platform(release_manifest.platform)
image_file_path = release_manifest.path_by_suffix(image_file_suffix)
resource_access = cm.S3Access(
type=cm.AccessType.S3,
resource_access = ocm.S3Access(
type=ocm.AccessType.S3,
bucketName=release_manifest.s3_bucket,
objectKey=image_file_path.s3_key,
)

return cm.Resource(
return ocm.Resource(
name='gardenlinux',
version=version,
extraIdentity={
Expand All @@ -178,7 +176,7 @@ def virtual_machine_image_resource(
type='virtual_machine_image',
labels=labels,
access=resource_access,
digest=cm.DigestSpec(
digest=ocm.DigestSpec(
hashAlgorithm='NO-DIGEST',
normalisationAlgorithm='EXCLUDE-FROM-SIGNATURE',
value='NO-DIGEST',
Expand All @@ -192,7 +190,7 @@ def _image_rootfs_resource(
version: str,
):
labels = [
cm.Label(
ocm.Label(
name='gardener.cloud/gardenlinux/ci/build-metadata',
value={
'modifiers': release_manifest.modifiers,
Expand All @@ -206,7 +204,7 @@ def _image_rootfs_resource(
],
}
),
cm.Label(
ocm.Label(
name='cloud.gardener.cnudie/responsibles',
value=[
{
Expand All @@ -223,7 +221,7 @@ def _image_rootfs_resource(

rootfs_file_path = release_manifest.path_by_suffix('.tar')

return cm.Resource(
return ocm.Resource(
name='rootfs',
version=version,
extraIdentity={
Expand All @@ -233,12 +231,12 @@ def _image_rootfs_resource(
},
type='application/tar+vm-image-rootfs',
labels=labels,
access=cm.S3Access(
type=cm.AccessType.S3,
access=ocm.S3Access(
type=ocm.AccessType.S3,
bucketName=release_manifest.s3_bucket,
objectKey=rootfs_file_path.s3_key,
),
digest=cm.DigestSpec(
digest=ocm.DigestSpec(
hashAlgorithm='NO-DIGEST',
normalisationAlgorithm='EXCLUDE-FROM-SIGNATURE',
value='NO-DIGEST',
Expand All @@ -253,18 +251,18 @@ def release_manifest_set_resource(
):
bucket_name = cicd_cfg.build.s3_bucket_name

resource_access = cm.S3Access(
type=cm.AccessType.S3,
resource_access = ocm.S3Access(
type=ocm.AccessType.S3,
bucketName=bucket_name,
objectKey=manifest_set_s3_key,
)

return cm.Resource(
return ocm.Resource(
name='release_manifest_set',
version=effective_version,
type='release_manifest_set',
access=resource_access,
digest=cm.DigestSpec(
digest=ocm.DigestSpec(
hashAlgorithm='NO-DIGEST',
normalisationAlgorithm='EXCLUDE-FROM-SIGNATURE',
value='NO-DIGEST',
Expand Down

0 comments on commit 08c1b98

Please sign in to comment.