Skip to content

Commit

Permalink
Remove duplicated imports
Browse files Browse the repository at this point in the history
  • Loading branch information
wpjunior committed May 13, 2024
1 parent f476d48 commit 6251938
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion internal/pkg/rpaas/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

var (
ErrNoPoolDefined = errors.New("No pool defined")
ErrNoPoolDefined = errors.New("no pool defined")
)

type NotModifiedError struct {
Expand Down
19 changes: 9 additions & 10 deletions internal/pkg/rpaas/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
nginxv1alpha1 "github.com/tsuru/nginx-operator/api/v1alpha1"
nginxk8s "github.com/tsuru/nginx-operator/pkg/k8s"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
Expand Down Expand Up @@ -175,7 +174,7 @@ func (m *k8sRpaasManager) Debug(ctx context.Context, instanceName string, args D
return executorStream(args.CommonTerminalArgs, executor, ctx)
}

func (m *k8sRpaasManager) debugPodWithContainerStatus(ctx context.Context, args *DebugArgs, instanceName string) (*v1alpha1.RpaasInstance, string, *v1.ContainerStatus, error) {
func (m *k8sRpaasManager) debugPodWithContainerStatus(ctx context.Context, args *DebugArgs, instanceName string) (*v1alpha1.RpaasInstance, string, *corev1.ContainerStatus, error) {
if args.Image == "" && config.Get().DebugImage == "" {
return nil, "", nil, ValidationError{Msg: "Debug image not set and no default image configured"}
}
Expand Down Expand Up @@ -227,11 +226,11 @@ func (m *k8sRpaasManager) generateDebugContainer(ctx context.Context, args *Debu
}
instancePodWithDebug := instancePod.DeepCopy()
instancePodWithDebug.Spec.EphemeralContainers = append(instancePod.Spec.EphemeralContainers, *debugContainer)
err = m.patchEphemeralContainers(ctx, instancePodWithDebug, instancePod, debugContainer)
err = m.patchEphemeralContainers(ctx, instancePodWithDebug, instancePod)
return debugContainerName, err
}

func (m *k8sRpaasManager) patchEphemeralContainers(ctx context.Context, instancePodWithDebug *v1.Pod, instancePod v1.Pod, debugContainer *v1.EphemeralContainer) error {
func (m *k8sRpaasManager) patchEphemeralContainers(ctx context.Context, instancePodWithDebug *corev1.Pod, instancePod corev1.Pod) error {
podJS, err := json.Marshal(instancePod)
if err != nil {
return err
Expand Down Expand Up @@ -826,7 +825,7 @@ func (m *k8sRpaasManager) getFlavors(ctx context.Context) ([]v1alpha1.RpaasFlavo
return flavorList.Items, nil
}

func (m *k8sRpaasManager) selectFlavor(ctx context.Context, flavors []v1alpha1.RpaasFlavor, name string) *v1alpha1.RpaasFlavor {
func (m *k8sRpaasManager) selectFlavor(flavors []v1alpha1.RpaasFlavor, name string) *v1alpha1.RpaasFlavor {
for i := range flavors {
if flavors[i].Name == name {
return &flavors[i]
Expand Down Expand Up @@ -1146,7 +1145,7 @@ func (m *k8sRpaasManager) validateFlavors(ctx context.Context, instance *v1alpha
added, removed := diffFlavors(existingFlavors, flavors)

for _, f := range added {
flavorObj := m.selectFlavor(ctx, allFlavors, f)
flavorObj := m.selectFlavor(allFlavors, f)
if flavorObj == nil {
return &ValidationError{Msg: fmt.Sprintf("flavor %q not found", f)}
}
Expand All @@ -1161,7 +1160,7 @@ func (m *k8sRpaasManager) validateFlavors(ctx context.Context, instance *v1alpha
}

for _, f := range removed {
flavorObj := m.selectFlavor(ctx, allFlavors, f)
flavorObj := m.selectFlavor(allFlavors, f)
if flavorObj == nil {
continue
}
Expand Down Expand Up @@ -1783,7 +1782,7 @@ func sortAddresses(addresses []clientTypes.InstanceAddress) {
})
}

func (m *k8sRpaasManager) loadBalancerInstanceAddresses(ctx context.Context, svc *v1.Service) ([]clientTypes.InstanceAddress, error) {
func (m *k8sRpaasManager) loadBalancerInstanceAddresses(ctx context.Context, svc *corev1.Service) ([]clientTypes.InstanceAddress, error) {
var addresses []clientTypes.InstanceAddress

if isLoadBalancerReady(svc.Status.LoadBalancer.Ingress) {
Expand Down Expand Up @@ -1860,7 +1859,7 @@ func (m *k8sRpaasManager) ingressAddresses(ctx context.Context, ing *networkingv
return addresses, nil
}

func formatEventsToString(events []v1.Event) string {
func formatEventsToString(events []corev1.Event) string {
var buf bytes.Buffer
reasonMap := map[string]bool{}

Expand All @@ -1876,7 +1875,7 @@ func formatEventsToString(events []v1.Event) string {
return buf.String()
}

func isLoadBalancerReady(ings []v1.LoadBalancerIngress) bool {
func isLoadBalancerReady(ings []corev1.LoadBalancerIngress) bool {
if len(ings) == 0 {
return false
}
Expand Down
6 changes: 1 addition & 5 deletions internal/pkg/rpaas/validation/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package validation

import (
"context"
"errors"
"fmt"
"time"

Expand All @@ -14,7 +13,6 @@ import (
corev1 "k8s.io/api/core/v1"
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog/v2"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand All @@ -33,8 +31,6 @@ func New(manager rpaas.RpaasManager, cli client.Client) rpaas.RpaasManager {
}
}

var errNotImplementedYet = errors.New("not implemented yet")

func (v *validationManager) DeleteBlock(ctx context.Context, instanceName, blockName string) error {
validation, err := v.validationCRD(ctx, instanceName)
if err != nil {
Expand Down Expand Up @@ -314,7 +310,7 @@ func (v *validationManager) validationCRD(ctx context.Context, instanceName stri
}

return &v1alpha1.RpaasValidation{
ObjectMeta: v1.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: instance.Name,
Namespace: instance.Namespace,
Labels: instance.Labels,
Expand Down

0 comments on commit 6251938

Please sign in to comment.