Update SDK version to support AppName query for AppInst
This commit is contained in:
parent
676370b62b
commit
3ad1d4ec60
5 changed files with 19 additions and 66 deletions
|
|
@ -144,10 +144,12 @@ func (d *AppInstanceDataSource) Read(ctx context.Context, req datasource.ReadReq
|
|||
Name: data.CloudletName.ValueString(),
|
||||
},
|
||||
}
|
||||
|
||||
appKey := edgeclient.AppKey{
|
||||
Name: data.AppId.ValueString(),
|
||||
}
|
||||
region := data.Region.ValueString()
|
||||
|
||||
appInstances, err := d.client.ShowAppInstances(ctx, appInstKey, region)
|
||||
appInstances, err := d.client.ShowAppInstances(ctx, appInstKey, appKey, region)
|
||||
if err != nil {
|
||||
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to read app instance %s/%s in region %s, got error: %s",
|
||||
data.Organization.ValueString(), data.Name.ValueString(), region, err))
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ func (r *AppInstanceResource) Create(ctx context.Context, req resource.CreateReq
|
|||
data.Id = types.StringValue(appInstInput.AppInst.Key.Name)
|
||||
data.State = types.StringValue("created")
|
||||
|
||||
appInstance, err := r.client.ShowAppInstance(ctx, appInstInput.AppInst.Key, data.Region.ValueString())
|
||||
appInstance, err := r.client.ShowAppInstance(ctx, appInstInput.AppInst.Key, appInstInput.AppInst.AppKey, data.Region.ValueString())
|
||||
if err != nil {
|
||||
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to read app instance %s, got error: %s", data.Id.ValueString(), err))
|
||||
return
|
||||
|
|
@ -220,8 +220,11 @@ func (r *AppInstanceResource) Read(ctx context.Context, req resource.ReadRequest
|
|||
Name: data.CloudletName.ValueString(),
|
||||
},
|
||||
}
|
||||
appKey := edgeclient.AppKey{
|
||||
Name: data.AppName.ValueString(),
|
||||
}
|
||||
|
||||
appInstance, err := r.client.ShowAppInstance(ctx, appInstKey, data.Region.ValueString())
|
||||
appInstance, err := r.client.ShowAppInstance(ctx, appInstKey, appKey, data.Region.ValueString())
|
||||
if err != nil {
|
||||
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to read app instance %s, got error: %s", data.Id.ValueString(), err))
|
||||
return
|
||||
|
|
@ -261,6 +264,9 @@ func (r *AppInstanceResource) Update(ctx context.Context, req resource.UpdateReq
|
|||
Flavor: edgeclient.Flavor{Name: data.FlavorName.ValueString()},
|
||||
},
|
||||
}
|
||||
appInput := edgeclient.AppKey{
|
||||
Name: data.AppName.ValueString(),
|
||||
}
|
||||
|
||||
err := r.client.UpdateAppInstance(ctx, updateInput)
|
||||
if err != nil {
|
||||
|
|
@ -268,7 +274,7 @@ func (r *AppInstanceResource) Update(ctx context.Context, req resource.UpdateReq
|
|||
return
|
||||
}
|
||||
|
||||
appInstance, err := r.client.ShowAppInstance(ctx, updateInput.AppInst.Key, data.Region.ValueString())
|
||||
appInstance, err := r.client.ShowAppInstance(ctx, updateInput.AppInst.Key, appInput, data.Region.ValueString())
|
||||
if err != nil {
|
||||
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to read app instance %s, got error: %s", data.Id.ValueString(), err))
|
||||
return
|
||||
|
|
@ -310,7 +316,7 @@ func (r *AppInstanceResource) ImportState(ctx context.Context, req resource.Impo
|
|||
resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp)
|
||||
}
|
||||
|
||||
func UpdateDataFromAppInstance(appInstance *edgeclient.AppInstance, data *AppInstanceResourceModel){
|
||||
func UpdateDataFromAppInstance(appInstance *edgeclient.AppInstance, data *AppInstanceResourceModel) {
|
||||
data.Name = types.StringValue(appInstance.Key.Name)
|
||||
data.Organization = types.StringValue(appInstance.Key.Organization)
|
||||
data.CloudletOrg = types.StringValue(appInstance.Key.CloudletKey.Organization)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue