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

v1 -> v1alpha #20

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ projectName: conduit-operator
repo: github.com/conduitio/conduit-operator
resources:
- api:
crdVersion: v1
crdVersion: v1alpha
namespaced: true
controller: true
domain: conduit.io
group: operator
kind: Conduit
path: github.com/conduitio/conduit-operator/api/v1
path: github.com/conduitio/conduit-operator/api/v1alpha
version: v1
webhooks:
defaulting: true
validation: true
webhookVersion: v1
webhookVersion: v1alpha
version: "3"
2 changes: 1 addition & 1 deletion api/v1/condition.go → api/v1alpha/condition.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1
package v1alpha

import (
"sort"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1
package v1alpha

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion api/v1/conduit_types.go → api/v1alpha/conduit_types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1
package v1alpha

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1
package v1alpha

import (
"github.com/conduitio/conduit-operator/pkg/conduit"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1
package v1alpha

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Package v1 contains API Schema definitions for the operator v1 API group
// +kubebuilder:object:generate=true
// +groupName=operator.conduit.io
package v1
package v1alpha

import (
"k8s.io/apimachinery/pkg/runtime/schema"
Expand All @@ -10,7 +10,7 @@ import (

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "operator.conduit.io", Version: "v1"}
GroupVersion = schema.GroupVersion{Group: "operator.conduit.io", Version: "v1alpha"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion charts/conduit-operator/templates/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
singular: conduit
scope: Namespaced
versions:
- name: v1
- name: v1alpha
schema:
openAPIV3Schema:
description: Conduit is the Schema for the conduits API
Expand Down
10 changes: 5 additions & 5 deletions cmd/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"

v1 "github.com/conduitio/conduit-operator/api/v1"
v1alpha "github.com/conduitio/conduit-operator/api/v1alpha"
"github.com/conduitio/conduit-operator/controllers"
//+kubebuilder:scaffold:imports
)
Expand All @@ -30,7 +30,7 @@ var (

func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(v1.AddToScheme(scheme))
utilruntime.Must(v1alpha.AddToScheme(scheme))
//+kubebuilder:scaffold:scheme
}

Expand Down Expand Up @@ -87,7 +87,7 @@ func main() {
}).SetupWithManager(mgr); err != nil {
fatal(err, "unable to create controller", "controller", "Conduit")
}
if err = (&v1.Conduit{}).SetupWebhookWithManager(mgr); err != nil {
if err = (&v1alpha.Conduit{}).SetupWebhookWithManager(mgr); err != nil {
fatal(err, "unable to create webhook", "webhook", "Conduit")
}
//+kubebuilder:scaffold:builder
Expand All @@ -110,8 +110,8 @@ func fatal(err error, msg string, kv ...any) {
os.Exit(1)
}

func readMetadata(file string) (*v1.ConduitInstanceMetadata, error) {
c := v1.ConduitInstanceMetadata{
func readMetadata(file string) (*v1alpha.ConduitInstanceMetadata, error) {
c := v1alpha.ConduitInstanceMetadata{
PodAnnotations: make(map[string]string),
Labels: make(map[string]string),
}
Expand Down
2 changes: 1 addition & 1 deletion config/crd/bases/operator.conduit.io_conduits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
singular: conduit
scope: Namespaced
versions:
- name: v1
- name: v1alpha
schema:
openAPIV3Schema:
description: Conduit is the Schema for the conduits API
Expand Down
14 changes: 7 additions & 7 deletions controllers/conduit_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"sigs.k8s.io/controller-runtime/pkg/client"

v1 "github.com/conduitio/conduit-operator/api/v1"
v1alpha "github.com/conduitio/conduit-operator/api/v1alpha"
cyaml "github.com/conduitio/conduit/pkg/provisioning/config/yaml/v2"
"github.com/conduitio/yaml/v3"
corev1 "k8s.io/api/core/v1"
Expand All @@ -18,7 +18,7 @@ const pipelineConfigVersion = "2.0"

// PipelineConfigYAML produces a conduit pipeline configuration in YAML.
// Invalid configuration will result in a marshalling error.
func PipelineConfigYAML(ctx context.Context, client client.Client, conduit *v1.Conduit) (string, error) {
func PipelineConfigYAML(ctx context.Context, client client.Client, conduit *v1alpha.Conduit) (string, error) {
var (
spec = conduit.Spec
pipelineStatus = "stopped"
Expand Down Expand Up @@ -70,7 +70,7 @@ func PipelineConfigYAML(ctx context.Context, client client.Client, conduit *v1.C

// EnvVars returns a slice of EnvVar with all connector settings.
// Only secrets are put into environment variables.
func EnvVars(c *v1.Conduit) []corev1.EnvVar {
func EnvVars(c *v1alpha.Conduit) []corev1.EnvVar {
var envVars []corev1.EnvVar
for _, cc := range c.Spec.Connectors {
for _, v := range cc.Settings {
Expand All @@ -92,7 +92,7 @@ func EnvVars(c *v1.Conduit) []corev1.EnvVar {

// settingsWithEnvVars converts settings to a map, every secret key
// reference is converted to env var reference.
func settingsWithEnvVars(ctx context.Context, client client.Client, s []v1.SettingsVar) (map[string]string, error) {
func settingsWithEnvVars(ctx context.Context, client client.Client, s []v1alpha.SettingsVar) (map[string]string, error) {
settings := make(map[string]string)
for _, v := range s {
switch {
Expand All @@ -112,7 +112,7 @@ func settingsWithEnvVars(ctx context.Context, client client.Client, s []v1.Setti
return settings, nil
}

func configMapValue(ctx context.Context, cl client.Client, ref *v1.GlobalConfigMapRef) (string, error) {
func configMapValue(ctx context.Context, cl client.Client, ref *v1alpha.GlobalConfigMapRef) (string, error) {
configMap := &corev1.ConfigMap{}

// Fetch the ConfigMap using the client's Get method
Expand Down Expand Up @@ -146,7 +146,7 @@ func envVarName(s string) string {
// connectorConfig returns a conduit connector config which is created
// from a connector resource settings. Settings which refer to a secret are
// converted to env variables.
func connectorConfig(ctx context.Context, cl client.Client, c *v1.ConduitConnector) (cyaml.Connector, error) {
func connectorConfig(ctx context.Context, cl client.Client, c *v1alpha.ConduitConnector) (cyaml.Connector, error) {
var processors []cyaml.Processor
for _, p := range c.Processors {
procCfg, err := processorConfig(ctx, cl, p)
Expand All @@ -173,7 +173,7 @@ func connectorConfig(ctx context.Context, cl client.Client, c *v1.ConduitConnect
}, nil
}

func processorConfig(ctx context.Context, cl client.Client, p *v1.ConduitProcessor) (cyaml.Processor, error) {
func processorConfig(ctx context.Context, cl client.Client, p *v1alpha.ConduitProcessor) (cyaml.Processor, error) {
settings, err := settingsWithEnvVars(ctx, cl, p.Settings)
if err != nil {
return cyaml.Processor{}, fmt.Errorf("failed getting settings for processor %v: %w", p.Name, err)
Expand Down
4 changes: 2 additions & 2 deletions controllers/conduit_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/google/go-cmp/cmp"
corev1 "k8s.io/api/core/v1"

v1 "github.com/conduitio/conduit-operator/api/v1"
v1alpha "github.com/conduitio/conduit-operator/api/v1alpha"
ctrls "github.com/conduitio/conduit-operator/controllers"
)

Expand Down Expand Up @@ -49,7 +49,7 @@ func Test_EnvVars(t *testing.T) {
func Test_PipelineConfigYAML(t *testing.T) {
tests := []struct {
name string
conduit *v1.Conduit
conduit *v1alpha.Conduit
want string
}{
{
Expand Down
42 changes: 21 additions & 21 deletions controllers/conduit_containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"sync"

v1 "github.com/conduitio/conduit-operator/api/v1"
v1alpha "github.com/conduitio/conduit-operator/api/v1alpha"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)
Expand Down Expand Up @@ -74,22 +74,22 @@ func (c *commandBuilder) addConnectorBuild(b connectorBuild) {
}

// ConduitInitContainers returns a slice of kubernetes container definitions
func ConduitInitContainers(cc []*v1.ConduitConnector) []corev1.Container {
func ConduitInitContainers(cc []*v1alpha.ConduitConnector) []corev1.Container {
builder := &commandBuilder{}

containers := []corev1.Container{
{
Name: v1.ConduitInitContainerName,
Image: v1.ConduitInitImage,
Name: v1alpha.ConduitInitContainerName,
Image: v1alpha.ConduitInitImage,
ImagePullPolicy: corev1.PullIfNotPresent,
Args: []string{
"sh", "-xe", "-c",
fmt.Sprintf("mkdir -p %s %s", v1.ConduitProcessorsPath, v1.ConduitConnectorsPath),
fmt.Sprintf("mkdir -p %s %s", v1alpha.ConduitProcessorsPath, v1alpha.ConduitConnectorsPath),
},
VolumeMounts: []corev1.VolumeMount{
{
Name: v1.ConduitStorageVolumeMount,
MountPath: v1.ConduitVolumePath,
Name: v1alpha.ConduitStorageVolumeMount,
MountPath: v1alpha.ConduitVolumePath,
},
},
},
Expand All @@ -103,24 +103,24 @@ func ConduitInitContainers(cc []*v1.ConduitConnector) []corev1.Container {
name: fmt.Sprintf("%s-%s", filepath.Base(c.Plugin), c.PluginVersion),
goPkg: c.PluginPkg,
tmpDir: builderTempPath,
targetDir: v1.ConduitConnectorsPath,
targetDir: v1alpha.ConduitConnectorsPath,
ldflags: fmt.Sprintf(`-ldflags "-X 'github.com/%s.version=%s'"`, c.Plugin, c.PluginVersion),
})
}

if !builder.empty() {
containers = append(containers, corev1.Container{
Name: fmt.Sprint(v1.ConduitInitContainerName, "-connectors"),
Image: v1.ConduitInitImage,
Name: fmt.Sprint(v1alpha.ConduitInitContainerName, "-connectors"),
Image: v1alpha.ConduitInitImage,
ImagePullPolicy: corev1.PullIfNotPresent,
Args: []string{
"sh", "-xe",
"-c", builder.renderScript(),
},
VolumeMounts: []corev1.VolumeMount{
{
Name: v1.ConduitStorageVolumeMount,
MountPath: v1.ConduitVolumePath,
Name: v1alpha.ConduitStorageVolumeMount,
MountPath: v1alpha.ConduitVolumePath,
},
},
})
Expand All @@ -134,19 +134,19 @@ func ConduitInitContainers(cc []*v1.ConduitConnector) []corev1.Container {
func ConduitRuntimeContainer(image, version string, envVars []corev1.EnvVar) corev1.Container {
args := []string{
"/app/conduit",
"-pipelines.path", v1.ConduitPipelineFile,
"-connectors.path", v1.ConduitConnectorsPath,
"-pipelines.path", v1alpha.ConduitPipelineFile,
"-connectors.path", v1alpha.ConduitConnectorsPath,
"-db.type", "badger",
"-db.badger.path", v1.ConduitDBPath,
"-db.badger.path", v1alpha.ConduitDBPath,
"-pipelines.exit-on-error",
}

if withProcessors(version) {
args = append(args, "-processors.path", v1.ConduitProcessorsPath)
args = append(args, "-processors.path", v1alpha.ConduitProcessorsPath)
}

return corev1.Container{
Name: v1.ConduitContainerName,
Name: v1alpha.ConduitContainerName,
Image: fmt.Sprint(image, ":", version),
ImagePullPolicy: corev1.PullAlways,
Args: args,
Expand Down Expand Up @@ -177,12 +177,12 @@ func ConduitRuntimeContainer(image, version string, envVars []corev1.EnvVar) cor
},
VolumeMounts: []corev1.VolumeMount{
{
Name: v1.ConduitStorageVolumeMount,
MountPath: v1.ConduitVolumePath,
Name: v1alpha.ConduitStorageVolumeMount,
MountPath: v1alpha.ConduitVolumePath,
},
{
Name: v1.ConduitPipelineVolumeMount,
MountPath: v1.ConduitPipelinePath,
Name: v1alpha.ConduitPipelineVolumeMount,
MountPath: v1alpha.ConduitPipelinePath,
ReadOnly: true,
},
},
Expand Down
14 changes: 7 additions & 7 deletions controllers/conduit_containers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/intstr"

v1 "github.com/conduitio/conduit-operator/api/v1"
v1alpha "github.com/conduitio/conduit-operator/api/v1alpha"
ctrls "github.com/conduitio/conduit-operator/controllers"
)

Expand All @@ -26,13 +26,13 @@ func Test_ConduitInitContainers(t *testing.T) {

tests := []struct {
name string
connectors []*v1.ConduitConnector
connectors []*v1alpha.ConduitConnector
imageVer string
want []corev1.Container
}{
{
name: "only builtin connectors",
connectors: []*v1.ConduitConnector{
connectors: []*v1alpha.ConduitConnector{
{
Plugin: "builtin:builtin-test",
PluginVersion: "latest",
Expand All @@ -42,7 +42,7 @@ func Test_ConduitInitContainers(t *testing.T) {
},
{
name: "with latest standalone connector",
connectors: []*v1.ConduitConnector{
connectors: []*v1alpha.ConduitConnector{
{
Plugin: "builtin:builtin-test",
PluginVersion: "latest",
Expand Down Expand Up @@ -74,7 +74,7 @@ func Test_ConduitInitContainers(t *testing.T) {
},
{
name: "with version standalone connector",
connectors: []*v1.ConduitConnector{
connectors: []*v1alpha.ConduitConnector{
{
Plugin: "builtin:builtin-test",
PluginVersion: "latest",
Expand Down Expand Up @@ -106,7 +106,7 @@ func Test_ConduitInitContainers(t *testing.T) {
},
{
name: "with multiple standalone connector",
connectors: []*v1.ConduitConnector{
connectors: []*v1alpha.ConduitConnector{
{
Plugin: "builtin:builtin-test",
PluginVersion: "latest",
Expand Down Expand Up @@ -143,7 +143,7 @@ func Test_ConduitInitContainers(t *testing.T) {
},
{
name: "with duplicate standalone connector",
connectors: []*v1.ConduitConnector{
connectors: []*v1alpha.ConduitConnector{
{
Plugin: "builtin:builtin-test",
PluginVersion: "latest",
Expand Down
Loading