-
Notifications
You must be signed in to change notification settings - Fork 2
feat: automate gardenlinux image lifecycle management in OpenStack CloudProfiles #44
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
anton-paulovich
merged 8 commits into
cobaltcore-dev:master
from
yahor-kurachkin:feat/openstack-glance
Aug 21, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a3bdc15
Run go-makefile-maker
d79340b
feat: add OpenStack Glance source and provider for gardenlinux images
yahor-kurachkin 8033eae
feat: add OpenStack Glance source and provider for gardenlinux images
yahor-kurachkin 47cc6ee
fix: codeRabbitAI review
yahor-kurachkin 3fd2515
fix: CopilotAI review
yahor-kurachkin ae5405c
fix: Linter error
yahor-kurachkin e443242
fix: add license
yahor-kurachkin d0a7fc9
Merge branch 'master' into feat/openstack-glance
yahor-kurachkin 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
Some comments aren't visible on the classic Files Changed page.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,79 @@ | ||
| package openstack | ||
|
|
||
| // SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "slices" | ||
|
|
||
| openstackv1alpha1 "github.com/gardener/gardener-extension-provider-openstack/pkg/apis/openstack/v1alpha1" | ||
| gardencorev1beta1 "github.com/gardener/gardener/pkg/apis/core/v1beta1" | ||
| "k8s.io/apimachinery/pkg/runtime" | ||
|
|
||
| "github.com/cobaltcore-dev/cloud-profile-sync/cloudprofilesync/ossync" | ||
| ) | ||
|
|
||
| type OpenStackProvider struct { | ||
| ImageName string | ||
| } | ||
|
|
||
| func (p *OpenStackProvider) Configure(cpSpec *gardencorev1beta1.CloudProfileSpec, versions []ossync.SourceImage) error { | ||
| var cfg openstackv1alpha1.CloudProfileConfig | ||
| if cpSpec.ProviderConfig != nil { | ||
| if err := json.Unmarshal(cpSpec.ProviderConfig.Raw, &cfg); err != nil { | ||
| return err | ||
| } | ||
| } | ||
|
|
||
| imageIndex := slices.IndexFunc(cfg.MachineImages, func(m openstackv1alpha1.MachineImages) bool { | ||
| return m.Name == p.ImageName | ||
| }) | ||
| if imageIndex == -1 { | ||
| imageIndex = len(cfg.MachineImages) | ||
| cfg.MachineImages = append(cfg.MachineImages, openstackv1alpha1.MachineImages{ | ||
| Name: p.ImageName, | ||
| Versions: []openstackv1alpha1.MachineImageVersion{}, | ||
| }) | ||
| } | ||
| image := &cfg.MachineImages[imageIndex] | ||
|
|
||
| existingVersions := make(map[string]int, len(image.Versions)) | ||
| for i, v := range image.Versions { | ||
| existingVersions[v.Version] = i | ||
| } | ||
|
anton-paulovich marked this conversation as resolved.
|
||
|
|
||
| for _, src := range versions { | ||
| idx, exists := existingVersions[src.Version] | ||
| if !exists { | ||
| idx = len(image.Versions) | ||
| image.Versions = append(image.Versions, openstackv1alpha1.MachineImageVersion{ | ||
| Version: src.Version, | ||
| }) | ||
| existingVersions[src.Version] = idx | ||
| } | ||
| entry := &image.Versions[idx] | ||
|
|
||
| for _, r := range src.Regions { | ||
| existing := slices.IndexFunc(entry.Regions, func(m openstackv1alpha1.RegionIDMapping) bool { | ||
| return m.Name == r.Region | ||
| }) | ||
| if existing == -1 { | ||
| entry.Regions = append(entry.Regions, openstackv1alpha1.RegionIDMapping{ | ||
| Name: r.Region, | ||
| ID: r.ID, | ||
| }) | ||
| continue | ||
| } | ||
| // Update in place: a rebuilt image keeps the version but gets a new UUID. | ||
| entry.Regions[existing].ID = r.ID | ||
| } | ||
| } | ||
|
|
||
| raw, err := json.Marshal(cfg) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| cpSpec.ProviderConfig = &runtime.RawExtension{Raw: raw} | ||
| return nil | ||
| } | ||
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.