|
4 | 4 | "context" |
5 | 5 | "errors" |
6 | 6 | "fmt" |
| 7 | + "slices" |
7 | 8 |
|
8 | 9 | "github.com/kyma-project/cli.v3/internal/kube" |
9 | 10 | "github.com/kyma-project/cli.v3/internal/kube/kyma" |
@@ -52,18 +53,18 @@ func ManageModuleMissingInKyma(ctx context.Context, client kube.Client, repo rep |
52 | 53 | return fmt.Errorf("failed to get module release metas: %v", err) |
53 | 54 | } |
54 | 55 |
|
55 | | - channelAssignedToModuleVersion := getAssignedChannel(*moduleReleaseMetas, moduleName, installedModuleTemplate.Spec.Version) |
| 56 | + channelsAssignedToModuleVersion := getAssignedChannels(*moduleReleaseMetas, moduleName, installedModuleTemplate.Spec.Version) |
56 | 57 | kymaCR, err := client.Kyma().GetDefaultKyma(ctx) |
57 | 58 | if err != nil { |
58 | 59 | return fmt.Errorf("failed to get kyma cr") |
59 | 60 | } |
60 | 61 | expectedChannel := kymaCR.Spec.Channel |
61 | 62 |
|
62 | | - if channelAssignedToModuleVersion != expectedChannel { |
| 63 | + if !slices.Contains(channelsAssignedToModuleVersion, expectedChannel) { |
63 | 64 | return ErrModuleInstalledVersionNotInKymaChannel |
64 | 65 | } |
65 | 66 |
|
66 | | - clierr := Enable(ctx, client, repo, moduleName, channelAssignedToModuleVersion, enableDefaultCr(policy), []unstructured.Unstructured{}...) |
| 67 | + clierr := Enable(ctx, client, repo, moduleName, expectedChannel, enableDefaultCr(policy), []unstructured.Unstructured{}...) |
67 | 68 | if clierr != nil { |
68 | 69 | return fmt.Errorf("failed to manage module: %v", clierr) |
69 | 70 | } |
@@ -132,10 +133,10 @@ func GetAvailableChannelsAndVersions(ctx context.Context, client kube.Client, re |
132 | 133 | continue |
133 | 134 | } |
134 | 135 |
|
135 | | - assignedChannel := getAssignedChannel(*moduleReleaseMetas, moduleName, coreModuleTemplate.Spec.Version) |
| 136 | + assignedChannels := getAssignedChannels(*moduleReleaseMetas, moduleName, coreModuleTemplate.Spec.Version) |
136 | 137 |
|
137 | | - if assignedChannel != "" { |
138 | | - channelsAndVersions[assignedChannel] = coreModuleTemplate.Spec.Version |
| 138 | + for _, channel := range assignedChannels { |
| 139 | + channelsAndVersions[channel] = coreModuleTemplate.Spec.Version |
139 | 140 | } |
140 | 141 | } |
141 | 142 |
|
|
0 commit comments