From 88e562bef7d5a128d61c0596a494301bfa61dc4a Mon Sep 17 00:00:00 2001 From: Gahan Rakholia Date: Sun, 22 Oct 2023 18:56:53 +0530 Subject: [PATCH] refactor: move oauth to it's own module --- cmd/auth.go | 4 ++-- .../jira/auth/{ => api_token}/api_token_auth.go | 2 +- pkg/jira_changelog/jira/auth/{ => oauth}/oauth.go | 2 +- pkg/jira_changelog/jira/auth/{ => oauth}/resource.go | 2 +- pkg/jira_changelog/jira/auth/{ => oauth}/resource_test.go | 2 +- pkg/jira_changelog/jira/auth/{ => oauth}/token.go | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) rename pkg/jira_changelog/jira/auth/{ => api_token}/api_token_auth.go (94%) rename pkg/jira_changelog/jira/auth/{ => oauth}/oauth.go (99%) rename pkg/jira_changelog/jira/auth/{ => oauth}/resource.go (97%) rename pkg/jira_changelog/jira/auth/{ => oauth}/resource_test.go (98%) rename pkg/jira_changelog/jira/auth/{ => oauth}/token.go (96%) diff --git a/cmd/auth.go b/cmd/auth.go index 028c38d..c933b05 100644 --- a/cmd/auth.go +++ b/cmd/auth.go @@ -6,7 +6,7 @@ import ( "os" "github.com/fatih/color" - "github.com/handofgod94/gh-jira-changelog/pkg/jira_changelog/jira/auth" + "github.com/handofgod94/gh-jira-changelog/pkg/jira_changelog/jira/auth/oauth" "github.com/spf13/cobra" ) @@ -22,7 +22,7 @@ as Atlassian currently doesn't support PKCE verification for oauth flow.`, RunE: func(cmd *cobra.Command, args []string) error { switch args[0] { case "login": - a := auth.NewAuthenticator() + a := oauth.NewAuthenticator() if err := a.Login(context.Background()); err != nil { fmt.Fprintln(os.Stderr, color.RedString("Login attempt failed. Please try again")) return err diff --git a/pkg/jira_changelog/jira/auth/api_token_auth.go b/pkg/jira_changelog/jira/auth/api_token/api_token_auth.go similarity index 94% rename from pkg/jira_changelog/jira/auth/api_token_auth.go rename to pkg/jira_changelog/jira/auth/api_token/api_token_auth.go index 78bbbb1..a32fac1 100644 --- a/pkg/jira_changelog/jira/auth/api_token_auth.go +++ b/pkg/jira_changelog/jira/auth/api_token/api_token_auth.go @@ -1,4 +1,4 @@ -package auth +package api_token import "net/http" diff --git a/pkg/jira_changelog/jira/auth/oauth.go b/pkg/jira_changelog/jira/auth/oauth/oauth.go similarity index 99% rename from pkg/jira_changelog/jira/auth/oauth.go rename to pkg/jira_changelog/jira/auth/oauth/oauth.go index 256567c..ba9fac2 100644 --- a/pkg/jira_changelog/jira/auth/oauth.go +++ b/pkg/jira_changelog/jira/auth/oauth/oauth.go @@ -1,4 +1,4 @@ -package auth +package oauth import ( "context" diff --git a/pkg/jira_changelog/jira/auth/resource.go b/pkg/jira_changelog/jira/auth/oauth/resource.go similarity index 97% rename from pkg/jira_changelog/jira/auth/resource.go rename to pkg/jira_changelog/jira/auth/oauth/resource.go index 30c2168..a7216b6 100644 --- a/pkg/jira_changelog/jira/auth/resource.go +++ b/pkg/jira_changelog/jira/auth/oauth/resource.go @@ -1,4 +1,4 @@ -package auth +package oauth import ( "encoding/json" diff --git a/pkg/jira_changelog/jira/auth/resource_test.go b/pkg/jira_changelog/jira/auth/oauth/resource_test.go similarity index 98% rename from pkg/jira_changelog/jira/auth/resource_test.go rename to pkg/jira_changelog/jira/auth/oauth/resource_test.go index 350cff6..f79cc22 100644 --- a/pkg/jira_changelog/jira/auth/resource_test.go +++ b/pkg/jira_changelog/jira/auth/oauth/resource_test.go @@ -1,4 +1,4 @@ -package auth +package oauth import ( "testing" diff --git a/pkg/jira_changelog/jira/auth/token.go b/pkg/jira_changelog/jira/auth/oauth/token.go similarity index 96% rename from pkg/jira_changelog/jira/auth/token.go rename to pkg/jira_changelog/jira/auth/oauth/token.go index 1dae2a5..cded8ef 100644 --- a/pkg/jira_changelog/jira/auth/token.go +++ b/pkg/jira_changelog/jira/auth/oauth/token.go @@ -1,4 +1,4 @@ -package auth +package oauth import ( "time"