MCPcopy
hub / github.com/Azure/aztfexport / commandBeforeFunc

Function commandBeforeFunc

command_before_func.go:15–241  ·  view source on GitHub ↗
(fset *FlagSet, mode Mode)

Source from the content-addressed store, hash-verified

13)
14
15func commandBeforeFunc(fset *FlagSet, mode Mode) func(ctx *cli.Context) error {
16 return func(ctx *cli.Context) error {
17 // Common flags check
18 if fset.flagAppend {
19 if fset.flagOverwrite {
20 return fmt.Errorf("`--append` conflicts with `--overwrite`")
21 }
22 }
23 if !fset.flagNonInteractive {
24 if fset.flagContinue {
25 return fmt.Errorf("`--continue` must be used together with `--non-interactive`")
26 }
27 if fset.flagGenerateMappingFile {
28 return fmt.Errorf("`--generate-mapping-file` must be used together with `--non-interactive`")
29 }
30 }
31 if fset.flagHCLOnly {
32 if fset.flagAppend {
33 return fmt.Errorf("`--append` conflicts with `--hcl-only`")
34 }
35 if fset.flagModulePath != "" {
36 return fmt.Errorf("`--module-path` conflicts with `--hcl-only`")
37 }
38 }
39 if fset.flagModulePath != "" {
40 if !fset.flagAppend {
41 return fmt.Errorf("`--module-path` must be used together with `--append`")
42 }
43 }
44 if fset.flagDevProvider {
45 if fset.flagProviderVersion != "" {
46 return fmt.Errorf("`--dev-provider` conflicts with `--provider-version`")
47 }
48 }
49 if fset.hflagTFClientPluginPath != "" {
50 if !fset.flagHCLOnly {
51 return fmt.Errorf("`--tfclient-plugin-path` must be used together with `--hcl-only`")
52 }
53 }
54
55 if err := conflictArgs([]argDesc{
56 {
57 name: "--client-id",
58 isSet: fset.flagClientId != "",
59 },
60 {
61 name: "--client-id-file-path",
62 isSet: fset.flagClientIdFilePath != "",
63 },
64 }); err != nil {
65 return err
66 }
67
68 if err := conflictArgs([]argDesc{
69 {
70 name: "--client-certificate",
71 isSet: fset.flagClientCertificate != "",
72 },

Callers 2

TestCommondBeforeFuncFunction · 0.85
mainFunction · 0.85

Calls 4

DirIsEmptyFunction · 0.92
InspecTerraformBlockFunction · 0.92
conflictArgsFunction · 0.85
subscriptionIdFromCLIFunction · 0.85

Tested by 1

TestCommondBeforeFuncFunction · 0.68