Skip to content

Commit 7811041

Browse files
authored
Use --input for fun/res and provider format (#23322)
There's no need to support separate formats for provider config and resource/function config. Users are going to use the same format for both, so simplify down to just one `--input` flag.
1 parent ec98d48 commit 7811041

6 files changed

Lines changed: 30 additions & 35 deletions

File tree

‎pkg/cmd/pulumi/do/do.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ installed locally.
334334
Provider configuration can be supplied via:
335335
- the provider's standard environment variables (e.g. AWS_REGION)
336336
- an input file passed with --provider-file (PCL by default;
337-
set --provider-format to convert from another format)
337+
set --input to convert from another format)
338338
339339
Function inputs come from --input-file. PCL is the default; pass --input
340340
to convert from another format such as YAML. Non-PCL formats require a
@@ -399,7 +399,7 @@ type packageCommand struct {
399399
packageDescriptor *codegenrpc.GetSchemaRequest
400400
provider plugin.Provider
401401
providerFile string
402-
providerFormat string
402+
format string
403403
spec *schema.Package
404404
dryrun bool
405405
showSecrets bool

‎pkg/cmd/pulumi/do/do_function.go‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ func (pc *packageCommand) newFunctionCommand(fn *schema.Function) *cobra.Command
8888
}
8989

9090
var inputFile string
91-
var inputFormat string
9291

9392
cmd := &cobra.Command{
9493
Use: name,
@@ -103,7 +102,7 @@ func (pc *packageCommand) newFunctionCommand(fn *schema.Function) *cobra.Command
103102
}
104103

105104
inputs, err := evaluateFunctionFile(
106-
ctx, inputFile, "input", inputFormat, fn, pc.evalContext,
105+
ctx, inputFile, "input", pc.format, fn, pc.evalContext,
107106
pc.converter, pc.loaderTarget, pc.packageDescriptor)
108107
if err != nil {
109108
return fmt.Errorf("parse input file: %w", err)
@@ -143,12 +142,11 @@ func (pc *packageCommand) newFunctionCommand(fn *schema.Function) *cobra.Command
143142
},
144143
}
145144

146-
cmd.Flags().StringVar(&inputFormat, "input", "pcl", "Input file format")
147145
cmd.Flags().StringVar(&inputFile, "input-file", "", "Path to a file containing function inputs")
148146
cmd.Flags().StringVar(&pc.providerFile, "provider-file", "",
149147
"Path to a file containing provider configuration")
150-
cmd.Flags().StringVar(&pc.providerFormat, "provider-format", "pcl",
151-
"Format of the provider configuration file")
148+
cmd.Flags().StringVar(&pc.format, "input", "pcl",
149+
"Format of the configuration files")
152150

153151
return cmd
154152
}

