mirror of
https://github.com/storytold/irsa-manager.git
synced 2026-10-09 00:09:43 +00:00
apply keypair secret
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
)
|
||||
|
||||
type KubernetesClient interface {
|
||||
Apply(ctx context.Context, obj client.Object) error
|
||||
Delete(ctx context.Context, obj *unstructured.Unstructured, opts DeleteOptions) error
|
||||
}
|
||||
|
||||
// DeleteOptions contains options for delete requests.
|
||||
type DeleteOptions struct {
|
||||
// DeletionPropagation decides how the garbage collector will handle the propagation.
|
||||
DeletionPropagation metav1.DeletionPropagation
|
||||
|
||||
// Inclusions determines which in-cluster objects are subject to deletion
|
||||
// based on the labels.
|
||||
// A nil Inclusions map means all objects are subject to deletion
|
||||
Inclusions map[string]string
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
)
|
||||
|
||||
type KubernetesHandler struct {
|
||||
client KubernetesClient
|
||||
objs []client.Object
|
||||
}
|
||||
|
||||
func NewKubernetesHandler(k KubernetesClient) *KubernetesHandler {
|
||||
return &KubernetesHandler{
|
||||
client: k,
|
||||
objs: []client.Object{},
|
||||
}
|
||||
}
|
||||
|
||||
func (k *KubernetesHandler) Append(obj client.Object) {
|
||||
k.objs = append(k.objs, obj)
|
||||
}
|
||||
|
||||
func (k *KubernetesHandler) ApplyAll(ctx context.Context) error {
|
||||
for _, obj := range k.objs {
|
||||
err := k.client.Apply(ctx, obj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user