Wrangler - rancher/shepherd GitHub Wiki
Wrangler is a framework for using controllers. Controllers wrap clients, informers, and listers into a simple, usable controller pattern that promotes some good practices.
Wrangler provides a code generator that will generate the clientset, informers, and listers, as well as a controller per resource type.
Wrangler resource creation is wrapped in a test session call. Like other clients in Shepherd, a test session is passed to the different interface create calls in Wrangler so that test cleanup will occur in the event of an error or at the end of a test.
Wrangler cuts down on the code needed to achieve similar tasks than with using Steve or Norman.
Example
To create a global role with the dynamic client, you have to perform several conversion steps
globalRoleResource := dynamicClient.Resource(GlobalRoleGroupVersionResource)
unstructuredResp, err := globalRoleResource.Create(context.TODO(), unstructured.MustToUnstructured(globalRole), metav1.CreateOptions{})
if err != nil {
return nil, err
}
newGlobalRole := &v3.GlobalRole{}
err = scheme.Scheme.Convert(unstructuredResp, newGlobalRole, unstructuredResp.GroupVersionKind())
if err != nil {
return nil, err
}
With Wrangler you just have to perform one operation
createdGlobalRole, err := client.WranglerContext.Mgmt.GlobalRole().Create(&globalRole)
if err != nil {
return nil, err
}