cluster-templates-operator
cluster-templates-operator copied to clipboard
Add clientset generation for ClusterTemplate CRD
This PR add code for generating the clientset and the generated client set the example usage is:
package handlers
import (
"context"
"fmt"
"net/http"
"os"
"github.com/gin-gonic/gin"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/rest"
"github.com/stolostron/cluster-templates-operator/generated/clientset/versioned"
)
func main() {
config := &rest.Config{
BearerToken: os.Getenv("OCP_TOKEN"),
Host: os.Getenv("OCP_URL"),
TLSClientConfig: rest.TLSClientConfig{
Insecure: true,
},
}
clientset, err := versioned.NewForConfig(config)
if err != nil {
os.Exit(1)
}
ctemplates, err := clientset.V1alpha1().ClusterTemplates("").List(context.TODO(), metav1.ListOptions{})
if err != nil {
fmt.Printf("Error listing templates: %v\n", err)
os.Exit(1)
}
for _, ct := range ctemplates.Items {
fmt.Prinln("Template: %v\n", ct.GetName())
}
}
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: machacekondra
The full list of commands accepted by this bot can be found here.
The pull request process is described here
Needs approval from an approver in each of these files:
- ~~OWNERS~~ [machacekondra]
Approvers can indicate their approval by writing /approve
in a comment
Approvers can cancel approval by writing /approve cancel
in a comment
/retest
@rawagner PTAL
/retest
/retest