/
githubmirror
/
terraform
Обзор
Документация
Войти
/
githubmirror
/
terraform
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
internal/command/arguments/providers.go
47 строк
1 KB
Daniel Banck
command: Add vars to providers command
17 мар 2026, 18:41
17 мар 2026, 18:41
1cc8345
Код
Авторство
О чём код?
// Copyright IBM Corp. 2014, 2026 // SPDX-License-Identifier: BUSL-1.1 package arguments import "github.com/hashicorp/terraform/internal/tfdiags" // Providers represents the command-line arguments for the providers command. type Providers struct { // TestsDirectory is the directory containing Terraform test files. TestsDirectory string // Vars are the variable-related flags (-var, -var-file). Vars *Vars } // ParseProviders processes CLI arguments, returning a Providers value and // errors. If errors are encountered, a Providers value is still returned // representing the best effort interpretation of the arguments. func ParseProviders(args []string) (*Providers, tfdiags.Diagnostics) { var diags tfdiags.Diagnostics providers := &Providers{ Vars: &Vars{}, } cmdFlags := extendedFlagSet("providers", nil, nil, providers.Vars) cmdFlags.StringVar(&providers.TestsDirectory, "test-directory", "tests", "test-directory") if err := cmdFlags.Parse(args); err != nil { diags = diags.Append(tfdiags.Sourceless( tfdiags.Error, "Failed to parse command-line flags", err.Error(), )) } args = cmdFlags.Args() if len(args) > 0 { diags = diags.Append(tfdiags.Sourceless( tfdiags.Error, "Too many command line arguments", "Did you mean to use -chdir?", )) } return providers, diags }