Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jimassa committed Jun 25, 2024
1 parent e24aae7 commit 1251afa
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
6 changes: 5 additions & 1 deletion operator/cilium-crds/k8s/apis/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,17 @@ func createCRD(crdVersionedName, crdMetaName string) func(clientset apiextension
return func(clientset apiextensionsclient.Interface) error {
ciliumCRD := apisclient.GetPregeneratedCRD(crdVersionedName)

return crdhelpers.CreateUpdateCRD(
err := crdhelpers.CreateUpdateCRD(
clientset,
constructV1CRD(crdMetaName, ciliumCRD),
crdhelpers.NewDefaultPoller(),
k8sconst.CustomResourceDefinitionSchemaVersionKey,
versioncheck.MustVersion(k8sconst.CustomResourceDefinitionSchemaVersion),
)
if err != nil {
return fmt.Errorf("Unable to create CRD %s: %w", crdMetaName, err)
}
return nil
}
}

Expand Down
4 changes: 3 additions & 1 deletion operator/cilium-crds/k8s/resource_ctors.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"github.com/cilium/cilium/pkg/k8s/utils"
)

var ErrNotACiliumEndpoint = errors.New("object is not a *cilium_api_v2.CiliumEndpoint")

func CiliumEndpointResource(lc cell.Lifecycle, cs client.Clientset, opts ...func(*metav1.ListOptions)) (resource.Resource[*cilium_api_v2.CiliumEndpoint], error) {
if !cs.IsEnabled() {
return nil, nil
Expand All @@ -45,7 +47,7 @@ func identityIndexFunc(obj interface{}) ([]string, error) {
}
return []string{"0"}, nil
}
return nil, fmt.Errorf("%w - found %T", errors.New("object is not a *cilium_api_v2.CiliumEndpoint"), obj)
return nil, fmt.Errorf("%w - found %T", ErrNotACiliumEndpoint, obj)
}

func CiliumEndpointSliceResource(lc cell.Lifecycle, cs client.Clientset, opts ...func(*metav1.ListOptions)) (resource.Resource[*cilium_api_v2alpha1.CiliumEndpointSlice], error) {
Expand Down
16 changes: 14 additions & 2 deletions operator/cmd/cilium-crds/cells.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package ciliumcrds

import (
"context"
"fmt"
"sync/atomic"

"github.com/microsoft/retina/pkg/shared/telemetry"
Expand Down Expand Up @@ -119,7 +120,13 @@ var (
"Operator Control Plane",

cell.Config(cmtypes.DefaultClusterInfo),
cell.Invoke(func(cinfo cmtypes.ClusterInfo) error { return cinfo.Validate() }),
cell.Invoke(func(cinfo cmtypes.ClusterInfo) error {
err := cinfo.Validate()
if err != nil {
return fmt.Errorf("error validating cluster info: %w", err)
}
return nil
}),

cell.Invoke(
registerOperatorHooks,
Expand Down Expand Up @@ -182,7 +189,8 @@ var (
cell.Provide(func(scheme *k8sruntime.Scheme) (ctrl.Manager, error) {
// controller-runtime requires its own logger
logf.SetLogger(zapf.New())
return ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{

manager, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
// Metrics: server.Options{
// BindAddress: metricsAddr,
Expand All @@ -192,6 +200,10 @@ var (
// Port: 9443,
// HealthProbeBindAddress: probeAddr,
})
if err != nil {
return nil, fmt.Errorf("failed to create manager: %w", err)
}
return manager, nil
}),
endpointcontroller.Cell,

Expand Down
5 changes: 4 additions & 1 deletion operator/cmd/legacy/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
// to ensure that exec-entrypoint and run can make use of them.

"go.uber.org/zap"
v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
apiextv1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1"
k8sruntime "k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
Expand Down Expand Up @@ -155,7 +156,9 @@ func (o *Operator) Start() {

if oconfig.InstallCRDs {
mainLogger.Sugar().Infof("Installing CRDs")
crds, err := deploy.InstallOrUpdateCRDs(ctx, oconfig.EnableRetinaEndpoint, clientset)

var crds map[string]*v1.CustomResourceDefinition
crds, err = deploy.InstallOrUpdateCRDs(ctx, oconfig.EnableRetinaEndpoint, clientset)
if err != nil {
mainLogger.Error("unable to register CRDs", zap.Error(err))
os.Exit(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,9 @@ func TestPodDeleteNoOp(t *testing.T) {
r, ciliumEndpoints := newTestEndpointReconciler(t)

createNamespace(r.ciliumSlimClientSet.CoreV1())
podKey, pod := podTestX()
podKey, _ := podTestX()

require.NoError(t, r.ReconcilePod(context.TODO(), podKey, pod))
pod = nil
require.NoError(t, r.ReconcilePod(context.TODO(), podKey, nil))
assertCEPDoesNotExist(t, ciliumEndpoints, podKey)
}

Expand Down

0 comments on commit 1251afa

Please sign in to comment.