Skip to content

Commit

Permalink
Remove Warning message on astro login (#1621)
Browse files Browse the repository at this point in the history
* Remove Warning message on astro login

* Adding message
  • Loading branch information
kushalmalani committed Apr 17, 2024
1 parent 0383381 commit 67a44fe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
10 changes: 1 addition & 9 deletions cmd/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
cloudAuth "github.com/astronomer/astro-cli/cloud/auth"
"github.com/astronomer/astro-cli/context"
"github.com/astronomer/astro-cli/pkg/domainutil"
"github.com/astronomer/astro-cli/pkg/input"
softwareAuth "github.com/astronomer/astro-cli/software/auth"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -67,14 +66,7 @@ func login(cmd *cobra.Command, args []string, coreClient astrocore.CoreClient, p
// get the domain from context as an extra check
ctx, _ := context.GetCurrentContext()
if context.IsCloudDomain(ctx.Domain) {
// print an error if context domain is a valid cloud domain
fmt.Fprintf(out, "Error: %s is an invalid domain to login into Astro.\n", args[0])
// give the user an option to login to software
y, _ := input.Confirm("Are you trying to authenticate to Astronomer Software?")
if !y {
fmt.Println("Canceling login...")
return nil
}
fmt.Fprintf(out, "To login to Astronomer Software follow the instructions below. If you are attempting to login in to Astro cancel the login and run 'astro login'.\n\n")
}
return softwareLogin(args[0], oAuth, "", "", houstonVersion, houstonClient, out)
}
Expand Down
11 changes: 2 additions & 9 deletions cmd/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,10 @@ func TestLogin(t *testing.T) {
config.ResetCurrentContext()
login(&cobra.Command{}, []string{}, nil, nil, buf)

testUtil.InitTestConfig(testUtil.LocalPlatform)
defer testUtil.MockUserInput(t, "n")()
login(&cobra.Command{}, []string{"fail.astronomer.io"}, nil, nil, buf)
assert.Contains(t, buf.String(), "fail.astronomer.io is an invalid domain to login into Astro.\n")

testUtil.InitTestConfig(testUtil.LocalPlatform)
softwareDomain = "software.astronomer.io"
buf = new(bytes.Buffer)
defer testUtil.MockUserInput(t, "y")()
login(&cobra.Command{}, []string{"software.astronomer.io"}, nil, nil, buf)
assert.Contains(t, buf.String(), "software.astronomer.io is an invalid domain to login into Astro.\n")
login(&cobra.Command{}, []string{softwareDomain}, nil, nil, buf)
assert.Contains(t, buf.String(), "To login to Astronomer Software follow the instructions below. If you are attempting to login in to Astro cancel the login and run 'astro login'.\n\n")
}

func TestLogout(t *testing.T) {
Expand Down

0 comments on commit 67a44fe

Please sign in to comment.