Skip to content

Commit

Permalink
Fix error handling on object storage service enablement (#165)
Browse files Browse the repository at this point in the history
* Fix error handling on objecto storage service enablement

* Add message about depends_on

* Update docs
  • Loading branch information
vicentepinto98 authored Dec 18, 2023
1 parent 35275fd commit 506d1af
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docs/resources/objectstorage_bucket.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
page_title: "stackit_objectstorage_bucket Resource - stackit"
subcategory: ""
description: |-
ObjectStorage bucket resource schema. Must have a region specified in the provider configuration.
ObjectStorage bucket resource schema. Must have a region specified in the provider configuration. If you are creating credentialsgroup and bucket resources simultaneously, please include the depends_on field so that they are created sequentially. This prevents errors from concurrent calls to the service enablement that is done in the background.
---

# stackit_objectstorage_bucket (Resource)

ObjectStorage bucket resource schema. Must have a `region` specified in the provider configuration.
ObjectStorage bucket resource schema. Must have a `region` specified in the provider configuration. If you are creating `credentialsgroup` and `bucket` resources simultaneously, please include the `depends_on` field so that they are created sequentially. This prevents errors from concurrent calls to the service enablement that is done in the background.

## Example Usage

Expand Down
4 changes: 2 additions & 2 deletions docs/resources/objectstorage_credentials_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
page_title: "stackit_objectstorage_credentials_group Resource - stackit"
subcategory: ""
description: |-
ObjectStorage credentials group resource schema. Must have a region specified in the provider configuration.
ObjectStorage credentials group resource schema. Must have a region specified in the provider configuration. If you are creating credentialsgroup and bucket resources simultaneously, please include the depends_on field so that they are created sequentially. This prevents errors from concurrent calls to the service enablement that is done in the background.
---

# stackit_objectstorage_credentials_group (Resource)

ObjectStorage credentials group resource schema. Must have a `region` specified in the provider configuration.
ObjectStorage credentials group resource schema. Must have a `region` specified in the provider configuration. If you are creating `credentialsgroup` and `bucket` resources simultaneously, please include the `depends_on` field so that they are created sequentially. This prevents errors from concurrent calls to the service enablement that is done in the background.

## Example Usage

Expand Down
4 changes: 2 additions & 2 deletions stackit/internal/services/objectstorage/bucket/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (r *bucketResource) Configure(ctx context.Context, req resource.ConfigureRe
// Schema defines the schema for the resource.
func (r *bucketResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
descriptions := map[string]string{
"main": "ObjectStorage bucket resource schema. Must have a `region` specified in the provider configuration.",
"main": "ObjectStorage bucket resource schema. Must have a `region` specified in the provider configuration. If you are creating `credentialsgroup` and `bucket` resources simultaneously, please include the `depends_on` field so that they are created sequentially. This prevents errors from concurrent calls to the service enablement that is done in the background.",
"id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`name`\".",
"name": "The bucket name. It must be DNS conform.",
"project_id": "STACKIT Project ID to which the bucket is associated.",
Expand Down Expand Up @@ -156,7 +156,7 @@ func (r *bucketResource) Create(ctx context.Context, req resource.CreateRequest,

// Handle project init
err := enableProject(ctx, &model, r.client)
if resp.Diagnostics.HasError() {
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating bucket", fmt.Sprintf("Enabling object storage project before creation: %v", err))
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ

// Handle project init
err := enableProject(ctx, &model, r.client)
if resp.Diagnostics.HasError() {
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Enabling object storage project before creation: %v", err))
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (r *credentialsGroupResource) Configure(ctx context.Context, req resource.C
// Schema defines the schema for the resource.
func (r *credentialsGroupResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
descriptions := map[string]string{
"main": "ObjectStorage credentials group resource schema. Must have a `region` specified in the provider configuration.",
"main": "ObjectStorage credentials group resource schema. Must have a `region` specified in the provider configuration. If you are creating `credentialsgroup` and `bucket` resources simultaneously, please include the `depends_on` field so that they are created sequentially. This prevents errors from concurrent calls to the service enablement that is done in the background.",
"id": "Terraform's internal data source identifier. It is structured as \"`project_id`,`credentials_group_id`\".",
"credentials_group_id": "The credentials group ID",
"name": "The credentials group's display name.",
Expand Down Expand Up @@ -159,7 +159,7 @@ func (r *credentialsGroupResource) Create(ctx context.Context, req resource.Crea

// Handle project init
err := enableProject(ctx, &model, r.client)
if resp.Diagnostics.HasError() {
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials group", fmt.Sprintf("Enabling object storage project before creation: %v", err))
return
}
Expand Down

0 comments on commit 506d1af

Please sign in to comment.