Skip to content

Commit

Permalink
Change the v1alpha2 package to v1beta1 (#2641)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavolloffay authored Feb 16, 2024
1 parent 97c5121 commit 569871e
Show file tree
Hide file tree
Showing 69 changed files with 542 additions and 542 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha2
package v1beta1

type (
// TargetAllocatorAllocationStrategy represent a strategy Target Allocator uses to distribute targets to each collector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha2
package v1beta1

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha2
package v1beta1

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion apis/v1alpha2/common.go → apis/v1beta1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha2
package v1beta1

import (
autoscalingv2 "k8s.io/api/autoscaling/v2"
Expand Down
2 changes: 1 addition & 1 deletion apis/v1alpha2/config.go → apis/v1beta1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha2
package v1beta1

import (
"bytes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha2
package v1beta1

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Package v1alpha2 contains API Schema definitions for the v1alpha2 API group
// Package v1beta1 contains API Schema definitions for the v1beta1 API group
// +kubebuilder:object:generate=true
// +groupName=opentelemetry.io
package v1alpha2
package v1beta1

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

var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "opentelemetry.io", Version: "v1alpha2"}
GroupVersion = schema.GroupVersion{Group: "opentelemetry.io", Version: "v1beta1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha2
package v1beta1

type (
// IngressType represents how a collector should be exposed (ingress vs route).
Expand Down
2 changes: 1 addition & 1 deletion apis/v1alpha2/mode.go → apis/v1beta1/mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha2
package v1beta1

type (
// Mode represents how the collector should be deployed (deployment vs. daemonset)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// +kubebuilder:skip

package v1alpha2
package v1beta1

import (
appsv1 "k8s.io/api/apps/v1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// +kubebuilder:skip

package v1alpha2
package v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha2
package v1beta1

type (
// UpgradeStrategy represents how the operator will handle upgrades to the CR when a newer version of the operator is deployed
Expand Down

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

52 changes: 26 additions & 26 deletions controllers/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
colfeaturegate "go.opentelemetry.io/collector/featuregate"

"github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1"
"github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2"
"github.com/open-telemetry/opentelemetry-operator/apis/v1beta1"
"github.com/open-telemetry/opentelemetry-operator/internal/config"
"github.com/open-telemetry/opentelemetry-operator/internal/manifests"
"github.com/open-telemetry/opentelemetry-operator/pkg/featuregate"
Expand Down Expand Up @@ -87,12 +87,12 @@ service:
exporters: [logging]
`

goodConfig := v1alpha2.Config{}
goodConfig := v1beta1.Config{}
err := go_yaml.Unmarshal([]byte(goodConfigYaml), &goodConfig)
require.NoError(t, err)
one := int32(1)
type args struct {
instance v1alpha2.OpenTelemetryCollector
instance v1beta1.OpenTelemetryCollector
}
tests := []struct {
name string
Expand All @@ -103,13 +103,13 @@ service:
{
name: "base case",
args: args{
instance: v1alpha2.OpenTelemetryCollector{
instance: v1beta1.OpenTelemetryCollector{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
Namespace: "test",
},
Spec: v1alpha2.OpenTelemetryCollectorSpec{
OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{
Spec: v1beta1.OpenTelemetryCollectorSpec{
OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
Image: "test",
Replicas: &one,
},
Expand Down Expand Up @@ -342,19 +342,19 @@ service:
{
name: "ingress",
args: args{
instance: v1alpha2.OpenTelemetryCollector{
instance: v1beta1.OpenTelemetryCollector{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
Namespace: "test",
},
Spec: v1alpha2.OpenTelemetryCollectorSpec{
OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{
Spec: v1beta1.OpenTelemetryCollectorSpec{
OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
Image: "test",
Replicas: &one,
},
Mode: "deployment",
Ingress: v1alpha2.Ingress{
Type: v1alpha2.IngressTypeNginx,
Ingress: v1beta1.Ingress{
Type: v1beta1.IngressTypeNginx,
Hostname: "example.com",
Annotations: map[string]string{
"something": "true",
Expand Down Expand Up @@ -627,13 +627,13 @@ service:
{
name: "specified service account case",
args: args{
instance: v1alpha2.OpenTelemetryCollector{
instance: v1beta1.OpenTelemetryCollector{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
Namespace: "test",
},
Spec: v1alpha2.OpenTelemetryCollectorSpec{
OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{
Spec: v1beta1.OpenTelemetryCollectorSpec{
OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
Image: "test",
Replicas: &one,
ServiceAccount: "my-special-sa",
Expand Down Expand Up @@ -1121,12 +1121,12 @@ service:
exporters: [logging]
`

goodConfig := v1alpha2.Config{}
goodConfig := v1beta1.Config{}
err := go_yaml.Unmarshal([]byte(goodConfigYaml), &goodConfig)
require.NoError(t, err)
one := int32(1)
type args struct {
instance v1alpha2.OpenTelemetryCollector
instance v1beta1.OpenTelemetryCollector
}
tests := []struct {
name string
Expand All @@ -1138,22 +1138,22 @@ service:
{
name: "base case",
args: args{
instance: v1alpha2.OpenTelemetryCollector{
instance: v1beta1.OpenTelemetryCollector{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
Namespace: "test",
},
Spec: v1alpha2.OpenTelemetryCollectorSpec{
OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{
Spec: v1beta1.OpenTelemetryCollectorSpec{
OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
Image: "test",
Replicas: &one,
},
Mode: "statefulset",
Config: goodConfig,
TargetAllocator: v1alpha2.TargetAllocatorEmbedded{
TargetAllocator: v1beta1.TargetAllocatorEmbedded{
Enabled: true,
FilterStrategy: "relabel-config",
PrometheusCR: v1alpha2.TargetAllocatorPrometheusCR{
PrometheusCR: v1beta1.TargetAllocatorPrometheusCR{
Enabled: true,
},
},
Expand Down Expand Up @@ -1530,21 +1530,21 @@ prometheus_cr:
{
name: "enable metrics case",
args: args{
instance: v1alpha2.OpenTelemetryCollector{
instance: v1beta1.OpenTelemetryCollector{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
Namespace: "test",
},
Spec: v1alpha2.OpenTelemetryCollectorSpec{
OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{
Spec: v1beta1.OpenTelemetryCollectorSpec{
OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
Image: "test",
Replicas: &one,
},
Mode: "statefulset",
Config: goodConfig,
TargetAllocator: v1alpha2.TargetAllocatorEmbedded{
TargetAllocator: v1beta1.TargetAllocatorEmbedded{
Enabled: true,
PrometheusCR: v1alpha2.TargetAllocatorPrometheusCR{
PrometheusCR: v1beta1.TargetAllocatorPrometheusCR{
Enabled: true,
},
FilterStrategy: "relabel-config",
Expand Down
42 changes: 21 additions & 21 deletions internal/api/convert/v1alpha.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,37 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1"
"github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2"
"github.com/open-telemetry/opentelemetry-operator/apis/v1beta1"
)

func V1Alpha1to2(in v1alpha1.OpenTelemetryCollector) (v1alpha2.OpenTelemetryCollector, error) {
func V1Alpha1to2(in v1alpha1.OpenTelemetryCollector) (v1beta1.OpenTelemetryCollector, error) {
copy := in.DeepCopy()
out := v1alpha2.OpenTelemetryCollector{
out := v1beta1.OpenTelemetryCollector{
TypeMeta: copy.TypeMeta,
ObjectMeta: copy.ObjectMeta,
}

cfg := &v1alpha2.Config{}
cfg := &v1beta1.Config{}
if err := yaml.Unmarshal([]byte(in.Spec.Config), cfg); err != nil {
return v1alpha2.OpenTelemetryCollector{}, errors.New("could not convert config json to v1alpha2.Config")
return v1beta1.OpenTelemetryCollector{}, errors.New("could not convert config json to v1beta1.Config")
}
out.Spec.Config = *cfg

out.Spec.OpenTelemetryCommonFields.ManagementState = v1alpha2.ManagementStateType(copy.Spec.ManagementState)
out.Spec.OpenTelemetryCommonFields.ManagementState = v1beta1.ManagementStateType(copy.Spec.ManagementState)
out.Spec.OpenTelemetryCommonFields.Resources = copy.Spec.Resources
out.Spec.OpenTelemetryCommonFields.NodeSelector = copy.Spec.NodeSelector
out.Spec.OpenTelemetryCommonFields.Args = copy.Spec.NodeSelector
out.Spec.OpenTelemetryCommonFields.Replicas = copy.Spec.Replicas

if copy.Spec.Autoscaler != nil {
metrics := make([]v1alpha2.MetricSpec, len(copy.Spec.Autoscaler.Metrics))
metrics := make([]v1beta1.MetricSpec, len(copy.Spec.Autoscaler.Metrics))
for i, m := range copy.Spec.Autoscaler.Metrics {
metrics[i] = v1alpha2.MetricSpec{
metrics[i] = v1beta1.MetricSpec{
Type: m.Type,
Pods: m.Pods,
}
}
out.Spec.OpenTelemetryCommonFields.Autoscaler = &v1alpha2.AutoscalerSpec{
out.Spec.OpenTelemetryCommonFields.Autoscaler = &v1beta1.AutoscalerSpec{
MinReplicas: copy.Spec.Autoscaler.MinReplicas,
MaxReplicas: copy.Spec.Autoscaler.MaxReplicas,
Behavior: copy.Spec.Autoscaler.Behavior,
Expand All @@ -62,7 +62,7 @@ func V1Alpha1to2(in v1alpha1.OpenTelemetryCollector) (v1alpha2.OpenTelemetryColl
}

if copy.Spec.PodDisruptionBudget != nil {
out.Spec.OpenTelemetryCommonFields.PodDisruptionBudget = &v1alpha2.PodDisruptionBudgetSpec{
out.Spec.OpenTelemetryCommonFields.PodDisruptionBudget = &v1beta1.PodDisruptionBudgetSpec{
MinAvailable: copy.Spec.PodDisruptionBudget.MinAvailable,
MaxUnavailable: copy.Spec.PodDisruptionBudget.MaxUnavailable,
}
Expand Down Expand Up @@ -96,18 +96,18 @@ func V1Alpha1to2(in v1alpha1.OpenTelemetryCollector) (v1alpha2.OpenTelemetryColl

out.Spec.TargetAllocator = TargetAllocatorEmbedded(copy.Spec.TargetAllocator)

out.Spec.Mode = v1alpha2.Mode(copy.Spec.Mode)
out.Spec.UpgradeStrategy = v1alpha2.UpgradeStrategy(copy.Spec.UpgradeStrategy)
out.Spec.Ingress.Type = v1alpha2.IngressType(copy.Spec.Ingress.Type)
out.Spec.Ingress.RuleType = v1alpha2.IngressRuleType(copy.Spec.Ingress.RuleType)
out.Spec.Mode = v1beta1.Mode(copy.Spec.Mode)
out.Spec.UpgradeStrategy = v1beta1.UpgradeStrategy(copy.Spec.UpgradeStrategy)
out.Spec.Ingress.Type = v1beta1.IngressType(copy.Spec.Ingress.Type)
out.Spec.Ingress.RuleType = v1beta1.IngressRuleType(copy.Spec.Ingress.RuleType)
out.Spec.Ingress.Hostname = copy.Spec.Ingress.Hostname
out.Spec.Ingress.Annotations = copy.Spec.Ingress.Annotations
out.Spec.Ingress.TLS = copy.Spec.Ingress.TLS
out.Spec.Ingress.IngressClassName = copy.Spec.Ingress.IngressClassName
out.Spec.Ingress.Route.Termination = v1alpha2.TLSRouteTerminationType(copy.Spec.Ingress.Route.Termination)
out.Spec.Ingress.Route.Termination = v1beta1.TLSRouteTerminationType(copy.Spec.Ingress.Route.Termination)

if copy.Spec.LivenessProbe != nil {
out.Spec.LivenessProbe = &v1alpha2.Probe{
out.Spec.LivenessProbe = &v1beta1.Probe{
InitialDelaySeconds: copy.Spec.LivenessProbe.InitialDelaySeconds,
TimeoutSeconds: copy.Spec.LivenessProbe.TimeoutSeconds,
PeriodSeconds: copy.Spec.LivenessProbe.PeriodSeconds,
Expand All @@ -127,13 +127,13 @@ func V1Alpha1to2(in v1alpha1.OpenTelemetryCollector) (v1alpha2.OpenTelemetryColl
return out, nil
}

func TargetAllocatorEmbedded(in v1alpha1.OpenTelemetryTargetAllocator) v1alpha2.TargetAllocatorEmbedded {
out := v1alpha2.TargetAllocatorEmbedded{}
func TargetAllocatorEmbedded(in v1alpha1.OpenTelemetryTargetAllocator) v1beta1.TargetAllocatorEmbedded {
out := v1beta1.TargetAllocatorEmbedded{}
out.Replicas = in.Replicas
out.NodeSelector = in.NodeSelector
out.Resources = in.Resources
out.AllocationStrategy = v1alpha2.TargetAllocatorAllocationStrategy(in.AllocationStrategy)
out.FilterStrategy = v1alpha2.TargetAllocatorFilterStrategy(in.FilterStrategy)
out.AllocationStrategy = v1beta1.TargetAllocatorAllocationStrategy(in.AllocationStrategy)
out.FilterStrategy = v1beta1.TargetAllocatorFilterStrategy(in.FilterStrategy)
out.ServiceAccount = in.ServiceAccount
out.Image = in.Image
out.Enabled = in.Enabled
Expand All @@ -158,7 +158,7 @@ func TargetAllocatorEmbedded(in v1alpha1.OpenTelemetryTargetAllocator) v1alpha2.
MatchLabels: in.PrometheusCR.ServiceMonitorSelector,
}
if in.PodDisruptionBudget != nil {
out.PodDisruptionBudget = &v1alpha2.PodDisruptionBudgetSpec{
out.PodDisruptionBudget = &v1beta1.PodDisruptionBudgetSpec{
MinAvailable: in.PodDisruptionBudget.MinAvailable,
MaxUnavailable: in.PodDisruptionBudget.MaxUnavailable,
}
Expand Down
Loading

0 comments on commit 569871e

Please sign in to comment.