package main import ( "github.com/googlecloudplatform/kubernetes/pkg/kubectl/cmd/util" "os" ) func main() { factory := util.NewFactory(nil) ns := "my-namespace" // Set the default namespace for the command factory util.DefaultNamespace(factory, ns) // Create a new `kubectl` command to get all pods in the namespace set above cmd := factory.CreateCmd("get", "pods") // Set the output to stdout and execute the command cmd.SetOutput(os.Stdout) cmd.Execute() }
package main import ( "github.com/googlecloudplatform/kubernetes/pkg/kubectl/cmd/util" "os" ) func main() { factory := util.NewFactory(nil) ns := "my-namespace" // Set the default namespace for the command factory util.DefaultNamespace(factory, ns) // Create a new `kubectl` command to create a new deployment in the namespace cmd := factory.CreateCmd("create", "deployment", "my-deployment", "--image=my-image") // Set the output to stdout and execute the command cmd.SetOutput(os.Stdout) cmd.Execute() }In this example, we create a `kubectl` command to create a new deployment in the namespace set earlier. We specify the deployment name and image using the `--image` flag. Finally, we set the output to stdout and execute the command. Overall, the `github.com.googlecloudplatform.kubernetes.pkg.kubectl.cmd.util` package is a library package that provides functions to manage Kubernetes clusters using `kubectl`. The `Factory` and `DefaultNamespace` functions are just two of the many functions provided by this package.