Repository navigation
add info messages when starting override - #229
Conversation
|
Gitar analyzes/fixes CI failures, runs prompts as workflows and addresses comments starting with ⚙️ Options:
|
| // Add policy message | ||
| policyMessage := fmt.Sprintf("Policy: HTTP/gRPC responses containing the 'sd-override: true' header will be intercepted by the local process for sandbox <%s>", cfg.Sandbox) | ||
| fmt.Fprintf(out, "%s\n", policyMessage) | ||
|
|
||
| if len(cfg.ExcludedStatusCodes) > 0 { | ||
| codes := strings.Trim(strings.Join(strings.Fields(fmt.Sprint(cfg.ExcludedStatusCodes)), ","), "[]") | ||
| excludedStatusCodesMessage := fmt.Sprintf("Override will not apply to responses with status codes: %s", codes) | ||
| fmt.Fprintf(out, "%s\n", excludedStatusCodesMessage) | ||
| } |
There was a problem hiding this comment.
The policy explanation from here is not right, in particular check this case:
$ signadot local override --sandbox=test1 --workload=location --port=8081 --to=localhost:8000 --except-status 404
Waiting (up to --wait-timeout=3m0s) for sandbox to be ready...
✓ Sandbox status: Ready: All desired workloads are available.
✓ Override created port 8081 to localhost:8000
Policy: HTTP/gRPC responses containing the 'sd-override: true' header will be intercepted by the local process for sandbox <test1>
Override will not apply to responses with status codes: 404That's not true, in that case, everything will be overriden, except the 404s (the user doesn't need to insert any sd-override: true in this case).
See the existing help:
By default, overrides apply when the response from the local service
includes the header 'sd-override: true'.
You can use the '--except-status' flag to specify HTTP response codes that
should not be overridden. When set, all other traffic will be overridden
except for the specified status codes
There was a problem hiding this comment.
Much better, but I don't think the wording is right.
What about something like:
-
Case 1:
Policy: HTTP/gRPC responses from the local process that include the header sd-override: true will be overridden for sandbox test1. -
Case 2:
Policy: All HTTP/gRPC traffic will be overridden by the local process for sandbox test1, except responses with status code 404.
There was a problem hiding this comment.
I think we can remove the prefix that says "Policy", but the rest looks good to me from @daniel-de-vera 's text above. Let's call it overridden, not "intercepted" etc.
There was a problem hiding this comment.
Actually, something that seems a bit nicer to me is to combine the 2 messages (this one and the one above in https://github.com/signadot/cli/pull/229/files#diff-92d3d1666d17fbbdad2bd9f4ad27307fa016a76dfa83da57494e7b186b803bcaR150. Like:
Case 1: Header-Based Override
override has been set up successfully.
* If localhost:8080 responds with `sd-override: true` header
-> Final response from: **localhost:8080**
* Default: (All other local responses)
-> Final response from: **virtual-apiserver:80** (Sandbox)
Case 2: Status-Based Override
override has been set up successfully.
* If localhost:8080 responds with status 404
-> Final response from: **virtual-apiserver:80** (Sandbox)
* Default: (All other local responses)
-> Final response from: **localhost:8080**
WDYT @daniel-de-vera @davixcky
| // Add policy message | ||
| if len(cfg.ExcludedStatusCodes) > 0 { | ||
| // When except-status is used, everything is overridden by default except specified status codes | ||
| policyMessage := fmt.Sprintf("Policy: All traffic will be overridden by the local process for sandbox <%s>", cfg.Sandbox) |
There was a problem hiding this comment.
I would remove the "<" ">" surrounding the sandbox name.
This resolves #227