Kubetest2 - fix temp directory created for GCE SSH keys

Also update all ioutil references to their go 1.16 replacements
This commit is contained in:
Peter Rifel 2021-03-24 06:17:24 -05:00
parent e691d55544
commit 462cfffb02
No known key found for this signature in database
GPG Key ID: BC6469E5B16DB2B6
7 changed files with 15 additions and 15 deletions

View File

@ -20,7 +20,7 @@ import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"os"
"strings"
"k8s.io/klog/v2"
@ -43,7 +43,7 @@ func (d *deployer) PostTest(testErr error) error {
if err := util.HTTPGETWithHeaders(d.KopsVersionMarker, nil, &b); err != nil {
return err
}
tempSrc, err := ioutil.TempFile("", "kops-version-marker")
tempSrc, err := os.CreateTemp("", "kops-version-marker")
if err != nil {
return err
}

View File

@ -17,7 +17,7 @@ limitations under the License.
package deployer
import (
"io/ioutil"
"os"
"path"
"strings"
@ -29,7 +29,7 @@ import (
// renderTemplate will render the manifest template with the provided values,
// setting the deployer's manifestPath
func (d *deployer) renderTemplate(values map[string]interface{}) error {
dir, err := ioutil.TempDir("", "kops-template")
dir, err := os.MkdirTemp("", "kops-template")
if err != nil {
return err
}
@ -39,7 +39,10 @@ func (d *deployer) renderTemplate(values map[string]interface{}) error {
return err
}
valuesPath := path.Join(dir, "values.yaml")
ioutil.WriteFile(valuesPath, valuesBytes, 0644)
err = os.WriteFile(valuesPath, valuesBytes, 0644)
if err != nil {
return err
}
manifestPath := path.Join(dir, "manifest.yaml")
d.manifestPath = manifestPath
@ -64,7 +67,7 @@ func (d *deployer) renderTemplate(values map[string]interface{}) error {
}
func (d *deployer) templateValues(zones []string, publicIP string) (map[string]interface{}, error) {
publicKey, err := ioutil.ReadFile(d.SSHPublicKeyPath)
publicKey, err := os.ReadFile(d.SSHPublicKeyPath)
if err != nil {
return nil, err
}

View File

@ -27,7 +27,7 @@ import (
)
func SetupSSH(project string) (string, string, error) {
dir, err := os.MkdirTemp("kops", "ssh")
dir, err := os.MkdirTemp("", "kops-ssh")
if err != nil {
return "", "", err
}

View File

@ -19,7 +19,6 @@ package kops
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"runtime"
"strings"
@ -39,7 +38,7 @@ func DownloadKops(markerURL, downloadPath string) (string, string, error) {
var kopsFile *os.File
if downloadPath == "" {
tmp, err := ioutil.TempFile("", "kops")
tmp, err := os.CreateTemp("", "kops")
if err != nil {
return "", "", err
}

View File

@ -19,7 +19,7 @@ package target
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"runtime"
"strings"
@ -48,7 +48,7 @@ func NewTerraform(version string) (*Terraform, error) {
if err != nil {
return nil, err
}
tfDir, err := ioutil.TempDir("", "kops-terraform")
tfDir, err := os.MkdirTemp("", "kops-terraform")
if err != nil {
return nil, err
}

View File

@ -23,7 +23,6 @@ import (
"encoding/hex"
"fmt"
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
@ -84,7 +83,7 @@ func (t *Tester) extractBinaries(downloadPath string) (string, error) {
}
tarReader := tar.NewReader(gzf)
kubectlDir, err := ioutil.TempDir("", "kubectl")
kubectlDir, err := os.MkdirTemp("", "kubectl")
if err != nil {
return "", err
}

View File

@ -21,7 +21,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
@ -33,7 +32,7 @@ func UnzipToTempDir(data []byte) (string, error) {
if err != nil {
return "", err
}
dir, err := ioutil.TempDir("", "")
dir, err := os.MkdirTemp("", "")
if err != nil {
return "", err
}