Skip to content

Commit f883f38

Browse files
loresusopoiana
authored andcommitted
chore: don't use logrus as logger
Signed-off-by: Lorenzo Susini <[email protected]>
1 parent 4c4cd3d commit f883f38

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ require (
1212
github.com/onsi/gomega v1.20.0
1313
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799
1414
github.com/pterm/pterm v0.12.45
15-
github.com/sirupsen/logrus v1.9.0
1615
github.com/spf13/cobra v1.5.0
1716
github.com/spf13/pflag v1.0.5
1817
gopkg.in/yaml.v3 v3.0.1
@@ -97,6 +96,7 @@ require (
9796
github.com/prometheus/procfs v0.7.3 // indirect
9897
github.com/rivo/uniseg v0.2.0 // indirect
9998
github.com/russross/blackfriday v1.5.2 // indirect
99+
github.com/sirupsen/logrus v1.9.0 // indirect
100100
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca // indirect
101101
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
102102
github.com/yvasiyarov/go-metrics v0.0.0-20150112132944-c25f46c4b940 // indirect

pkg/install/tls/generator.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ import (
2727
"os"
2828
"path/filepath"
2929
"time"
30-
31-
logger "github.com/sirupsen/logrus"
3230
)
3331

3432
// DefaultRSABits is the default bit size to generate an RSA keypair
@@ -208,7 +206,6 @@ func (g *GRPCTLS) FlushToDisk(path string) error {
208206

209207
for _, name := range certsFilenames {
210208
f := filepath.Join(path, name)
211-
logger.Infof("Writing: %s", f)
212209
if err := ioutil.WriteFile(f, g.certs[name].Bytes(), 0600); err != nil {
213210
return fmt.Errorf(`unable to write "%s": %v`, name, err)
214211
}

pkg/oci/authn/credentialstore.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"github.com/docker/cli/cli/config/configfile"
2626
"github.com/docker/cli/cli/config/credentials"
2727
"github.com/docker/cli/cli/config/types"
28-
logger "github.com/sirupsen/logrus"
2928
"oras.land/oras-go/v2/registry/remote/auth"
3029
)
3130

@@ -66,9 +65,8 @@ func NewStore(configPaths ...string) (*Store, error) {
6665
}
6766

6867
// loadConfigFile reads the credential-related configurationfrom the given path.
69-
func loadConfigFile(path string) (*configfile.ConfigFile, error) {
70-
var cfg *configfile.ConfigFile
71-
if _, err := os.Stat(path); err != nil {
68+
func loadConfigFile(path string) (cfg *configfile.ConfigFile, err error) {
69+
if _, err = os.Stat(path); err != nil {
7270
if os.IsNotExist(err) {
7371
cfg = configfile.New(path)
7472
} else {
@@ -80,12 +78,13 @@ func loadConfigFile(path string) (*configfile.ConfigFile, error) {
8078
return nil, err
8179
}
8280
defer func() {
83-
if err := file.Close(); err != nil {
84-
logger.Printf("Error closing file: %s\n", err)
81+
if err != nil {
82+
return
8583
}
84+
err = file.Close()
8685
}()
8786
cfg = configfile.New(path)
88-
if err := cfg.LoadFromReader(file); err != nil {
87+
if err = cfg.LoadFromReader(file); err != nil {
8988
return nil, err
9089
}
9190
}

pkg/oci/pusher/pusher.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525

2626
"github.com/opencontainers/image-spec/specs-go"
2727
v1 "github.com/opencontainers/image-spec/specs-go/v1"
28-
logger "github.com/sirupsen/logrus"
2928
"oras.land/oras-go/v2"
3029
"oras.land/oras-go/v2/content/file"
3130
"oras.land/oras-go/v2/registry/remote"
@@ -251,7 +250,7 @@ func (p *Pusher) storeArtifactsIndex(ctx context.Context, fileStore *file.Store,
251250
return p.toFileStore(ctx, fileStore, index.MediaType, ArtifactsIndexName, index)
252251
}
253252

254-
func (p *Pusher) toFileStore(ctx context.Context, fileStore *file.Store, mediaType, name string, data interface{}) (*v1.Descriptor, error) {
253+
func (p *Pusher) toFileStore(ctx context.Context, fileStore *file.Store, mediaType, name string, data interface{}) (desc *v1.Descriptor, err error) {
255254
dataBytes, err := json.Marshal(data)
256255
if err != nil {
257256
return nil, fmt.Errorf("unable to marshal data of media type %q: %w", mediaType, err)
@@ -263,20 +262,22 @@ func (p *Pusher) toFileStore(ctx context.Context, fileStore *file.Store, mediaTy
263262
return nil, err
264263
}
265264
defer func() {
266-
if err := configFile.Close(); err != nil {
267-
logger.Printf("Error closing file: %s\n", err)
265+
if err != nil {
266+
return
268267
}
268+
err = configFile.Close()
269269
}()
270270

271271
if _, err := configFile.Write(dataBytes); err != nil {
272272
return nil, fmt.Errorf("unable to write data of media type %q to temporary file %s: %w", mediaType, configFile.Name(), err)
273273
}
274274

275-
desc, err := fileStore.Add(ctx, name, mediaType, filepath.Clean(configFile.Name()))
275+
d, err := fileStore.Add(ctx, name, mediaType, filepath.Clean(configFile.Name()))
276276
if err != nil {
277277
return nil, fmt.Errorf("unable to store data of media type %q in the file store: %w", mediaType, err)
278278
}
279-
return &desc, nil
279+
desc = &d
280+
return
280281
}
281282

282283
func (p *Pusher) packManifest(ctx context.Context, fileStore *file.Store,

0 commit comments

Comments
 (0)