‎pkg/cmd/pulumi/do/do_function_test.go‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,13 @@ Usage:
129129
myOtherFunction [flags]
130130
131131
Flags:
132-
--dry-run Run the operation in preview mode
133-
-h, --help help for do
134-
--input string Input file format (default "pcl")
135-
--input-file string Path to a file containing function inputs
136-
--package string The package to load, in the form 'name@version' or a path to a plugin binary or folder. If the package supports parameterization, additional space-separated parameters can be included after the package name, e.g. --package "name@version param1 \"multi word param\""
137-
--provider-file string Path to a file containing provider configuration
138-
--provider-format string Format of the provider configuration file (default "pcl")
139-
--show-secrets Show secret values in output
132+
--dry-run Run the operation in preview mode
133+
-h, --help help for do
134+
--input string Format of the configuration files (default "pcl")
135+
--input-file string Path to a file containing function inputs
136+
--package string The package to load, in the form 'name@version' or a path to a plugin binary or folder. If the package supports parameterization, additional space-separated parameters can be included after the package name, e.g. --package "name@version param1 \"multi word param\""
137+
--provider-file string Path to a file containing provider configuration
138+
--show-secrets Show secret values in output
140139
`
141140
assert.Equal(t, expected, stdout.String())
142141
}
@@ -2075,7 +2074,7 @@ func TestDoCmdFunctionInvokeParameterizedSchemaWithoutArgs(t *testing.T) {
20752074
assert.ErrorContains(t, err, "provider returned parameterization but no parameterization args were sent")
20762075
}
20772076

2078-
// TestDoCmdFunctionInvokeWithYAMLProviderFile exercises the provider-config converter path: --provider-format yaml
2077+
// TestDoCmdFunctionInvokeWithYAMLProviderFile exercises the provider-config converter path: --input yaml
20792078
// + --provider-file p.yaml should run the YAML through the converter, hand the resulting PCL to Configure, and
20802079
// pass the right token (the provider's pulumi:providers:<pkg> token) and the same package descriptor we use for
20812080
// function inputs.
@@ -2158,7 +2157,7 @@ func TestDoCmdFunctionInvokeWithYAMLProviderFile(t *testing.T) {
21582157
cmd.SetErr(&stdout)
21592158
cmd.SetArgs([]string{
21602159
"azure:index:myFunction",
2161-
"--provider-file", providerFile, "--provider-format", "yaml",
2160+
"--provider-file", providerFile, "--input", "yaml",
21622161
})
21632162
err := cmd.Execute()
21642163
require.NoError(t, err)

‎pkg/cmd/pulumi/do/do_resource.go‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (pc *packageCommand) newResourceCommand(res *schema.Resource) *cobra.Comman
102102
// Provider configuration applies to all sub-operations, so register here as persistent flags.
103103
cmd.PersistentFlags().StringVar(&pc.providerFile, "provider-file", "",
104104
"Path to a file containing provider configuration")
105-
cmd.PersistentFlags().StringVar(&pc.providerFormat, "provider-format", "pcl",
105+
cmd.PersistentFlags().StringVar(&pc.format, "input", "pcl",
106106
"Format of the provider configuration file")
107107
cmd.AddCommand(pc.newResourceCreateCommand(res))
108108
cmd.AddCommand(pc.newResourceReadCommand(res))
@@ -116,7 +116,6 @@ func (pc *packageCommand) newResourceCommand(res *schema.Resource) *cobra.Comman
116116

117117
func (pc *packageCommand) newResourceCreateCommand(res *schema.Resource) *cobra.Command {
118118
var inputFile string
119-
var inputFormat string
120119
var yes bool
121120
cmd := &cobra.Command{
122121
Use: "create",
@@ -132,7 +131,7 @@ func (pc *packageCommand) newResourceCreateCommand(res *schema.Resource) *cobra.
132131
}
133132
urn := resourceURN(res)
134133
inputs, err := evaluateResourceFile(
135-
ctx, inputFile, "input", inputFormat, res, pc.evalContext,
134+
ctx, inputFile, "input", pc.format, res, pc.evalContext,
136135
pc.converter, pc.loaderTarget, pc.packageDescriptor)
137136
if err != nil {
138137
return fmt.Errorf("parse input file: %w", err)
@@ -165,7 +164,6 @@ func (pc *packageCommand) newResourceCreateCommand(res *schema.Resource) *cobra.
165164
return pc.printResourceResult(cmd, response.ID, response.Properties, res)
166165
},
167166
}
168-
cmd.Flags().StringVar(&inputFormat, "input", "pcl", "Input file format")
169167
cmd.Flags().StringVar(&inputFile, "input-file", "", "Path to a file containing resource inputs")
170168
cmd.Flags().BoolVar(&yes, "yes", false,
171169
"Automatically approve and perform the operation without a confirmation prompt")
@@ -292,7 +290,7 @@ func (pc *packageCommand) newResourcePatchCommand(res *schema.Resource) *cobra.C
292290
return pc.printResourceResult(cmd, id, response.Properties, res)
293291
},
294292
}
295-
cmd.Flags().StringVar(&inputFormat, "input", "pcl", "Input file format")
293+
cmd.Flags().StringVar(&inputFormat, "input", "pcl", "Format of the configuration files")
296294
cmd.Flags().StringVar(&inputFile, "input-file", "", "Path to a file containing resource inputs")
297295
cmd.Flags().BoolVar(&yes, "yes", false,
298296
"Automatically approve and perform the operation without a confirmation prompt")

‎pkg/cmd/pulumi/do/do_resource_test.go‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ Available Commands:
131131
read Read a resource
132132
133133
Flags:
134-
--dry-run Run the operation in preview mode
135-
-h, --help help for do
136-
--package string The package to load, in the form 'name@version' or a path to a plugin binary or folder. If the package supports parameterization, additional space-separated parameters can be included after the package name, e.g. --package "name@version param1 \"multi word param\""
137-
--provider-file string Path to a file containing provider configuration
138-
--provider-format string Format of the provider configuration file (default "pcl")
139-
--show-secrets Show secret values in output
134+
--dry-run Run the operation in preview mode
135+
-h, --help help for do
136+
--input string Format of the provider configuration file (default "pcl")
137+
--package string The package to load, in the form 'name@version' or a path to a plugin binary or folder. If the package supports parameterization, additional space-separated parameters can be included after the package name, e.g. --package "name@version param1 \"multi word param\""
138+
--provider-file string Path to a file containing provider configuration
139+
--show-secrets Show secret values in output
140140
141141
Use "myResource [command] --help" for more information about a command.
142142
`
@@ -180,12 +180,12 @@ Available Commands:
180180
read Read a resource
181181
182182
Flags:
183-
--dry-run Run the operation in preview mode
184-
-h, --help help for do
185-
--package string The package to load, in the form 'name@version' or a path to a plugin binary or folder. If the package supports parameterization, additional space-separated parameters can be included after the package name, e.g. --package "name@version param1 \"multi word param\""
186-
--provider-file string Path to a file containing provider configuration
187-
--provider-format string Format of the provider configuration file (default "pcl")
188-
--show-secrets Show secret values in output
183+
--dry-run Run the operation in preview mode
184+
-h, --help help for do
185+
--input string Format of the provider configuration file (default "pcl")
186+
--package string The package to load, in the form 'name@version' or a path to a plugin binary or folder. If the package supports parameterization, additional space-separated parameters can be included after the package name, e.g. --package "name@version param1 \"multi word param\""
187+
--provider-file string Path to a file containing provider configuration
188+
--show-secrets Show secret values in output
189189
190190
Use "myResource [command] --help" for more information about a command.
191191
`

‎pkg/cmd/pulumi/do/do_shared.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ func resourceURN(res *schema.Resource) resource.URN {
385385

386386
func (pc *packageCommand) configureProvider(ctx context.Context) error {
387387
config, err := evaluateResourceFile(
388-
ctx, pc.providerFile, "provider", pc.providerFormat,
388+
ctx, pc.providerFile, "provider", pc.format,
389389
pc.spec.Provider, pc.evalContext, pc.converter, pc.loaderTarget, pc.packageDescriptor)
390390
if err != nil {
391391
return fmt.Errorf("parse provider file: %w", err)

0 commit comments

Comments
 (0)