kubecuddler

package module
v0.0.0-...-5836f3e Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2018 License: Apache-2.0 Imports: 5 Imported by: 7

README

kubecuddler

Go Report Card godoc

A simple Go package wrapping kubectl invocations. It only depends on the stdlib and overall has a minimal footprint.

First, make sure you've got the package installed, for example, in a global scope:

$ go get -u github.com/mhausenblas/kubecuddler

A minimal usage example would look like the following:

package main

import (
	"fmt"

	"github.com/mhausenblas/kubecuddler"
)

func main() {
	res, _ := kubecuddler.Kubectl(true, true, "", "get", "po,svc")
	fmt.Println(res)
}

This produces an output like so:

screen shot of successful execution

Another example, this time with a failing command, looks like this:

package main

import (
	"fmt"

	"github.com/mhausenblas/kubecuddler"
)

func main() {
	res, _ := kubecuddler.Kubectl(true, true, "", "get", "depl")
	fmt.Println(res)
}

The above produces an output akin to:

screen shot of failed execution

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Kubectl

func Kubectl(withstderr, verbose bool, kubectlbin, cmd string, args ...string) (result string, err error)

Kubectl executes a 'kubectl xxx' command and returns the literal result. The first two parameters influence output behavior: withstderr adds stderr output, of the kubectl invocation and verbose gives additional details. For example:

Kubectl(false, false, "~/bin/kubectl", "get", "--namespace=foo", "pods", "--output=yaml")

Types

This section is empty.

Jump to

Keyboard shortcuts

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