From 92149b71f98c74823ac812ffebe25202765aec86 Mon Sep 17 00:00:00 2001 From: Bianca Date: Wed, 1 Jun 2022 12:14:51 +0100 Subject: [PATCH 1/5] CLOUDP-120254: Address advocate experience feedback --- internal/cli/auth/login.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/cli/auth/login.go b/internal/cli/auth/login.go index 2eed5759a2..64c296811d 100644 --- a/internal/cli/auth/login.go +++ b/internal/cli/auth/login.go @@ -189,6 +189,14 @@ func (opts *LoginOpts) setUpProfile(ctx context.Context) error { // Only make references to profile if user was asked about org or projects if opts.AskedOrgsOrProjects && opts.ProjectID != "" && opts.OrgID != "" { + if !opts.ProjectExists(config.ProjectID()) { + return fmt.Errorf("you don't have access to the project id you provided or it does not exist") + } + + if !opts.ProjectExists(config.OrgID()) { + return fmt.Errorf("you don't have access to the organization id you provided or it does not exist") + } + _, _ = fmt.Fprint(opts.OutWriter, "\nYour profile is now configured.\n") _, _ = fmt.Fprintf(opts.OutWriter, "You can use [%s config set] to change these settings at a later time.\n", config.BinName()) } From 45debcbe772ca6886282d9311c5c9218af03a1ba Mon Sep 17 00:00:00 2001 From: Bianca Date: Wed, 1 Jun 2022 14:09:32 +0100 Subject: [PATCH 2/5] Address comments --- internal/cli/auth/login.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cli/auth/login.go b/internal/cli/auth/login.go index 64c296811d..a9a9513583 100644 --- a/internal/cli/auth/login.go +++ b/internal/cli/auth/login.go @@ -193,7 +193,7 @@ func (opts *LoginOpts) setUpProfile(ctx context.Context) error { return fmt.Errorf("you don't have access to the project id you provided or it does not exist") } - if !opts.ProjectExists(config.OrgID()) { + if !opts.OrgExists(config.OrgID()) { return fmt.Errorf("you don't have access to the organization id you provided or it does not exist") } From fc54fb323168cd208b845fcc243eb5b3683186a1 Mon Sep 17 00:00:00 2001 From: Bianca Date: Wed, 1 Jun 2022 15:44:53 +0100 Subject: [PATCH 3/5] Address doc comments --- internal/cli/auth/login.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/cli/auth/login.go b/internal/cli/auth/login.go index a9a9513583..3e624b4ba0 100644 --- a/internal/cli/auth/login.go +++ b/internal/cli/auth/login.go @@ -190,11 +190,11 @@ func (opts *LoginOpts) setUpProfile(ctx context.Context) error { // Only make references to profile if user was asked about org or projects if opts.AskedOrgsOrProjects && opts.ProjectID != "" && opts.OrgID != "" { if !opts.ProjectExists(config.ProjectID()) { - return fmt.Errorf("you don't have access to the project id you provided or it does not exist") + return fmt.Errorf("you don't have access to this project ID or it doesn't exist") } if !opts.OrgExists(config.OrgID()) { - return fmt.Errorf("you don't have access to the organization id you provided or it does not exist") + return fmt.Errorf("you don't have access to this organization ID or it doesn't exist") } _, _ = fmt.Fprint(opts.OutWriter, "\nYour profile is now configured.\n") From 3d04f2156d646a205fbca76c53df7dd11483a94f Mon Sep 17 00:00:00 2001 From: Bianca Date: Wed, 1 Jun 2022 16:45:41 +0100 Subject: [PATCH 4/5] Address comments --- internal/cli/auth/login.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/cli/auth/login.go b/internal/cli/auth/login.go index 3e624b4ba0..dbc9c3e312 100644 --- a/internal/cli/auth/login.go +++ b/internal/cli/auth/login.go @@ -16,6 +16,7 @@ package auth import ( "context" + "errors" "fmt" "os" "time" @@ -56,6 +57,11 @@ const ( LogoutToLoginAccountMsg = `run "atlas auth logout" first if you want to login with another Atlas account on the same Atlas CLI profile` ) +var ( + ErrProjectIDNotFound = errors.New("you don't have access to this or it doesn't exist") + ErrOrgIDNotFound = errors.New("you don't have access to this organization ID or it doesn't exist") +) + type LoginOpts struct { cli.DefaultSetterOpts AccessToken string @@ -190,11 +196,11 @@ func (opts *LoginOpts) setUpProfile(ctx context.Context) error { // Only make references to profile if user was asked about org or projects if opts.AskedOrgsOrProjects && opts.ProjectID != "" && opts.OrgID != "" { if !opts.ProjectExists(config.ProjectID()) { - return fmt.Errorf("you don't have access to this project ID or it doesn't exist") + return fmt.Errorf("%w", ErrProjectIDNotFound) } if !opts.OrgExists(config.OrgID()) { - return fmt.Errorf("you don't have access to this organization ID or it doesn't exist") + return fmt.Errorf("%w", ErrOrgIDNotFound) } _, _ = fmt.Fprint(opts.OutWriter, "\nYour profile is now configured.\n") From 8f4537c6e0cd506d30824b6bd0e75137fe963cb5 Mon Sep 17 00:00:00 2001 From: Bianca Date: Wed, 1 Jun 2022 17:05:10 +0100 Subject: [PATCH 5/5] Address comments --- internal/cli/auth/login.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/cli/auth/login.go b/internal/cli/auth/login.go index dbc9c3e312..7f790550b0 100644 --- a/internal/cli/auth/login.go +++ b/internal/cli/auth/login.go @@ -58,8 +58,8 @@ const ( ) var ( - ErrProjectIDNotFound = errors.New("you don't have access to this or it doesn't exist") - ErrOrgIDNotFound = errors.New("you don't have access to this organization ID or it doesn't exist") + ErrProjectIDNotFound = errors.New("you don't have access to this or it doesn't exist") + ErrOrgIDNotFound = errors.New("you don't have access to this organization ID or it doesn't exist") ) type LoginOpts struct { @@ -196,11 +196,11 @@ func (opts *LoginOpts) setUpProfile(ctx context.Context) error { // Only make references to profile if user was asked about org or projects if opts.AskedOrgsOrProjects && opts.ProjectID != "" && opts.OrgID != "" { if !opts.ProjectExists(config.ProjectID()) { - return fmt.Errorf("%w", ErrProjectIDNotFound) + return ErrProjectIDNotFound } if !opts.OrgExists(config.OrgID()) { - return fmt.Errorf("%w", ErrOrgIDNotFound) + return ErrOrgIDNotFound } _, _ = fmt.Fprint(opts.OutWriter, "\nYour profile is now configured.\n")