Skip to content

Add --force flag to target command#286

Open
duanemay wants to merge 1 commit intomasterfrom
target_force
Open

Add --force flag to target command#286
duanemay wants to merge 1 commit intomasterfrom
target_force

Conversation

@duanemay
Copy link
Copy Markdown
Member

Allows skipping connectivity checks

 Allows skipping connectivity checks
Copilot AI review requested due to automatic review settings April 24, 2026 19:31
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a --force flag to the uaa target command so users can persist a target URL without performing the usual connectivity check against /info.

Changes:

  • Document --force/-f for uaa target, including an example invocation.
  • Add --force flag wiring to the target command and skip the /info connectivity check when set.
  • Add CLI integration tests covering the new --force behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
docs/commands/target.md Documents the new --force flag and provides an example usage.
cmd/target.go Implements --force by conditionally skipping the /info connectivity check.
cmd/target_test.go Adds tests verifying that --force skips connectivity checks and still saves config.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/target.go
Comment on lines +48 to 54
if !forceTarget {
api := GetUnauthenticatedAPIFromConfig(cfg)
_, err := api.GetInfo()
if err != nil {
return errors.New(fmt.Sprintf("The target %s could not be set: %v", newTarget, err.Error()))
}
}
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

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

With --force, the code skips api.GetInfo() entirely, which also means we no longer validate that newTarget is a syntactically valid URL. This can result in persisting an invalid target (e.g., missing scheme/host) that later causes panics/failures when creating a UAA client. Consider adding a lightweight URL parse/validation step that always runs (even when --force), while still skipping the network /info call.

Copilot uses AI. Check for mistakes.
Comment thread cmd/target_test.go
Comment on lines +141 to +142
runCommand("target", server.URL(), "--force", "--skip-ssl-validation")

Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

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

This test relies on runCommand(...) succeeding but doesn't assert the exit code. Adding an explicit Eventually(session).Should(Exit(0)) (and capturing the session) would make failures clearer and ensure the combined --force + --skip-ssl-validation path is actually exercised successfully.

Suggested change
runCommand("target", server.URL(), "--force", "--skip-ssl-validation")
session := runCommand("target", server.URL(), "--force", "--skip-ssl-validation")
Eventually(session).Should(Exit(0))

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants