Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(cli): Adding CLI cloud login and auth logic #3100

Merged
merged 2 commits into from
Aug 28, 2023

Conversation

xoscar
Copy link
Contributor

@xoscar xoscar commented Aug 25, 2023

This PR adds the base logic to support CLI cloud login and authentication

Changes

  • Adds tracetest login command
  • Implements oauth logic for resources and the API

Checklist

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test

@xoscar xoscar self-assigned this Aug 25, 2023
@xoscar xoscar marked this pull request as ready for review August 25, 2023 17:50
@xoscar xoscar added the CLI label Aug 25, 2023
@xoscar xoscar changed the base branch from main to feat/cli-cloud August 25, 2023 17:51
@@ -271,6 +271,9 @@ func setupResources() {
extraHeaders := http.Header{}
extraHeaders.Set("x-client-id", analytics.ClientID())
extraHeaders.Set("x-source", "cli")
extraHeaders.Set("x-organization-id", cliConfig.OrganizationID)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are attaching the new headers as part of the request

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we are always going to send this headers, right? even for OSS?

cliConfig.Token = token
cliConfig.Jwt = jwt
serverPath := ""
cliConfig.ServerPath = &serverPath
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to remove the /api server prefix

@@ -47,7 +47,7 @@ func NewHTTPClient(baseURL string, extraHeaders http.Header) *HTTPClient {
}

func (c HTTPClient) url(resourceName string, extra ...string) *url.URL {
urlStr := c.baseURL + path.Join("/api", resourceName, strings.Join(extra, "/"))
urlStr := c.baseURL + path.Join("/", resourceName, strings.Join(extra, "/"))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prefix will be part of the server path now

Copy link
Contributor

@jorgeepc jorgeepc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, added a couple of comments

var loginCmd = &cobra.Command{
GroupID: cmdGroupCloud.ID,
Use: "login",
Short: "Tracetst Cloud Login",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Short: "Tracetst Cloud Login",
Short: "Tracetest Cloud Login",

GroupID: cmdGroupCloud.ID,
Use: "login",
Short: "Tracetst Cloud Login",
Long: "Initializes the Tracetst Cloud Login process",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Long: "Initializes the Tracetst Cloud Login process",
Long: "Initializes the Tracetest Cloud Login process",

@@ -271,6 +271,9 @@ func setupResources() {
extraHeaders := http.Header{}
extraHeaders.Set("x-client-id", analytics.ClientID())
extraHeaders.Set("x-source", "cli")
extraHeaders.Set("x-organization-id", cliConfig.OrganizationID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we are always going to send this headers, right? even for OSS?

@xoscar xoscar merged commit 7caa9b7 into feat/cli-cloud Aug 28, 2023
@xoscar xoscar deleted the feat/cli-cloud-login branch August 28, 2023 16:17
xoscar added a commit that referenced this pull request Sep 5, 2023
* feature(cli): Adding CLI cloud login and auth logic (#3100)

* feature(cli): adding CLI cloud login and auth logic

* feature(cli): adding CLI cloud login and auth logic

* feat(cloud): adding support for cloud resources (#3101)

* feature(cli): adding CLI cloud login and auth logic

* feature(cli): adding CLI cloud login and auth logic

* feat(cloud): adding support for cloud resources

* feat(cloud): adding select command for cloud resources

* feat(cloud): Tracetest configure improvements (#3102)

* feature(cli): adding CLI cloud login and auth logic

* feature(cli): adding CLI cloud login and auth logic

* feat(cloud): adding support for cloud resources

* feat(cloud): adding select command for cloud resources

* fixing CLI e2e

* Fixing missing prefix and CLI e2e tests

* removing deprecation tests for environments

* downgrading the goreleaser version

* fixing CLI e2e

* fixing status code

* fixing FE port

* fixing FE port

* Implementing tracetest configure command

* cleanup

* adding missing select cmd

* adding path validation for configure

* re adding missing tests

* feat(cli): adding `tracetest start` command (#3114)

* feat(cli): adding start command

* feat(cli): adding start command

* feat(cli): cleanup and dynamic endpoint support (#3121)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants