-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename OperatorVersion CRs from
name-<operatorVersion>
to `name-<ap…
…pVersion>-<operatorVersion>` (#1684) * Changed the generated name for OperatorVersion CRDs * NO automatic migration - but the OperatTaskDependency Lookup now iterates over the OVs to find a match * Created a bit more framework for future migrations Co-authored-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com> Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
- Loading branch information
1 parent
7eefce1
commit 5e7546b
Showing
36 changed files
with
491 additions
and
111 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 |
---|---|---|
@@ -1,8 +1,12 @@ | ||
package migration | ||
|
||
import "github.com/kudobuilder/kudo/pkg/kudoctl/kube" | ||
|
||
// Migrater is the base interface for migrations. | ||
type Migrater interface { | ||
CanMigrate(client *kube.Client) error | ||
Migrate(client *kube.Client) error | ||
// CanMigrate checks if there are any conditions that would prevent this migration to run | ||
// This function should only return an error if it is sure that the migration can not be executed | ||
CanMigrate() error | ||
|
||
// Migrate executes the migration. The call must be idempotent and ignore already migrated resources | ||
// It can be called multiple times on the same cluster and encounter migrated and unmigrated resources. | ||
Migrate() error | ||
} |
This file contains 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,56 @@ | ||
// This package contains helper functions that can be reused by all migrations | ||
package migration | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
kudoapi "github.com/kudobuilder/kudo/pkg/apis/kudo/v1beta1" | ||
"github.com/kudobuilder/kudo/pkg/kudoctl/kube" | ||
) | ||
|
||
// ForEachNamespace calls the given function for all namespaces in the cluster | ||
func ForEachNamespace(client *kube.Client, f func(ns string) error) error { | ||
l, err := client.KubeClient.CoreV1().Namespaces().List(context.TODO(), v1.ListOptions{}) | ||
if err != nil { | ||
return fmt.Errorf("failed to fetch namespaces: %v", err) | ||
} | ||
for _, ns := range l.Items { | ||
if err := f(ns.Name); err != nil { | ||
return fmt.Errorf("failed to run function for namespace %q: %v", ns.Name, err) | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
// ForEachOperatorVersion calls the given function for all operatorversions in the given namespace | ||
func ForEachOperatorVersion(client *kube.Client, ns string, f func(ov *kudoapi.OperatorVersion) error) error { | ||
l, err := client.KudoClient.KudoV1beta1().OperatorVersions(ns).List(context.TODO(), v1.ListOptions{}) | ||
if err != nil { | ||
return fmt.Errorf("failed to fetch OperatorVersions from namespace %q: %v", ns, err) | ||
} | ||
for _, ov := range l.Items { | ||
ov := ov | ||
if err := f(&ov); err != nil { | ||
return fmt.Errorf("failed to run function for OperatorVersion \"%s/%s\": %v", ov.Namespace, ov.Name, err) | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
// ForEachInstance calls the given function for all instances in the given namespace | ||
func ForEachInstance(client *kube.Client, ns string, f func(ov *kudoapi.Instance) error) error { | ||
l, err := client.KudoClient.KudoV1beta1().Instances(ns).List(context.TODO(), v1.ListOptions{}) | ||
if err != nil { | ||
return fmt.Errorf("failed to fetch Instances from namespace %q: %v", ns, err) | ||
} | ||
for _, i := range l.Items { | ||
i := i | ||
if err := f(&i); err != nil { | ||
return fmt.Errorf("failed to run function for Instance \"%s/%s\": %v", i.Namespace, i.Name, err) | ||
} | ||
} | ||
return nil | ||
} |
This file contains 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 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
Oops, something went wrong.