@@ -233,6 +233,9 @@ func (c *Kubectl) Get(ctx context.Context, kubeconfig, namespace string, r Resou
233
233
return ms [0 ], nil
234
234
}
235
235
236
+ // getAPIResources retrieves the list of available API resources from the Kubernetes cluster.
237
+ // It runs the `kubectl api-resources` command with the specified kubeconfig and returns the
238
+ // names of the resources that support the "list", "get", and "delete" verbs.
236
239
func (c * Kubectl ) getAPIResources (ctx context.Context , kubeconfig string ) ([]string , error ) {
237
240
args := []string {"api-resources" , "--namespaced=false" , "--verbs=list,get,delete" , "--output=name" }
238
241
if kubeconfig != "" {
@@ -254,6 +257,9 @@ func (c *Kubectl) getAPIResources(ctx context.Context, kubeconfig string) ([]str
254
257
return resources , nil
255
258
}
256
259
260
+ // GetAllClusterScoped retrieves all cluster-scoped resources from the Kubernetes cluster
261
+ // using the provided kubeconfig and optional selectors. It returns a slice of Manifests
262
+ // representing the resources or an error if the operation fails.
257
263
func (c * Kubectl ) GetAllClusterScoped (ctx context.Context , kubeconfig string , selector ... string ) ([]Manifest , error ) {
258
264
resources , err := c .getAPIResources (ctx , kubeconfig )
259
265
if err != nil {
@@ -289,6 +295,9 @@ func (c *Kubectl) GetAllClusterScoped(ctx context.Context, kubeconfig string, se
289
295
return ms , nil
290
296
}
291
297
298
+ // GetAll retrieves all Kubernetes resources in the specified namespace and matching the given selector.
299
+ // It returns a list of manifests or an error if the retrieval or unmarshalling fails.
300
+ // If no resources are found, it returns nil without an error.
292
301
func (c * Kubectl ) GetAll (ctx context.Context , kubeconfig , namespace string , selector ... string ) (ms []Manifest , err error ) {
293
302
args := make ([]string , 0 , 7 )
294
303
args = append (args , "get" , "all" , "-o" , "yaml" , "--selector" , strings .Join (selector , "," ))
0 commit comments