@@ -116,14 +116,23 @@ func (r *mpgAttachmentResource) Create(ctx context.Context, req resource.CreateR
116116 args = append (args , "--variable-name" , v )
117117 }
118118
119- var result flyctlMPGAttachment
120- err := r .flyctl .RunJSONMut (ctx , & result , args ... )
119+ _ , err := r .flyctl .RunMut (ctx , args ... )
121120 if err != nil {
122121 resp .Diagnostics .AddError ("Error attaching MPG cluster" , err .Error ())
123122 return
124123 }
125124
126- r .setModelFromAPI (& plan , & result )
125+ // Attachment has no read/status command. Set state from plan values.
126+ plan .ID = types .StringValue (plan .ClusterID .ValueString () + "/" + plan .App .ValueString ())
127+ if plan .Database .IsUnknown () {
128+ plan .Database = types .StringValue ("" )
129+ }
130+ if plan .VariableName .IsUnknown () {
131+ plan .VariableName = types .StringValue ("DATABASE_URL" )
132+ }
133+ if plan .ConnectionURI .IsUnknown () {
134+ plan .ConnectionURI = types .StringValue ("" )
135+ }
127136 resp .Diagnostics .Append (resp .State .Set (ctx , & plan )... )
128137}
129138
@@ -175,15 +184,3 @@ func (r *mpgAttachmentResource) ImportState(ctx context.Context, req resource.Im
175184 resp .Diagnostics .Append (resp .State .SetAttribute (ctx , path .Root ("app" ), parts [1 ])... )
176185}
177186
178- func (r * mpgAttachmentResource ) setModelFromAPI (model * models.MPGAttachmentResourceModel , api * flyctlMPGAttachment ) {
179- model .ID = types .StringValue (model .ClusterID .ValueString () + "/" + model .App .ValueString ())
180- model .ConnectionURI = types .StringValue (api .ConnectionURI )
181- model .VariableName = types .StringValue (api .VariableName )
182- model .Database = types .StringValue (api .Database )
183- }
184-
185- type flyctlMPGAttachment struct {
186- ConnectionURI string `json:"connection_uri"`
187- VariableName string `json:"variable_name"`
188- Database string `json:"database"`
189- }
0 commit comments