From 82bd13b127ba08c941956bdbdf787e47275dcdf9 Mon Sep 17 00:00:00 2001 From: Meredith Lancaster Date: Fri, 1 Mar 2024 17:52:20 -0700 Subject: [PATCH] add logger and test packages Signed-off-by: Meredith Lancaster --- pkg/cmd/attestation/logger/logger.go | 22 ++++++++++++++++++++++ pkg/cmd/attestation/test/path.go | 13 +++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 pkg/cmd/attestation/logger/logger.go create mode 100644 pkg/cmd/attestation/test/path.go diff --git a/pkg/cmd/attestation/logger/logger.go b/pkg/cmd/attestation/logger/logger.go new file mode 100644 index 000000000..0e5beb62e --- /dev/null +++ b/pkg/cmd/attestation/logger/logger.go @@ -0,0 +1,22 @@ +package logger + +import ( + "fmt" + + "github.com/cli/cli/v2/pkg/iostreams" +) + +type Logger struct { + IO *iostreams.IOStreams + Quiet bool + Verbose bool +} + +func (l *Logger) VerbosePrint(msg string) (int, error) { + if !l.verbose || !opts.IO.IsStdoutTTY() { + return 0, nil + } + + return fmt.Fprintf(l.IO.ErrOut, msg) +} + diff --git a/pkg/cmd/attestation/test/path.go b/pkg/cmd/attestation/test/path.go new file mode 100644 index 000000000..1e8d52cf9 --- /dev/null +++ b/pkg/cmd/attestation/test/path.go @@ -0,0 +1,13 @@ +package test + +import ( + "path/filepath" + "runtime" +) + +func NormalizeRelativePath(posixPath string) string { + if runtime.GOOS == "windows" { + return filepath.FromSlash(posixPath) + } + return posixPath +}