From 1c671bef6c223dd88f8c57dd9be6d2cd16163a9b Mon Sep 17 00:00:00 2001 From: Fedor Korotkiy Date: Fri, 10 Mar 2023 15:23:34 +0400 Subject: [PATCH] Redoing public export --- build.docker | 5 ++- tools/testtool/commands/list_private_files.go | 45 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 tools/testtool/commands/list_private_files.go diff --git a/build.docker b/build.docker index 7895c31..03832db 100644 --- a/build.docker +++ b/build.docker @@ -1,7 +1,10 @@ FROM golang:1.20 +# enable backports for git-filter-repo +RUN echo "deb http://deb.debian.org/debian bullseye-backports main" >> /etc/apt/sources.list.d/backports.list + RUN apt-get update && apt-get install -y \ - rsync libssl-dev postgresql sudo redis-server \ + rsync libssl-dev postgresql sudo redis-server git-filter-repo/bullseye-backports \ && rm -rf /var/lib/apt/lists/* RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.51.1 diff --git a/tools/testtool/commands/list_private_files.go b/tools/testtool/commands/list_private_files.go new file mode 100644 index 0000000..a338682 --- /dev/null +++ b/tools/testtool/commands/list_private_files.go @@ -0,0 +1,45 @@ +package commands + +import ( + "fmt" + "os" + "path/filepath" + + "github.com/spf13/cobra" +) + +var listPrivateFilesCmd = &cobra.Command{ + Use: "list-private-files", + Short: "list private files", + Run: runListPrivateFiles, +} + +func init() { + rootCmd.AddCommand(listPrivateFilesCmd) +} + +func doListPrivateFiles() error { + cwd, err := os.Getwd() + if err != nil { + return err + } + + privateFiles := listPrivateFiles(".") + for _, f := range privateFiles { + rel, err := filepath.Rel(cwd, f) + if err != nil { + return err + } + + fmt.Println(rel) + } + + return nil +} + +func runListPrivateFiles(cmd *cobra.Command, args []string) { + if err := doListPrivateFiles(); err != nil { + fmt.Fprintf(os.Stderr, "testtool: %v\n", err) + os.Exit(1) + } +}