From edda93245f89feb9031daeb8dc1fb77fd77b85ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorben=20G=C3=BCnther?= Date: Mon, 15 Nov 2021 13:06:16 +0100 Subject: [PATCH] Rename api to rest package As preparation for the GraphQL update, the api package will be renamed to rest. In the future the api package will be a wrapper that will call either the GraphQL or the REST API and house common support code. --- cmd/builds.go | 14 +++++++------- cmd/git.go | 8 ++++---- cmd/lists.go | 10 +++++----- cmd/meta.go | 8 ++++---- cmd/paste.go | 14 +++++++------- cmd/root.go | 4 ++-- cmd/todo.go | 8 ++++---- {api => rest}/api.go | 2 +- {api => rest}/builds.go | 2 +- {api => rest}/git.go | 2 +- {api => rest}/lists.go | 2 +- {api => rest}/meta.go | 2 +- {api => rest}/paste.go | 2 +- {api => rest}/todo.go | 2 +- 14 files changed, 40 insertions(+), 40 deletions(-) rename {api => rest}/api.go (99%) rename {api => rest}/builds.go (99%) rename {api => rest}/git.go (98%) rename {api => rest}/lists.go (99%) rename {api => rest}/meta.go (99%) rename {api => rest}/paste.go (99%) rename {api => rest}/todo.go (99%) diff --git a/cmd/builds.go b/cmd/builds.go index 5927477..9ac10df 100644 --- a/cmd/builds.go +++ b/cmd/builds.go @@ -1,8 +1,8 @@ package cmd import ( - "git.xenrox.net/~xenrox/srhtctl/api" "git.xenrox.net/~xenrox/srhtctl/helpers/errorhelper" + "git.xenrox.net/~xenrox/srhtctl/rest" "github.com/spf13/cobra" ) @@ -22,7 +22,7 @@ Takes yml manifests as arguments.`, Args: cobra.MinimumNArgs(1), ValidArgsFunction: completeYamlFiles, Run: func(cmd *cobra.Command, args []string) { - err := api.BuildDeploy(args) + err := rest.BuildDeploy(args) errorhelper.ExitError(err) }, } @@ -35,7 +35,7 @@ Takes one job ID as argument.`, Args: cobra.ExactArgs(1), ValidArgsFunction: completeNoFiles, Run: func(cmd *cobra.Command, args []string) { - err := api.BuildResubmit(args) + err := rest.BuildResubmit(args) errorhelper.ExitError(err) }, } @@ -48,7 +48,7 @@ Takes one job ID as argument.`, Args: cobra.ExactArgs(1), ValidArgsFunction: completeNoFiles, Run: func(cmd *cobra.Command, args []string) { - err := api.BuildInformation(args) + err := rest.BuildInformation(args) errorhelper.ExitError(err) }, } @@ -57,13 +57,13 @@ func init() { rootCmd.AddCommand(buildsCmd) buildsCmd.AddCommand(deployCmd) - deployCmd.PersistentFlags().StringVarP(&api.BuildNote, "note", "n", "", "Build note") + deployCmd.PersistentFlags().StringVarP(&rest.BuildNote, "note", "n", "", "Build note") deployCmd.RegisterFlagCompletionFunc("note", completeNoFiles) - deployCmd.PersistentFlags().StringSliceVarP(&api.BuildTags, "tags", "t", nil, "Comma seperated string of tags") + deployCmd.PersistentFlags().StringSliceVarP(&rest.BuildTags, "tags", "t", nil, "Comma seperated string of tags") deployCmd.RegisterFlagCompletionFunc("tags", completeNoFiles) buildsCmd.AddCommand(resubmitCmd) - resubmitCmd.PersistentFlags().BoolVarP(&api.BuildEdit, "edit", "e", false, "Edit manifest") + resubmitCmd.PersistentFlags().BoolVarP(&rest.BuildEdit, "edit", "e", false, "Edit manifest") buildsCmd.AddCommand(infoCmd) } diff --git a/cmd/git.go b/cmd/git.go index 60a4375..70cc1ef 100644 --- a/cmd/git.go +++ b/cmd/git.go @@ -1,8 +1,8 @@ package cmd import ( - "git.xenrox.net/~xenrox/srhtctl/api" "git.xenrox.net/~xenrox/srhtctl/helpers/errorhelper" + "git.xenrox.net/~xenrox/srhtctl/rest" "github.com/spf13/cobra" ) @@ -18,17 +18,17 @@ var artifactsCmd = &cobra.Command{ Short: "Upload artifact(s) to a ref", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - err := api.ArtifactsUpload(args) + err := rest.ArtifactsUpload(args) errorhelper.ExitError(err) }, } func init() { rootCmd.AddCommand(gitCmd) - gitCmd.PersistentFlags().StringVarP(&api.RepoName, "repo", "r", "", "Repository name") + gitCmd.PersistentFlags().StringVarP(&rest.RepoName, "repo", "r", "", "Repository name") gitCmd.RegisterFlagCompletionFunc("repo", completeNoFiles) gitCmd.AddCommand(artifactsCmd) - artifactsCmd.Flags().StringVar(&api.RefName, "ref", "", "Ref name") + artifactsCmd.Flags().StringVar(&rest.RefName, "ref", "", "Ref name") artifactsCmd.RegisterFlagCompletionFunc("ref", completeNoFiles) } diff --git a/cmd/lists.go b/cmd/lists.go index 1fd0766..05b412e 100644 --- a/cmd/lists.go +++ b/cmd/lists.go @@ -1,8 +1,8 @@ package cmd import ( - "git.xenrox.net/~xenrox/srhtctl/api" "git.xenrox.net/~xenrox/srhtctl/helpers/errorhelper" + "git.xenrox.net/~xenrox/srhtctl/rest" "github.com/spf13/cobra" ) @@ -25,7 +25,7 @@ var patchListCmd = &cobra.Command{ Use: "list", Short: "List patchsets", Run: func(cmd *cobra.Command, args []string) { - err := api.PrintPatchsets(args) + err := rest.PrintPatchsets(args) errorhelper.ExitError(err) }, } @@ -36,14 +36,14 @@ func init() { listsCmd.AddCommand(patchCmd) patchCmd.AddCommand(patchListCmd) - patchListCmd.Flags().StringVarP(&api.ListName, "list", "l", "", "List name") + patchListCmd.Flags().StringVarP(&rest.ListName, "list", "l", "", "List name") patchListCmd.RegisterFlagCompletionFunc("list", completeNoFiles) - patchListCmd.Flags().StringVarP(&api.PatchStatus, "status", "s", "proposed", "Patchset status") + patchListCmd.Flags().StringVarP(&rest.PatchStatus, "status", "s", "proposed", "Patchset status") patchListCmd.RegisterFlagCompletionFunc("status", func(cmd *cobra.Command, args []string, toComplete string) ( []string, cobra.ShellCompDirective) { return []string{"proposed", "needs_revision", "superseded", "approved", "rejected", "applied", "all"}, cobra.ShellCompDirectiveNoFileComp }) - patchListCmd.Flags().StringVarP(&api.PatchPrefix, "prefix", "p", "", "Patchset prefix") + patchListCmd.Flags().StringVarP(&rest.PatchPrefix, "prefix", "p", "", "Patchset prefix") patchListCmd.RegisterFlagCompletionFunc("prefix", completeNoFiles) } diff --git a/cmd/meta.go b/cmd/meta.go index b02b9f3..cd10291 100644 --- a/cmd/meta.go +++ b/cmd/meta.go @@ -1,8 +1,8 @@ package cmd import ( - "git.xenrox.net/~xenrox/srhtctl/api" "git.xenrox.net/~xenrox/srhtctl/helpers/errorhelper" + "git.xenrox.net/~xenrox/srhtctl/rest" "github.com/spf13/cobra" ) @@ -18,7 +18,7 @@ var profileCmd = &cobra.Command{ Short: "Get profile information", Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - err := api.MetaGetProfile() + err := rest.MetaGetProfile() errorhelper.ExitError(err) }, } @@ -27,7 +27,7 @@ var logCmd = &cobra.Command{ Use: "logs", Short: "Get audit logs", Run: func(cmd *cobra.Command, args []string) { - err := api.MetaGetLogs() + err := rest.MetaGetLogs() errorhelper.ExitError((err)) }, } @@ -36,7 +36,7 @@ func init() { rootCmd.AddCommand(metaCmd) metaCmd.AddCommand(profileCmd) - profileCmd.PersistentFlags().BoolVarP(&api.MetaEdit, "edit", "e", false, "Edit profile information") + profileCmd.PersistentFlags().BoolVarP(&rest.MetaEdit, "edit", "e", false, "Edit profile information") metaCmd.AddCommand(logCmd) } diff --git a/cmd/paste.go b/cmd/paste.go index cc622ea..60078a3 100644 --- a/cmd/paste.go +++ b/cmd/paste.go @@ -1,8 +1,8 @@ package cmd import ( - "git.xenrox.net/~xenrox/srhtctl/api" "git.xenrox.net/~xenrox/srhtctl/helpers/errorhelper" + "git.xenrox.net/~xenrox/srhtctl/rest" "github.com/spf13/cobra" ) @@ -19,7 +19,7 @@ var createCmd = &cobra.Command{ Long: `Create a new paste resource. Takes files as arguments.`, Run: func(cmd *cobra.Command, args []string) { - err := api.PasteCreate(args) + err := rest.PasteCreate(args) errorhelper.ExitError(err) }, } @@ -31,7 +31,7 @@ var deleteCmd = &cobra.Command{ Takes paste SHA hashes as arguments`, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - err := api.PasteDelete(args) + err := rest.PasteDelete(args) errorhelper.ExitError(err) }, } @@ -40,7 +40,7 @@ var cleanupCmd = &cobra.Command{ Use: "cleanup", Short: "Delete expired paste resources", Run: func(cmd *cobra.Command, args []string) { - err := api.PasteCleanup() + err := rest.PasteCleanup() errorhelper.ExitError(err) }, } @@ -49,12 +49,12 @@ func init() { rootCmd.AddCommand(pasteCmd) pasteCmd.AddCommand(createCmd) - createCmd.PersistentFlags().StringVarP(&api.PasteName, "name", "n", "unnamed", "Paste name") - createCmd.PersistentFlags().StringVarP(&api.PasteVisibility, "visibility", "v", "", "Paste visibility") + createCmd.PersistentFlags().StringVarP(&rest.PasteName, "name", "n", "unnamed", "Paste name") + createCmd.PersistentFlags().StringVarP(&rest.PasteVisibility, "visibility", "v", "", "Paste visibility") createCmd.RegisterFlagCompletionFunc("visibility", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return []string{"public", "private", "unlisted"}, cobra.ShellCompDirectiveNoFileComp }) - createCmd.PersistentFlags().StringVarP(&api.PasteExpiration, "expiration", "e", "", "Paste expiration in days") + createCmd.PersistentFlags().StringVarP(&rest.PasteExpiration, "expiration", "e", "", "Paste expiration in days") createCmd.RegisterFlagCompletionFunc("expiration", completeNoFiles) pasteCmd.AddCommand(deleteCmd) diff --git a/cmd/root.go b/cmd/root.go index d5c0ed9..a76ad41 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -4,8 +4,8 @@ import ( "fmt" "os" - "git.xenrox.net/~xenrox/srhtctl/api" "git.xenrox.net/~xenrox/srhtctl/config" + "git.xenrox.net/~xenrox/srhtctl/rest" "github.com/spf13/cobra" ) @@ -29,5 +29,5 @@ func init() { rootCmd.PersistentFlags().StringVar(&config.ConfigPath, "config", "", "Path to config.ini") - rootCmd.PersistentFlags().StringVarP(&api.UserName, "user", "u", "", "Sourcehut username") + rootCmd.PersistentFlags().StringVarP(&rest.UserName, "user", "u", "", "Sourcehut username") } diff --git a/cmd/todo.go b/cmd/todo.go index e7361d9..05aa222 100644 --- a/cmd/todo.go +++ b/cmd/todo.go @@ -1,8 +1,8 @@ package cmd import ( - "git.xenrox.net/~xenrox/srhtctl/api" "git.xenrox.net/~xenrox/srhtctl/helpers/errorhelper" + "git.xenrox.net/~xenrox/srhtctl/rest" "github.com/spf13/cobra" ) @@ -24,7 +24,7 @@ var ticketListCmd = &cobra.Command{ Use: "list", Short: "List tickets", Run: func(cmd *cobra.Command, args []string) { - err := api.PrintTickets(args) + err := rest.PrintTickets(args) errorhelper.ExitError(err) }, } @@ -35,12 +35,12 @@ func init() { todoCmd.AddCommand(ticketCmd) ticketCmd.AddCommand(ticketListCmd) - ticketListCmd.Flags().StringVarP(&api.TicketStatus, "status", "s", "reported", "Ticket status") + ticketListCmd.Flags().StringVarP(&rest.TicketStatus, "status", "s", "reported", "Ticket status") ticketListCmd.RegisterFlagCompletionFunc("status", func(cmd *cobra.Command, args []string, toComplete string) ( []string, cobra.ShellCompDirective) { return []string{"reported", "confirmed", "in_progress", "pending", "resolved", "all"}, cobra.ShellCompDirectiveNoFileComp }) - ticketListCmd.Flags().StringVarP(&api.TrackerName, "tracker", "t", "", "Tracker name") + ticketListCmd.Flags().StringVarP(&rest.TrackerName, "tracker", "t", "", "Tracker name") ticketListCmd.RegisterFlagCompletionFunc("tracker", completeNoFiles) } diff --git a/api/api.go b/rest/api.go similarity index 99% rename from api/api.go rename to rest/api.go index a275346..eca34c0 100644 --- a/api/api.go +++ b/rest/api.go @@ -1,4 +1,4 @@ -package api +package rest import ( "bytes" diff --git a/api/builds.go b/rest/builds.go similarity index 99% rename from api/builds.go rename to rest/builds.go index ede1e3b..71c3701 100644 --- a/api/builds.go +++ b/rest/builds.go @@ -1,4 +1,4 @@ -package api +package rest import ( "fmt" diff --git a/api/git.go b/rest/git.go similarity index 98% rename from api/git.go rename to rest/git.go index 81d1794..2e3d2ec 100644 --- a/api/git.go +++ b/rest/git.go @@ -1,4 +1,4 @@ -package api +package rest import ( "fmt" diff --git a/api/lists.go b/rest/lists.go similarity index 99% rename from api/lists.go rename to rest/lists.go index 1fde16d..b98f87d 100644 --- a/api/lists.go +++ b/rest/lists.go @@ -1,4 +1,4 @@ -package api +package rest import ( "fmt" diff --git a/api/meta.go b/rest/meta.go similarity index 99% rename from api/meta.go rename to rest/meta.go index cee08a9..dbeaeab 100644 --- a/api/meta.go +++ b/rest/meta.go @@ -1,4 +1,4 @@ -package api +package rest import ( "fmt" diff --git a/api/paste.go b/rest/paste.go similarity index 99% rename from api/paste.go rename to rest/paste.go index 881894d..6f20ed5 100644 --- a/api/paste.go +++ b/rest/paste.go @@ -1,4 +1,4 @@ -package api +package rest import ( "fmt" diff --git a/api/todo.go b/rest/todo.go similarity index 99% rename from api/todo.go rename to rest/todo.go index e716b44..8263955 100644 --- a/api/todo.go +++ b/rest/todo.go @@ -1,4 +1,4 @@ -package api +package rest import ( "fmt" -- 2.44.0