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 64465e2
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 21 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, func(ctx context.Context) (bool, error) {

Check failure on line 158 in internal/cloud/kubernetes.go

View workflow job for this annotation

GitHub Actions / Verify k8s build (macos-latest, 1.19.x)

not enough arguments in call to wait.PollUntilContextTimeout

Check failure on line 158 in internal/cloud/kubernetes.go

View workflow job for this annotation

GitHub Actions / Verify k8s build (ubuntu-latest, 1.19.x)

not enough arguments in call to wait.PollUntilContextTimeout

Check failure on line 158 in internal/cloud/kubernetes.go

View workflow job for this annotation

GitHub Actions / Test (macos-latest, 1.23.x)

not enough arguments in call to wait.PollUntilContextTimeout

Check failure on line 158 in internal/cloud/kubernetes.go

View workflow job for this annotation

GitHub Actions / Lint

not enough arguments in call to wait.PollUntilContextTimeout

Check failure on line 158 in internal/cloud/kubernetes.go

View workflow job for this annotation

GitHub Actions / Test (macos-latest, 1.19.x)

not enough arguments in call to wait.PollUntilContextTimeout

Check failure on line 158 in internal/cloud/kubernetes.go

View workflow job for this annotation

GitHub Actions / Verify k8s build (macos-latest, 1.19.x)

not enough arguments in call to wait.PollUntilContextTimeout

Check failure on line 158 in internal/cloud/kubernetes.go

View workflow job for this annotation

GitHub Actions / Test (macos-latest, 1.19.x)

not enough arguments in call to wait.PollUntilContextTimeout

Check failure on line 158 in internal/cloud/kubernetes.go

View workflow job for this annotation

GitHub Actions / Lint

not enough arguments in call to wait.PollUntilContextTimeout
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
10 changes: 5 additions & 5 deletions 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 Expand Up @@ -237,7 +237,7 @@ func (i *kubernetesContainerImage) Prepare() error {

download := func(vol volume.Volume, downloadPath string, containerPath string) error {
log.Infof("Downloading %s to %s", downloadPath, containerPath)
return i.Run(i.runner.vol, options{},
return i.Run(context.Background(), i.runner.vol, options{},
AddAWSParameters(i.runner.aws, "fyne-cross-s3", "download-directory", downloadPath, containerPath),
)
}
Expand Down Expand Up @@ -282,13 +282,13 @@ func (i *kubernetesContainerImage) Finalize(packageName string) (ret error) {
// to compress it in a format that Darwin understand by default
if strings.ToLower(filepath.Ext(packageName)) == ".app" {
uploadPath += ".tar.xz"
ret = i.Run(i.runner.vol, options{},
ret = i.Run(context.Background(), i.runner.vol, options{},
AddAWSParameters(i.runner.aws,
"fyne-cross-s3", "upload-directory",
volume.JoinPathContainer(i.runner.vol.TmpDirContainer(), i.ID(), packageName), uploadPath),
)
} else {
ret = i.Run(i.runner.vol, options{},
ret = i.Run(context.Background(), i.runner.vol, options{},
AddAWSParameters(i.runner.aws,
"fyne-cross-s3", "upload-file",
volume.JoinPathContainer(i.runner.vol.TmpDirContainer(), i.ID(), packageName), uploadPath),
Expand All @@ -301,7 +301,7 @@ func (i *kubernetesContainerImage) Finalize(packageName string) (ret error) {
// Upload cached data to S3
for _, mountPoint := range i.cloudLocalMount {
log.Infof("Uploading %s to %s", mountPoint.inContainer, i.runner.s3Path+"/"+mountPoint.name+"-"+i.ID()+".tar.zstd")
err := i.Run(i.runner.vol, options{},
err := i.Run(context.Background(), i.runner.vol, options{},
AddAWSParameters(i.runner.aws,
"fyne-cross-s3", "upload-directory",
mountPoint.inContainer, i.runner.s3Path+"/"+mountPoint.name+"-"+i.ID()+".tar.zstd"),
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 64465e2

Please sign in to comment.