@@ -30,23 +30,26 @@ var _ = (infer.CustomUpdate[CommandInputs, CommandOutputs])((*Command)(nil))
3030var _ = (infer.CustomDelete [CommandOutputs ])((* Command )(nil ))
3131
3232// This is the Create method. This will be run on every Command resource creation.
33- func (c * Command ) Create (ctx context.Context , name string , input CommandInputs , preview bool ) (string , CommandOutputs , error ) {
33+ func (c * Command ) Create (ctx context.Context , req infer.CreateRequest [CommandInputs ]) (infer.CreateResponse [CommandOutputs ], error ) {
34+ name := req .Name
35+ input := req .Inputs
36+ preview := req .DryRun
3437 state := CommandOutputs {CommandInputs : input }
3538 id , err := resource .NewUniqueHex (name , 8 , 0 )
3639 if err != nil {
37- return id , state , err
40+ return infer. CreateResponse [ CommandOutputs ]{ ID : id , Output : state } , err
3841 }
3942
4043 // If in preview, don't run the command.
4144 if preview {
42- return id , state , nil
45+ return infer. CreateResponse [ CommandOutputs ]{ ID : id , Output : state } , nil
4346 }
4447 if input .Create == nil {
45- return id , state , nil
48+ return infer. CreateResponse [ CommandOutputs ]{ ID : id , Output : state } , nil
4649 }
4750 cmd := * input .Create
4851 err = run (ctx , cmd , state .BaseInputs , & state .BaseOutputs , input .Logging )
49- return id , state , err
52+ return infer. CreateResponse [ CommandOutputs ]{ ID : id , Output : state } , err
5053}
5154
5255// WireDependencies controls how secrets and unknowns flow through a resource.
@@ -57,11 +60,14 @@ func (c *Command) Create(ctx context.Context, name string, input CommandInputs,
5760// Because we want every output to depend on every input, we can leave the default behavior.
5861
5962// The Update method will be run on every update.
60- func (c * Command ) Update (ctx context.Context , id string , olds CommandOutputs , news CommandInputs , preview bool ) (CommandOutputs , error ) {
63+ func (c * Command ) Update (ctx context.Context , req infer.UpdateRequest [CommandInputs , CommandOutputs ]) (infer.UpdateResponse [CommandOutputs ], error ) {
64+ olds := req .State
65+ news := req .Inputs
66+ preview := req .DryRun
6167 state := CommandOutputs {CommandInputs : news , BaseOutputs : olds .BaseOutputs }
6268 // If in preview, don't run the command.
6369 if preview {
64- return state , nil
70+ return infer. UpdateResponse [ CommandOutputs ]{ Output : state } , nil
6571 }
6672 // Use Create command if Update is unspecified.
6773 cmd := news .Create
@@ -70,16 +76,17 @@ func (c *Command) Update(ctx context.Context, id string, olds CommandOutputs, ne
7076 }
7177 // If neither are specified, do nothing.
7278 if cmd == nil {
73- return state , nil
79+ return infer. UpdateResponse [ CommandOutputs ]{ Output : state } , nil
7480 }
7581 err := run (ctx , * cmd , state .BaseInputs , & state .BaseOutputs , news .Logging )
76- return state , err
82+ return infer. UpdateResponse [ CommandOutputs ]{ Output : state } , err
7783}
7884
7985// The Delete method will run when the resource is deleted.
80- func (c * Command ) Delete (ctx context.Context , id string , props CommandOutputs ) error {
86+ func (c * Command ) Delete (ctx context.Context , req infer.DeleteRequest [CommandOutputs ]) (infer.DeleteResponse , error ) {
87+ props := req .State
8188 if props .Delete == nil {
82- return nil
89+ return infer. DeleteResponse {}, nil
8390 }
84- return run (ctx , * props .Delete , props .BaseInputs , & props .BaseOutputs , props .Logging )
91+ return infer. DeleteResponse {}, run (ctx , * props .Delete , props .BaseInputs , & props .BaseOutputs , props .Logging )
8592}
0 commit comments