Skip to content

Commit

Permalink
Remove use of deprecated functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bluebugs committed Jan 18, 2025
1 parent 52c676d commit 344ab76
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 17 deletions.
8 changes: 4 additions & 4 deletions internal/cloud/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ func (k8s *K8sClient) NewPod(ctx context.Context, name string, image string, nam
}

logWrapper("Waiting for pod to be ready")
err = wait.PollImmediate(time.Second, time.Duration(10)*time.Minute, func() (bool, error) {
pod, err := api.Pods(namespace).Get(context.Background(), name, meta.GetOptions{})
err = wait.PollUntilContextTimeout(ctx, time.Second, time.Duration(10)*time.Minute, true, func(ctx context.Context) (bool, error) {
pod, err := api.Pods(namespace).Get(ctx, name, meta.GetOptions{})
if err != nil {
return false, err
}
Expand All @@ -182,7 +182,7 @@ func (k8s *K8sClient) NewPod(ctx context.Context, name string, image string, nam
}, nil
}

func (p *Pod) Run(workDir string, cmdArgs []string) error {
func (p *Pod) Run(ctx context.Context, workDir string, cmdArgs []string) error {
api := p.client.kubectl.CoreV1()

if workDir != "" && workDir != p.workDir {
Expand Down Expand Up @@ -218,7 +218,7 @@ func (p *Pod) Run(workDir string, cmdArgs []string) error {
}

logWrapper("Executing command %v", cmdArgs)
err = exec.Stream(remotecommand.StreamOptions{
err = exec.StreamWithContext(ctx, remotecommand.StreamOptions{
Stdin: os.Stdin,
Stdout: os.Stderr,
Stderr: os.Stderr,
Expand Down
5 changes: 2 additions & 3 deletions internal/cloud/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -104,7 +103,7 @@ func (a *AWSSession) UploadFile(localFile string, s3FilePath string) error {
}

func (a *AWSSession) UploadCompressedDirectory(localDirectoy string, s3FilePath string) error {
file, err := ioutil.TempFile("", "fyne-cross-s3")
file, err := os.CreateTemp("", "fyne-cross-s3")
if err != nil {
return err
}
Expand Down Expand Up @@ -255,7 +254,7 @@ func (a *AWSSession) DownloadFile(s3FilePath string, localFile string) error {
}

func (a *AWSSession) DownloadCompressedDirectory(s3FilePath string, localRootDirectory string) error {
file, err := ioutil.TempFile("", "fyne-cross-s3")
file, err := os.CreateTemp("", "fyne-cross-s3")
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions internal/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package command

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -134,7 +133,7 @@ func prepareIcon(ctx Context, image containerImage) error {
}

log.Infof("[!] Default icon not found at %q", ctx.Icon)
err = ioutil.WriteFile(volume.JoinPathHost(ctx.WorkDirHost(), ctx.Icon), icon.FyneLogo, 0644)
err = os.WriteFile(volume.JoinPathHost(ctx.WorkDirHost(), ctx.Icon), icon.FyneLogo, 0644)
if err != nil {
return fmt.Errorf("could not create the temporary icon: %s", err)
}
Expand Down
3 changes: 1 addition & 2 deletions internal/command/darwin_sdk_extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package command
import (
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -78,7 +77,7 @@ func (cmd *DarwinSDKExtract) Run() error {
}

// mount the fyne-cross volume
workDir, err := ioutil.TempDir("", cmd.Name())
workDir, err := os.MkdirTemp("", cmd.Name())
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/command/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (i *kubernetesContainerImage) close() error {
}

func (i *kubernetesContainerImage) Run(vol volume.Volume, opts options, cmdArgs []string) error {
return i.pod.Run(opts.WorkDir, cmdArgs)
return i.pod.Run(context.Background(), opts.WorkDir, cmdArgs)
}

func AddAWSParameters(aws *cloud.AWSSession, command string, s ...string) []string {
Expand Down
3 changes: 1 addition & 2 deletions internal/metadata/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package metadata

import (
"io"
"io/ioutil"
"os"
"path/filepath"

Expand All @@ -12,7 +11,7 @@ import (
// Load attempts to read a FyneApp metadata from the provided reader.
// If this cannot be done an error will be returned.
func Load(r io.Reader) (*FyneApp, error) {
str, err := ioutil.ReadAll(r)
str, err := io.ReadAll(r)
if err != nil {
return nil, err
}
Expand Down
5 changes: 2 additions & 3 deletions internal/volume/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"archive/zip"
"fmt"
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
Expand All @@ -31,11 +30,11 @@ const (

// Copy copies a resource from src to dest
func Copy(src string, dst string) error {
data, err := ioutil.ReadFile(src)
data, err := os.ReadFile(src)
if err != nil {
return err
}
return ioutil.WriteFile(dst, data, 0644)
return os.WriteFile(dst, data, 0644)
}

// DefaultCacheDirHost returns the default cache dir on the host
Expand Down

0 comments on commit 344ab76

Please sign in to comment.