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
- staticcheck
- unused
- tenv
linters-settings: # please keep this alphabetized
staticcheck:

View File

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

View File

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

View File

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

View File

@ -17,7 +17,6 @@ limitations under the License.
package cloudup
import (
"os"
"testing"
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"
desiredCNIVersionHash := "sha256:0000000000000000000000000000000000000000000000000000000000000000"
os.Setenv(ENV_VAR_CNI_ASSET_URL, desiredCNIVersion)
os.Setenv(ENV_VAR_CNI_ASSET_HASH, desiredCNIVersionHash)
defer func() {
os.Unsetenv(ENV_VAR_CNI_ASSET_URL)
os.Unsetenv(ENV_VAR_CNI_ASSET_HASH)
}()
t.Setenv(ENV_VAR_CNI_ASSET_URL, desiredCNIVersion)
t.Setenv(ENV_VAR_CNI_ASSET_HASH, desiredCNIVersionHash)
cluster := &api.Cluster{}
cluster.Spec.KubernetesVersion = "v1.18.0"

View File

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