Skip to content

Commit

Permalink
chore: added taskrun script moduleDisable (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmilos77 authored Jul 9, 2024
1 parent fdc851b commit 874eb26
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 11 deletions.
6 changes: 3 additions & 3 deletions internal/controller/cloud-control/iprange_aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var _ = Describe("Feature: KCP IpRange", func() {
Eventually(CreateKcpIpRange).
WithArguments(infra.Ctx(), infra.KCP().Client(), iprange,
WithName(iprangeName),
WithKcpIpRangeRemoteRef("skr-namespace", "skr-aws-ip-range"),
WithKcpIpRangeRemoteRef("skr-aws-ip-range"),
WithKcpIpRangeSpecScope(kymaName),
WithKcpIpRangeSpecCidr(iprangeCidr),
).
Expand Down Expand Up @@ -190,7 +190,7 @@ var _ = Describe("Feature: KCP IpRange", func() {
Eventually(CreateKcpIpRange).
WithArguments(infra.Ctx(), infra.KCP().Client(), iprange,
WithName(iprangeName),
WithKcpIpRangeRemoteRef("skr-namespace", "skr-aws-ip-range"),
WithKcpIpRangeRemoteRef("skr-aws-ip-range"),
WithKcpIpRangeSpecScope(kymaName),
WithKcpIpRangeSpecCidr(iprangeCidr),
).
Expand Down Expand Up @@ -300,7 +300,7 @@ var _ = Describe("Feature: KCP IpRange", func() {
Eventually(CreateKcpIpRange).
WithArguments(infra.Ctx(), infra.KCP().Client(), iprange,
WithName(iprangeName),
WithKcpIpRangeRemoteRef("skr-namespace", iprangeName),
WithKcpIpRangeRemoteRef(iprangeName),
WithKcpIpRangeSpecScope(kymaName),
).
Should(Succeed())
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/cloud-control/iprange_gcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ var _ = Describe("Feature: KCP IpRange for GCP", func() {
infra.Ctx(), infra.KCP().Client(), iprange,
WithName("gcp-ip-range"),
WithNamespace(infra.KCP().Namespace()),
WithKcpIpRangeRemoteRef("skr-namespace", "skr-ip-range"),
WithKcpIpRangeRemoteRef("skr-ip-range"),
WithKcpIpRangeSpecScope(kymaName),
WithKcpIpRangeSpecCidr("10.20.30.0/24"),
).
Expand Down
7 changes: 6 additions & 1 deletion pkg/common/actions/focal/loadScopeFromRef.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ func loadScopeFromRef(ctx context.Context, st composed.State) (error, context.Co
"scopeNamespace", state.ObjAsCommonObj().GetNamespace(),
)
ctx = composed.LoggerIntoCtx(ctx, logger)
logger.Info("Loading Scope from reference")
logger.
WithValues(
"scopeName", state.ObjAsCommonObj().ScopeRef().Name,
"scopeNamespace", state.ObjAsCommonObj().GetNamespace(),
).
Info("Loading Scope from reference")

scope := &cloudcontrolv1beta1.Scope{}
err := state.Cluster().K8sClient().Get(ctx, types.NamespacedName{
Expand Down
2 changes: 1 addition & 1 deletion pkg/testinfra/dsl/awsIpRange.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func CreateAwsIpRangeWithSubnets(ctx context.Context, infra testinfra.Infra, ipr

err := CreateKcpIpRange(ctx, infra.KCP().Client(), iprange,
WithName(name),
WithKcpIpRangeRemoteRef(name, name),
WithKcpIpRangeRemoteRef(name),
WithKcpIpRangeSpecScope(name),
WithKcpIpRangeSpecCidr(iprangeCidr),
)
Expand Down
5 changes: 1 addition & 4 deletions pkg/testinfra/dsl/kcpIpRange.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,10 @@ func WithKcpIpRangeSpecScope(scopeName string) ObjAction {
}
}

func WithKcpIpRangeRemoteRef(ns, name string) ObjAction {
func WithKcpIpRangeRemoteRef(name string) ObjAction {
return &objAction{
f: func(obj client.Object) {
x := obj.(*cloudcontrolv1beta1.IpRange)
if x.Spec.RemoteRef.Namespace == "" {
x.Spec.RemoteRef.Namespace = ns
}
if x.Spec.RemoteRef.Name == "" {
x.Spec.RemoteRef.Name = name
}
Expand Down
2 changes: 1 addition & 1 deletion tools/scripts/kcp/listSkrs.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env zx

const argv = minimist(process.argv.slice(2), {
const argv = minimist(process.argv.slice(3), {
alias: {
a: "all",
o: "output",
Expand Down
14 changes: 14 additions & 0 deletions tools/scripts/taskrun/moduleDisable.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env zx

let out


out = await $`kubectl get -n kyma-system kyma default -o json | jq '.spec.modules | map(.name == "cloud-manager") | index(true)'`
const idx = `${out.stdout}`.trim()

console.log("CM Index: ", idx);


out = await $`kubectl patch -n kyma-system kyma default --type=json -p="[{'op': 'remove', 'path': '/spec/modules/${idx}'}]"`
console.log(out.stdout);

0 comments on commit 874eb26

Please sign in to comment.