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

views: add cloud view #35929

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

bschaatsbergen
Copy link
Member

@bschaatsbergen bschaatsbergen commented Oct 30, 2024

Closes #35159

The cloud backend implements a retry mechanism for its client, go-tfe. Currently, retry messages from this logic were not rendered through a view, so the -json flag was not respected. This resulted in mixed (non-pure JSON) output in the terminal whenever retry messages were printed.

This PR introduces a new view: cloud, which handles rendering output in human-readable or machine-readable format from cloud-specific operations.

The PR works around the current lack of native support for views in the backends. To work around this limitation, we have introduced a ViewType field in the CLI options, which we are now passing down the to the cloud backend.

The cloud backend includes a retry hook that relies on a go-tfe implementation. Since these retry messages were not rendered through a view, the `-json` flag was not respected, leading to mixed (non-pure JSON) output in the terminal whenever retry messages were printed.

Before passing the init view to the cloud backend, we ensure the retryLog hook is included in the init view.

Signed-off-by: Bruno Schaatsbergen <[email protected]>
@bschaatsbergen bschaatsbergen force-pushed the b/fix-retry-messages-in-cloud-backend-json branch from f9d9df0 to f979759 Compare November 1, 2024 10:44
@bschaatsbergen bschaatsbergen force-pushed the b/fix-retry-messages-in-cloud-backend-json branch from ecbb274 to cb2d019 Compare November 1, 2024 11:38
@bschaatsbergen bschaatsbergen force-pushed the b/fix-retry-messages-in-cloud-backend-json branch from cb2d019 to a909304 Compare November 1, 2024 11:45
The cloud view is responsible for rendering messages related to cloud operations, presenting them to the user in either a human-readable format or as JSON output in the terminal.

Signed-off-by: Bruno Schaatsbergen <[email protected]>
…based on view type.

Signed-off-by: Bruno Schaatsbergen <[email protected]>
Signed-off-by: Bruno Schaatsbergen <[email protected]>
Signed-off-by: Bruno Schaatsbergen <[email protected]>
Added a comment to explain the rationale behind the guard statement, which prevents potential nil errors during backend initialization and retryLogHook call.

Signed-off-by: Bruno Schaatsbergen <[email protected]>
Signed-off-by: Bruno Schaatsbergen <[email protected]>
@bschaatsbergen bschaatsbergen changed the title views: move retryLog hook to init view views: add cloud view Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Print retryLogHook messages to stderr
1 participant