mirror of
https://github.com/opentofu/opentofu.git
synced 2026-06-10 00:50:50 -04:00
Some checks are pending
build / Build for freebsd_386 (push) Waiting to run
build / Build for linux_386 (push) Waiting to run
build / Build for openbsd_386 (push) Waiting to run
build / Build for windows_386 (push) Waiting to run
build / Build for freebsd_amd64 (push) Waiting to run
build / Build for linux_amd64 (push) Waiting to run
build / Build for openbsd_amd64 (push) Waiting to run
build / Build for solaris_amd64 (push) Waiting to run
build / Build for windows_amd64 (push) Waiting to run
build / Build for freebsd_arm (push) Waiting to run
build / Build for linux_arm (push) Waiting to run
build / Build for linux_arm64 (push) Waiting to run
build / Build for darwin_amd64 (push) Waiting to run
build / Build for darwin_arm64 (push) Waiting to run
build / End-to-end Tests for linux_386 (push) Waiting to run
build / End-to-end Tests for windows_386 (push) Waiting to run
build / End-to-end Tests for darwin_amd64 (push) Waiting to run
build / End-to-end Tests for linux_amd64 (push) Waiting to run
build / End-to-end Tests for windows_amd64 (push) Waiting to run
Quick Checks / List files changed for pull request (push) Waiting to run
Quick Checks / Unit tests for linux_386 (push) Blocked by required conditions
Quick Checks / Unit tests for linux_amd64 (push) Blocked by required conditions
Quick Checks / Unit tests for windows_amd64 (push) Blocked by required conditions
Quick Checks / Unit tests for linux_arm (push) Blocked by required conditions
Quick Checks / Unit tests for darwin_arm64 (push) Blocked by required conditions
Quick Checks / Unit tests for linux_arm64 (push) Blocked by required conditions
Quick Checks / Race Tests (push) Blocked by required conditions
Quick Checks / End-to-end Tests (push) Blocked by required conditions
Quick Checks / Code Consistency Checks (push) Blocked by required conditions
Quick Checks / License Checks (push) Waiting to run
Website checks / List files changed for pull request (push) Waiting to run
Website checks / Build (push) Blocked by required conditions
Website checks / Test Installation Instructions (push) Blocked by required conditions
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
56 lines
1.6 KiB
Go
56 lines
1.6 KiB
Go
// Copyright (c) The OpenTofu Authors
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
// Copyright (c) 2023 HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package arguments
|
|
|
|
import (
|
|
"github.com/opentofu/opentofu/internal/tfdiags"
|
|
)
|
|
|
|
// Logout represents the command-line arguments for the logout command.
|
|
type Logout struct {
|
|
// Host represents the host that OpenTofu will try to log out of
|
|
Host string
|
|
|
|
// ViewOptions specifies which view options to use
|
|
ViewOptions ViewOptions
|
|
// Vars holds and provides information for the flags related to variables that a user can give into the process
|
|
Vars *Vars
|
|
}
|
|
|
|
// ParseLogout processes CLI arguments, returning a Logout value, a closer function, and errors.
|
|
// If errors are encountered, a Logout value is still returned representing
|
|
// the best effort interpretation of the arguments.
|
|
func ParseLogout(args []string) (*Logout, func(), tfdiags.Diagnostics) {
|
|
var diags tfdiags.Diagnostics
|
|
arguments := &Logout{}
|
|
|
|
cmdFlags := defaultFlagSet("logout")
|
|
arguments.ViewOptions.AddFlags(cmdFlags, false)
|
|
if err := cmdFlags.Parse(args); err != nil {
|
|
diags = diags.Append(tfdiags.Sourceless(
|
|
tfdiags.Error,
|
|
"Failed to parse command-line flags",
|
|
err.Error(),
|
|
))
|
|
}
|
|
|
|
closer, moreDiags := arguments.ViewOptions.Parse()
|
|
diags = diags.Append(moreDiags)
|
|
if diags.HasErrors() {
|
|
return arguments, closer, diags
|
|
}
|
|
|
|
if len(cmdFlags.Args()) != 1 {
|
|
diags = diags.Append(tfdiags.Sourceless(
|
|
tfdiags.Error,
|
|
"Unexpected argument",
|
|
"The logout command expects exactly one argument: the host to log out of.",
|
|
))
|
|
return arguments, closer, diags
|
|
}
|
|
arguments.Host = cmdFlags.Args()[0]
|
|
return arguments, closer, diags
|
|
}
|