summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/run.go3
-rw-r--r--cmd/template.go4
-rw-r--r--docs/configuration/applications.md2
-rw-r--r--ext/git/creds.go11
-rw-r--r--ext/git/git_test.go16
-rw-r--r--pkg/argocd/git.go11
-rw-r--r--pkg/argocd/update_test.go9
-rw-r--r--pkg/registry/config.go4
-rw-r--r--test/fixture/capture.go6
-rw-r--r--test/fixture/fileutil.go6
10 files changed, 34 insertions, 38 deletions
diff --git a/cmd/run.go b/cmd/run.go
index 581bc4b..305863d 100644
--- a/cmd/run.go
+++ b/cmd/run.go
@@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
- "io/ioutil"
"os"
"strings"
"sync"
@@ -62,7 +61,7 @@ func newRunCommand() *cobra.Command {
// User can specify a path to a template used for Git commit messages
if commitMessagePath != "" {
- tpl, err := ioutil.ReadFile(commitMessagePath)
+ tpl, err := os.ReadFile(commitMessagePath)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
log.Warnf("commit message template at %s does not exist, using default", commitMessagePath)
diff --git a/cmd/template.go b/cmd/template.go
index c73fd30..4c6c925 100644
--- a/cmd/template.go
+++ b/cmd/template.go
@@ -2,7 +2,7 @@ package main
import (
"fmt"
- "io/ioutil"
+ "os"
"text/template"
"time"
@@ -37,7 +37,7 @@ If PATH is not given, will show you the default message that is used.
tplStr = common.DefaultGitCommitMessage
} else {
commitMessageTemplatePath = args[0]
- tplData, err := ioutil.ReadFile(commitMessageTemplatePath)
+ tplData, err := os.ReadFile(commitMessageTemplatePath)
if err != nil {
log.Fatalf("%v", err)
}
diff --git a/docs/configuration/applications.md b/docs/configuration/applications.md
index c334c4b..dfbb0f6 100644
--- a/docs/configuration/applications.md
+++ b/docs/configuration/applications.md
@@ -51,7 +51,7 @@ spec:
project: default
source:
path: helm-guestbook
- repoURL: https://github.com/argocd-example-apps/argocd-example-apps
+ repoURL: https://github.com/argoproj/argocd-example-apps
targetRevision: HEAD
```
diff --git a/ext/git/creds.go b/ext/git/creds.go
index d326277..c8f6493 100644
--- a/ext/git/creds.go
+++ b/ext/git/creds.go
@@ -5,7 +5,6 @@ import (
"crypto/sha256"
"fmt"
"io"
- "io/ioutil"
"os"
"strconv"
"strings"
@@ -118,10 +117,10 @@ func (c HTTPSCreds) Environ() (io.Closer, []string, error) {
// We need to actually create two temp files, one for storing cert data and
// another for storing the key. If we fail to create second fail, the first
// must be removed.
- certFile, err := ioutil.TempFile(argoio.TempDir, "")
+ certFile, err := os.CreateTemp(argoio.TempDir, "")
if err == nil {
defer certFile.Close()
- keyFile, err = ioutil.TempFile(argoio.TempDir, "")
+ keyFile, err = os.CreateTemp(argoio.TempDir, "")
if err != nil {
removeErr := os.Remove(certFile.Name())
if removeErr != nil {
@@ -204,7 +203,7 @@ func (f authFilePaths) Close() error {
func (c SSHCreds) Environ() (io.Closer, []string, error) {
// use the SHM temp dir from util, more secure
- file, err := ioutil.TempFile(argoio.TempDir, "")
+ file, err := os.CreateTemp(argoio.TempDir, "")
if err != nil {
return nil, nil, err
}
@@ -275,10 +274,10 @@ func (g GitHubAppCreds) Environ() (io.Closer, []string, error) {
// We need to actually create two temp files, one for storing cert data and
// another for storing the key. If we fail to create second fail, the first
// must be removed.
- certFile, err := ioutil.TempFile(argoio.TempDir, "")
+ certFile, err := os.CreateTemp(argoio.TempDir, "")
if err == nil {
defer certFile.Close()
- keyFile, err = ioutil.TempFile(argoio.TempDir, "")
+ keyFile, err = os.CreateTemp(argoio.TempDir, "")
if err != nil {
removeErr := os.Remove(certFile.Name())
if removeErr != nil {
diff --git a/ext/git/git_test.go b/ext/git/git_test.go
index 8738b75..de04454 100644
--- a/ext/git/git_test.go
+++ b/ext/git/git_test.go
@@ -2,7 +2,7 @@ package git
import (
"fmt"
- "io/ioutil"
+ "io"
"net/http"
"os"
"path/filepath"
@@ -137,11 +137,11 @@ func TestCustomHTTPClient(t *testing.T) {
assert.NoError(t, err)
assert.NotEqual(t, "", keyFile)
- certData, err := ioutil.ReadFile(certFile)
+ certData, err := os.ReadFile(certFile)
assert.NoError(t, err)
assert.NotEqual(t, "", string(certData))
- keyData, err := ioutil.ReadFile(keyFile)
+ keyData, err := os.ReadFile(keyFile)
assert.NoError(t, err)
assert.NotEqual(t, "", string(keyData))
@@ -245,7 +245,7 @@ func TestLFSClient(t *testing.T) {
// TODO(alexmt): dockerize tests in and enabled it
t.Skip()
- tempDir, err := ioutil.TempDir("", "git-client-lfs-test-")
+ tempDir, err := os.MkdirTemp("", "git-client-lfs-test-")
assert.NoError(t, err)
if err == nil {
defer func() { _ = os.RemoveAll(tempDir) }()
@@ -275,7 +275,7 @@ func TestLFSClient(t *testing.T) {
assert.NoError(t, err)
if err == nil {
defer fileHandle.Close()
- text, err := ioutil.ReadAll(fileHandle)
+ text, err := io.ReadAll(fileHandle)
assert.NoError(t, err)
if err == nil {
assert.Equal(t, "This is not a YAML, sorry.\n", string(text))
@@ -284,7 +284,7 @@ func TestLFSClient(t *testing.T) {
}
func TestVerifyCommitSignature(t *testing.T) {
- p, err := ioutil.TempDir("", "test-verify-commit-sig")
+ p, err := os.MkdirTemp("", "test-verify-commit-sig")
if err != nil {
panic(err.Error())
}
@@ -343,7 +343,7 @@ func TestNewFactory(t *testing.T) {
test.Flaky(t)
}
- dirName, err := ioutil.TempDir("", "git-client-test-")
+ dirName, err := os.MkdirTemp("", "git-client-test-")
assert.NoError(t, err)
defer func() { _ = os.RemoveAll(dirName) }()
@@ -381,7 +381,7 @@ func TestNewFactory(t *testing.T) {
}
func TestListRevisions(t *testing.T) {
- dir, err := ioutil.TempDir("", "test-list-revisions")
+ dir, err := os.MkdirTemp("", "test-list-revisions")
if err != nil {
panic(err.Error())
}
diff --git a/pkg/argocd/git.go b/pkg/argocd/git.go
index d97d0a5..6aa4b42 100644
--- a/pkg/argocd/git.go
+++ b/pkg/argocd/git.go
@@ -5,7 +5,6 @@ import (
"crypto/sha256"
"encoding/hex"
"fmt"
- "io/ioutil"
"os"
"path"
"path/filepath"
@@ -136,7 +135,7 @@ func commitChangesGit(app *v1alpha1.Application, wbc *WriteBackConfig, changeLis
}
var gitC git.Client
if wbc.GitClient == nil {
- tempRoot, err := ioutil.TempDir(os.TempDir(), fmt.Sprintf("git-%s", app.Name))
+ tempRoot, err := os.MkdirTemp(os.TempDir(), fmt.Sprintf("git-%s", app.Name))
if err != nil {
return err
}
@@ -220,12 +219,12 @@ func commitChangesGit(app *v1alpha1.Application, wbc *WriteBackConfig, changeLis
commitOpts := &git.CommitOptions{}
if wbc.GitCommitMessage != "" {
- cm, err := ioutil.TempFile("", "image-updater-commit-msg")
+ cm, err := os.CreateTemp("", "image-updater-commit-msg")
if err != nil {
return fmt.Errorf("cold not create temp file: %v", err)
}
logCtx.Debugf("Writing commit message to %s", cm.Name())
- err = ioutil.WriteFile(cm.Name(), []byte(wbc.GitCommitMessage), 0600)
+ err = os.WriteFile(cm.Name(), []byte(wbc.GitCommitMessage), 0600)
if err != nil {
_ = cm.Close()
return fmt.Errorf("could not write commit message to %s: %v", cm.Name(), err)
@@ -269,7 +268,7 @@ func writeOverrides(app *v1alpha1.Application, wbc *WriteBackConfig, gitC git.Cl
// our generated new file is the same as the existing one, and if yes, we
// don't proceed further for commit.
if targetExists {
- data, err := ioutil.ReadFile(targetFile)
+ data, err := os.ReadFile(targetFile)
if err != nil {
return err, false
}
@@ -279,7 +278,7 @@ func writeOverrides(app *v1alpha1.Application, wbc *WriteBackConfig, gitC git.Cl
}
}
- err = ioutil.WriteFile(targetFile, override, 0600)
+ err = os.WriteFile(targetFile, override, 0600)
if err != nil {
return
}
diff --git a/pkg/argocd/update_test.go b/pkg/argocd/update_test.go
index c18e3ee..ea5cdcc 100644
--- a/pkg/argocd/update_test.go
+++ b/pkg/argocd/update_test.go
@@ -3,7 +3,6 @@ package argocd
import (
"errors"
"fmt"
- "io/ioutil"
"os"
"path/filepath"
"strings"
@@ -1816,7 +1815,7 @@ func Test_CommitUpdates(t *testing.T) {
gitMock, dir, cleanup := mockGit(t)
defer cleanup()
kf := filepath.Join(dir, "kustomization.yml")
- assert.NoError(t, ioutil.WriteFile(kf, []byte(`
+ assert.NoError(t, os.WriteFile(kf, []byte(`
kind: Kustomization
apiVersion: kustomize.config.k8s.io/v1beta1
@@ -1838,7 +1837,7 @@ replacements: []
err = commitChanges(app, wbc, nil)
assert.NoError(t, err)
- kust, err := ioutil.ReadFile(kf)
+ kust, err := os.ReadFile(kf)
assert.NoError(t, err)
assert.YAMLEq(t, `
kind: Kustomization
@@ -1857,7 +1856,7 @@ replacements: []
app.Spec.Source.Kustomize.Images = v1alpha1.KustomizeImages{"foo:123", "bar=qux"}
err = commitChanges(app, wbc, nil)
assert.NoError(t, err)
- kust, err = ioutil.ReadFile(kf)
+ kust, err = os.ReadFile(kf)
assert.NoError(t, err)
assert.YAMLEq(t, `
kind: Kustomization
@@ -2044,7 +2043,7 @@ func Test_parseTarget(t *testing.T) {
}
func mockGit(t *testing.T) (gitMock *gitmock.Client, dir string, cleanup func()) {
- dir, err := ioutil.TempDir("", "wb-kust")
+ dir, err := os.MkdirTemp("", "wb-kust")
assert.NoError(t, err)
gitMock = &gitmock.Client{}
gitMock.On("Root").Return(dir)
diff --git a/pkg/registry/config.go b/pkg/registry/config.go
index 0592648..0b6dbe9 100644
--- a/pkg/registry/config.go
+++ b/pkg/registry/config.go
@@ -2,7 +2,7 @@ package registry
import (
"fmt"
- "io/ioutil"
+ "os"
"time"
"github.com/argoproj-labs/argocd-image-updater/pkg/log"
@@ -40,7 +40,7 @@ func clearRegistries() {
// LoadRegistryConfiguration loads a YAML-formatted registry configuration from
// a given file at path.
func LoadRegistryConfiguration(path string, clear bool) error {
- registryBytes, err := ioutil.ReadFile(path)
+ registryBytes, err := os.ReadFile(path)
if err != nil {
return err
}
diff --git a/test/fixture/capture.go b/test/fixture/capture.go
index 57073bb..cf09ed3 100644
--- a/test/fixture/capture.go
+++ b/test/fixture/capture.go
@@ -1,7 +1,7 @@
package fixture
import (
- "io/ioutil"
+ "io"
"os"
)
@@ -22,7 +22,7 @@ func CaptureStdout(callback func()) (string, error) {
w.Close()
- data, err := ioutil.ReadAll(r)
+ data, err := io.ReadAll(r)
if err != nil {
return "", err
@@ -46,7 +46,7 @@ func CaptureStderr(callback func()) (string, error) {
callback()
w.Close()
- data, err := ioutil.ReadAll(r)
+ data, err := io.ReadAll(r)
if err != nil {
return "", err
diff --git a/test/fixture/fileutil.go b/test/fixture/fileutil.go
index ce75911..7820b72 100644
--- a/test/fixture/fileutil.go
+++ b/test/fixture/fileutil.go
@@ -1,12 +1,12 @@
package fixture
-// Fixture functions for tests related to files
+import "os"
-import "io/ioutil"
+// Fixture functions for tests related to files
// MustReadFile must read a file from given path. Panics if it can't.
func MustReadFile(path string) string {
- retBytes, err := ioutil.ReadFile(path)
+ retBytes, err := os.ReadFile(path)
if err != nil {
panic(err)
}