-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Nicolas Bigler <[email protected]>
- Loading branch information
Showing
30 changed files
with
313 additions
and
266 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package common | ||
|
||
import ( | ||
exoscalesdk "github.com/exoscale/egoscale/v3" | ||
exoscalev1 "github.com/vshn/provider-exoscale/apis/exoscale/v1" | ||
) | ||
|
||
var ( | ||
ZoneTranslation = map[exoscalev1.Zone]exoscalesdk.Endpoint{ | ||
"CH-DK-2": exoscalesdk.CHDk2, | ||
"CH-GVA-2": exoscalesdk.CHGva2, | ||
"DE-FRA-1": exoscalesdk.DEFra1, | ||
"DE-MUC-1": exoscalesdk.DEMuc1, | ||
"AT-VIE-1": exoscalesdk.ATVie1, | ||
"AT-VIE-2": exoscalesdk.ATVie2, | ||
"BG-SOF-1": exoscalesdk.BGSof1, | ||
"ch-dk-2": exoscalesdk.CHDk2, | ||
"ch-gva-2": exoscalesdk.CHGva2, | ||
"de-fra-1": exoscalesdk.DEFra1, | ||
"de-muc-1": exoscalesdk.DEMuc1, | ||
"at-vie-1": exoscalesdk.ATVie1, | ||
"at-vie-2": exoscalesdk.ATVie2, | ||
"bg-sof-1": exoscalesdk.BGSof1, | ||
} | ||
) |
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,39 @@ | ||
package kafkacontroller | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/crossplane/crossplane-runtime/pkg/event" | ||
"github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" | ||
"github.com/crossplane/crossplane-runtime/pkg/resource" | ||
exoscalesdk "github.com/exoscale/egoscale/v3" | ||
exoscalev1 "github.com/vshn/provider-exoscale/apis/exoscale/v1" | ||
"github.com/vshn/provider-exoscale/operator/common" | ||
"github.com/vshn/provider-exoscale/operator/pipelineutil" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
type connector struct { | ||
Kube client.Client | ||
Recorder event.Recorder | ||
} | ||
|
||
// Connect to the exoscale kafka provider. | ||
func (c *connector) Connect(ctx context.Context, mg resource.Managed) (managed.ExternalClient, error) { | ||
log := ctrl.LoggerFrom(ctx) | ||
log.V(1).Info("connecting resource") | ||
|
||
kafkaInstance, ok := mg.(*exoscalev1.Kafka) | ||
if !ok { | ||
return nil, fmt.Errorf("invalid managed resource type %T for kafka connector", mg) | ||
} | ||
|
||
exo, err := pipelineutil.OpenExoscaleClient(ctx, c.Kube, kafkaInstance.GetProviderConfigName(), exoscalesdk.ClientOptWithEndpoint(common.ZoneTranslation[kafkaInstance.Spec.ForProvider.Zone])) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return newPipeline(c.Kube, c.Recorder, exo.Exoscale), nil | ||
|
||
} |
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
Oops, something went wrong.