diff --git a/internal/pkg/rpaas/errors.go b/internal/pkg/rpaas/errors.go index 57f66780..0ffe91c9 100644 --- a/internal/pkg/rpaas/errors.go +++ b/internal/pkg/rpaas/errors.go @@ -11,7 +11,7 @@ import ( ) var ( - ErrNoPoolDefined = errors.New("No pool defined") + ErrNoPoolDefined = errors.New("no pool defined") ) type NotModifiedError struct { diff --git a/internal/pkg/rpaas/k8s.go b/internal/pkg/rpaas/k8s.go index 44bbee96..114c4c1b 100644 --- a/internal/pkg/rpaas/k8s.go +++ b/internal/pkg/rpaas/k8s.go @@ -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" @@ -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"} } @@ -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 @@ -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] @@ -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)} } @@ -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 } @@ -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) { @@ -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{} @@ -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 } diff --git a/internal/pkg/rpaas/validation/manager.go b/internal/pkg/rpaas/validation/manager.go index 9258508c..a20e045d 100644 --- a/internal/pkg/rpaas/validation/manager.go +++ b/internal/pkg/rpaas/validation/manager.go @@ -5,7 +5,6 @@ package validation import ( "context" - "errors" "fmt" "time" @@ -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" ) @@ -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 { @@ -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,