Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultAuditConfig(ns string, workloads, nodes, admission bool) mondoov2.MondooAuditConfig
- func ExitStatus(err error) (int, bool)
- func FindRootFolder() (string, error)
- func GenerateTLSCerts(dnsNames []string) (*bytes.Buffer, *bytes.Buffer, *bytes.Buffer, error)
- func LabelSelectorListOptions(labelSelector string) (*client.ListOptions, error)
- func ReadFile(filename string) string
- type CommandArgs
- type CommandExecutor
- func (c *CommandExecutor) ExecuteCommand(command string, arg ...string) error
- func (*CommandExecutor) ExecuteCommandWithCombinedOutput(command string, arg ...string) (string, error)
- func (*CommandExecutor) ExecuteCommandWithEnv(env []string, command string, arg ...string) error
- func (*CommandExecutor) ExecuteCommandWithOutput(command string, arg ...string) (string, error)
- func (*CommandExecutor) ExecuteCommandWithOutputFile(command, outfileArg string, arg ...string) (string, error)
- func (*CommandExecutor) ExecuteCommandWithOutputFileTimeout(timeout time.Duration, command, outfileArg string, arg ...string) (string, error)
- func (*CommandExecutor) ExecuteCommandWithTimeout(timeout time.Duration, command string, arg ...string) (string, error)
- type CommandOut
- type K8sHelper
- func (k8sh *K8sHelper) DeleteResourceIfExists(r client.Object) error
- func (k8sh *K8sHelper) GetEventsFromNamespace(namespace, testName string)
- func (k8sh *K8sHelper) GetLogsFromNamespace(namespace, testName string)
- func (k8sh *K8sHelper) GetPodDescribeFromNamespace(namespace, testName string)
- func (k8sh *K8sHelper) IsPodReady(labelSelector, namespace string) bool
- func (k8sh *K8sHelper) Kubectl(args ...string) (string, error)
- func (k8sh *K8sHelper) KubectlWithStdin(stdin string, args ...string) (string, error)
- func (k8sh *K8sHelper) PrintPodDescribe(namespace string, args ...string)
- func (k8sh *K8sHelper) WaitForResourceDeletion(r client.Object) error
Constants ¶
const MondooClientSecret = "mondoo-client"
Variables ¶
var ( CreateArgs = []string{"create", "-f"} CreateFromStdinArgs = append(CreateArgs, "-") DeleteArgs = []string{"delete", "-f"} DeleteArgsIgnoreNotFound = []string{"delete", "--ignore-not-found=true", "-f"} DeleteFromStdinArgs = append(DeleteArgs, "-") DeleteIngoreNotFoundFromStdinArgs = append(DeleteArgsIgnoreNotFound, "-") )
Functions ¶
func DefaultAuditConfig ¶
func DefaultAuditConfig(ns string, workloads, nodes, admission bool) mondoov2.MondooAuditConfig
DefaultAuditConfig returns a new Mondoo audit config with some default settings to make sure a tests passes (e.g. setting the correct secret name).
func ExitStatus ¶
func FindRootFolder ¶
func GenerateTLSCerts ¶
GenerateTLSCerts will return create a CA and return the CA certificate, the Server certificate, and the Server private key for the provided list of dnsNames
func LabelSelectorListOptions ¶
func LabelSelectorListOptions(labelSelector string) (*client.ListOptions, error)
Types ¶
type CommandArgs ¶
type CommandArgs struct { Command string CmdArgs []string PipeToStdIn string EnvironmentVariable []string }
CommandArgs is a warpper for cmd args
type CommandExecutor ¶
type CommandExecutor struct { }
CommandExecutor is the type of the Executor
func (*CommandExecutor) ExecuteCommand ¶
func (c *CommandExecutor) ExecuteCommand(command string, arg ...string) error
ExecuteCommand starts a process and wait for its completion
func (*CommandExecutor) ExecuteCommandWithCombinedOutput ¶
func (*CommandExecutor) ExecuteCommandWithCombinedOutput(command string, arg ...string) (string, error)
ExecuteCommandWithCombinedOutput executes a command with combined output
func (*CommandExecutor) ExecuteCommandWithEnv ¶
func (*CommandExecutor) ExecuteCommandWithEnv(env []string, command string, arg ...string) error
ExecuteCommandWithEnv starts a process with env variables and wait for its completion
func (*CommandExecutor) ExecuteCommandWithOutput ¶
func (*CommandExecutor) ExecuteCommandWithOutput(command string, arg ...string) (string, error)
ExecuteCommandWithOutput executes a command with output
func (*CommandExecutor) ExecuteCommandWithOutputFile ¶
func (*CommandExecutor) ExecuteCommandWithOutputFile(command, outfileArg string, arg ...string) (string, error)
ExecuteCommandWithOutputFile executes a command with output on a file #nosec G307 Calling defer to close the file without checking the error return is not a risk for a simple file open and close
func (*CommandExecutor) ExecuteCommandWithOutputFileTimeout ¶
func (*CommandExecutor) ExecuteCommandWithOutputFileTimeout(timeout time.Duration, command, outfileArg string, arg ...string) (string, error)
ExecuteCommandWithOutputFileTimeout Same as ExecuteCommandWithOutputFile but with a timeout limit. #nosec G307 Calling defer to close the file without checking the error return is not a risk for a simple file open and close
func (*CommandExecutor) ExecuteCommandWithTimeout ¶
func (*CommandExecutor) ExecuteCommandWithTimeout(timeout time.Duration, command string, arg ...string) (string, error)
ExecuteCommandWithTimeout starts a process and wait for its completion with timeout.
type CommandOut ¶
CommandOut is a wrapper for cmd out returned after executing command args
func ExecuteCommand ¶
func ExecuteCommand(cmdStruct CommandArgs) CommandOut
ExecuteCommand executes a os command with stdin and returns output
type K8sHelper ¶
type K8sHelper struct { Clientset client.Client RunningInCluster bool // contains filtered or unexported fields }
func CreateK8sHelper ¶
CreateK8sHelper creates a instance of k8sHelper
func (*K8sHelper) DeleteResourceIfExists ¶
DeleteResourceIfExists Deletes the requested resource if it exists. If the resource does not exist, the function does nothing (return no error).
func (*K8sHelper) GetEventsFromNamespace ¶
func (*K8sHelper) GetLogsFromNamespace ¶
GetLogsFromNamespace collects logs for all containers in all pods in the namespace
func (*K8sHelper) GetPodDescribeFromNamespace ¶
func (*K8sHelper) IsPodReady ¶
IsPodInExpectedState waits for a pod to be in a Ready state If the pod is in expected state within the time retry limit true is returned, if not false
func (*K8sHelper) KubectlWithStdin ¶
KubectlWithStdin is wrapper for executing kubectl commands in stdin