From 270611d321bf47457aa8351033658122dea11c78 Mon Sep 17 00:00:00 2001 From: Philip Laine Date: Mon, 20 May 2024 15:31:28 +0200 Subject: [PATCH] refactor: enable ineffassign linter (#2500) This change enables the ineffassign linter and fixes the only complaint by refactoring the select state filter. Part of #2503 Depends on #2499 - [x] Test, docs, adr added or updated as needed - [x] [Contributor Guide Steps](https://github.com/defenseunicorns/zarf/blob/main/.github/CONTRIBUTING.md#developer-workflow) followed --- src/pkg/cluster/state.go | 3 +++ src/pkg/cluster/state_test.go | 13 ------------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/pkg/cluster/state.go b/src/pkg/cluster/state.go index 550f9a4fc6..a0414f8793 100644 --- a/src/pkg/cluster/state.go +++ b/src/pkg/cluster/state.go @@ -267,6 +267,7 @@ func MergeZarfState(oldState *types.ZarfState, initOptions types.ZarfInitOptions // TODO: Replace use of reflections with explicit setting newState.RegistryInfo = helpers.MergeNonZero(newState.RegistryInfo, initOptions.RegistryInfo) // Set the state of the internal registry if it has changed + // TODO: Internal registry should be a function of the address and not a property. if newState.RegistryInfo.Address == fmt.Sprintf("%s:%d", helpers.IPV4Localhost, newState.RegistryInfo.NodePort) { newState.RegistryInfo.InternalRegistry = true } else { @@ -290,6 +291,7 @@ func MergeZarfState(oldState *types.ZarfState, initOptions types.ZarfInitOptions newState.GitServer = helpers.MergeNonZero(newState.GitServer, initOptions.GitServer) // Set the state of the internal git server if it has changed + // TODO: Internal server should be a function of the address and not a property. if newState.GitServer.Address == types.ZarfInClusterGitServiceURL { newState.GitServer.InternalServer = true } else { @@ -313,6 +315,7 @@ func MergeZarfState(oldState *types.ZarfState, initOptions types.ZarfInitOptions newState.ArtifactServer = helpers.MergeNonZero(newState.ArtifactServer, initOptions.ArtifactServer) // Set the state of the internal artifact server if it has changed + // TODO: Internal server should be a function of the address and not a property. if newState.ArtifactServer.Address == types.ZarfInClusterArtifactServiceURL { newState.ArtifactServer.InternalServer = true } else { diff --git a/src/pkg/cluster/state_test.go b/src/pkg/cluster/state_test.go index 114b47d1b4..72f10cd873 100644 --- a/src/pkg/cluster/state_test.go +++ b/src/pkg/cluster/state_test.go @@ -236,19 +236,6 @@ func TestMergeZarfStateArtifact(t *testing.T) { InternalServer: true, }, }, - { - name: "old state is not internal server auto generate push token", - oldArtifactServer: types.ArtifactServerInfo{ - PushToken: "foobar", - Address: types.ZarfInClusterArtifactServiceURL, - InternalServer: false, - }, - expectedArtifactServer: types.ArtifactServerInfo{ - PushToken: "foobar", - Address: types.ZarfInClusterArtifactServiceURL, - InternalServer: true, - }, - }, { name: "old state is not internal server auto generate push token but init options does not match", initArtifactServer: types.ArtifactServerInfo{