Skip to content

Commit

Permalink
feat(cli): deprecate endpoint flag in favor of server-url (#3563)
Browse files Browse the repository at this point in the history
  • Loading branch information
schoren authored Jan 25, 2024
1 parent 71bcf62 commit bf06ecc
Show file tree
Hide file tree
Showing 41 changed files with 74 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ jobs:
./scripts/wait-for-port.sh 11633
./dist/tracetest configure -g --endpoint http://localhost:11633
./dist/tracetest configure -g --server-url http://localhost:11633
./dist/tracetest run test -f examples/${{ matrix.example_dir }}/tests/list-tests.yaml || (cat /tmp/docker-log; exit 1)
smoke-test-cli:
Expand Down
38 changes: 26 additions & 12 deletions cli/cmd/configure_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ var configureCmd = &cobra.Command{
return "", err
}

if flagProvided(cmd, "endpoint") {
flags.Endpoint = configParams.Endpoint
if flagProvided(cmd, "server-url") || flagProvided(cmd, "endpoint") {
flags.Endpoint = configParams.ServerURL
}

if flagProvided(cmd, "token") {
Expand All @@ -57,42 +57,56 @@ func flagProvided(cmd *cobra.Command, name string) bool {
return cmd.Flags().Lookup(name).Changed
}

var deprecatedEndpoint string

func init() {
configureCmd.PersistentFlags().BoolVarP(&configParams.Global, "global", "g", false, "configuration will be saved in your home dir")
configureCmd.PersistentFlags().StringVarP(&configParams.Endpoint, "endpoint", "e", "", "set the value for the endpoint, so the CLI won't ask for this value")

configureCmd.PersistentFlags().StringVarP(&configParams.Token, "token", "t", "", "set authetication with token, so the CLI won't ask you for authentication")
configureCmd.PersistentFlags().StringVarP(&configParams.EnvironmentID, "environment", "", "", "set environmentID, so the CLI won't ask you for it")
configureCmd.PersistentFlags().StringVarP(&configParams.OrganizationID, "organization", "", "", "set organizationID, so the CLI won't ask you for it")

configureCmd.PersistentFlags().BoolVarP(&configParams.CI, "ci", "", false, "if cloud is used, don't ask for authentication")

configureCmd.PersistentFlags().StringVarP(&deprecatedEndpoint, "endpoint", "e", "", "set the value for the endpoint, so the CLI won't ask for this value")
configureCmd.PersistentFlags().MarkDeprecated("endpoint", "use --server-url instead")
configureCmd.PersistentFlags().MarkShorthandDeprecated("e", "use --server-url instead")

rootCmd.AddCommand(configureCmd)
}

type configureParameters struct {
Endpoint string
ServerURL string
Global bool
CI bool
Token string
OrganizationID string
EnvironmentID string
}

func (p configureParameters) Validate(cmd *cobra.Command, args []string) []error {
func (p *configureParameters) Validate(cmd *cobra.Command, args []string) []error {
var errors []error

if cmd.Flags().Lookup("endpoint").Changed {
if p.Endpoint == "" {
p.ServerURL = overrideEndpoint
flagUpdated := cmd.Flags().Lookup("server-url").Changed

if deprecatedEndpoint != "" {
p.ServerURL = deprecatedEndpoint
flagUpdated = true
}

if flagUpdated {
if p.ServerURL == "" {
errors = append(errors, paramError{
Parameter: "endpoint",
Message: "endpoint cannot be empty",
Parameter: "server-url",
Message: "server-url cannot be empty",
})
} else {
_, err := url.Parse(p.Endpoint)
_, err := url.Parse(p.ServerURL)
if err != nil {
errors = append(errors, paramError{
Parameter: "endpoint",
Message: "endpoint is not a valid URL",
Parameter: "server-url",
Message: "server-url is not a valid URL",
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/ci-cd-automation/github-actions-pipeline.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
run: curl -L https://raw.githubusercontent.com/kubeshop/tracetest/main/install-cli.sh | bash

- name: Configure Tracetest CLI
run: tracetest configure -g --endpoint http://localhost:11633
run: tracetest configure -g --server-url http://localhost:11633

- name: Run tests via the Tracetest CLI
run: |
Expand Down Expand Up @@ -101,7 +101,7 @@ jobs:
run: curl -L https://raw.githubusercontent.com/kubeshop/tracetest/main/install-cli.sh | bash

- name: Configure Tracetest CLI
run: tracetest configure -g --endpoint http://localhost:11633
run: tracetest configure -g --server-url http://localhost:11633

- name: Run tests via the Tracetest CLI
run: |
Expand Down Expand Up @@ -400,7 +400,7 @@ First, [install the CLI](https://docs.tracetest.io/getting-started/installation#
Then, configure the CLI:

```bash
tracetest configure --endpoint http://localhost:11633
tracetest configure --server-url http://localhost:11633
```

Once configured, you can run a test against the Tracetest instance via the terminal.
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/ci-cd-automation/tekton-pipeline.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ spec:
image: kubeshop/tracetest:v0.11.9 # The official Tracetest image comes with the Tracetest CLI installed
script: |
# Configure and Run Tracetest CLI
tracetest configure -g --endpoint http://tracetest.tracetest.svc.cluster.local:11633/
tracetest configure -g --server-url http://tracetest.tracetest.svc.cluster.local:11633/
tracetest run test -f /workspace/test-api.yaml
volumeMounts:
- name: custom
Expand Down Expand Up @@ -371,7 +371,7 @@ metadata:
spec:
serviceAccountName: tekton-robot
triggers:
- name: install-and-run-tracetest-trigger
- name: install-and-run-tracetest-trigger
bindings:
- ref: install-and-run-tracetest-binding
template:
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/cli/configuring-your-cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ Configure your CLI to connect to your Tracetest server.
tracetest configure
```

If you want to set values without having to answer questions from a prompt, you can provide the flag `--endpoint` to define the server endpoint.
If you want to set values without having to answer questions from a prompt, you can provide the flag `--server-url` to define the server endpoint.

```sh
tracetest configure --endpoint http://my-tracetest-server:11633
tracetest configure --server-url http://my-tracetest-server:11633
```

### Test List
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ The final output from the Terraform command should be a list of endpoints that i
Now that all of the required services and infra have been created, you can start running some Trace-based testing by doing the following:

1. From the Terraform output you can copy the `api_endpoint` and replace the `<your_api_endpoint>` placeholder from the `tests/test.yaml` file.
2. Configure the [Tracetest CLI](https://docs.tracetest.io/cli/configuring-your-cli) to point to the public load balancer endpoint with `tracetest configure --endpoint <tracetest_url>`.
2. Configure the [Tracetest CLI](https://docs.tracetest.io/cli/configuring-your-cli) to point to the public load balancer endpoint with `tracetest configure --server-url <tracetest_url>`.
3. Run the test YAML file using the CLI `tracetest run test -f tests/test.yaml`.
4. Follow the link to find the results.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ To start both OpenTelemetry and Tracetest, run this command:
docker-compose -f docker-compose.yaml -f tracetest/docker-compose.yaml up
```

This will start your Tracetest instance on `http://localhost:11633/`.
This will start your Tracetest instance on `http://localhost:11633/`.

Open the URL and [start creating tests in the Web UI](https://docs.tracetest.io/web-ui/creating-tests)! Make sure to use the endpoints within your Docker network like `http://frontend:8084/` when creating tests.

Expand All @@ -288,7 +288,7 @@ First, [install the CLI](https://docs.tracetest.io/getting-started/installation#
Then, configure the CLI:

```bash
tracetest configure --endpoint http://localhost:11633
tracetest configure --server-url http://localhost:11633
```

Once configured, you can run a test against the Tracetest instance via the terminal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ First, [install the CLI](https://docs.tracetest.io/getting-started/installation#
Then, configure the CLI:

```bash
tracetest configure --endpoint http://localhost:11633
tracetest configure --server-url http://localhost:11633
```

Once configured, you can run a test against the Tracetest instance via the terminal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ First, [install the CLI](https://docs.tracetest.io/getting-started/installation#
Then, configure the CLI:

```bash
tracetest configure --endpoint http://localhost:11633
tracetest configure --server-url http://localhost:11633
```

Once configured, you can run a test against the Tracetest instance via the terminal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ First, [install the CLI](https://docs.tracetest.io/getting-started/installation#
Then, configure the CLI:

```bash
tracetest configure --endpoint http://localhost:11633
tracetest configure --server-url http://localhost:11633
```

Once configured, you can run a test against the Tracetest instance via the terminal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ First, [install the CLI](https://docs.tracetest.io/getting-started/installation#
Then, configure the CLI:

```bash
tracetest configure --endpoint http://localhost:11633
tracetest configure --server-url http://localhost:11633
```

Once configured, you can run a test against the Tracetest instance via the terminal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ The `docker-compose.yaml` file includes the definitions for all of the required
```yaml
version: "3"

#...
#...

services:
#...
#...

# Demo
postgres:
Expand Down Expand Up @@ -574,7 +574,7 @@ First, [install the CLI](https://docs.tracetest.io/getting-started/installation#
Then, configure the CLI:

```bash
tracetest configure --endpoint http://localhost:11633
tracetest configure --server-url http://localhost:11633
```

Once configured, you can run a test against the Tracetest instance via the terminal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ The output from the previous command should look similar to this:
Now that all of the required services and infra have been created, you can start running trace-based testing by doing the following:

1. Run this `sam list stack-outputs --stack-name <your_app_name>` command where you can copy the `StepFunctionsAPIUrl` value and add the `<your_api_endpoint>` placeholder from the `tests/incident.yaml` and `tests/exam.yaml` files.
2. From the Terraform output, configure the [Tracetest CLI](https://docs.tracetest.io/cli/configuring-your-cli) to point to the public load balancer endpoint with `tracetest configure --endpoint <tracetest_url>`.
2. From the Terraform output, configure the [Tracetest CLI](https://docs.tracetest.io/cli/configuring-your-cli) to point to the public load balancer endpoint with `tracetest configure --server-url <tracetest_url>`.
3. Run the tests YAML file using the CLI.

```bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ To start both the Node.js services and Tracetest we will run this command:
docker-compose -f docker-compose.yaml -f tracetest/docker-compose.yaml up # add --build if the images are not built already
```

This will start your Tracetest instance on `http://localhost:11633/`.
This will start your Tracetest instance on `http://localhost:11633/`.

Open the URL and [start creating tests in the Web UI](https://docs.tracetest.io/web-ui/creating-tests)! Make sure to use the `http://app:8080/books` URL in your test creation, because your Node.js app and Tracetest are in the same network.

Expand All @@ -329,7 +329,7 @@ First, [install the CLI](https://docs.tracetest.io/getting-started/installation#
Then, configure the CLI:

```bash
tracetest configure --endpoint http://localhost:11633
tracetest configure --server-url http://localhost:11633
```

Once configured, you can run a test against the Tracetest instance via the terminal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: curl -L https://raw.githubusercontent.com/kubeshop/tracetest/main/install-cli.sh | bash

- name: Configure Tracetest CLI
run: tracetest configure -g --endpoint http://localhost:11633
run: tracetest configure -g --server-url http://localhost:11633

- name: Run tests via the Tracetest CLI
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
run: curl -L https://raw.githubusercontent.com/kubeshop/tracetest/main/install-cli.sh | bash

- name: Configure Tracetest CLI
run: tracetest configure -g --endpoint http://localhost:11633
run: tracetest configure -g --server-url http://localhost:11633

- name: Run tests via the Tracetest CLI
run: |
Expand Down
2 changes: 1 addition & 1 deletion examples/quick-start-net-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This is a simple quick start on how to configure a .NET Core API to use OpenTele
## Steps

1. [Install the tracetest CLI](https://github.com/kubeshop/tracetest/blob/main/docs/installing.md#cli-installation)
2. Run `tracetest configure --endpoint http://localhost:11633` on a terminal to configure the CLI to send all commands to that address
2. Run `tracetest configure --server-url http://localhost:11633` on a terminal to configure the CLI to send all commands to that address
3. Run the project by using docker-compose: `docker-compose up -d` (Linux) or `docker compose up -d` (Mac)
4. Test if it works by running: `tracetest run test -f tests/test.yaml`. This would execute a test against the .NET Core API that will send spans to Jaeger to be fetched from the Tracetest server.

Expand Down
2 changes: 1 addition & 1 deletion examples/quick-start-pokeshop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ This examples' objective is to show how you can:
## Steps

1. [Install the tracetest CLI](https://docs.tracetest.io/installing/)
2. Run `tracetest configure --endpoint http://localhost:11633` on a terminal
2. Run `tracetest configure --server-url http://localhost:11633` on a terminal
3. Run the project by using docker-compose: `docker-compose up -d` (Linux) or `docker compose up -d` (Mac)
4. Test if it works by running: `tracetest run test -f tests/test.yaml`. This would trigger a test that will send and retrieve spans from the OpenTelemetry Collector instance. View the test on `http://localhost:11633`.
2 changes: 1 addition & 1 deletion examples/quick-start-tekton/install-and-run-tracetest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ spec:
# The official Tracetest image comes with the Tracetest CLI installed
script: |
# Configure and Run Tracetest CLI
tracetest configure -g --endpoint http://tracetest.tracetest.svc.cluster.local:11633/
tracetest configure -g --server-url http://tracetest.tracetest.svc.cluster.local:11633/
tracetest run test --file /workspace/test-api.yaml --required-gates test-specs --output pretty
volumeMounts:
- name: custom
Expand Down
2 changes: 1 addition & 1 deletion examples/tracetest-amazon-x-ray-adot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This repository objective is to show how you can configure your Tracetest instan
## Steps

1. [Install the tracetest CLI](https://docs.tracetest.io/installing/)
2. Run `tracetest configure --endpoint http://localhost:11633` on a terminal
2. Run `tracetest configure --server-url http://localhost:11633` on a terminal
3. Update the `.env` file adding a valid set of AWS credentials
4. Run the project by using docker-compose: `docker-compose up -d` (Linux) or `docker compose up -d` (Mac)
5. Test if it works by running: `tracetest run test -f tests/test.yaml`. This would trigger a test that will send and retrieve spans from the X-Ray instance that is running on your machine.
2 changes: 1 addition & 1 deletion examples/tracetest-amazon-x-ray-pokeshop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This repository objective is to show how you can configure your Tracetest instan
## Steps

1. [Install the tracetest CLI](https://docs.tracetest.io/installing/)
2. Run `tracetest configure --endpoint http://localhost:11633` on a terminal
2. Run `tracetest configure --server-url http://localhost:11633` on a terminal
3. Update the `.env` file adding a valid set of AWS credentials
4. Update the `tracetest.provision.yaml` file adding a valid set of AWS credentials
5. Run the project by using docker-compose: `docker-compose up -d` (Linux) or `docker compose up -d` (Mac)
Expand Down
2 changes: 1 addition & 1 deletion examples/tracetest-amazon-x-ray/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This repository objective is to show how you can configure your Tracetest instan
## Steps

1. [Install the tracetest CLI](https://docs.tracetest.io/installing/)
2. Run `tracetest configure --endpoint http://localhost:11633` on a terminal
2. Run `tracetest configure --server-url http://localhost:11633` on a terminal
3. Update the `.env` file adding a valid set of AWS credentials
4. Update the `tracetest.provision.yaml` file adding a valid set of AWS credentials
5. Run the project by using docker-compose: `docker-compose up -d` (Linux) or `docker compose up -d` (Mac)
Expand Down
2 changes: 1 addition & 1 deletion examples/tracetest-aws-step-functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This is a simple quick start on how to configure a .NET State Machine (AWS Step

1. [Install the tracetest CLI](https://github.com/kubeshop/tracetest/blob/main/docs/installing.md#cli-installation)
2. From the `infra` folder run `terraform init` and `terraform apply` and accept the changes
3. From the terraform outputs, grab the `tracetest_url` and run `tracetest configure --endpoint <tracetest_url>` on a terminal to configure the CLI to send all commands to that address
3. From the terraform outputs, grab the `tracetest_url` and run `tracetest configure --server-url <tracetest_url>` on a terminal to configure the CLI to send all commands to that address
4. From the `src` folder run `sam build` and `sam deploy --guided`
5. Follow the instructions from the guided deployment
![functions](./assets/functions.png)
Expand Down
2 changes: 1 addition & 1 deletion examples/tracetest-aws-step-functions/infra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This is a simple quick start on how to configure a Node.js lambda function API t

1. [Install the tracetest CLI](https://github.com/kubeshop/tracetest/blob/main/docs/installing.md#cli-installation)
2. Run `terraform init`, `terraform apply` and accept the changes
3. From the terraform outputs, grab the `tracetes_url` and run `tracetest configure --endpoint <tracetest_url>` on a terminal to configure the CLI to send all commands to that address
3. From the terraform outputs, grab the `tracetes_url` and run `tracetest configure --server-url <tracetest_url>` on a terminal to configure the CLI to send all commands to that address
4. From the terraform outputs, grab the `api_endpoint` and update the `<your_api_endpoint>` section from `test/test.yaml`
5. Test if it works by running: `tracetest run test -f tests/test.yaml`. This would execute a test against the Node.js API Gateway endpoint that will send spans to Jaeger to be fetched from the Tracetest server.

Expand Down
2 changes: 1 addition & 1 deletion examples/tracetest-aws-terraform-serverless/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This is a simple quick start on how to configure a Node.js lambda function API t

1. [Install the tracetest CLI](https://github.com/kubeshop/tracetest/blob/main/docs/installing.md#cli-installation)
2. Run `terraform init`, `terraform apply` and accept the changes
3. From the terraform outputs, grab the `tracetes_url` and run `tracetest configure --endpoint <tracetest_url>` on a terminal to configure the CLI to send all commands to that address
3. From the terraform outputs, grab the `tracetes_url` and run `tracetest configure --server-url <tracetest_url>` on a terminal to configure the CLI to send all commands to that address
4. From the terraform outputs, grab the `api_endpoint` and update the `<your_api_endpoint>` section from `tests/test.yaml`
5. Test if it works by running: `tracetest run test -f tests/test.yaml`. This would execute a test against the Node.js API Gateway endpoint that will send spans to Jaeger to be fetched from the Tracetest server.

Expand Down
2 changes: 1 addition & 1 deletion examples/tracetest-azure-app-insights-collector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This repository objective is to show how you can configure your Tracetest instan
## Steps

1. [Install the tracetest CLI](https://docs.tracetest.io/installing/)
2. Run `tracetest configure --endpoint http://localhost:11633` on a terminal
2. Run `tracetest configure --server-url http://localhost:11633` on a terminal
3. Update the `.env` file adding a valid set the valid App Insights Instrumentation Key
4. Run the project by using docker-compose: `docker compose -f ./docker-compose.yaml -f ./tracetest/docker-compose.yaml up -d`
5. Test if it works by running: `tracetest run test -f tests/test.yaml`. This would trigger a test that will send spans to Azure Monitor API and directly to Tracetest that is running on your machine.
2 changes: 1 addition & 1 deletion examples/tracetest-azure-app-insights-pokeshop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This repository objective is to show how you can configure your Tracetest instan
## Steps

1. [Install the tracetest CLI](https://docs.tracetest.io/installing/)
2. Run `tracetest configure --endpoint http://localhost:11633` on a terminal
2. Run `tracetest configure --server-url http://localhost:11633` on a terminal
3. Update the `.env` file adding a valid set the valid App Insights Instrumentation Key
4. Update the `tracetest.provision.yaml` file adding a valid set the Azure ARM Id and secret token
5. Run the project by using docker-compose: `docker compose -f ./docker-compose.yaml -f ./tracetest/docker-compose.yaml up -d`
Expand Down
Loading

0 comments on commit bf06ecc

Please sign in to comment.