From 60d4de7c6806d348f1658064a8ef94f453880f19 Mon Sep 17 00:00:00 2001 From: Dan Lorenc <dlorenc@google.com> Date: Wed, 18 Nov 2020 10:25:34 -0600 Subject: [PATCH] Create a "cli" directory under cmd. This is the first step in code reorganization. This follows the patterns from kubernetes/kubernetes - each binary gets a directory under cmd/. The main.go file for each binary lives there. The commands live under cmd//app. --- cmd/{ => cli/app}/root.go | 2 +- cmd/{ => cli/app}/upload.go | 12 ++++++------ cmd/{ => cli/app}/verify.go | 8 ++++---- main.go => cmd/cli/main.go | 4 ++-- go.mod | 2 +- {app => pkg}/client.go | 4 ++-- {app => pkg}/file.go | 2 +- {app => pkg}/gpg.go | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) rename cmd/{ => cli/app}/root.go (99%) rename cmd/{ => cli/app}/upload.go (96%) rename cmd/{ => cli/app}/verify.go (95%) rename main.go => cmd/cli/main.go (90%) rename {app => pkg}/client.go (97%) rename {app => pkg}/file.go (97%) rename {app => pkg}/gpg.go (99%) diff --git a/cmd/root.go b/cmd/cli/app/root.go similarity index 99% rename from cmd/root.go rename to cmd/cli/app/root.go index fa50bce..f3c5421 100644 --- a/cmd/root.go +++ b/cmd/cli/app/root.go @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -package cmd +package app import ( "fmt" diff --git a/cmd/upload.go b/cmd/cli/app/upload.go similarity index 96% rename from cmd/upload.go rename to cmd/cli/app/upload.go index 0c5f4c2..c349627 100644 --- a/cmd/upload.go +++ b/cmd/cli/app/upload.go @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -package cmd +package app import ( "bytes" @@ -32,8 +32,8 @@ import ( "github.com/google/trillian" homedir "github.com/mitchellh/go-homedir" - "github.com/projectrekor/rekor-cli/app" - "github.com/projectrekor/rekor-cli/log" + "github.com/projectrekor/rekor/log" + "github.com/projectrekor/rekor/pkg" "github.com/spf13/cobra" "github.com/spf13/viper" "golang.org/x/crypto/openpgp" @@ -122,13 +122,13 @@ of the release artifact and uploads it to the rekor server.`, // Let's check the formatting is correct, if not we // exit and allow the user to resolve their corrupted // GPG files. - sig, err := app.FormatSignature(signature) + sig, err := pkg.FormatSignature(signature) if err != nil { log.Error("Signature validation failed: ", err) os.Exit(1) } - pub_key, err := app.FormatPubKey(publicKey) + pub_key, err := pkg.FormatPubKey(publicKey) if err != nil { log.Error("Pubic key validation failed: ", err) os.Exit(1) @@ -249,7 +249,7 @@ of the release artifact and uploads it to the rekor server.`, log.Fatal(err) } - if err := app.AddFileToRequest(request, f); err != nil { + if err := pkg.AddFileToRequest(request, f); err != nil { log.Fatal(err) } client := &http.Client{} diff --git a/cmd/verify.go b/cmd/cli/app/verify.go similarity index 95% rename from cmd/verify.go rename to cmd/cli/app/verify.go index 28d4316..7b4d688 100644 --- a/cmd/verify.go +++ b/cmd/cli/app/verify.go @@ -13,16 +13,16 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -package cmd +package app import ( "encoding/json" "io/ioutil" "os" - "github.com/projectrekor/rekor-cli/app" - "github.com/projectrekor/rekor-cli/log" "github.com/projectrekor/rekor-server/types" + "github.com/projectrekor/rekor/log" + "github.com/projectrekor/rekor/pkg" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -79,7 +79,7 @@ var verifyCmd = &cobra.Command{ if err != nil { log.Fatal(err) } - app.DoGet(url, b) + pkg.DoGet(url, b) }, } diff --git a/main.go b/cmd/cli/main.go similarity index 90% rename from main.go rename to cmd/cli/main.go index 4c47f7a..766e1fe 100644 --- a/main.go +++ b/cmd/cli/main.go @@ -15,8 +15,8 @@ limitations under the License. */ package main -import "github.com/projectrekor/rekor-cli/cmd" +import "github.com/projectrekor/rekor/cmd/cli/app" func main() { - cmd.Execute() + app.Execute() } diff --git a/go.mod b/go.mod index a14b214..efca0cf 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/projectrekor/rekor-cli +module github.com/projectrekor/rekor go 1.14 diff --git a/app/client.go b/pkg/client.go similarity index 97% rename from app/client.go rename to pkg/client.go index 07ff982..fc34b98 100644 --- a/app/client.go +++ b/pkg/client.go @@ -1,4 +1,4 @@ -package app +package pkg import ( "bytes" @@ -15,7 +15,7 @@ import ( tcrypto "github.com/google/trillian/crypto" "github.com/google/trillian/merkle" "github.com/google/trillian/merkle/rfc6962" - "github.com/projectrekor/rekor-cli/log" + "github.com/projectrekor/rekor/log" ) type getProofResponse struct { diff --git a/app/file.go b/pkg/file.go similarity index 97% rename from app/file.go rename to pkg/file.go index 8eecf62..a49a206 100644 --- a/app/file.go +++ b/pkg/file.go @@ -1,4 +1,4 @@ -package app +package pkg import ( "bytes" diff --git a/app/gpg.go b/pkg/gpg.go similarity index 99% rename from app/gpg.go rename to pkg/gpg.go index cf663db..1c6c31e 100644 --- a/app/gpg.go +++ b/pkg/gpg.go @@ -1,4 +1,4 @@ -package app +package pkg import ( "bytes" -- GitLab