Skip to content

Commit fc8d29f

Browse files
committed
fix review
1 parent 75b6b6f commit fc8d29f

File tree

4 files changed

+271
-229
lines changed

4 files changed

+271
-229
lines changed

internal/services/inference/deployment.go

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func ResourceDeployment() *schema.Resource {
2222
Importer: &schema.ResourceImporter{
2323
StateContext: schema.ImportStatePassthroughContext,
2424
},
25-
Timeouts: &schema.ResourceTimeout{ // TODO: remove unused timeouts
25+
Timeouts: &schema.ResourceTimeout{
2626
Create: schema.DefaultTimeout(defaultInferenceDeploymentTimeout),
2727
Read: schema.DefaultTimeout(defaultInferenceDeploymentTimeout),
2828
Update: schema.DefaultTimeout(defaultInferenceDeploymentTimeout),
@@ -238,24 +238,15 @@ func ResourceDeploymentRead(ctx context.Context, d *schema.ResourceData, m inter
238238
_ = d.Set("created_at", types.FlattenTime(deployment.CreatedAt))
239239
_ = d.Set("updated_at", types.FlattenTime(deployment.UpdatedAt))
240240

241-
if deployment.Endpoints[0].PrivateNetwork != nil {
242-
_ = d.Set("endpoint_private_url", deployment.Endpoints[0].URL)
243-
_ = d.Set("endpoint_private_id", deployment.Endpoints[0].ID)
244-
_ = d.Set("disable_auth_private", deployment.Endpoints[0].DisableAuth)
245-
} else {
246-
_ = d.Set("endpoint_public_url", deployment.Endpoints[0].URL)
247-
_ = d.Set("endpoint_public_id", deployment.Endpoints[0].ID)
248-
_ = d.Set("disable_auth_public", deployment.Endpoints[0].DisableAuth)
249-
}
250-
if len(deployment.Endpoints) == 2 {
251-
if deployment.Endpoints[1].PrivateNetwork != nil {
252-
_ = d.Set("endpoint_private_url", deployment.Endpoints[1].URL)
253-
_ = d.Set("endpoint_private_id", deployment.Endpoints[1].ID)
254-
_ = d.Set("disable_auth_private", deployment.Endpoints[1].DisableAuth)
241+
for _, endpoint := range deployment.Endpoints {
242+
if endpoint.PrivateNetwork != nil {
243+
_ = d.Set("endpoint_private_url", endpoint.URL)
244+
_ = d.Set("endpoint_private_id", endpoint.ID)
245+
_ = d.Set("disable_auth_private", endpoint.DisableAuth)
255246
} else {
256-
_ = d.Set("endpoint_public_url", deployment.Endpoints[1].URL)
257-
_ = d.Set("endpoint_public_id", deployment.Endpoints[1].ID)
258-
_ = d.Set("disable_auth_public", deployment.Endpoints[1].DisableAuth)
247+
_ = d.Set("endpoint_public_url", endpoint.URL)
248+
_ = d.Set("endpoint_public_id", endpoint.ID)
249+
_ = d.Set("disable_auth_public", endpoint.DisableAuth)
259250
}
260251
}
261252
return nil

internal/services/inference/deployment_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestAccDeployment_Basic(t *testing.T) {
1919
resource.ParallelTest(t, resource.TestCase{
2020
PreCheck: func() { acctest.PreCheck(t) },
2121
ProviderFactories: tt.ProviderFactories,
22-
CheckDestroy: inferencetestfuncs.IsDeploymentDestroy(tt),
22+
CheckDestroy: inferencetestfuncs.IsDeploymentDestroyed(tt),
2323
Steps: []resource.TestStep{
2424
{
2525
Config: `
@@ -49,7 +49,7 @@ func TestAccDeployment_Endpoint(t *testing.T) {
4949
resource.ParallelTest(t, resource.TestCase{
5050
PreCheck: func() { acctest.PreCheck(t) },
5151
ProviderFactories: tt.ProviderFactories,
52-
CheckDestroy: inferencetestfuncs.IsDeploymentDestroy(tt),
52+
CheckDestroy: inferencetestfuncs.IsDeploymentDestroyed(tt),
5353
Steps: []resource.TestStep{
5454
{
5555
Config: `
@@ -69,6 +69,7 @@ func TestAccDeployment_Endpoint(t *testing.T) {
6969
Check: resource.ComposeTestCheckFunc(
7070
testAccCheckDeploymentExists(tt, "scaleway_inference_deployment.main"),
7171
resource.TestCheckResourceAttr("scaleway_inference_deployment.main", "name", "test-inference-deployment-endpoint-private"),
72+
resource.TestCheckResourceAttr("scaleway_inference_deployment.main", "node_type", "L4"),
7273
),
7374
},
7475
{
@@ -90,6 +91,7 @@ func TestAccDeployment_Endpoint(t *testing.T) {
9091
Check: resource.ComposeTestCheckFunc(
9192
testAccCheckDeploymentExists(tt, "scaleway_inference_deployment.main"),
9293
resource.TestCheckResourceAttr("scaleway_inference_deployment.main", "name", "test-inference-deployment-basic-endpoints-private-public"),
94+
resource.TestCheckResourceAttrSet("scaleway_inference_deployment.main", "endpoints.0.public_endpoint"),
9395
),
9496
},
9597
},

0 commit comments

Comments
 (0)