-
Notifications
You must be signed in to change notification settings - Fork 29
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
maintenance: remove hardcoded crd constants in restoreCrd #354
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the kubectl-rook-ceph repo we will only want to include upstream Rook resources. Instead, I would suggest that this ResourceCrd()
method could accept arguments for a resource group name. In this repo the command will only set the ceph.rook.io
group, while external repos that are extending this code could pass a different group name.
72aafbd
to
1b30ff8
Compare
cmd/commands/restore.go
Outdated
@@ -31,6 +31,6 @@ var RestoreCmd = &cobra.Command{ | |||
verifyOperatorPodIsRunning(cmd.Context(), clientSets) | |||
}, | |||
Run: func(cmd *cobra.Command, args []string) { | |||
restore.RestoreCrd(cmd.Context(), clientSets, operatorNamespace, cephClusterNamespace, args) | |||
restore.RestoreCrd(cmd.Context(), clientSets, operatorNamespace, cephClusterNamespace, nil, nil, args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
restore.RestoreCrd(cmd.Context(), clientSets, operatorNamespace, cephClusterNamespace, nil, nil, args) | |
restore.RestoreCrd(cmd.Context(), clientSets, operatorNamespace, cephClusterNamespace, crds.CephRookIoGroup, crds.CephRookResourcesVersion, args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pkg/restore/crd.go
Outdated
@@ -32,7 +32,8 @@ import ( | |||
"k8s.io/apimachinery/pkg/types" | |||
) | |||
|
|||
func RestoreCrd(ctx context.Context, k8sclientset *k8sutil.Clientsets, operatorNamespace, clusterNamespace string, args []string) { | |||
func RestoreCrd(ctx context.Context, k8sclientset *k8sutil.Clientsets, operatorNamespace, clusterNamespace string, | |||
groupNameOptional, versionResourceOptional *string, args []string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just require these names, it seems simpler this way.
groupNameOptional, versionResourceOptional *string, args []string) { | |
groupName, versionResource string, args []string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pkg/restore/crd.go
Outdated
crdList, err := k8sclientset.ListResourcesDynamically(ctx, crds.CephRookIoGroup, crds.CephRookResourcesVersion, crd, clusterNamespace) | ||
var groupName, versionResource string | ||
// Set default values for groupName and versionResource | ||
if groupNameOptional == nil || versionResourceOptional == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for these checks if we just require them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, fix the CI issues
01d0437
to
3648b9a
Compare
3648b9a
to
e35bdae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still a CI issue, but not sure it's related or intermittent. When you push this small fix, let's see if it passes
pkg/restore/crd.go
Outdated
@@ -32,7 +32,8 @@ import ( | |||
"k8s.io/apimachinery/pkg/types" | |||
) | |||
|
|||
func RestoreCrd(ctx context.Context, k8sclientset *k8sutil.Clientsets, operatorNamespace, clusterNamespace string, args []string) { | |||
func RestoreCrd(ctx context.Context, k8sclientset *k8sutil.Clientsets, operatorNamespace, clusterNamespace string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func RestoreCrd(ctx context.Context, k8sclientset *k8sutil.Clientsets, operatorNamespace, clusterNamespace string, | |
func RestoreCrd(ctx context.Context, k8sclientset *k8sutil.Clientsets, operatorNamespace, clusterNamespace, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Refactored the RestoreCrd function to accept groupName and versionResource as parameters instead of relying on the hardcoded constants crds.CephRookIoGroup and crds.CephRookResourcesVersion. This improves flexibility and allows the function to handle different CRDs dynamically. Signed-off-by: Oded Viner <[email protected]>
e35bdae
to
0774806
Compare
Refactored the RestoreCrd function to accept groupName and
versionResource as parameters instead of relying on the hardcoded
constants crds.CephRookIoGroup and crds.CephRookResourcesVersion.
This improves flexibility and allows the function to handle
different CRDs dynamically.
Checklist: