Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit 8047646

Browse files
shubinmi0ndi
authored andcommitted
+ storage import s3,sftp,keys
1 parent c06cba0 commit 8047646

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

gcore/resource_gcore_storage_s3.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ func resourceStorageS3() *schema.Resource {
106106
ReadContext: resourceStorageS3Read,
107107
DeleteContext: resourceStorageS3Delete,
108108
Description: "Represent s3 storage resource. https://storage.gcorelabs.com/storage/list",
109+
Importer: &schema.ResourceImporter{
110+
StateContext: schema.ImportStatePassthroughContext,
111+
},
109112
}
110113
}
111114

@@ -141,9 +144,6 @@ func resourceStorageS3Create(ctx context.Context, d *schema.ResourceData, m inte
141144
if result.Credentials.S3.SecretKey != "" {
142145
_ = d.Set(StorageS3SchemaGenerateSecretKey, result.Credentials.S3.SecretKey)
143146
}
144-
_ = d.Set(StorageSchemaGenerateEndpoint, fmt.Sprintf("%s.cloud.gcore.lu/%s", result.Location, result.Name))
145-
_ = d.Set(StorageSchemaGenerateHTTPEndpoint, fmt.Sprintf("https://%s.cloud.gcore.lu/{bucket_name}", result.Location))
146-
_ = d.Set(StorageSchemaGenerateS3Endpoint, fmt.Sprintf("https://%s.cloud.gcore.lu", result.Location))
147147

148148
return resourceStorageS3Read(ctx, d, m)
149149
}
@@ -192,6 +192,9 @@ func resourceStorageS3Read(ctx context.Context, d *schema.ResourceData, m interf
192192
}
193193
_ = d.Set(StorageSchemaId, st.ID)
194194
_ = d.Set(StorageSchemaLocation, st.Location)
195+
_ = d.Set(StorageSchemaGenerateEndpoint, fmt.Sprintf("%s.cloud.gcore.lu/%s", st.Location, st.Name))
196+
_ = d.Set(StorageSchemaGenerateHTTPEndpoint, fmt.Sprintf("https://%s.cloud.gcore.lu/{bucket_name}", st.Location))
197+
_ = d.Set(StorageSchemaGenerateS3Endpoint, fmt.Sprintf("https://%s.cloud.gcore.lu", st.Location))
195198

196199
return nil
197200
}

gcore/resource_gcore_storage_sftp.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ func resourceStorageSFTP() *schema.Resource {
139139
UpdateContext: resourceStorageSFTPUpdate,
140140
DeleteContext: resourceStorageSFTPDelete,
141141
Description: "Represent sftp storage resource. https://storage.gcorelabs.com/storage/list",
142+
Importer: &schema.ResourceImporter{
143+
StateContext: schema.ImportStatePassthroughContext,
144+
},
142145
}
143146
}
144147

@@ -277,10 +280,6 @@ func resourceStorageSFTPCreate(ctx context.Context, d *schema.ResourceData, m in
277280
if result.Credentials.SftpPassword != "" {
278281
_ = d.Set(StorageSFTPSchemaSftpPassword, result.Credentials.SftpPassword)
279282
}
280-
_ = d.Set(StorageSchemaGenerateHTTPEndpoint,
281-
fmt.Sprintf("http://%s.%s.origin.gcdn.co", result.Name, result.Location))
282-
_ = d.Set(StorageSchemaGenerateSFTPEndpoint,
283-
fmt.Sprintf("ssh://%s@%s.origin.gcdn.co:2200", result.Name, result.Location))
284283

285284
err = resourceStorageLinkKeys(ctx, client, d, result.ID)
286285
if err != nil {
@@ -352,6 +351,10 @@ func resourceStorageSFTPRead(ctx context.Context, d *schema.ResourceData, m inte
352351
_ = d.Set(StorageSFTPSchemaExpires, st.Expires)
353352
_ = d.Set(StorageSchemaId, st.ID)
354353
_ = d.Set(StorageSchemaLocation, st.Location)
354+
_ = d.Set(StorageSchemaGenerateHTTPEndpoint,
355+
fmt.Sprintf("http://%s.%s.origin.gcdn.co", st.Name, st.Location))
356+
_ = d.Set(StorageSchemaGenerateSFTPEndpoint,
357+
fmt.Sprintf("ssh://%s@%s.origin.gcdn.co:2200", st.Name, st.Location))
355358

356359
return nil
357360
}

gcore/resource_gcore_storage_sftp_key.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ func resourceStorageSFTPKey() *schema.Resource {
5454
ReadContext: resourceStorageSFTPKeyRead,
5555
DeleteContext: resourceStorageSFTPKeyDelete,
5656
Description: "Represent storage key resource. https://storage.gcorelabs.com/ssh-key/list",
57+
Importer: &schema.ResourceImporter{
58+
StateContext: schema.ImportStatePassthroughContext,
59+
},
5760
}
5861
}
5962

0 commit comments

Comments
 (0)