-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial work on finalizers * working on finalizers * finalizers working! * chore: code cleanup
- Loading branch information
Showing
9 changed files
with
145 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package crds | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/acorn-io/baaah/pkg/restconfig" | ||
"github.com/rancher/wrangler/pkg/crd" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
kclient "sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
func Create(ctx context.Context, scheme *runtime.Scheme, gvs ...schema.GroupVersion) error { | ||
var wranglerCRDs []crd.CRD | ||
|
||
for _, gv := range gvs { | ||
for kind := range scheme.KnownTypes(gv) { | ||
gvk := gv.WithKind(kind) | ||
obj, err := scheme.New(gvk) | ||
if err != nil { | ||
return err | ||
} | ||
_, isObj := obj.(kclient.Object) | ||
_, isListObj := obj.(kclient.ObjectList) | ||
if isObj && !isListObj { | ||
wranglerCRDs = append(wranglerCRDs, crd.CRD{ | ||
GVK: gvk, | ||
SchemaObject: obj, | ||
Status: true, | ||
}.WithColumnsFromStruct(obj)) | ||
} | ||
} | ||
} | ||
|
||
restConfig, err := restconfig.New(scheme) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
factory, err := crd.NewFactoryFromClient(restConfig) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return factory.BatchCreateCRDs(ctx, wranglerCRDs...).BatchWait() | ||
} |