Skip to content
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

✨ clusterctl: Add public function to create new CRD migrator #10075

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/cluster/cert_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func (cm *certManagerClient) migrateCRDs(ctx context.Context) error {
return err
}

return newCRDMigrator(c).Run(ctx, objs)
return NewCRDMigrator(c).Run(ctx, objs)
}

func (cm *certManagerClient) deleteObjs(ctx context.Context, objs []unstructured.Unstructured) error {
Expand Down
9 changes: 7 additions & 2 deletions cmd/clusterctl/client/cluster/crd_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,20 @@ import (
logf "sigs.k8s.io/cluster-api/cmd/clusterctl/log"
)

// CRDMigrator interface defines methods for migrating CRs to the storage version of new CRDs.
type CRDMigrator interface {
Run(ctx context.Context, objs []unstructured.Unstructured) error
}

// crdMigrator migrates CRs to the storage version of new CRDs.
// This is necessary when the new CRD drops a version which
// was previously used as a storage version.
type crdMigrator struct {
Client client.Client
}

// newCRDMigrator creates a new CRD migrator.
func newCRDMigrator(client client.Client) *crdMigrator {
// NewCRDMigrator creates a new CRD migrator.
func NewCRDMigrator(client client.Client) CRDMigrator {
return &crdMigrator{
Client: client,
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/cluster/upgrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ func (u *providerUpgrader) doUpgrade(ctx context.Context, upgradePlan *UpgradePl
return err
}

if err := newCRDMigrator(c).Run(ctx, components.Objs()); err != nil {
if err := NewCRDMigrator(c).Run(ctx, components.Objs()); err != nil {
return err
}
}
Expand Down
Loading