diff --git a/.golangci.yaml b/.golangci.yaml index bf37f1f3eb..1f96503e38 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -67,7 +67,7 @@ output: linters: disable-all: true enable: - # - deadcode + - deadcode - errcheck # - gofmt - gosimple diff --git a/lib/resourcemerge/core.go b/lib/resourcemerge/core.go index c220882e7c..01a2a74445 100644 --- a/lib/resourcemerge/core.go +++ b/lib/resourcemerge/core.go @@ -508,16 +508,6 @@ func ensureCapabilities(modified *bool, existing *corev1.Capabilities, required } } -func setStringSliceIfSet(modified *bool, existing *[]string, required []string) { - if required == nil { - return - } - if !equality.Semantic.DeepEqual(required, *existing) { - *existing = required - *modified = true - } -} - func setStringSlice(modified *bool, existing *[]string, required []string) { if !reflect.DeepEqual(required, *existing) { *existing = required diff --git a/lib/validation/validation.go b/lib/validation/validation.go index 6c38c633be..93223a15ee 100644 --- a/lib/validation/validation.go +++ b/lib/validation/validation.go @@ -69,20 +69,6 @@ func countPayloadsForVersion(config *configv1.ClusterVersion, version string) in return 0 } -func hasAmbiguousPayloadForVersion(config *configv1.ClusterVersion, version string) bool { - for _, update := range config.Status.AvailableUpdates { - if update.Version == version { - return len(update.Image) > 0 - } - } - for _, history := range config.Status.History { - if history.Version == version { - return len(history.Image) > 0 - } - } - return false -} - func ClearInvalidFields(config *configv1.ClusterVersion, errs field.ErrorList) *configv1.ClusterVersion { if len(errs) == 0 { return config diff --git a/pkg/cvo/cvo_test.go b/pkg/cvo/cvo_test.go index f896c853f2..1a9f9cf415 100644 --- a/pkg/cvo/cvo_test.go +++ b/pkg/cvo/cvo_test.go @@ -3313,11 +3313,6 @@ func expectCreate(t *testing.T, a ktesting.Action, resource, namespace string, o expectMutation(t, a, "create", resource, "", namespace, obj) } -func expectUpdate(t *testing.T, a ktesting.Action, resource, namespace string, obj interface{}) { - t.Helper() - expectMutation(t, a, "update", resource, "", namespace, obj) -} - func expectUpdateStatus(t *testing.T, a ktesting.Action, resource, namespace string, obj interface{}) { t.Helper() expectMutation(t, a, "update", resource, "status", namespace, obj) diff --git a/pkg/cvo/internal/generic.go b/pkg/cvo/internal/generic.go index ba4305f2a6..62384853f6 100644 --- a/pkg/cvo/internal/generic.go +++ b/pkg/cvo/internal/generic.go @@ -2,7 +2,6 @@ package internal import ( "context" - "encoding/json" "fmt" "github.com/openshift/cluster-version-operator/lib/resourceapply" @@ -10,10 +9,8 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/diff" "k8s.io/apimachinery/pkg/util/sets" - "k8s.io/apimachinery/pkg/util/strategicpatch" "k8s.io/client-go/dynamic" "k8s.io/klog/v2" @@ -152,15 +149,3 @@ func (b *genericBuilder) Do(ctx context.Context) error { } return err } - -func createPatch(original, modified runtime.Object) ([]byte, error) { - originalData, err := json.Marshal(original) - if err != nil { - return nil, err - } - modifiedData, err := json.Marshal(modified) - if err != nil { - return nil, err - } - return strategicpatch.CreateTwoWayMergePatch(originalData, modifiedData, original) -} diff --git a/pkg/cvo/internal/operatorstatus.go b/pkg/cvo/internal/operatorstatus.go index 5c76a5eacb..cf7cb8057d 100644 --- a/pkg/cvo/internal/operatorstatus.go +++ b/pkg/cvo/internal/operatorstatus.go @@ -5,7 +5,6 @@ import ( "fmt" "sort" "strings" - "unicode" kerrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -232,10 +231,3 @@ func checkOperatorHealth(ctx context.Context, client ClusterOperatorsGetter, exp return nil } - -func lowerFirst(str string) string { - for i, v := range str { - return string(unicode.ToLower(v)) + str[i+1:] - } - return "" -} diff --git a/pkg/cvo/sync_worker.go b/pkg/cvo/sync_worker.go index 4b1c29149b..38be867064 100644 --- a/pkg/cvo/sync_worker.go +++ b/pkg/cvo/sync_worker.go @@ -14,7 +14,6 @@ import ( "github.com/prometheus/client_golang/prometheus" "golang.org/x/time/rate" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/errors" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/wait" @@ -23,7 +22,6 @@ import ( configv1 "github.com/openshift/api/config/v1" - "github.com/openshift/cluster-version-operator/lib/resourcebuilder" "github.com/openshift/cluster-version-operator/pkg/payload" "github.com/openshift/cluster-version-operator/pkg/payload/precondition" "github.com/openshift/library-go/pkg/manifest" @@ -1072,16 +1070,6 @@ func getOverrideForManifest(overrides []configv1.ComponentOverride, manifest *ma return configv1.ComponentOverride{}, false } -// ownerKind contains the schema.GroupVersionKind for type that owns objects managed by CVO. -var ownerKind = configv1.SchemeGroupVersion.WithKind("ClusterVersion") - -func ownerRefModifier(config *configv1.ClusterVersion) resourcebuilder.MetaV1ObjectModifierFunc { - oref := metav1.NewControllerRef(config, ownerKind) - return func(obj metav1.Object) { - obj.SetOwnerReferences([]metav1.OwnerReference{*oref}) - } -} - // runThrottledStatusNotifier invokes fn every time ch is updated, but no more often than once // every interval. If bucket is non-zero then the channel is throttled like a rate limiter bucket. func runThrottledStatusNotifier(ctx context.Context, interval time.Duration, bucket int, ch <-chan SyncWorkerStatus, fn func()) { diff --git a/pkg/payload/task_graph.go b/pkg/payload/task_graph.go index 4ae4577484..d31c0847eb 100644 --- a/pkg/payload/task_graph.go +++ b/pkg/payload/task_graph.go @@ -386,15 +386,6 @@ func (g *TaskGraph) Tree() string { return strings.Join(out, "\n") } -func covers(all []int, some []int) bool { - for _, i := range some { - if all[i] == 0 { - return false - } - } - return true -} - func (g *TaskGraph) bulkAdd(nodes []*TaskNode, inNodes []int) []int { from := len(g.Nodes) g.Nodes = append(g.Nodes, nodes...)