utils

package
v0.0.25 Latest Latest
Warning

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

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

Documentation

Overview

Package utils provides CLI utility functions and structs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateKubernetesClient

func CreateKubernetesClient(contextName string) (client.Client, error)

func CreateKubernetesClientOrDie

func CreateKubernetesClientOrDie(contextName string) client.Client

func CreateROrDie

func CreateROrDie(env *ENV, obj client.Object)

func DeleteAllOfOrDie

func DeleteAllOfOrDie(env *ENV, obj client.Object, opts ...client.DeleteAllOfOption)

func DeleteOrDie

func DeleteOrDie(env *ENV, obj client.Object, opts ...client.DeleteOption) bool

func EnsureNamespaceOrDie added in v0.0.24

func EnsureNamespaceOrDie(env *ENV, name string)

func EnsureServiceAccountOrDie added in v0.0.24

func EnsureServiceAccountOrDie(env *ENV, name string)

func GetCRUDSubcommands

func GetCRUDSubcommands() (*cobra.Command, *cobra.Command, *cobra.Command)

func GetFileContent

func GetFileContent(filePath string) ([]byte, error)

func GetM

func GetM(env *ENV, name string, obj client.Object) (bool, error)

func GetMOrDie

func GetMOrDie(env *ENV, name string, obj client.Object) bool

func RunCmdOrDie added in v0.0.23

func RunCmdOrDie(cmd string, args ...string) string

func RunCmdWithEnvOrDie added in v0.0.23

func RunCmdWithEnvOrDie(environ []string, cmd string, args ...string) string

func UpdateROrDie

func UpdateROrDie(env *ENV, obj client.Object)

func VarListToMap added in v0.0.24

func VarListToMap(varsList []string) map[string]string

Types

type ENV

type ENV struct {
	Cli client.Client
	Ns  string
	Ctx context.Context
}

Moving code from cli/sfconfig/cmd/utils/utils.go as we need it to avoid dead code

type SoftwareFactoryConfig

type SoftwareFactoryConfig struct {
	Contexts map[string]SoftwareFactoryConfigContext `json:"contexts" mapstructure:"contexts"`
	Default  string                                  `json:"default-context" mapstructure:"default-context"`
}

type SoftwareFactoryConfigContext

type SoftwareFactoryConfigContext struct {
	ConfigRepository string `json:"config-repository-path" mapstructure:"config-repository-path"`
	Manifest         string `json:"manifest-file" mapstructure:"manifest-file"`
	IsStandalone     bool   `json:"standalone" mapstructure:"standalone"`
	Namespace        string `json:"namespace" mapstructure:"namespace"`
	KubeContext      string `json:"kube-context" mapstructure:"kube-context"`
	FQDN             string `json:"fqdn" mapstructure:"fqdn"`
	Dev              struct {
		AnsibleMicroshiftRolePath string `json:"ansible-microshift-role-path" mapstructure:"ansible-microshift-role-path"`
		SFOperatorRepositoryPath  string `json:"sf-operator-repository-path" mapstructure:"sf-operator-repository-path"`
		Microshift                struct {
			Host                string `json:"host" mapstructure:"host"`
			User                string `json:"user" mapstructure:"user"`
			OpenshiftPullSecret string `json:"openshift-pull-secret" mapstructure:"openshift-pull-secret"`
			DiskFileSize        string `json:"disk-file-size" mapstructure:"disk-file-size"`
		} `json:"microshift" mapstructure:"microshift"`
		Tests struct {
			DemoReposPath string            `json:"demo-repos-path" mapstructure:"demo-repos-path"`
			ExtraVars     map[string]string `json:"extra-vars" mapstructure:"extra-vars"`
		} `json:"tests" mapstructure:"tests"`
	} `json:"development" mapstructure:"development"`
	Components struct {
		Nodepool struct {
			CloudsFile string `json:"clouds-file" mapstructure:"clouds-file"`
			KubeFile   string `json:"kube-file" mapstructure:"kube-file"`
		} `json:"nodepool" mapstructure:"nodepool"`
	} `json:"components" mapstructure:"components"`
}

CLI config struct

func GetCLIContext

func GetCLIContext(command *cobra.Command) (SoftwareFactoryConfigContext, error)

func GetCLIctxOrDie

func GetCLIctxOrDie(kmd *cobra.Command, args []string, allowedArgs []string) SoftwareFactoryConfigContext

Jump to

Keyboard shortcuts

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