Skip to content

Commit 0af584e

Browse files
committed
fix:delete Type attribute, using default param value
1 parent 23f2a5c commit 0af584e

File tree

1 file changed

+12
-59
lines changed

1 file changed

+12
-59
lines changed

zstack/provider/resource_zstack_image.go

Lines changed: 12 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type imageResourceModel struct {
4141
BackupStorageUuids types.List `tfsdk:"backup_storage_uuids"`
4242
Architecture types.String `tfsdk:"architecture"`
4343
Virtio types.Bool `tfsdk:"virtio"`
44-
Type types.String `tfsdk:"type"`
44+
// Type types.String `tfsdk:"type"`
4545
//Marketplace types.Bool `tfsdk:"marketplace"`
4646
BootMode types.String `tfsdk:"boot_mode"`
4747
Expunge types.Bool `tfsdk:"expunge"`
@@ -118,55 +118,6 @@ func (r *imageResource) Create(ctx context.Context, req resource.CreateRequest,
118118
return
119119
}
120120
}
121-
/*
122-
if imagePlan.Marketplace.ValueBool() {
123-
124-
// for marketplace image, if the image with same name status is Ready and state is Enabled, then skip add it.
125-
qparam := param.NewQueryParam()
126-
qparam.AddQ("name=" + imagePlan.Name.ValueString())
127-
//qparam.AddQ("url=" + imagePlan.Url.ValueString())
128-
qparam.AddQ("architecture=" + imagePlan.Architecture.ValueString())
129-
qparam.AddQ("status=Ready")
130-
qparam.AddQ("state=Enabled")
131-
132-
images, err := r.client.QueryImage(qparam)
133-
if err != nil {
134-
resp.Diagnostics.AddError(
135-
"fail to get image",
136-
fmt.Sprintf("fail to get image: %v", err),
137-
)
138-
return
139-
}
140-
141-
tflog.Info(ctx, fmt.Sprintf("find %d images", len(images)))
142-
for _, image := range images {
143-
for _, backupStorageRef := range image.BackupStorageRefs {
144-
backupStorageUuids = removeStringFromSlice(backupStorageUuids, backupStorageRef.BackupStorageUuid)
145-
}
146-
147-
if len(backupStorageUuids) == 0 {
148-
tflog.Info(ctx, "image has been imported to all backup storage")
149-
150-
imagePlan.Uuid = types.StringValue(image.UUID)
151-
imagePlan.Name = types.StringValue(image.Name)
152-
imagePlan.Description = types.StringValue(image.Description)
153-
imagePlan.Url = types.StringValue(image.Url)
154-
imagePlan.GuestOsType = types.StringValue(image.GuestOsType)
155-
imagePlan.System = types.StringValue(image.System)
156-
imagePlan.Platform = types.StringValue(image.Platform)
157-
imagePlan.Type = types.StringValue(image.Type)
158-
imagePlan.LastUpdated = types.StringValue(image.LastOpDate.String())
159-
ctx = tflog.SetField(ctx, "url", image.Url)
160-
diags = resp.State.Set(ctx, imagePlan)
161-
resp.Diagnostics.Append(diags...)
162-
return
163-
}
164-
}
165-
166-
tflog.Info(ctx, fmt.Sprintf("unimported backupStorageUuids: %v", backupStorageUuids))
167-
systemTags = append(systemTags, "marketplace::true")
168-
}
169-
*/
170121

171122
if imagePlan.Description.IsNull() {
172123
imagePlan.Description = types.StringValue("")
@@ -193,10 +144,10 @@ func (r *imageResource) Create(ctx context.Context, req resource.CreateRequest,
193144
Format: param.ImageFormat(imagePlan.Format.ValueString()), // param.Qcow2,
194145
Platform: imagePlan.Platform.ValueString(),
195146
BackupStorageUuids: backupStorageUuids,
196-
Type: imagePlan.Type.ValueString(),
197-
ResourceUuid: "",
198-
Architecture: param.Architecture(imagePlan.Architecture.ValueString()),
199-
Virtio: imagePlan.Virtio.ValueBool(),
147+
//Type: imagePlan.Type.ValueString(),
148+
ResourceUuid: "",
149+
Architecture: param.Architecture(imagePlan.Architecture.ValueString()),
150+
Virtio: imagePlan.Virtio.ValueBool(),
200151
},
201152
}
202153

@@ -216,7 +167,7 @@ func (r *imageResource) Create(ctx context.Context, req resource.CreateRequest,
216167
imagePlan.GuestOsType = types.StringValue(image.GuestOsType)
217168
imagePlan.System = types.StringValue(image.System)
218169
imagePlan.Platform = types.StringValue(image.Platform)
219-
imagePlan.Type = types.StringValue(image.Type)
170+
//imagePlan.Type = types.StringValue(image.Type)
220171
imagePlan.LastUpdated = types.StringValue(image.LastOpDate.String())
221172
ctx = tflog.SetField(ctx, "url", image.Url)
222173
diags = resp.State.Set(ctx, imagePlan)
@@ -380,10 +331,12 @@ func (r *imageResource) Schema(_ context.Context, req resource.SchemaRequest, re
380331
stringvalidator.OneOf("x86_64", "aarch64", "mips64el", "loongarch64"),
381332
},
382333
},
383-
"type": schema.StringAttribute{
384-
Computed: true,
385-
Description: "The type of the image, for example, 'ISO' or 'RootVolumeTemplate'.",
386-
},
334+
/*
335+
"type": schema.StringAttribute{
336+
Computed: true,
337+
Description: "The type of the image, for example, 'ISO' or 'RootVolumeTemplate'.",
338+
},
339+
*/
387340
"virtio": schema.BoolAttribute{
388341
Optional: true,
389342
Description: "Indicates if the VirtIO drivers are required for the image.",

0 commit comments

Comments
 (0)