mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
feat(helm): update helm view [r8s-256] (#582)
Co-authored-by: Cara Ryan <cara.ryan@portainer.io> Co-authored-by: James Player <james.player@portainer.io> Co-authored-by: stevensbkang <skan070@gmail.com>
This commit is contained in:
parent
46eddbe7b9
commit
0ca9321db1
57 changed files with 2635 additions and 222 deletions
40
pkg/libkubectl/describe.go
Normal file
40
pkg/libkubectl/describe.go
Normal file
|
@ -0,0 +1,40 @@
|
|||
package libkubectl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
"k8s.io/cli-runtime/pkg/resource"
|
||||
describecmd "k8s.io/kubectl/pkg/cmd/describe"
|
||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
||||
"k8s.io/kubectl/pkg/describe"
|
||||
)
|
||||
|
||||
// Describe returns the description of a resource
|
||||
// name is the name of the resource, kind is the kind of the resource, and namespace is the namespace of the resource
|
||||
// this is identical to running `kubectl describe <kind> <name> --namespace <namespace>`
|
||||
func (c *Client) Describe(namespace, name, kind string) (string, error) {
|
||||
describeOptions := &describecmd.DescribeOptions{
|
||||
BuilderArgs: []string{kind, name},
|
||||
Describer: func(mapping *meta.RESTMapping) (describe.ResourceDescriber, error) {
|
||||
return describe.DescriberFn(c.factory, mapping)
|
||||
},
|
||||
FilenameOptions: &resource.FilenameOptions{},
|
||||
DescriberSettings: &describe.DescriberSettings{
|
||||
ShowEvents: true,
|
||||
ChunkSize: cmdutil.DefaultChunkSize,
|
||||
},
|
||||
IOStreams: c.streams,
|
||||
NewBuilder: c.factory.NewBuilder,
|
||||
}
|
||||
|
||||
if namespace != "" {
|
||||
describeOptions.Namespace = namespace
|
||||
}
|
||||
|
||||
if err := describeOptions.Run(); err != nil {
|
||||
return "", fmt.Errorf("error describing resources: %w", err)
|
||||
}
|
||||
|
||||
return c.out.String(), nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue