utils

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name                  = "akcess"
	ResourceAnnotationKey = "allow.akcess.id"
)

Variables

View Source
var (
	// Valid resource verb list for validation.
	ValidResourceVerbs = []string{"*", "get", "delete", "list", "create", "update", "patch", "watch", "proxy", "deletecollection", "use", "bind", "escalate", "impersonate"}
	SpecialVerbs       = map[string][]schema.GroupResource{
		"use": {
			{
				Group:    "policy",
				Resource: "podsecuritypolicies",
			},
			{
				Group:    "extensions",
				Resource: "podsecuritypolicies",
			},
		},
		"bind": {
			{
				Group:    "rbac.authorization.k8s.io",
				Resource: "roles",
			},
			{
				Group:    "rbac.authorization.k8s.io",
				Resource: "clusterroles",
			},
		},
		"escalate": {
			{
				Group:    "rbac.authorization.k8s.io",
				Resource: "roles",
			},
			{
				Group:    "rbac.authorization.k8s.io",
				Resource: "clusterroles",
			},
		},
		"impersonate": {
			{
				Group:    "",
				Resource: "users",
			},
			{
				Group:    "",
				Resource: "serviceaccounts",
			},
			{
				Group:    "",
				Resource: "groups",
			},
			{
				Group:    "authentication.k8s.io",
				Resource: "userextras",
			},
		},
	}
)

Functions

func ArrayContains

func ArrayContains(s []string, e string) bool

func Base64EncodeCSR

func Base64EncodeCSR(c []byte) []byte

func Config

func Config(kubeConfigFlag string) (*rest.Config, *clientcmdapi.Config, error)

Config gets us rest.Config considering the kubeconfig flag provided as kubeConfigFlag if not, falls back 1. KUBECONFIG env var 2. default kubeconfig file location

func DynClient added in v0.0.3

func DynClient(config *rest.Config) (dynamic.Interface, error)

func FilePath

func FilePath() (string, string)

func KubeClient

func KubeClient(config *rest.Config) (kubernetes.Interface, error)

func Username added in v0.0.4

func Username(u string) string

Types

type Cluster

type Cluster struct {
	CertificateAuthorityData string `yaml:"certificate-authority-data"`
	Server                   string `yaml:"server"`
}

Cluster holds the cluster data

type Clusters

type Clusters []struct {
	Cluster Cluster `yaml:"cluster"`
	Name    string  `yaml:"name"`
}

Clusters hold an array of the clusters that would exist in the config file

type Context

type Context struct {
	Cluster string `yaml:"cluster"`
	User    string `yaml:"user"`
}

Context holds the cluster context

type Contexts

type Contexts []struct {
	Context Context `yaml:"context"`
	Name    string  `yaml:"name"`
}

Contexts holds an array of the contexts

type KubeConfig

type KubeConfig struct {
	APIVersion     string   `yaml:"apiVersion"`
	Clusters       Clusters `yaml:"clusters"`
	Contexts       Contexts `yaml:"contexts"`
	CurrentContext string   `yaml:"current-context"`
	Kind           string   `yaml:"kind"`
	Preferences    struct{} `yaml:"preferences"`
	Users          Users    `yaml:"users"`
}

KubeConfig holds the necessary data for creating a new KubeConfig file

type User

type User struct {
	ClientCertificateData string `yaml:"client-certificate-data"`
	ClientKeyData         string `yaml:"client-key-data"`
}

User holds the user authentication data

type Users

type Users []struct {
	User User   `yaml:"user"`
	Name string `yaml:"name"`
}

Users holds an array of the users that would exist in the config file

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL