mirror of https://github.com/kubernetes/kops.git
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:
parent
e691d55544
commit
462cfffb02
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"k8s.io/klog/v2"
|
"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 {
|
if err := util.HTTPGETWithHeaders(d.KopsVersionMarker, nil, &b); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tempSrc, err := ioutil.TempFile("", "kops-version-marker")
|
tempSrc, err := os.CreateTemp("", "kops-version-marker")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
package deployer
|
package deployer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
|
@ -29,7 +29,7 @@ import (
|
||||||
// renderTemplate will render the manifest template with the provided values,
|
// renderTemplate will render the manifest template with the provided values,
|
||||||
// setting the deployer's manifestPath
|
// setting the deployer's manifestPath
|
||||||
func (d *deployer) renderTemplate(values map[string]interface{}) error {
|
func (d *deployer) renderTemplate(values map[string]interface{}) error {
|
||||||
dir, err := ioutil.TempDir("", "kops-template")
|
dir, err := os.MkdirTemp("", "kops-template")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -39,7 +39,10 @@ func (d *deployer) renderTemplate(values map[string]interface{}) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
valuesPath := path.Join(dir, "values.yaml")
|
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")
|
manifestPath := path.Join(dir, "manifest.yaml")
|
||||||
d.manifestPath = manifestPath
|
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) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func SetupSSH(project string) (string, string, error) {
|
func SetupSSH(project string) (string, string, error) {
|
||||||
dir, err := os.MkdirTemp("kops", "ssh")
|
dir, err := os.MkdirTemp("", "kops-ssh")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ package kops
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -39,7 +38,7 @@ func DownloadKops(markerURL, downloadPath string) (string, string, error) {
|
||||||
|
|
||||||
var kopsFile *os.File
|
var kopsFile *os.File
|
||||||
if downloadPath == "" {
|
if downloadPath == "" {
|
||||||
tmp, err := ioutil.TempFile("", "kops")
|
tmp, err := os.CreateTemp("", "kops")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ package target
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -48,7 +48,7 @@ func NewTerraform(version string) (*Terraform, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
tfDir, err := ioutil.TempDir("", "kops-terraform")
|
tfDir, err := os.MkdirTemp("", "kops-terraform")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -84,7 +83,7 @@ func (t *Tester) extractBinaries(downloadPath string) (string, error) {
|
||||||
}
|
}
|
||||||
tarReader := tar.NewReader(gzf)
|
tarReader := tar.NewReader(gzf)
|
||||||
|
|
||||||
kubectlDir, err := ioutil.TempDir("", "kubectl")
|
kubectlDir, err := os.MkdirTemp("", "kubectl")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -33,7 +32,7 @@ func UnzipToTempDir(data []byte) (string, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
dir, err := ioutil.TempDir("", "")
|
dir, err := os.MkdirTemp("", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue