diff --git a/components/operatorv2/api/v1beta1/shared.go b/components/operatorv2/api/v1beta1/shared.go index e0380d871f..2a616d4125 100644 --- a/components/operatorv2/api/v1beta1/shared.go +++ b/components/operatorv2/api/v1beta1/shared.go @@ -4,6 +4,11 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +// +kubebuilder:object:generate=false +type EventPublisher interface { + isEventPublisher() +} + type DevProperties struct { // +optional Debug bool `json:"debug"` @@ -129,8 +134,3 @@ type StackDependency struct { func (d StackDependency) GetStack() string { return d.Stack } - -// +kubebuilder:object:generate=false -type EventPublisher interface { - isEventPublisher() -} diff --git a/components/operatorv2/internal/controllers/ledger_controller.go b/components/operatorv2/internal/controllers/ledger_controller.go index a945284427..58b9b0c563 100644 --- a/components/operatorv2/internal/controllers/ledger_controller.go +++ b/components/operatorv2/internal/controllers/ledger_controller.go @@ -74,7 +74,8 @@ func (r *LedgerController) Reconcile(ctx Context, ledger *v1beta1.Ledger) error return err } - if err := streams.LoadFromFileSystem(ctx, benthos.Streams, ledger.Spec.Stack, "streams/ledger/v2.0.0"); err != nil { + if err := streams.LoadFromFileSystem(ctx, benthos.Streams, ledger.Spec.Stack, "streams/ledger/v2.0.0", + WithController[*v1beta1.Stream](ctx.GetScheme(), ledger)); err != nil { return err } diff --git a/components/operatorv2/internal/controllers/payments_controller.go b/components/operatorv2/internal/controllers/payments_controller.go index 26b4c40861..9aaf8c2c4a 100644 --- a/components/operatorv2/internal/controllers/payments_controller.go +++ b/components/operatorv2/internal/controllers/payments_controller.go @@ -142,7 +142,8 @@ func (r *PaymentsController) createReadDeployment(ctx Context, stack *v1beta1.St return err } - if err := streams.LoadFromFileSystem(ctx, benthos.Streams, payments.Spec.Stack, "streams/payments/v0.0.0"); err != nil { + if err := streams.LoadFromFileSystem(ctx, benthos.Streams, payments.Spec.Stack, "streams/payments/v0.0.0", + WithController[*v1beta1.Stream](ctx.GetScheme(), payments)); err != nil { return err } diff --git a/components/operatorv2/internal/resources/streams/streams.go b/components/operatorv2/internal/resources/streams/streams.go index e23d98a7db..7dca7c18b0 100644 --- a/components/operatorv2/internal/resources/streams/streams.go +++ b/components/operatorv2/internal/resources/streams/streams.go @@ -12,7 +12,7 @@ import ( ) func LoadFromFileSystem(ctx core.Context, fs embed.FS, - stackName string, streamDirectory string) error { + stackName string, streamDirectory string, opts ...core.ObjectMutator[*v1beta1.Stream]) error { streamFiles, err := fs.ReadDir(streamDirectory) if err != nil { return err @@ -27,12 +27,13 @@ func LoadFromFileSystem(ctx core.Context, fs embed.FS, sanitizedName := strings.ReplaceAll(file.Name(), "_", "-") + opts = append(opts, func(stream *v1beta1.Stream) { + stream.Spec.Data = string(streamContent) + stream.Spec.Stack = stackName + }) _, _, err = core.CreateOrUpdate[*v1beta1.Stream](ctx, types.NamespacedName{ Name: fmt.Sprintf("%s-%s", stackName, sanitizedName), - }, func(t *v1beta1.Stream) { - t.Spec.Data = string(streamContent) - t.Spec.Stack = stackName - }) + }, opts...) if err != nil { return errors.Wrap(err, "creating stream") } diff --git a/components/operatorv2/pkg/v1beta1/auth.go b/components/operatorv2/pkg/v1beta1/auth.go new file mode 100644 index 0000000000..f570978023 --- /dev/null +++ b/components/operatorv2/pkg/v1beta1/auth.go @@ -0,0 +1,92 @@ +package v1beta1 + +import ( + "context" + "github.com/formancehq/operator/v2/api/v1beta1" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/rest" +) + +type AuthInterface interface { + List(ctx context.Context, opts metav1.ListOptions) (*v1beta1.AuthList, error) + Get(ctx context.Context, name string, options metav1.GetOptions) (*v1beta1.Auth, error) + Create(ctx context.Context, Auth *v1beta1.Auth) (*v1beta1.Auth, error) + Update(ctx context.Context, Auth *v1beta1.Auth) (*v1beta1.Auth, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Delete(ctx context.Context, name string) error +} + +type AuthClient struct { + restClient rest.Interface +} + +func (c *AuthClient) List(ctx context.Context, opts metav1.ListOptions) (*v1beta1.AuthList, error) { + result := v1beta1.AuthList{} + err := c.restClient. + Get(). + Resource("Auths"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *AuthClient) Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1beta1.Auth, error) { + result := v1beta1.Auth{} + err := c.restClient. + Get(). + Resource("Auths"). + Name(name). + VersionedParams(&opts, scheme.ParameterCodec). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *AuthClient) Create(ctx context.Context, Auth *v1beta1.Auth) (*v1beta1.Auth, error) { + result := v1beta1.Auth{} + err := c.restClient. + Post(). + Resource("Auths"). + Body(Auth). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *AuthClient) Delete(ctx context.Context, name string) error { + return c.restClient. + Delete(). + Resource("Auths"). + Name(name). + Do(ctx). + Error() +} + +func (c *AuthClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.restClient. + Get(). + Resource("Auths"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch(ctx) +} + +func (c *AuthClient) Update(ctx context.Context, o *v1beta1.Auth) (*v1beta1.Auth, error) { + result := v1beta1.Auth{} + err := c.restClient. + Put(). + Resource("Auths"). + Name(o.Name). + Body(o). + Do(ctx). + Into(&result) + + return &result, err +} diff --git a/components/operatorv2/pkg/v1beta1/client.go b/components/operatorv2/pkg/v1beta1/client.go new file mode 100644 index 0000000000..0af55a17c3 --- /dev/null +++ b/components/operatorv2/pkg/v1beta1/client.go @@ -0,0 +1,83 @@ +package v1beta1 + +import ( + "github.com/formancehq/operator/v2/api/v1beta1" + "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/rest" +) + +func init() { + if err := v1beta1.AddToScheme(scheme.Scheme); err != nil { + panic(err) + } +} + +type Client struct { + rest.Interface +} + +func NewClient(restClient rest.Interface) *Client { + return &Client{ + Interface: restClient, + } +} + +func (c *Client) Stacks() StackInterface { + return &stackClient{ + restClient: c.Interface, + } +} + +func (c *Client) Auths() AuthInterface { + return &AuthClient{ + restClient: c.Interface, + } +} + +func (c *Client) Gateways() GatewayInterface { + return &gatewayClient{ + restClient: c.Interface, + } +} + +func (c *Client) Ledgers() LedgerInterface { + return &LedgerClient{ + restClient: c.Interface, + } +} + +func (c *Client) Orchestrations() OrchestrationInterface { + return &OrchestrationClient{ + restClient: c.Interface, + } +} + +func (c *Client) Payments() PaymentsInterface { + return &paymentsClient{ + restClient: c.Interface, + } +} + +func (c *Client) Reconciliations() ReconciliationInterface { + return &reconciliationClient{ + restClient: c.Interface, + } +} + +func (c *Client) Searches() SearchInterface { + return &SearchClient{ + restClient: c.Interface, + } +} + +func (c *Client) Wallets() WalletsInterface { + return &walletsClient{ + restClient: c.Interface, + } +} + +func (c *Client) Webhooks() WebhooksInterface { + return &webhooksClient{ + restClient: c.Interface, + } +} diff --git a/components/operatorv2/pkg/v1beta1/gateway.go b/components/operatorv2/pkg/v1beta1/gateway.go new file mode 100644 index 0000000000..c1eb8d7ddc --- /dev/null +++ b/components/operatorv2/pkg/v1beta1/gateway.go @@ -0,0 +1,92 @@ +package v1beta1 + +import ( + "context" + "github.com/formancehq/operator/v2/api/v1beta1" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/rest" +) + +type GatewayInterface interface { + List(ctx context.Context, opts metav1.ListOptions) (*v1beta1.GatewayList, error) + Get(ctx context.Context, name string, options metav1.GetOptions) (*v1beta1.Gateway, error) + Create(ctx context.Context, Gateway *v1beta1.Gateway) (*v1beta1.Gateway, error) + Update(ctx context.Context, Gateway *v1beta1.Gateway) (*v1beta1.Gateway, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Delete(ctx context.Context, name string) error +} + +type gatewayClient struct { + restClient rest.Interface +} + +func (c *gatewayClient) List(ctx context.Context, opts metav1.ListOptions) (*v1beta1.GatewayList, error) { + result := v1beta1.GatewayList{} + err := c.restClient. + Get(). + Resource("Gateways"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *gatewayClient) Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1beta1.Gateway, error) { + result := v1beta1.Gateway{} + err := c.restClient. + Get(). + Resource("Gateways"). + Name(name). + VersionedParams(&opts, scheme.ParameterCodec). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *gatewayClient) Create(ctx context.Context, Gateway *v1beta1.Gateway) (*v1beta1.Gateway, error) { + result := v1beta1.Gateway{} + err := c.restClient. + Post(). + Resource("Gateways"). + Body(Gateway). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *gatewayClient) Delete(ctx context.Context, name string) error { + return c.restClient. + Delete(). + Resource("Gateways"). + Name(name). + Do(ctx). + Error() +} + +func (c *gatewayClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.restClient. + Get(). + Resource("Gateways"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch(ctx) +} + +func (c *gatewayClient) Update(ctx context.Context, o *v1beta1.Gateway) (*v1beta1.Gateway, error) { + result := v1beta1.Gateway{} + err := c.restClient. + Put(). + Resource("Gateways"). + Name(o.Name). + Body(o). + Do(ctx). + Into(&result) + + return &result, err +} diff --git a/components/operatorv2/pkg/v1beta1/ledger.go b/components/operatorv2/pkg/v1beta1/ledger.go new file mode 100644 index 0000000000..9377e3180a --- /dev/null +++ b/components/operatorv2/pkg/v1beta1/ledger.go @@ -0,0 +1,92 @@ +package v1beta1 + +import ( + "context" + "github.com/formancehq/operator/v2/api/v1beta1" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/rest" +) + +type LedgerInterface interface { + List(ctx context.Context, opts metav1.ListOptions) (*v1beta1.LedgerList, error) + Get(ctx context.Context, name string, options metav1.GetOptions) (*v1beta1.Ledger, error) + Create(ctx context.Context, Ledger *v1beta1.Ledger) (*v1beta1.Ledger, error) + Update(ctx context.Context, Ledger *v1beta1.Ledger) (*v1beta1.Ledger, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Delete(ctx context.Context, name string) error +} + +type LedgerClient struct { + restClient rest.Interface +} + +func (c *LedgerClient) List(ctx context.Context, opts metav1.ListOptions) (*v1beta1.LedgerList, error) { + result := v1beta1.LedgerList{} + err := c.restClient. + Get(). + Resource("Ledgers"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *LedgerClient) Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1beta1.Ledger, error) { + result := v1beta1.Ledger{} + err := c.restClient. + Get(). + Resource("Ledgers"). + Name(name). + VersionedParams(&opts, scheme.ParameterCodec). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *LedgerClient) Create(ctx context.Context, Ledger *v1beta1.Ledger) (*v1beta1.Ledger, error) { + result := v1beta1.Ledger{} + err := c.restClient. + Post(). + Resource("Ledgers"). + Body(Ledger). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *LedgerClient) Delete(ctx context.Context, name string) error { + return c.restClient. + Delete(). + Resource("Ledgers"). + Name(name). + Do(ctx). + Error() +} + +func (c *LedgerClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.restClient. + Get(). + Resource("Ledgers"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch(ctx) +} + +func (c *LedgerClient) Update(ctx context.Context, o *v1beta1.Ledger) (*v1beta1.Ledger, error) { + result := v1beta1.Ledger{} + err := c.restClient. + Put(). + Resource("Ledgers"). + Name(o.Name). + Body(o). + Do(ctx). + Into(&result) + + return &result, err +} diff --git a/components/operatorv2/pkg/v1beta1/orchestration.go b/components/operatorv2/pkg/v1beta1/orchestration.go new file mode 100644 index 0000000000..3106052bda --- /dev/null +++ b/components/operatorv2/pkg/v1beta1/orchestration.go @@ -0,0 +1,92 @@ +package v1beta1 + +import ( + "context" + "github.com/formancehq/operator/v2/api/v1beta1" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/rest" +) + +type OrchestrationInterface interface { + List(ctx context.Context, opts metav1.ListOptions) (*v1beta1.OrchestrationList, error) + Get(ctx context.Context, name string, options metav1.GetOptions) (*v1beta1.Orchestration, error) + Create(ctx context.Context, Orchestration *v1beta1.Orchestration) (*v1beta1.Orchestration, error) + Update(ctx context.Context, Orchestration *v1beta1.Orchestration) (*v1beta1.Orchestration, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Delete(ctx context.Context, name string) error +} + +type OrchestrationClient struct { + restClient rest.Interface +} + +func (c *OrchestrationClient) List(ctx context.Context, opts metav1.ListOptions) (*v1beta1.OrchestrationList, error) { + result := v1beta1.OrchestrationList{} + err := c.restClient. + Get(). + Resource("Orchestrations"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *OrchestrationClient) Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1beta1.Orchestration, error) { + result := v1beta1.Orchestration{} + err := c.restClient. + Get(). + Resource("Orchestrations"). + Name(name). + VersionedParams(&opts, scheme.ParameterCodec). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *OrchestrationClient) Create(ctx context.Context, Orchestration *v1beta1.Orchestration) (*v1beta1.Orchestration, error) { + result := v1beta1.Orchestration{} + err := c.restClient. + Post(). + Resource("Orchestrations"). + Body(Orchestration). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *OrchestrationClient) Delete(ctx context.Context, name string) error { + return c.restClient. + Delete(). + Resource("Orchestrations"). + Name(name). + Do(ctx). + Error() +} + +func (c *OrchestrationClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.restClient. + Get(). + Resource("Orchestrations"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch(ctx) +} + +func (c *OrchestrationClient) Update(ctx context.Context, o *v1beta1.Orchestration) (*v1beta1.Orchestration, error) { + result := v1beta1.Orchestration{} + err := c.restClient. + Put(). + Resource("Orchestrations"). + Name(o.Name). + Body(o). + Do(ctx). + Into(&result) + + return &result, err +} diff --git a/components/operatorv2/pkg/v1beta1/payments.go b/components/operatorv2/pkg/v1beta1/payments.go new file mode 100644 index 0000000000..21cf2be412 --- /dev/null +++ b/components/operatorv2/pkg/v1beta1/payments.go @@ -0,0 +1,92 @@ +package v1beta1 + +import ( + "context" + "github.com/formancehq/operator/v2/api/v1beta1" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/rest" +) + +type PaymentsInterface interface { + List(ctx context.Context, opts metav1.ListOptions) (*v1beta1.PaymentsList, error) + Get(ctx context.Context, name string, options metav1.GetOptions) (*v1beta1.Payments, error) + Create(ctx context.Context, Payments *v1beta1.Payments) (*v1beta1.Payments, error) + Update(ctx context.Context, Payments *v1beta1.Payments) (*v1beta1.Payments, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Delete(ctx context.Context, name string) error +} + +type paymentsClient struct { + restClient rest.Interface +} + +func (c *paymentsClient) List(ctx context.Context, opts metav1.ListOptions) (*v1beta1.PaymentsList, error) { + result := v1beta1.PaymentsList{} + err := c.restClient. + Get(). + Resource("Payments"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *paymentsClient) Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1beta1.Payments, error) { + result := v1beta1.Payments{} + err := c.restClient. + Get(). + Resource("Payments"). + Name(name). + VersionedParams(&opts, scheme.ParameterCodec). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *paymentsClient) Create(ctx context.Context, Payments *v1beta1.Payments) (*v1beta1.Payments, error) { + result := v1beta1.Payments{} + err := c.restClient. + Post(). + Resource("Payments"). + Body(Payments). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *paymentsClient) Delete(ctx context.Context, name string) error { + return c.restClient. + Delete(). + Resource("Payments"). + Name(name). + Do(ctx). + Error() +} + +func (c *paymentsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.restClient. + Get(). + Resource("Payments"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch(ctx) +} + +func (c *paymentsClient) Update(ctx context.Context, o *v1beta1.Payments) (*v1beta1.Payments, error) { + result := v1beta1.Payments{} + err := c.restClient. + Put(). + Resource("Payments"). + Name(o.Name). + Body(o). + Do(ctx). + Into(&result) + + return &result, err +} diff --git a/components/operatorv2/pkg/v1beta1/reconciliation.go b/components/operatorv2/pkg/v1beta1/reconciliation.go new file mode 100644 index 0000000000..f8e5690513 --- /dev/null +++ b/components/operatorv2/pkg/v1beta1/reconciliation.go @@ -0,0 +1,92 @@ +package v1beta1 + +import ( + "context" + "github.com/formancehq/operator/v2/api/v1beta1" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/rest" +) + +type ReconciliationInterface interface { + List(ctx context.Context, opts metav1.ListOptions) (*v1beta1.ReconciliationList, error) + Get(ctx context.Context, name string, options metav1.GetOptions) (*v1beta1.Reconciliation, error) + Create(ctx context.Context, Reconciliation *v1beta1.Reconciliation) (*v1beta1.Reconciliation, error) + Update(ctx context.Context, Reconciliation *v1beta1.Reconciliation) (*v1beta1.Reconciliation, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Delete(ctx context.Context, name string) error +} + +type reconciliationClient struct { + restClient rest.Interface +} + +func (c *reconciliationClient) List(ctx context.Context, opts metav1.ListOptions) (*v1beta1.ReconciliationList, error) { + result := v1beta1.ReconciliationList{} + err := c.restClient. + Get(). + Resource("Reconciliations"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *reconciliationClient) Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1beta1.Reconciliation, error) { + result := v1beta1.Reconciliation{} + err := c.restClient. + Get(). + Resource("Reconciliations"). + Name(name). + VersionedParams(&opts, scheme.ParameterCodec). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *reconciliationClient) Create(ctx context.Context, Reconciliation *v1beta1.Reconciliation) (*v1beta1.Reconciliation, error) { + result := v1beta1.Reconciliation{} + err := c.restClient. + Post(). + Resource("Reconciliations"). + Body(Reconciliation). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *reconciliationClient) Delete(ctx context.Context, name string) error { + return c.restClient. + Delete(). + Resource("Reconciliations"). + Name(name). + Do(ctx). + Error() +} + +func (c *reconciliationClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.restClient. + Get(). + Resource("Reconciliations"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch(ctx) +} + +func (c *reconciliationClient) Update(ctx context.Context, o *v1beta1.Reconciliation) (*v1beta1.Reconciliation, error) { + result := v1beta1.Reconciliation{} + err := c.restClient. + Put(). + Resource("Reconciliations"). + Name(o.Name). + Body(o). + Do(ctx). + Into(&result) + + return &result, err +} diff --git a/components/operatorv2/pkg/v1beta1/search.go b/components/operatorv2/pkg/v1beta1/search.go new file mode 100644 index 0000000000..9bc4d10a71 --- /dev/null +++ b/components/operatorv2/pkg/v1beta1/search.go @@ -0,0 +1,92 @@ +package v1beta1 + +import ( + "context" + "github.com/formancehq/operator/v2/api/v1beta1" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/rest" +) + +type SearchInterface interface { + List(ctx context.Context, opts metav1.ListOptions) (*v1beta1.SearchList, error) + Get(ctx context.Context, name string, options metav1.GetOptions) (*v1beta1.Search, error) + Create(ctx context.Context, Search *v1beta1.Search) (*v1beta1.Search, error) + Update(ctx context.Context, Search *v1beta1.Search) (*v1beta1.Search, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Delete(ctx context.Context, name string) error +} + +type SearchClient struct { + restClient rest.Interface +} + +func (c *SearchClient) List(ctx context.Context, opts metav1.ListOptions) (*v1beta1.SearchList, error) { + result := v1beta1.SearchList{} + err := c.restClient. + Get(). + Resource("Searchs"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *SearchClient) Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1beta1.Search, error) { + result := v1beta1.Search{} + err := c.restClient. + Get(). + Resource("Searchs"). + Name(name). + VersionedParams(&opts, scheme.ParameterCodec). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *SearchClient) Create(ctx context.Context, Search *v1beta1.Search) (*v1beta1.Search, error) { + result := v1beta1.Search{} + err := c.restClient. + Post(). + Resource("Searchs"). + Body(Search). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *SearchClient) Delete(ctx context.Context, name string) error { + return c.restClient. + Delete(). + Resource("Searchs"). + Name(name). + Do(ctx). + Error() +} + +func (c *SearchClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.restClient. + Get(). + Resource("Searchs"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch(ctx) +} + +func (c *SearchClient) Update(ctx context.Context, o *v1beta1.Search) (*v1beta1.Search, error) { + result := v1beta1.Search{} + err := c.restClient. + Put(). + Resource("Searchs"). + Name(o.Name). + Body(o). + Do(ctx). + Into(&result) + + return &result, err +} diff --git a/components/operatorv2/pkg/v1beta1/stack.go b/components/operatorv2/pkg/v1beta1/stack.go new file mode 100644 index 0000000000..b3e6cddc42 --- /dev/null +++ b/components/operatorv2/pkg/v1beta1/stack.go @@ -0,0 +1,92 @@ +package v1beta1 + +import ( + "context" + "github.com/formancehq/operator/v2/api/v1beta1" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/rest" +) + +type StackInterface interface { + List(ctx context.Context, opts metav1.ListOptions) (*v1beta1.StackList, error) + Get(ctx context.Context, name string, options metav1.GetOptions) (*v1beta1.Stack, error) + Create(ctx context.Context, stack *v1beta1.Stack) (*v1beta1.Stack, error) + Update(ctx context.Context, stack *v1beta1.Stack) (*v1beta1.Stack, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Delete(ctx context.Context, name string) error +} + +type stackClient struct { + restClient rest.Interface +} + +func (c *stackClient) List(ctx context.Context, opts metav1.ListOptions) (*v1beta1.StackList, error) { + result := v1beta1.StackList{} + err := c.restClient. + Get(). + Resource("stacks"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *stackClient) Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1beta1.Stack, error) { + result := v1beta1.Stack{} + err := c.restClient. + Get(). + Resource("stacks"). + Name(name). + VersionedParams(&opts, scheme.ParameterCodec). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *stackClient) Create(ctx context.Context, stack *v1beta1.Stack) (*v1beta1.Stack, error) { + result := v1beta1.Stack{} + err := c.restClient. + Post(). + Resource("stacks"). + Body(stack). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *stackClient) Delete(ctx context.Context, name string) error { + return c.restClient. + Delete(). + Resource("stacks"). + Name(name). + Do(ctx). + Error() +} + +func (c *stackClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.restClient. + Get(). + Resource("stacks"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch(ctx) +} + +func (c *stackClient) Update(ctx context.Context, o *v1beta1.Stack) (*v1beta1.Stack, error) { + result := v1beta1.Stack{} + err := c.restClient. + Put(). + Resource("stacks"). + Name(o.Name). + Body(o). + Do(ctx). + Into(&result) + + return &result, err +} diff --git a/components/operatorv2/pkg/v1beta1/wallets.go b/components/operatorv2/pkg/v1beta1/wallets.go new file mode 100644 index 0000000000..5ef4c9ce89 --- /dev/null +++ b/components/operatorv2/pkg/v1beta1/wallets.go @@ -0,0 +1,92 @@ +package v1beta1 + +import ( + "context" + "github.com/formancehq/operator/v2/api/v1beta1" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/rest" +) + +type WalletsInterface interface { + List(ctx context.Context, opts metav1.ListOptions) (*v1beta1.WalletsList, error) + Get(ctx context.Context, name string, options metav1.GetOptions) (*v1beta1.Wallets, error) + Create(ctx context.Context, Wallets *v1beta1.Wallets) (*v1beta1.Wallets, error) + Update(ctx context.Context, Wallets *v1beta1.Wallets) (*v1beta1.Wallets, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Delete(ctx context.Context, name string) error +} + +type walletsClient struct { + restClient rest.Interface +} + +func (c *walletsClient) List(ctx context.Context, opts metav1.ListOptions) (*v1beta1.WalletsList, error) { + result := v1beta1.WalletsList{} + err := c.restClient. + Get(). + Resource("Wallets"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *walletsClient) Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1beta1.Wallets, error) { + result := v1beta1.Wallets{} + err := c.restClient. + Get(). + Resource("Wallets"). + Name(name). + VersionedParams(&opts, scheme.ParameterCodec). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *walletsClient) Create(ctx context.Context, Wallets *v1beta1.Wallets) (*v1beta1.Wallets, error) { + result := v1beta1.Wallets{} + err := c.restClient. + Post(). + Resource("Wallets"). + Body(Wallets). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *walletsClient) Delete(ctx context.Context, name string) error { + return c.restClient. + Delete(). + Resource("Wallets"). + Name(name). + Do(ctx). + Error() +} + +func (c *walletsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.restClient. + Get(). + Resource("Wallets"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch(ctx) +} + +func (c *walletsClient) Update(ctx context.Context, o *v1beta1.Wallets) (*v1beta1.Wallets, error) { + result := v1beta1.Wallets{} + err := c.restClient. + Put(). + Resource("Wallets"). + Name(o.Name). + Body(o). + Do(ctx). + Into(&result) + + return &result, err +} diff --git a/components/operatorv2/pkg/v1beta1/webhooks.go b/components/operatorv2/pkg/v1beta1/webhooks.go new file mode 100644 index 0000000000..7f913639cf --- /dev/null +++ b/components/operatorv2/pkg/v1beta1/webhooks.go @@ -0,0 +1,92 @@ +package v1beta1 + +import ( + "context" + "github.com/formancehq/operator/v2/api/v1beta1" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/rest" +) + +type WebhooksInterface interface { + List(ctx context.Context, opts metav1.ListOptions) (*v1beta1.WebhooksList, error) + Get(ctx context.Context, name string, options metav1.GetOptions) (*v1beta1.Webhooks, error) + Create(ctx context.Context, Webhooks *v1beta1.Webhooks) (*v1beta1.Webhooks, error) + Update(ctx context.Context, Webhooks *v1beta1.Webhooks) (*v1beta1.Webhooks, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Delete(ctx context.Context, name string) error +} + +type webhooksClient struct { + restClient rest.Interface +} + +func (c *webhooksClient) List(ctx context.Context, opts metav1.ListOptions) (*v1beta1.WebhooksList, error) { + result := v1beta1.WebhooksList{} + err := c.restClient. + Get(). + Resource("Webhooks"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *webhooksClient) Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1beta1.Webhooks, error) { + result := v1beta1.Webhooks{} + err := c.restClient. + Get(). + Resource("Webhooks"). + Name(name). + VersionedParams(&opts, scheme.ParameterCodec). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *webhooksClient) Create(ctx context.Context, Webhooks *v1beta1.Webhooks) (*v1beta1.Webhooks, error) { + result := v1beta1.Webhooks{} + err := c.restClient. + Post(). + Resource("Webhooks"). + Body(Webhooks). + Do(ctx). + Into(&result) + + return &result, err +} + +func (c *webhooksClient) Delete(ctx context.Context, name string) error { + return c.restClient. + Delete(). + Resource("Webhooks"). + Name(name). + Do(ctx). + Error() +} + +func (c *webhooksClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.restClient. + Get(). + Resource("Webhooks"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch(ctx) +} + +func (c *webhooksClient) Update(ctx context.Context, o *v1beta1.Webhooks) (*v1beta1.Webhooks, error) { + result := v1beta1.Webhooks{} + err := c.restClient. + Put(). + Resource("Webhooks"). + Name(o.Name). + Body(o). + Do(ctx). + Into(&result) + + return &result, err +}