-
Notifications
You must be signed in to change notification settings - Fork 45
Constants update #107
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
base: main
Are you sure you want to change the base?
Constants update #107
Conversation
18fabe6 to
83f44bf
Compare
slickwarren
left a comment
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.
some small nits but this is actually awesome!
markusewalker
left a comment
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.
Overall, LGTM just a reminder for myself that there are some annotations in parallel PRs that will require updating here.
|
I will make a final pass through shepherd and update any new consts that get merged in before this PR. |
83f44bf to
ed6c4bd
Compare
|
@susesgartner can you also add the globalconstant linter as well? And see if it passes that? |
9001dba to
47ae7c8
Compare
|
The globalconstant linter was what sparked my interest in creating this PR. While I have removed most of the global constants there is 1 remaining that I am currently looking into. |
I know, what I'm saying is can you add this to our GHA linter? Since you're already doing the work it would be a great time to add it our configuration and have it pass the official verify |
|
Sure! |
351b5e9 to
a748cb3
Compare
c5c9e5e to
9a45c95
Compare
8560da6 to
0f6ff49
Compare
8569c84 to
5052bfd
Compare
5317272 to
c25e288
Compare
slickwarren
left a comment
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.
lgtm
b76f5e9 to
713005f
Compare
caliskanugur
left a comment
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.
Looks good, I've got couple of questions
| func Node() schema.GroupVersionResource { | ||
| node := schema.GroupVersionResource{ | ||
| Group: "", | ||
| Version: "v1", | ||
| Resource: "nodes", | ||
| } | ||
|
|
||
| return node | ||
| } | ||
|
|
||
| func Pod() schema.GroupVersionResource { | ||
| pod := schema.GroupVersionResource{ | ||
| Group: "", | ||
| Version: "v1", | ||
| Resource: "pods", | ||
| } | ||
|
|
||
| return pod | ||
| } | ||
|
|
||
| func ConfigMap() schema.GroupVersionResource { | ||
| configMap := schema.GroupVersionResource{ | ||
| Group: "", | ||
| Version: "v1", | ||
| Resource: "configmaps", | ||
| } | ||
|
|
||
| return configMap | ||
| } | ||
|
|
||
| func CustomResourceDefinition() schema.GroupVersionResource { | ||
| customResourceDefinition := schema.GroupVersionResource{ | ||
| Group: "apiextensions.k8s.io", | ||
| Version: "v1", | ||
| Resource: "customresourcedefinitions", | ||
| } | ||
|
|
||
| return customResourceDefinition | ||
| } | ||
|
|
||
| func Ingress() schema.GroupVersionResource { | ||
| ingress := schema.GroupVersionResource{ | ||
| Group: "networking.k8s.io", | ||
| Version: "v1", | ||
| Resource: "ingresses", | ||
| } | ||
|
|
||
| return ingress | ||
| } | ||
|
|
||
| func Project() schema.GroupVersionResource { | ||
| project := schema.GroupVersionResource{ | ||
| Group: "management.cattle.io", | ||
| Version: "v3", | ||
| Resource: "projects", | ||
| } | ||
|
|
||
| return project | ||
| } | ||
|
|
||
| func Role() schema.GroupVersionResource { | ||
| role := schema.GroupVersionResource{ | ||
| Group: rbacv1.SchemeGroupVersion.Group, | ||
| Version: rbacv1.SchemeGroupVersion.Version, | ||
| Resource: "roles", | ||
| } | ||
|
|
||
| return role | ||
| } | ||
|
|
||
| func ClusterRole() schema.GroupVersionResource { | ||
| clusterRole := schema.GroupVersionResource{ | ||
| Group: rbacv1.SchemeGroupVersion.Group, | ||
| Version: rbacv1.SchemeGroupVersion.Version, | ||
| Resource: "clusterroles", | ||
| } | ||
|
|
||
| return clusterRole | ||
| } | ||
|
|
||
| func RoleBinding() schema.GroupVersionResource { | ||
| roleBinding := schema.GroupVersionResource{ | ||
| Group: rbacv1.SchemeGroupVersion.Group, | ||
| Version: rbacv1.SchemeGroupVersion.Version, | ||
| Resource: "rolebindings", | ||
| } | ||
|
|
||
| return roleBinding | ||
| } | ||
|
|
||
| func ClusterRoleBinding() schema.GroupVersionResource { | ||
| clusterRoleBinding := schema.GroupVersionResource{ | ||
| Group: rbacv1.SchemeGroupVersion.Group, | ||
| Version: rbacv1.SchemeGroupVersion.Version, | ||
| Resource: "clusterrolebindings", | ||
| } | ||
|
|
||
| return clusterRoleBinding | ||
| } | ||
|
|
||
| func GlobalRole() schema.GroupVersionResource { | ||
| globalRole := schema.GroupVersionResource{ | ||
| Group: "management.cattle.io", | ||
| Version: "v3", | ||
| Resource: "globalroles", | ||
| } | ||
|
|
||
| return globalRole | ||
| } | ||
|
|
||
| func GlobalRoleBinding() schema.GroupVersionResource { | ||
| globalRoleBinding := schema.GroupVersionResource{ | ||
| Group: "management.cattle.io", | ||
| Version: "v3", | ||
| Resource: "globalrolebindings", | ||
| } | ||
|
|
||
| return globalRoleBinding | ||
| } | ||
|
|
||
| func ClusterRoleTemplateBinding() schema.GroupVersionResource { | ||
| clusterRoleTemplateBinding := schema.GroupVersionResource{ | ||
| Group: "management.cattle.io", | ||
| Version: "v3", | ||
| Resource: "clusterroletemplatebindings", | ||
| } | ||
|
|
||
| return clusterRoleTemplateBinding | ||
| } | ||
|
|
||
| func RoleTemplate() schema.GroupVersionResource { | ||
| roleTemplate := schema.GroupVersionResource{ | ||
| Group: "management.cattle.io", | ||
| Version: "v3", | ||
| Resource: "roletemplates", | ||
| } | ||
|
|
||
| return roleTemplate | ||
| } | ||
|
|
||
| func ProjectRoleTemplateBinding() schema.GroupVersionResource { | ||
| projectRoleTemplateBinding := schema.GroupVersionResource{ | ||
| Group: "management.cattle.io", | ||
| Version: "v3", | ||
| Resource: "projectroletemplatebindings", | ||
| } | ||
|
|
||
| return projectRoleTemplateBinding | ||
| } | ||
|
|
||
| func ResourceQuota() schema.GroupVersionResource { | ||
| resourceQuota := schema.GroupVersionResource{ | ||
| Group: "", | ||
| Version: "v1", | ||
| Resource: "resourcequotas", | ||
| } | ||
|
|
||
| return resourceQuota | ||
| } | ||
|
|
||
| func Secret() schema.GroupVersionResource { | ||
| secret := schema.GroupVersionResource{ | ||
| Group: "", | ||
| Version: "v1", | ||
| Resource: "secrets", | ||
| } | ||
|
|
||
| return secret | ||
| } | ||
|
|
||
| func Service() schema.GroupVersionResource { | ||
| service := schema.GroupVersionResource{ | ||
| Group: "", | ||
| Version: "v1", | ||
| Resource: "services", | ||
| } | ||
|
|
||
| return service | ||
| } | ||
|
|
||
| func StorageClass() schema.GroupVersionResource { | ||
| storageClass := schema.GroupVersionResource{ | ||
| Group: "storage.k8s.io", | ||
| Version: "v1", | ||
| Resource: "storageclasses", | ||
| } | ||
|
|
||
| return storageClass | ||
| } | ||
|
|
||
| func Token() schema.GroupVersionResource { | ||
| token := schema.GroupVersionResource{ | ||
| Group: "management.cattle.io", | ||
| Version: "v3", | ||
| Resource: "tokens", | ||
| } | ||
|
|
||
| return token | ||
| } | ||
|
|
||
| func PersistentVolumeClaim() schema.GroupVersionResource { | ||
| persistentVolumeClaim := schema.GroupVersionResource{ | ||
| Group: "", | ||
| Version: "v1", | ||
| Resource: "persistentvolumeclaims", | ||
| } | ||
|
|
||
| return persistentVolumeClaim | ||
| } | ||
|
|
||
| func PersistentVolume() schema.GroupVersionResource { | ||
| persistentVolume := schema.GroupVersionResource{ | ||
| Group: "", | ||
| Version: "v1", | ||
| Resource: "persistentvolumes", | ||
| } | ||
|
|
||
| return persistentVolume | ||
| } | ||
|
|
||
| func Namespace() schema.GroupVersionResource { | ||
| namespace := schema.GroupVersionResource{ | ||
| Group: "", | ||
| Version: "v1", | ||
| Resource: "namespaces", | ||
| } | ||
|
|
||
| return namespace | ||
| } | ||
|
|
||
| func Daemonset() schema.GroupVersionResource { | ||
| daemonset := schema.GroupVersionResource{ | ||
| Group: "apps", | ||
| Version: "v1", | ||
| Resource: "daemonsets", | ||
| } | ||
|
|
||
| return daemonset | ||
| } | ||
|
|
||
| func Deployment() schema.GroupVersionResource { | ||
| deployment := schema.GroupVersionResource{ | ||
| Group: "apps", | ||
| Version: "v1", | ||
| Resource: "deployments", | ||
| } | ||
|
|
||
| return deployment | ||
| } | ||
|
|
||
| func Job() schema.GroupVersionResource { | ||
| job := schema.GroupVersionResource{ | ||
| Group: "batch", | ||
| Version: "v1", | ||
| Resource: "jobs", | ||
| } | ||
|
|
||
| return job | ||
| } | ||
|
|
||
| func CronJob() schema.GroupVersionResource { | ||
| cronJob := schema.GroupVersionResource{ | ||
| Group: "batch", | ||
| Version: "v1beta1", | ||
| Resource: "cronjobs", | ||
| } | ||
|
|
||
| return cronJob | ||
| } |
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.
Do these have to be separated? I think this file would get longer whenever a new GVR is used in the framework.
What do you think about making this a template? Something like this:
| func Node() schema.GroupVersionResource { | |
| node := schema.GroupVersionResource{ | |
| Group: "", | |
| Version: "v1", | |
| Resource: "nodes", | |
| } | |
| return node | |
| } | |
| func Pod() schema.GroupVersionResource { | |
| pod := schema.GroupVersionResource{ | |
| Group: "", | |
| Version: "v1", | |
| Resource: "pods", | |
| } | |
| return pod | |
| } | |
| func ConfigMap() schema.GroupVersionResource { | |
| configMap := schema.GroupVersionResource{ | |
| Group: "", | |
| Version: "v1", | |
| Resource: "configmaps", | |
| } | |
| return configMap | |
| } | |
| func CustomResourceDefinition() schema.GroupVersionResource { | |
| customResourceDefinition := schema.GroupVersionResource{ | |
| Group: "apiextensions.k8s.io", | |
| Version: "v1", | |
| Resource: "customresourcedefinitions", | |
| } | |
| return customResourceDefinition | |
| } | |
| func Ingress() schema.GroupVersionResource { | |
| ingress := schema.GroupVersionResource{ | |
| Group: "networking.k8s.io", | |
| Version: "v1", | |
| Resource: "ingresses", | |
| } | |
| return ingress | |
| } | |
| func Project() schema.GroupVersionResource { | |
| project := schema.GroupVersionResource{ | |
| Group: "management.cattle.io", | |
| Version: "v3", | |
| Resource: "projects", | |
| } | |
| return project | |
| } | |
| func Role() schema.GroupVersionResource { | |
| role := schema.GroupVersionResource{ | |
| Group: rbacv1.SchemeGroupVersion.Group, | |
| Version: rbacv1.SchemeGroupVersion.Version, | |
| Resource: "roles", | |
| } | |
| return role | |
| } | |
| func ClusterRole() schema.GroupVersionResource { | |
| clusterRole := schema.GroupVersionResource{ | |
| Group: rbacv1.SchemeGroupVersion.Group, | |
| Version: rbacv1.SchemeGroupVersion.Version, | |
| Resource: "clusterroles", | |
| } | |
| return clusterRole | |
| } | |
| func RoleBinding() schema.GroupVersionResource { | |
| roleBinding := schema.GroupVersionResource{ | |
| Group: rbacv1.SchemeGroupVersion.Group, | |
| Version: rbacv1.SchemeGroupVersion.Version, | |
| Resource: "rolebindings", | |
| } | |
| return roleBinding | |
| } | |
| func ClusterRoleBinding() schema.GroupVersionResource { | |
| clusterRoleBinding := schema.GroupVersionResource{ | |
| Group: rbacv1.SchemeGroupVersion.Group, | |
| Version: rbacv1.SchemeGroupVersion.Version, | |
| Resource: "clusterrolebindings", | |
| } | |
| return clusterRoleBinding | |
| } | |
| func GlobalRole() schema.GroupVersionResource { | |
| globalRole := schema.GroupVersionResource{ | |
| Group: "management.cattle.io", | |
| Version: "v3", | |
| Resource: "globalroles", | |
| } | |
| return globalRole | |
| } | |
| func GlobalRoleBinding() schema.GroupVersionResource { | |
| globalRoleBinding := schema.GroupVersionResource{ | |
| Group: "management.cattle.io", | |
| Version: "v3", | |
| Resource: "globalrolebindings", | |
| } | |
| return globalRoleBinding | |
| } | |
| func ClusterRoleTemplateBinding() schema.GroupVersionResource { | |
| clusterRoleTemplateBinding := schema.GroupVersionResource{ | |
| Group: "management.cattle.io", | |
| Version: "v3", | |
| Resource: "clusterroletemplatebindings", | |
| } | |
| return clusterRoleTemplateBinding | |
| } | |
| func RoleTemplate() schema.GroupVersionResource { | |
| roleTemplate := schema.GroupVersionResource{ | |
| Group: "management.cattle.io", | |
| Version: "v3", | |
| Resource: "roletemplates", | |
| } | |
| return roleTemplate | |
| } | |
| func ProjectRoleTemplateBinding() schema.GroupVersionResource { | |
| projectRoleTemplateBinding := schema.GroupVersionResource{ | |
| Group: "management.cattle.io", | |
| Version: "v3", | |
| Resource: "projectroletemplatebindings", | |
| } | |
| return projectRoleTemplateBinding | |
| } | |
| func ResourceQuota() schema.GroupVersionResource { | |
| resourceQuota := schema.GroupVersionResource{ | |
| Group: "", | |
| Version: "v1", | |
| Resource: "resourcequotas", | |
| } | |
| return resourceQuota | |
| } | |
| func Secret() schema.GroupVersionResource { | |
| secret := schema.GroupVersionResource{ | |
| Group: "", | |
| Version: "v1", | |
| Resource: "secrets", | |
| } | |
| return secret | |
| } | |
| func Service() schema.GroupVersionResource { | |
| service := schema.GroupVersionResource{ | |
| Group: "", | |
| Version: "v1", | |
| Resource: "services", | |
| } | |
| return service | |
| } | |
| func StorageClass() schema.GroupVersionResource { | |
| storageClass := schema.GroupVersionResource{ | |
| Group: "storage.k8s.io", | |
| Version: "v1", | |
| Resource: "storageclasses", | |
| } | |
| return storageClass | |
| } | |
| func Token() schema.GroupVersionResource { | |
| token := schema.GroupVersionResource{ | |
| Group: "management.cattle.io", | |
| Version: "v3", | |
| Resource: "tokens", | |
| } | |
| return token | |
| } | |
| func PersistentVolumeClaim() schema.GroupVersionResource { | |
| persistentVolumeClaim := schema.GroupVersionResource{ | |
| Group: "", | |
| Version: "v1", | |
| Resource: "persistentvolumeclaims", | |
| } | |
| return persistentVolumeClaim | |
| } | |
| func PersistentVolume() schema.GroupVersionResource { | |
| persistentVolume := schema.GroupVersionResource{ | |
| Group: "", | |
| Version: "v1", | |
| Resource: "persistentvolumes", | |
| } | |
| return persistentVolume | |
| } | |
| func Namespace() schema.GroupVersionResource { | |
| namespace := schema.GroupVersionResource{ | |
| Group: "", | |
| Version: "v1", | |
| Resource: "namespaces", | |
| } | |
| return namespace | |
| } | |
| func Daemonset() schema.GroupVersionResource { | |
| daemonset := schema.GroupVersionResource{ | |
| Group: "apps", | |
| Version: "v1", | |
| Resource: "daemonsets", | |
| } | |
| return daemonset | |
| } | |
| func Deployment() schema.GroupVersionResource { | |
| deployment := schema.GroupVersionResource{ | |
| Group: "apps", | |
| Version: "v1", | |
| Resource: "deployments", | |
| } | |
| return deployment | |
| } | |
| func Job() schema.GroupVersionResource { | |
| job := schema.GroupVersionResource{ | |
| Group: "batch", | |
| Version: "v1", | |
| Resource: "jobs", | |
| } | |
| return job | |
| } | |
| func CronJob() schema.GroupVersionResource { | |
| cronJob := schema.GroupVersionResource{ | |
| Group: "batch", | |
| Version: "v1beta1", | |
| Resource: "cronjobs", | |
| } | |
| return cronJob | |
| } | |
| func NewSchemaGVR(g, v, r string) schema.GroupVersionResource { | |
| return schema.GroupVersionResource{ | |
| Group: g, | |
| Version: v, | |
| Resource: r, | |
| } | |
| } |
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.
I am not entirely sure if this is a good idea. For similar reasons as the comment below. This would no longer really be a constant, it would be a "create" function and all of the values would have to be stored in place in the code. This would mean that if we decided to update one of these in future we would have to do so in every place NewSchemaGVR is referenced. If we are going to have to do that anyway that begs the question, what do we gain from storing this in centralized place at all? I suppose another valid question would be if we went with this approach should we just store this under schema dir instead of defaults
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.
These would be constructor functions. They all seem like functions that return fixed values. So one way or another they are functions right now, right? So what I am trying to say is, is it expected to add a new function for every new GVR instead of having a constructor function?
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.
I think this makes sense Sam, essentially have a constructor that the default funcs call. That's what you're saying right Ugur?
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.
Yes, they are returning fixed values, they are the equivalent of a "const" @caliskanugur. The 2 concerns I have for axing them and putting a nice generic constructor are:
- They would no longer be equivalent in function to a "const". This is the case since it would be the equivalent of declaring each GVR in place wherever it is called. i.e NewSchemaGVR("x", "y", "z") is dynamic, not const and therefore there is no way to update/reuse a given GVR across the framework.
- If we go with the above approach then I would vote on moving the constructor into the Schema directory since it would no longer be a "const".
| @@ -0,0 +1,38 @@ | |||
| etcdControlPlaneWorker: | |||
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.
Where are these YAML files used? Are these going to be used on r/r side?
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.
The ymls aren't going to be used on the rancher side but the functions that pull the data from the ymls will be used.
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.
Could you elaborate on this one for me, I don't think I understand this move yet, is there a code reference to these files that I am potentially missing?
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.
If you look in pools.go the 2 files are referenced by their respective functions. The main design goal here is to provide a way to store parts of our configs that are widely used and not sensitive without using global vars.
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.
Oh, I missed it, thanks for the reference. Could you give more details about the design selection, what's the net positive implementation of having a YAML file, reading that file, and making it a Golang object, instead of using it as a Golang object?
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.
I do think the LoadDefault function should not be here then, and more in the pkg. What do you think?
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.
The consistency thing I was referring to, is why is this in a yaml where as the GroupVersions in functions. That is what I am talking about. I want to reiterate, my overall concern is that some thing is added to the yaml and we're not testing what we say we're testing. Does that make sense?
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.
I'm fine with moving the loadDefault function into pkg.
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.
Going to reiterate: If I could put the GroupVersions in a yaml I would however, I cannot because they are upstream k8s objects that do not have struct tags and as such I cannot simply unmarshal or change 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.
I am not sure I understand your final comment. Can you give me an example of "some thing is added to the yaml and we're not testing what we say we're testing"
bbedb19 to
c64d062
Compare
Update to remove several global constants and generally rework how we store/utilize certain constants that appear across many files in both rancher/rancher and rancher/shepherd. Removed duplicate const file apiobjects comment update Updated deflabels to default labels as per Calebs comment PR update to address comments Updated the stevetypes.Setting const to ManagementSetting for clarity Update node_status.go Update constants PR with more constants change defaults back Removed more global vars Removed a global vars for Rbac and provisioning and added them to defaults directory. Also replacing them in the rancher PR Removed the machine pools/node roles globals now that they have been replaced Update to add a few more constants Moved the pools to provisioning input Update rancheralerting.go update the states A few small fixes for errors fixed namespaces Update .golangci.yaml Update .golangci.yaml Update machinepools.go Update for comments fix
c64d062 to
c675e33
Compare
extensions/defaults/apiobjects.go
Outdated
| @@ -0,0 +1,11 @@ | |||
| package defaults | |||
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.
This is going away correct?
| func Node() schema.GroupVersionResource { | ||
| node := schema.GroupVersionResource{ | ||
| Group: "", | ||
| Version: "v1", | ||
| Resource: "nodes", | ||
| } | ||
|
|
||
| return node | ||
| } | ||
|
|
||
| func Pod() schema.GroupVersionResource { | ||
| pod := schema.GroupVersionResource{ | ||
| Group: "", | ||
| Version: "v1", | ||
| Resource: "pods", | ||
| } | ||
|
|
||
| return pod | ||
| } | ||
|
|
||
| func ConfigMap() schema.GroupVersionResource { | ||
| configMap := schema.GroupVersionResource{ | ||
| Group: "", | ||
| Version: "v1", | ||
| Resource: "configmaps", | ||
| } | ||
|
|
||
| return configMap | ||
| } | ||
|
|
||
| func CustomResourceDefinition() schema.GroupVersionResource { | ||
| customResourceDefinition := schema.GroupVersionResource{ | ||
| Group: "apiextensions.k8s.io", | ||
| Version: "v1", | ||
| Resource: "customresourcedefinitions", | ||
| } | ||
|
|
||
| return customResourceDefinition | ||
| } | ||
|
|
||
| func Ingress() schema.GroupVersionResource { | ||
| ingress := schema.GroupVersionResource{ | ||
| Group: "networking.k8s.io", | ||
| Version: "v1", | ||
| Resource: "ingresses", | ||
| } | ||
|
|
||
| return ingress | ||
| } | ||
|
|
||
| func Project() schema.GroupVersionResource { | ||
| project := schema.GroupVersionResource{ | ||
| Group: "management.cattle.io", | ||
| Version: "v3", | ||
| Resource: "projects", | ||
| } | ||
|
|
||
| return project | ||
| } | ||
|
|
||
| func Role() schema.GroupVersionResource { | ||
| role := schema.GroupVersionResource{ | ||
| Group: rbacv1.SchemeGroupVersion.Group, | ||
| Version: rbacv1.SchemeGroupVersion.Version, | ||
| Resource: "roles", | ||
| } | ||
|
|
||
| return role | ||
| } | ||
|
|
||
| func ClusterRole() schema.GroupVersionResource { | ||
| clusterRole := schema.GroupVersionResource{ | ||
| Group: rbacv1.SchemeGroupVersion.Group, | ||
| Version: rbacv1.SchemeGroupVersion.Version, | ||
| Resource: "clusterroles", | ||
| } | ||
|
|
||
| return clusterRole | ||
| } | ||
|
|
||
| func RoleBinding() schema.GroupVersionResource { | ||
| roleBinding := schema.GroupVersionResource{ | ||
| Group: rbacv1.SchemeGroupVersion.Group, | ||
| Version: rbacv1.SchemeGroupVersion.Version, | ||
| Resource: "rolebindings", | ||
| } | ||
|
|
||
| return roleBinding | ||
| } | ||
|
|
||
| func ClusterRoleBinding() schema.GroupVersionResource { | ||
| clusterRoleBinding := schema.GroupVersionResource{ | ||
| Group: rbacv1.SchemeGroupVersion.Group, | ||
| Version: rbacv1.SchemeGroupVersion.Version, | ||
| Resource: "clusterrolebindings", | ||
| } | ||
|
|
||
| return clusterRoleBinding | ||
| } | ||
|
|
||
| func GlobalRole() schema.GroupVersionResource { | ||
| globalRole := schema.GroupVersionResource{ | ||
| Group: "management.cattle.io", | ||
| Version: "v3", | ||
| Resource: "globalroles", | ||
| } | ||
|
|
||
| return globalRole | ||
| } | ||
|
|
||
| func GlobalRoleBinding() schema.GroupVersionResource { | ||
| globalRoleBinding := schema.GroupVersionResource{ | ||
| Group: "management.cattle.io", | ||
| Version: "v3", | ||
| Resource: "globalrolebindings", | ||
| } | ||
|
|
||
| return globalRoleBinding | ||
| } | ||
|
|
||
| func ClusterRoleTemplateBinding() schema.GroupVersionResource { | ||
| clusterRoleTemplateBinding := schema.GroupVersionResource{ | ||
| Group: "management.cattle.io", | ||
| Version: "v3", | ||
| Resource: "clusterroletemplatebindings", | ||
| } | ||
|
|
||
| return clusterRoleTemplateBinding | ||
| } | ||
|
|
||
| func RoleTemplate() schema.GroupVersionResource { | ||
| roleTemplate := schema.GroupVersionResource{ | ||
| Group: "management.cattle.io", | ||
| Version: "v3", | ||
| Resource: "roletemplates", | ||
| } | ||
|
|
||
| return roleTemplate | ||
| } | ||
|
|
||
| func ProjectRoleTemplateBinding() schema.GroupVersionResource { | ||
| projectRoleTemplateBinding := schema.GroupVersionResource{ | ||
| Group: "management.cattle.io", | ||
| Version: "v3", | ||
| Resource: "projectroletemplatebindings", | ||
| } | ||
|
|
||
| return projectRoleTemplateBinding | ||
| } | ||
|
|
||
| func ResourceQuota() schema.GroupVersionResource { | ||
| resourceQuota := schema.GroupVersionResource{ | ||
| Group: "", | ||
| Version: "v1", | ||
| Resource: "resourcequotas", | ||
| } | ||
|
|
||
| return resourceQuota | ||
| } | ||
|
|
||
| func Secret() schema.GroupVersionResource { | ||
| secret := schema.GroupVersionResource{ | ||
| Group: "", | ||
| Version: "v1", | ||
| Resource: "secrets", | ||
| } | ||
|
|
||
| return secret | ||
| } | ||
|
|
||
| func Service() schema.GroupVersionResource { | ||
| service := schema.GroupVersionResource{ | ||
| Group: "", | ||
| Version: "v1", | ||
| Resource: "services", | ||
| } | ||
|
|
||
| return service | ||
| } | ||
|
|
||
| func StorageClass() schema.GroupVersionResource { | ||
| storageClass := schema.GroupVersionResource{ | ||
| Group: "storage.k8s.io", | ||
| Version: "v1", | ||
| Resource: "storageclasses", | ||
| } | ||
|
|
||
| return storageClass | ||
| } | ||
|
|
||
| func Token() schema.GroupVersionResource { | ||
| token := schema.GroupVersionResource{ | ||
| Group: "management.cattle.io", | ||
| Version: "v3", | ||
| Resource: "tokens", | ||
| } | ||
|
|
||
| return token | ||
| } | ||
|
|
||
| func PersistentVolumeClaim() schema.GroupVersionResource { | ||
| persistentVolumeClaim := schema.GroupVersionResource{ | ||
| Group: "", | ||
| Version: "v1", | ||
| Resource: "persistentvolumeclaims", | ||
| } | ||
|
|
||
| return persistentVolumeClaim | ||
| } | ||
|
|
||
| func PersistentVolume() schema.GroupVersionResource { | ||
| persistentVolume := schema.GroupVersionResource{ | ||
| Group: "", | ||
| Version: "v1", | ||
| Resource: "persistentvolumes", | ||
| } | ||
|
|
||
| return persistentVolume | ||
| } | ||
|
|
||
| func Namespace() schema.GroupVersionResource { | ||
| namespace := schema.GroupVersionResource{ | ||
| Group: "", | ||
| Version: "v1", | ||
| Resource: "namespaces", | ||
| } | ||
|
|
||
| return namespace | ||
| } | ||
|
|
||
| func Daemonset() schema.GroupVersionResource { | ||
| daemonset := schema.GroupVersionResource{ | ||
| Group: "apps", | ||
| Version: "v1", | ||
| Resource: "daemonsets", | ||
| } | ||
|
|
||
| return daemonset | ||
| } | ||
|
|
||
| func Deployment() schema.GroupVersionResource { | ||
| deployment := schema.GroupVersionResource{ | ||
| Group: "apps", | ||
| Version: "v1", | ||
| Resource: "deployments", | ||
| } | ||
|
|
||
| return deployment | ||
| } | ||
|
|
||
| func Job() schema.GroupVersionResource { | ||
| job := schema.GroupVersionResource{ | ||
| Group: "batch", | ||
| Version: "v1", | ||
| Resource: "jobs", | ||
| } | ||
|
|
||
| return job | ||
| } | ||
|
|
||
| func CronJob() schema.GroupVersionResource { | ||
| cronJob := schema.GroupVersionResource{ | ||
| Group: "batch", | ||
| Version: "v1beta1", | ||
| Resource: "cronjobs", | ||
| } | ||
|
|
||
| return cronJob | ||
| } |
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.
I think this makes sense Sam, essentially have a constructor that the default funcs call. That's what you're saying right Ugur?
| module github.com/rancher/shepherd | ||
|
|
||
| go 1.22 | ||
| go 1.22.0 |
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.
why is this change necessary?
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.
It is only necessary on macs due to a golang issue. I will remove it.
Update to remove several global constants and generally rework how we store/utilize certain constants that appear across many files in both rancher/rancher and rancher/shepherd.
Motivation: The overall goal here is to streamline how we declare and use constants, this should result in fewer global vars, less importing/declaring of generic constants in specific packages, and generally more convenient code writing since generic constants can be found and imported from one place.