Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fixing informer issues #191

Merged
merged 13 commits into from
Oct 13, 2022
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ github.com/bufbuild/connect-go v0.5.0 h1:JFbWPWpasBqzM5h/awoRhAXmLERZQlQ5xTn42uf
github.com/bufbuild/connect-go v0.5.0/go.mod h1:ZEtBnQ7J/m7bvWOW+H8T/+hKQCzPVfhhhICuvtcnjlI=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
Expand Down
149 changes: 0 additions & 149 deletions pkg/sync/kubernetes/featureflagconfiguration/clientset.go

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package featureflagconfiguration
package kubernetes

import (
"context"
"errors"

"github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
ffv1alpha1 "github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
)

const (
featureFlagConfigurationName = "featureflagconfigurations"
)

type Interface interface {
AlexsJones marked this conversation as resolved.
Show resolved Hide resolved
List(opts metav1.ListOptions) (*v1alpha1.FeatureFlagConfigurationList, error)
Get(name string, options metav1.GetOptions) (*v1alpha1.FeatureFlagConfiguration, error)
Expand All @@ -26,6 +26,14 @@ type FeatureFlagClient struct {
ns string
}

type FFCInterface interface {
FeatureFlagConfigurations(namespace string) Interface
AlexsJones marked this conversation as resolved.
Show resolved Hide resolved
}

type FFCClient struct {
restClient rest.Interface
}

func (c *FeatureFlagClient) List(opts metav1.ListOptions) (*v1alpha1.FeatureFlagConfigurationList, error) {
result := v1alpha1.FeatureFlagConfigurationList{}
err := c.restClient.
Expand Down Expand Up @@ -75,3 +83,30 @@ func (c *FeatureFlagClient) Watch(opts metav1.ListOptions) (watch.Interface, err
VersionedParams(&opts, scheme.ParameterCodec).
Watch(context.Background())
}

func NewForConfig(config *rest.Config) (*FFCClient, error) {
if config == nil {
return nil, errors.New("rest config is nil")
}
config.ContentConfig.GroupVersion = &schema.
GroupVersion{
Group: ffv1alpha1.GroupVersion.Group,
Version: ffv1alpha1.GroupVersion.Version,
}
config.APIPath = "/apis"
config.UserAgent = rest.DefaultKubernetesUserAgent()
config.NegotiatedSerializer = serializer.NewCodecFactory(scheme.Scheme)
client, err := rest.RESTClientFor(config)
if err != nil {
return nil, err
}

return &FFCClient{restClient: client}, nil
}

func (c *FFCClient) FeatureFlagConfigurations(namespace string) Interface {
return &FeatureFlagClient{
restClient: c.restClient,
ns: namespace,
}
}
Loading