Merge pull request #13802 from remyleone/fix_tenv

fix tenv linter
This commit is contained in:
Kubernetes Prow Robot 2022-06-16 04:12:48 -07:00 committed by GitHub
commit 08fc101353
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 28 deletions

View File

@ -23,6 +23,7 @@ linters:
- ineffassign - ineffassign
- staticcheck - staticcheck
- unused - unused
- tenv
linters-settings: # please keep this alphabetized linters-settings: # please keep this alphabetized
staticcheck: staticcheck:

View File

@ -17,7 +17,6 @@ limitations under the License.
package bootstrap package bootstrap
import ( import (
"os"
"path/filepath" "path/filepath"
"testing" "testing"
@ -26,11 +25,7 @@ import (
) )
func TestBootstarapBuilder_Simple(t *testing.T) { func TestBootstarapBuilder_Simple(t *testing.T) {
origRegion := os.Getenv("AWS_REGION") t.Setenv("AWS_REGION", "us-test1")
os.Setenv("AWS_REGION", "us-test1")
defer func() {
os.Setenv("AWS_REGION", origRegion)
}()
runInstallBuilderTest(t, "tests/simple") runInstallBuilderTest(t, "tests/simple")
} }

View File

@ -17,7 +17,6 @@ limitations under the License.
package featureflag package featureflag
import ( import (
"os"
"testing" "testing"
"k8s.io/klog/v2" "k8s.io/klog/v2"
@ -49,7 +48,7 @@ func TestSetenv(t *testing.T) {
t.Fatalf("Flag did not default true") t.Fatalf("Flag did not default true")
} }
os.Setenv("KOPS_FEATURE_FLAGS", "-UnitTest2") t.Setenv("KOPS_FEATURE_FLAGS", "-UnitTest2")
if !f.Enabled() { if !f.Enabled() {
t.Fatalf("Flag was reparsed immediately after os.Setenv") t.Fatalf("Flag was reparsed immediately after os.Setenv")
} }

View File

@ -18,7 +18,6 @@ package instancegroups
import ( import (
"context" "context"
"os"
"testing" "testing"
"time" "time"
@ -103,11 +102,7 @@ var TempTestSkip = func(t *testing.T, message string) {
func TestRollingUpdateDisabledSurgeOS(t *testing.T) { func TestRollingUpdateDisabledSurgeOS(t *testing.T) {
TempTestSkip(t, "Failing in new release PR when build is not yet published") TempTestSkip(t, "Failing in new release PR when build is not yet published")
origRegion := os.Getenv("OS_REGION_NAME") t.Setenv("OS_REGION_NAME", "us-test1")
os.Setenv("OS_REGION_NAME", "us-test1")
defer func() {
os.Setenv("OS_REGION_NAME", origRegion)
}()
c, cloud := getTestSetupOS(t) c, cloud := getTestSetupOS(t)

View File

@ -17,7 +17,6 @@ limitations under the License.
package cloudup package cloudup
import ( import (
"os"
"testing" "testing"
api "k8s.io/kops/pkg/apis/kops" api "k8s.io/kops/pkg/apis/kops"
@ -29,12 +28,8 @@ func Test_FindCNIAssetFromEnvironmentVariable(t *testing.T) {
desiredCNIVersion := "https://storage.googleapis.com/kubernetes-release/network-plugins/cni-TEST-VERSION.tar.gz" desiredCNIVersion := "https://storage.googleapis.com/kubernetes-release/network-plugins/cni-TEST-VERSION.tar.gz"
desiredCNIVersionHash := "sha256:0000000000000000000000000000000000000000000000000000000000000000" desiredCNIVersionHash := "sha256:0000000000000000000000000000000000000000000000000000000000000000"
os.Setenv(ENV_VAR_CNI_ASSET_URL, desiredCNIVersion) t.Setenv(ENV_VAR_CNI_ASSET_URL, desiredCNIVersion)
os.Setenv(ENV_VAR_CNI_ASSET_HASH, desiredCNIVersionHash) t.Setenv(ENV_VAR_CNI_ASSET_HASH, desiredCNIVersionHash)
defer func() {
os.Unsetenv(ENV_VAR_CNI_ASSET_URL)
os.Unsetenv(ENV_VAR_CNI_ASSET_HASH)
}()
cluster := &api.Cluster{} cluster := &api.Cluster{}
cluster.Spec.KubernetesVersion = "v1.18.0" cluster.Spec.KubernetesVersion = "v1.18.0"

View File

@ -19,7 +19,6 @@ package tests
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"os"
"strings" "strings"
"testing" "testing"
@ -52,13 +51,9 @@ func TestS3RenderTerraform(t *testing.T) {
`, `,
}, },
} }
origEndpoint := os.Getenv("S3_ENDPOINT") t.Setenv("S3_ENDPOINT", "foo.s3.amazonaws.com")
os.Setenv("S3_ENDPOINT", "foo.s3.amazonaws.com")
defer os.Setenv("S3_ENDPOINT", origEndpoint)
origACL := os.Getenv("KOPS_STATE_S3_ACL") t.Setenv("KOPS_STATE_S3_ACL", "bucket-owner-full-control")
os.Setenv("KOPS_STATE_S3_ACL", "bucket-owner-full-control")
defer os.Setenv("KOPS_STATE_S3_ACL", origACL)
for _, tc := range grid { for _, tc := range grid {
t.Run(tc.s3Path, func(t *testing.T) { t.Run(tc.s3Path, func(t *testing.T) {