Skip to content

Commit

Permalink
Drop deprecated module and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hdkshingala committed Jan 1, 2024
1 parent 2d93d7d commit 89a54e4
Show file tree
Hide file tree
Showing 27 changed files with 182 additions and 176 deletions.
4 changes: 2 additions & 2 deletions cmd/aperturectl/cmd/tui/radio-button.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

tea "github.com/charmbracelet/bubbletea"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

type radioButtonModel struct {
Expand All @@ -20,7 +20,7 @@ type optionMsg int
func InitialRadioButtonModel(options []string, msg string) *radioButtonModel {
return &radioButtonModel{
options: options,
Selected: pointer.Int(0),
Selected: ptr.To(0),
msg: msg,
}
}
Expand Down
6 changes: 6 additions & 0 deletions operator/controllers/agent/config_test.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,9 @@ object_storage:
bucket: list
key_prefix: asdf
operations_channel_size: 1000
retry_policy:
timeout: 10s
backoff:
initial: 0.500s
multiplier: 1.5
maximum: 2s
6 changes: 3 additions & 3 deletions operator/controllers/agent/configmaps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

agent "github.com/fluxninja/aperture/v2/cmd/aperture-agent/config"
agentv1alpha1 "github.com/fluxninja/aperture/v2/operator/api/agent/v1alpha1"
Expand Down Expand Up @@ -143,8 +143,8 @@ var _ = Describe("ConfigMap for Agent", func() {
APIVersion: "fluxninja.com/v1alpha1",
Name: instance.GetName(),
Kind: "Agent",
Controller: pointer.Bool(true),
BlockOwnerDeletion: pointer.Bool(true),
Controller: ptr.To(true),
BlockOwnerDeletion: ptr.To(true),
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions operator/controllers/agent/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

Expand Down Expand Up @@ -92,7 +92,7 @@ func daemonsetForAgent(instance *agentv1alpha1.Agent, log logr.Logger, scheme *r
Affinity: spec.Affinity,
Tolerations: spec.Tolerations,
SecurityContext: controllers.PodSecurityContext(spec.PodSecurityContext),
TerminationGracePeriodSeconds: pointer.Int64(spec.TerminationGracePeriodSeconds),
TerminationGracePeriodSeconds: ptr.To[int64](spec.TerminationGracePeriodSeconds),
InitContainers: spec.InitContainers,
Containers: []corev1.Container{
{
Expand Down
30 changes: 15 additions & 15 deletions operator/controllers/agent/daemonset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

agent "github.com/fluxninja/aperture/v2/cmd/aperture-agent/config"
agentv1alpha1 "github.com/fluxninja/aperture/v2/operator/api/agent/v1alpha1"
Expand Down Expand Up @@ -148,8 +148,8 @@ var _ = Describe("Agent DaemonSet", func() {
APIVersion: "fluxninja.com/v1alpha1",
Name: instance.GetName(),
Kind: "Agent",
Controller: pointer.Bool(true),
BlockOwnerDeletion: pointer.Bool(true),
Controller: ptr.To(true),
BlockOwnerDeletion: ptr.To(true),
},
},
Annotations: nil,
Expand All @@ -174,7 +174,7 @@ var _ = Describe("Agent DaemonSet", func() {
NodeSelector: nil,
Tolerations: nil,
SecurityContext: &corev1.PodSecurityContext{},
TerminationGracePeriodSeconds: pointer.Int64(0),
TerminationGracePeriodSeconds: ptr.To[int64](0),
InitContainers: nil,
Containers: []corev1.Container{
{
Expand Down Expand Up @@ -265,7 +265,7 @@ var _ = Describe("Agent DaemonSet", func() {
Name: "aperture-agent-config",
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
DefaultMode: pointer.Int32(420),
DefaultMode: ptr.To[int32](420),
LocalObjectReference: corev1.LocalObjectReference{
Name: AgentServiceName,
},
Expand Down Expand Up @@ -412,8 +412,8 @@ var _ = Describe("Agent DaemonSet", func() {
APIVersion: "fluxninja.com/v1alpha1",
Name: instance.GetName(),
Kind: "Agent",
Controller: pointer.Bool(true),
BlockOwnerDeletion: pointer.Bool(true),
Controller: ptr.To(true),
BlockOwnerDeletion: ptr.To(true),
},
},
Annotations: TestMap,
Expand Down Expand Up @@ -446,9 +446,9 @@ var _ = Describe("Agent DaemonSet", func() {
Affinity: affinity,
Tolerations: tolerations,
SecurityContext: &corev1.PodSecurityContext{
FSGroup: pointer.Int64(1001),
FSGroup: ptr.To[int64](1001),
},
TerminationGracePeriodSeconds: pointer.Int64(10),
TerminationGracePeriodSeconds: ptr.To[int64](10),
InitContainers: []corev1.Container{
{
Name: Test,
Expand All @@ -460,10 +460,10 @@ var _ = Describe("Agent DaemonSet", func() {
Image: "docker.io/fluxninja/aperture-agent:latest",
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &corev1.SecurityContext{
RunAsUser: pointer.Int64(0),
RunAsGroup: pointer.Int64(0),
RunAsNonRoot: pointer.Bool(false),
ReadOnlyRootFilesystem: pointer.Bool(false),
RunAsUser: ptr.To[int64](0),
RunAsGroup: ptr.To[int64](0),
RunAsNonRoot: ptr.To(false),
ReadOnlyRootFilesystem: ptr.To(false),
},
Command: TestArray,
Args: TestArray,
Expand Down Expand Up @@ -606,7 +606,7 @@ var _ = Describe("Agent DaemonSet", func() {
Name: "aperture-agent-config",
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
DefaultMode: pointer.Int32(420),
DefaultMode: ptr.To[int32](420),
LocalObjectReference: corev1.LocalObjectReference{
Name: AgentServiceName,
},
Expand Down Expand Up @@ -646,7 +646,7 @@ var _ = Describe("Test DaemonSet Mutate", func() {
NodeSelector: map[string]string{},
Tolerations: []corev1.Toleration{},
SecurityContext: &corev1.PodSecurityContext{
FSGroup: pointer.Int64(1001),
FSGroup: ptr.To[int64](1001),
},
InitContainers: []corev1.Container{},
Containers: []corev1.Container{
Expand Down
6 changes: 3 additions & 3 deletions operator/controllers/agent/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

Expand Down Expand Up @@ -76,7 +76,7 @@ func deploymentForAgent(instance *agentv1alpha1.Agent, log logr.Logger, scheme *
Annotations: spec.Annotations,
},
Spec: appsv1.DeploymentSpec{
Replicas: pointer.Int32(spec.DeploymentConfigSpec.Replicas),
Replicas: ptr.To[int32](spec.DeploymentConfigSpec.Replicas),
Selector: &v1.LabelSelector{
MatchLabels: controllers.SelectorLabels(instance.GetName(), controllers.AgentServiceName),
},
Expand All @@ -95,7 +95,7 @@ func deploymentForAgent(instance *agentv1alpha1.Agent, log logr.Logger, scheme *
Affinity: spec.Affinity,
Tolerations: spec.Tolerations,
SecurityContext: controllers.PodSecurityContext(spec.PodSecurityContext),
TerminationGracePeriodSeconds: pointer.Int64(spec.TerminationGracePeriodSeconds),
TerminationGracePeriodSeconds: ptr.To[int64](spec.TerminationGracePeriodSeconds),
InitContainers: spec.InitContainers,
Containers: []corev1.Container{
{
Expand Down
34 changes: 17 additions & 17 deletions operator/controllers/agent/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

agent "github.com/fluxninja/aperture/v2/cmd/aperture-agent/config"
agentv1alpha1 "github.com/fluxninja/aperture/v2/operator/api/agent/v1alpha1"
Expand Down Expand Up @@ -152,14 +152,14 @@ var _ = Describe("Agent Deployment", func() {
APIVersion: "fluxninja.com/v1alpha1",
Name: instance.GetName(),
Kind: "Agent",
Controller: pointer.Bool(true),
BlockOwnerDeletion: pointer.Bool(true),
Controller: ptr.To(true),
BlockOwnerDeletion: ptr.To(true),
},
},
Annotations: nil,
},
Spec: appsv1.DeploymentSpec{
Replicas: pointer.Int32(1),
Replicas: ptr.To[int32](1),
Selector: &metav1.LabelSelector{
MatchLabels: selectorLabels,
},
Expand All @@ -181,7 +181,7 @@ var _ = Describe("Agent Deployment", func() {
NodeSelector: nil,
Tolerations: nil,
SecurityContext: &corev1.PodSecurityContext{},
TerminationGracePeriodSeconds: pointer.Int64(0),
TerminationGracePeriodSeconds: ptr.To[int64](0),
InitContainers: nil,
Containers: []corev1.Container{
{
Expand Down Expand Up @@ -268,7 +268,7 @@ var _ = Describe("Agent Deployment", func() {
Name: "aperture-agent-config",
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
DefaultMode: pointer.Int32(420),
DefaultMode: ptr.To[int32](420),
LocalObjectReference: corev1.LocalObjectReference{
Name: AgentServiceName,
},
Expand Down Expand Up @@ -420,14 +420,14 @@ var _ = Describe("Agent Deployment", func() {
APIVersion: "fluxninja.com/v1alpha1",
Name: instance.GetName(),
Kind: "Agent",
Controller: pointer.Bool(true),
BlockOwnerDeletion: pointer.Bool(true),
Controller: ptr.To(true),
BlockOwnerDeletion: ptr.To(true),
},
},
Annotations: TestMap,
},
Spec: appsv1.DeploymentSpec{
Replicas: pointer.Int32(1),
Replicas: ptr.To[int32](1),
Selector: &metav1.LabelSelector{
MatchLabels: selectorLabels,
},
Expand Down Expand Up @@ -457,9 +457,9 @@ var _ = Describe("Agent Deployment", func() {
Affinity: affinity,
Tolerations: tolerations,
SecurityContext: &corev1.PodSecurityContext{
FSGroup: pointer.Int64(1001),
FSGroup: ptr.To[int64](1001),
},
TerminationGracePeriodSeconds: pointer.Int64(10),
TerminationGracePeriodSeconds: ptr.To[int64](10),
InitContainers: []corev1.Container{
{
Name: Test,
Expand All @@ -471,10 +471,10 @@ var _ = Describe("Agent Deployment", func() {
Image: "docker.io/fluxninja/aperture-agent:latest",
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &corev1.SecurityContext{
RunAsUser: pointer.Int64(0),
RunAsGroup: pointer.Int64(0),
RunAsNonRoot: pointer.Bool(false),
ReadOnlyRootFilesystem: pointer.Bool(false),
RunAsUser: ptr.To[int64](0),
RunAsGroup: ptr.To[int64](0),
RunAsNonRoot: ptr.To(false),
ReadOnlyRootFilesystem: ptr.To(false),
},
Command: TestArray,
Args: TestArray,
Expand Down Expand Up @@ -613,7 +613,7 @@ var _ = Describe("Agent Deployment", func() {
Name: "aperture-agent-config",
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
DefaultMode: pointer.Int32(420),
DefaultMode: ptr.To[int32](420),
LocalObjectReference: corev1.LocalObjectReference{
Name: Test,
},
Expand Down Expand Up @@ -658,7 +658,7 @@ var _ = Describe("Test Deployment Mutate", func() {
NodeSelector: map[string]string{},
Tolerations: []corev1.Toleration{},
SecurityContext: &corev1.PodSecurityContext{
FSGroup: pointer.Int64(1001),
FSGroup: ptr.To[int64](1001),
},
InitContainers: []corev1.Container{},
Containers: []corev1.Container{
Expand Down
8 changes: 4 additions & 4 deletions operator/controllers/agent/mutating_webhook_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

agentv1alpha1 "github.com/fluxninja/aperture/v2/operator/api/agent/v1alpha1"
)
Expand All @@ -51,8 +51,8 @@ func podMutatingWebhookConfiguration(instance *agentv1alpha1.Agent) (*admissionr
Service: &admissionregistrationv1.ServiceReference{
Name: os.Getenv("APERTURE_OPERATOR_SERVICE_NAME"),
Namespace: os.Getenv("APERTURE_OPERATOR_NAMESPACE"),
Path: pointer.String(controllers.MutatingWebhookURI),
Port: pointer.Int32(443),
Path: ptr.To(controllers.MutatingWebhookURI),
Port: ptr.To[int32](443),
},
},
NamespaceSelector: &v1.LabelSelector{
Expand All @@ -78,7 +78,7 @@ func podMutatingWebhookConfiguration(instance *agentv1alpha1.Agent) (*admissionr
AdmissionReviewVersions: []string{controllers.V1Version},
FailurePolicy: &[]admissionregistrationv1.FailurePolicyType{admissionregistrationv1.Fail}[0],
SideEffects: &[]admissionregistrationv1.SideEffectClass{admissionregistrationv1.SideEffectClassNone}[0],
TimeoutSeconds: pointer.Int32(10),
TimeoutSeconds: ptr.To[int32](10),
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
. "github.com/onsi/gomega"
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

agentv1alpha1 "github.com/fluxninja/aperture/v2/operator/api/agent/v1alpha1"
"github.com/fluxninja/aperture/v2/operator/api/common"
Expand Down Expand Up @@ -90,8 +90,8 @@ var _ = Describe("MutatingWebhookConfiguration for Pods", func() {
Service: &admissionregistrationv1.ServiceReference{
Name: AppName,
Namespace: AppName,
Path: pointer.String(MutatingWebhookURI),
Port: pointer.Int32(443),
Path: ptr.To(MutatingWebhookURI),
Port: ptr.To[int32](443),
},
CABundle: serverCertPEM.Bytes(),
},
Expand All @@ -118,7 +118,7 @@ var _ = Describe("MutatingWebhookConfiguration for Pods", func() {
AdmissionReviewVersions: []string{V1Version},
FailurePolicy: &[]admissionregistrationv1.FailurePolicyType{admissionregistrationv1.Fail}[0],
SideEffects: &[]admissionregistrationv1.SideEffectClass{admissionregistrationv1.SideEffectClassNone}[0],
TimeoutSeconds: pointer.Int32(10),
TimeoutSeconds: ptr.To[int32](10),
},
},
}
Expand Down
10 changes: 5 additions & 5 deletions operator/controllers/agent/secrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

agentv1alpha1 "github.com/fluxninja/aperture/v2/operator/api/agent/v1alpha1"
"github.com/fluxninja/aperture/v2/operator/api/common"
Expand Down Expand Up @@ -66,8 +66,8 @@ var _ = Describe("Secret for Agent", func() {
APIVersion: "fluxninja.com/v1alpha1",
Name: instance.GetName(),
Kind: "Agent",
Controller: pointer.Bool(true),
BlockOwnerDeletion: pointer.Bool(true),
Controller: ptr.To(true),
BlockOwnerDeletion: ptr.To(true),
},
},
},
Expand Down Expand Up @@ -122,8 +122,8 @@ var _ = Describe("Secret for Agent", func() {
APIVersion: "fluxninja.com/v1alpha1",
Name: instance.GetName(),
Kind: "Agent",
Controller: pointer.Bool(true),
BlockOwnerDeletion: pointer.Bool(true),
Controller: ptr.To(true),
BlockOwnerDeletion: ptr.To(true),
},
},
},
Expand Down
Loading

0 comments on commit 89a54e4

Please sign in to comment.