Documentation ¶
Index ¶
- Variables
- type CommandGuard
- func (g *CommandGuard) FilterSupportedVerbs(allVerbs []string) []string
- func (g *CommandGuard) GetAllowedResourcesForVerb(verb string, allConfiguredResources []string) ([]Resource, error)
- func (g *CommandGuard) GetResourceDetails(selectedVerb, resourceType string) (Resource, error)
- func (g *CommandGuard) GetResourceDetailsFromMap(selectedVerb, resourceType string, resMap map[string]v1.APIResource) (Resource, error)
- func (g *CommandGuard) GetServerResourceMap() (map[string]v1.APIResource, error)
- type K8sDiscoveryInterface
- type Resource
Constants ¶
This section is empty.
Variables ¶
var ( // ErrVerbNotSupported is returned when the verb is not supported for the resource. ErrVerbNotSupported = errors.New("verb not supported") // ErrResourceNotFound is returned when the resource is not found on the server. ErrResourceNotFound = errors.New("resource not found") )
Functions ¶
This section is empty.
Types ¶
type CommandGuard ¶
type CommandGuard struct {
// contains filtered or unexported fields
}
CommandGuard is responsible for getting allowed resources for a given command.
func NewCommandGuard ¶
func NewCommandGuard(log logrus.FieldLogger, discoveryCli K8sDiscoveryInterface) *CommandGuard
NewCommandGuard creates a new CommandGuard instance.
func (*CommandGuard) FilterSupportedVerbs ¶
func (g *CommandGuard) FilterSupportedVerbs(allVerbs []string) []string
FilterSupportedVerbs filters out unsupported verbs by the interactive commands.
func (*CommandGuard) GetAllowedResourcesForVerb ¶
func (g *CommandGuard) GetAllowedResourcesForVerb(verb string, allConfiguredResources []string) ([]Resource, error)
GetAllowedResourcesForVerb returns a list of allowed resources for a given verb.
func (*CommandGuard) GetResourceDetails ¶
func (g *CommandGuard) GetResourceDetails(selectedVerb, resourceType string) (Resource, error)
GetResourceDetails returns a Resource struct for a given resource type and verb.
func (*CommandGuard) GetResourceDetailsFromMap ¶
func (g *CommandGuard) GetResourceDetailsFromMap(selectedVerb, resourceType string, resMap map[string]v1.APIResource) (Resource, error)
GetResourceDetailsFromMap returns a Resource struct for a given resource type and verb based on the server resource map.
func (*CommandGuard) GetServerResourceMap ¶
func (g *CommandGuard) GetServerResourceMap() (map[string]v1.APIResource, error)
GetServerResourceMap returns a map of all resources available on the server. LIMITATION: This method ignores second occurrences of the same resource name.
type K8sDiscoveryInterface ¶
type K8sDiscoveryInterface interface {
ServerPreferredResources() ([]*v1.APIResourceList, error)
}
K8sDiscoveryInterface describes an interface for getting K8s server resources.
type Resource ¶
type Resource struct { // Name is always plural, e.g. "pods". Name string Namespaced bool // SlashSeparatedInCommand indicates if the resource name should be separated with a slash in the command. // So, instead of `kubectl logs pods <name>` it should be `kubectl logs pods/<name>`. SlashSeparatedInCommand bool }
Resource represents a Kubernetes resource.