Skip to content

Commit 5c14654

Browse files
committed
chore: fix local setup and the index creation
1 parent c27acf7 commit 5c14654

9 files changed

Lines changed: 18 additions & 8 deletions

File tree

internal/common/helpers.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,15 @@ func WaitForDeploymentReady(ctx context.Context, getDeployment func() (string, e
192192
}
193193

194194
// WaitForColumnAvailable polls a column until its status becomes "available",
195-
// with a maximum wait of 60 seconds.
195+
// with a maximum wait of 5 minutes.
196196
func WaitForColumnAvailable(ctx context.Context, getColumn func() (interface{}, error), key string) error {
197-
deadline := time.After(60 * time.Second)
197+
deadline := time.After(5 * time.Minute)
198198
for {
199199
select {
200200
case <-ctx.Done():
201201
return fmt.Errorf("timed out waiting for column %q to become available", key)
202202
case <-deadline:
203-
return fmt.Errorf("column %q did not become available within 60s", key)
203+
return fmt.Errorf("column %q did not become available within 5m", key)
204204
default:
205205
}
206206

internal/services/file/resource.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package file
33
import (
44
"context"
55
"fmt"
6+
"os"
67
"strings"
78

89
"github.com/appwrite/sdk-for-go/v3/appwrite"
@@ -138,7 +139,15 @@ func (r *fileResource) Create(ctx context.Context, req resource.CreateRequest, r
138139
if plan.Name.IsNull() || plan.Name.IsUnknown() {
139140
fileName = ""
140141
}
141-
inputFile := appwritefile.NewInputFile(plan.FilePath.ValueString(), fileName)
142+
filePath := plan.FilePath.ValueString()
143+
if _, err := os.Stat(filePath); os.IsNotExist(err) {
144+
resp.Diagnostics.AddError(
145+
"File not found",
146+
fmt.Sprintf("The file at path %q does not exist. Please verify the file_path attribute points to a valid local file.", filePath),
147+
)
148+
return
149+
}
150+
inputFile := appwritefile.NewInputFile(filePath, fileName)
142151

143152
var opts []storage.CreateFileOption
144153
if !plan.Permissions.IsNull() && !plan.Permissions.IsUnknown() {

internal/services/index/resource.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,10 @@ func (r *indexResource) Create(ctx context.Context, req resource.CreateRequest,
134134

135135
databaseId := plan.DatabaseID.ValueString()
136136
tableId := plan.TableID.ValueString()
137+
rawClient := r.clients.ClientForProject(projectID)
137138
for _, col := range columns {
138139
if err := common.WaitForColumnAvailable(ctx, func() (interface{}, error) {
139-
return tablesdbClient.GetColumn(databaseId, tableId, col)
140+
return common.GetColumnRaw(rawClient, databaseId, tableId, col)
140141
}, col); err != nil {
141142
resp.Diagnostics.AddError("Error waiting for columns", err.Error())
142143
return

local/files/file.txt

Whitespace-only changes.

local/functions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ resource "appwrite_function_deployment" "process_order_code" {
3333
function_id = appwrite_function.process_order.id
3434
source_type = "code"
3535
code_path = "./process-order.tar.gz"
36-
code_hash = filesha256("./process-order.tar.gz")
36+
code_hash = filesha256("./files/process-order.tar.gz")
3737
entrypoint = "index.js"
3838
commands = "npm install"
3939
activate = true

local/sites.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ resource "appwrite_site_deployment" "landing_page_code" {
2929
site_id = appwrite_site.landing_page.id
3030
source_type = "code"
3131
code_path = "./dist.tar.gz"
32-
code_hash = filesha256("./dist.tar.gz")
32+
code_hash = filesha256("./files/dist.tar.gz")
3333
activate = true
3434
}
3535

local/storage.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ resource "appwrite_storage_bucket" "documents" {
2020
resource "appwrite_storage_file" "readme" {
2121
bucket_id = appwrite_storage_bucket.documents.id
2222
name = "readme.txt"
23-
file_path = "files/readme.txt"
23+
file_path = "./files/file.txt"
2424
}

0 commit comments

Comments
 (0)