util

package
v0.0.0-...-be29cce Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FlagSet *pflag.FlagSet = nil
View Source
var KnownDockerImages = map[string]bool{}

Functions

func Debug

func Debug(msg string, o interface{}, fields ...string)

Debug lets you print to the console a message and a value or fields of the value. if no fields are specified the whole value is dumped to the console in yaml format.

func Dump

func Dump(o interface{}, fields ...string) string

Dump returns the fields of the value o as string. If no fields are specified, then the whole value is dumped as yaml. fields are specified using go template expression like ".MyField"

func Exec

func Exec(o ExecOptions) error

func ExitOnError

func ExitOnError(err error)

func GetClientNamespace

func GetClientNamespace(configPath string) (string, error)

func GetOpenshift3ManagementConsoleUrl

func GetOpenshift3ManagementConsoleUrl(ctx context.Context, dynClient dynamic.Interface) (string, error)

Only on Openshift 3 - read the configmap/webconsole-config from openshift-web-console namespace to retrieve the URL of Web Admin Console

func GetOpenshift4ManagementConsoleUrl

func GetOpenshift4ManagementConsoleUrl(ctx context.Context, rtClient client.Client) (string, error)

Only on Openshift 4 - read the consoles/cluster object to retrieve the URL of Web Admin Console

func GetPodWithLabelSelector

func GetPodWithLabelSelector(ctx context.Context, api kubernetes.Interface, namespace string, LabelSelector string) (*v1.Pod, error)

func IsNoKindMatchError

func IsNoKindMatchError(err error) bool

func ListInChunks

func ListInChunks(ctx context.Context, c client.Client, options *client.ListOptions, list *unstructured.UnstructuredList, handler func([]unstructured.Unstructured) error) (err error)

func LoadJsonFromFile

func LoadJsonFromFile(path string) ([]byte, error)

func LoadRawResourceFromYaml

func LoadRawResourceFromYaml(data string) (*unstructured.Unstructured, error)

LoadRawResourceFromYaml loads a k8s resource from a yaml definition without making assumptions on the underlying type

func LoadResourceFromFile

func LoadResourceFromFile(scheme *runtime.Scheme, path string) (runtime.Object, error)

func LoadResourceFromYaml

func LoadResourceFromYaml(scheme *runtime.Scheme, source []byte) (runtime.Object, error)

func LoadUnstructuredObject

func LoadUnstructuredObject(data []byte) (*unstructured.Unstructured, error)

func LoadUnstructuredObjectFromFile

func LoadUnstructuredObjectFromFile(path string) (*unstructured.Unstructured, error)

func MustMarshal

func MustMarshal(data []byte, err error) []byte

func MustRenderGoTemplate

func MustRenderGoTemplate(goTemplate string, o interface{}) string

func MustString

func MustString(data string, err error) string

func NewFileInfoMappingFS

func NewFileInfoMappingFS(source http.FileSystem, mapper FileInfoMappingFunction) http.FileSystem

func NewObjectKey

func NewObjectKey(name string, namespace string) client.ObjectKey

func PostgreSQLVersionAt

func PostgreSQLVersionAt(username string, password string, database string, dbUrl string) (float64, error)

PostgreSQLVersionAt determines the version of a PotgreSQL database running at hostname and port

func RenderGoTemplate

func RenderGoTemplate(goTemplate string, o interface{}) (string, error)

func RunAsMinishiftAdminIfPossible

func RunAsMinishiftAdminIfPossible(c *rest.Config, action func() error) error

func RuntimeObjectFromUnstructured

func RuntimeObjectFromUnstructured(scheme *runtime.Scheme, u *unstructured.Unstructured) (runtime.Object, error)

RuntimeObjectFromUnstructured converts an unstructured to a runtime object

func SeperateStructuredAndUnstructured

func SeperateStructuredAndUnstructured(scheme *runtime.Scheme, in []unstructured.Unstructured) ([]runtime.Object, []unstructured.Unstructured)

func ToMetaObject

func ToMetaObject(resource interface{}) metav1.Object

func ToRuntimeObject

func ToRuntimeObject(resource interface{}) runtime.Object

func ToUnstructured

func ToUnstructured(obj runtime.Object) (*unstructured.Unstructured, error)

func UnifiedDiff

func UnifiedDiff(a string, b string) (string, error)

func UnmarshalYaml

func UnmarshalYaml(data []byte, target interface{}) error

func UnstructuredsToRuntimeObject

func UnstructuredsToRuntimeObject(items []unstructured.Unstructured) runtime.Object

func WaitForDeploymentReady

func WaitForDeploymentReady(ctx context.Context, client dynamic.Interface, namespace string, name string, timeout time.Duration) (bool, error)

func WaitForResourceCondition

func WaitForResourceCondition(ctx context.Context, client dynamic.Interface, gvr schema.GroupVersionResource, namespace string, name string, timeout time.Duration, condition func(resource *unstructured.Unstructured) (bool, error)) (bool, error)

func WithStackIfMissing

func WithStackIfMissing(err error) error

Types

type ExecOptions

type ExecOptions struct {
	Config    *rest.Config
	Api       kubernetes.Interface
	Namespace string
	Pod       string
	Container string
	Command   []string
	remotecommand.StreamOptions
}

type FileInfoMappingFunction

type FileInfoMappingFunction func(os.FileInfo) (os.FileInfo, error)

type MinishiftCluster

type MinishiftCluster struct {
	// contains filtered or unexported fields
}

func GetMinishiftCluster

func GetMinishiftCluster(c *rest.Config) *MinishiftCluster

func (*MinishiftCluster) MinishiftAdminLogin

func (this *MinishiftCluster) MinishiftAdminLogin() error

func (*MinishiftCluster) MinishiftUserLogin

func (this *MinishiftCluster) MinishiftUserLogin(username string) error

func (*MinishiftCluster) MinishiftWhoAmI

func (this *MinishiftCluster) MinishiftWhoAmI() (string, error)

Jump to

Keyboard shortcuts

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