Skip to content

Commit

Permalink
reorder functions
Browse files Browse the repository at this point in the history
Signed-off-by: Giovanni Liva <giovanni.liva@dynatrace.com>
  • Loading branch information
thisthat committed Mar 8, 2023
1 parent f919d00 commit e2cdfca
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions pkg/sync/kubernetes/kubernetes_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,40 @@ type Sync struct {
informer cache.SharedInformer
}

func NewK8sSync(
logger *logger.Logger,
uri string,
providerArgs sync.ProviderArgs,
reader client.Reader,
dynamic dynamic.Interface,
) *Sync {
return &Sync{
logger: logger,
URI: uri,
providerArgs: providerArgs,
readClient: reader,
dynamicClient: dynamic,
}
}

func GetClients() (client.Reader, dynamic.Interface, error) {
clusterConfig, err := k8sClusterConfig()
if err != nil {
return nil, nil, err
}

readClient, err := client.New(clusterConfig, client.Options{Scheme: scheme.Scheme})
if err != nil {
return nil, nil, err
}

dynamicClient, err := dynamic.NewForConfig(clusterConfig)
if err != nil {
return nil, nil, err
}
return readClient, dynamicClient, nil
}

func (k *Sync) ReSync(ctx context.Context, dataSync chan<- sync.DataSync) error {
fetch, err := k.fetch(ctx)
if err != nil {
Expand Down Expand Up @@ -311,37 +345,3 @@ func k8sClusterConfig() (*rest.Config, error) {

return clusterConfig, nil
}

func NewK8sSync(
logger *logger.Logger,
uri string,
providerArgs sync.ProviderArgs,
reader client.Reader,
dynamic dynamic.Interface,
) *Sync {
return &Sync{
logger: logger,
URI: uri,
providerArgs: providerArgs,
readClient: reader,
dynamicClient: dynamic,
}
}

func GetClients() (client.Reader, dynamic.Interface, error) {
clusterConfig, err := k8sClusterConfig()
if err != nil {
return nil, nil, err
}

readClient, err := client.New(clusterConfig, client.Options{Scheme: scheme.Scheme})
if err != nil {
return nil, nil, err
}

dynamicClient, err := dynamic.NewForConfig(clusterConfig)
if err != nil {
return nil, nil, err
}
return readClient, dynamicClient, nil
}

0 comments on commit e2cdfca

Please sign in to comment.