Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
branches: ["master", "codex/**"]

permissions: read-all

jobs:
ci:
permissions:
contents: read
id-token: write
# Reusable CI lives in 1set/meta — the single source of truth for every
# Star* module's pipeline. Pinned to a commit SHA for supply-chain safety;
# bump the pin when meta's workflow changes (Dependabot github-actions can
# automate this).
uses: 1set/meta/.github/workflows/go-ci.yml@5d86667e7264f012655dab2644dfa44e09597445
uses: 1set/meta/.github/workflows/go-ci.yml@6b334e6a2762acaeefcea9fc7d3e86964e9246be
with:
go-floor: "1.21"
doc-coverage: true
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Top-level builtins (`load("s3", …)`):
- `validate_object_key(key)` — whether `key` is a valid S3 object key.
- `get_supported_services()` — the list of supported service-type strings.

`part_size` and `concurrency` are retained in client configuration and reported by `get_client_info()`. Current uploads use single-request SDK operations; these settings do not enable multipart or concurrent transfers.

`Client` object methods (returned by `create_client`):

- `get_client_info()` — effective config struct (secret values reported only as `*_set` booleans).
Expand Down
83 changes: 83 additions & 0 deletions example_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package s3

// Script-level sections:
// - module/client configuration and public client information
// - offline validation, argument errors, and credential boundaries
// - explicitly opt-in live endpoint fixtures

import (
"fmt"
"os"
"strings"
"testing"
Expand Down Expand Up @@ -93,6 +99,83 @@ test_client_creation()
}
}

// TestS3PartSizeConfiguration checks that module configuration survives client
// creation. No operation is sent to S3: the getters are metadata-only public
// builtins. The ordinary default and explicit override are controls for the
// host/module configured-value regressions.
func TestS3PartSizeConfiguration(t *testing.T) {
cases := []struct {
name string
env string
hostValue int64
moduleValue int64
override int64
wantModule int64
wantClient int64
}{
{name: "default", wantModule: 5 * 1024 * 1024, wantClient: 5 * 1024 * 1024},
{name: "host_environment", env: "8388608", wantModule: 8 * 1024 * 1024, wantClient: 8 * 1024 * 1024},
{name: "wide_host_environment", env: "3221225472", wantModule: 3 * 1024 * 1024 * 1024, wantClient: 3 * 1024 * 1024 * 1024},
{name: "host_typed_setter", hostValue: 9 * 1024 * 1024, wantModule: 9 * 1024 * 1024, wantClient: 9 * 1024 * 1024},
{name: "module_setter", env: "8388608", moduleValue: 12 * 1024 * 1024, wantModule: 12 * 1024 * 1024, wantClient: 12 * 1024 * 1024},
{name: "explicit_override", env: "8388608", override: 16 * 1024 * 1024, wantModule: 8 * 1024 * 1024, wantClient: 16 * 1024 * 1024},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
// Known host-only credentials and disabled metadata/config files keep
// SDK configuration local. The script performs no object operation.
t.Setenv("S3_PART_SIZE", tc.env)
t.Setenv("S3_ACCESS_KEY", "test-access-key")
t.Setenv("S3_SECRET_KEY", "test-secret-key")
t.Setenv("AWS_EC2_METADATA_DISABLED", "true")
t.Setenv("AWS_CONFIG_FILE", t.TempDir()+"/absent-config")
t.Setenv("AWS_SHARED_CREDENTIALS_FILE", t.TempDir()+"/absent-credentials")
module := NewModule()
if tc.hostValue != 0 {
if err := base.SetConfigValue[int64](module.cfgMod, configKeyPartSize, tc.hostValue); err != nil {
t.Fatalf("host typed setter: %v", err)
}
}
setter := ""
if tc.moduleValue != 0 {
setter = fmt.Sprintf(" set_part_size(%d)\n", tc.moduleValue)
}
override := ""
if tc.override != 0 {
override = fmt.Sprintf(", part_size=%d", tc.override)
}
script := fmt.Sprintf(`
load("s3", "create_client", "get_part_size", "set_part_size")
def check():
%s
if get_part_size() != %d:
fail("module part_size getter did not preserve the configured int64 value")
client = create_client(service_type="aws"%s)
actual = client.get_client_info().part_size
if actual != %d:
fail("client part_size = %%d; expected %%d" %% (actual, %d))
check()
`, setter, tc.wantModule, override, tc.wantClient, tc.wantClient)
runner := starlet.NewDefault()
runner.SetLazyloadModules(map[string]starlet.ModuleLoader{ModuleName: module.LoadModule()})
runner.SetScriptContent([]byte(script))
_, runErr := runner.Run()
// Independent base public API controls prove that stored configuration
// is correct even when client construction consumes the wrong type.
value, err := base.GetConfigValue[int64](module.cfgMod, configKeyPartSize)
if err != nil || value != tc.wantModule {
t.Errorf("base typed getter = %d, %v; want %d", value, err, tc.wantModule)
}
if got := module.cfgMod.ListConfigs()[configKeyPartSize]["value"]; got != tc.wantModule {
t.Errorf("ListConfigs part_size = %#v, want %d", got, tc.wantModule)
}
if runErr != nil {
t.Errorf("public client configuration: %v", runErr)
}
})
}
}

// TestS3ClientInfoAndPublicURL covers the two client methods the README
// documents as the client-config surface: get_client_info() (which exposes the
// resolved non-secret config plus *_set booleans, never the secret values) and
Expand Down
2 changes: 1 addition & 1 deletion s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (m *Module) starCreateClient(thread *starlark.Thread, b *starlark.Builtin,
UseSSL: getBoolConfigValue(m.ext.GetBool(configKeyUseSSL), useSSL),
Timeout: getIntConfigValue(m.ext.GetInt(configKeyTimeout), timeout),
MaxRetries: getIntConfigValue(m.ext.GetInt(configKeyMaxRetries), maxRetries),
PartSize: getInt64ConfigValue(int64(m.ext.GetInt(configKeyPartSize)), partSize),
PartSize: getInt64ConfigValue(base.GetConfigValueWithFallback[int64](m.cfgMod, configKeyPartSize, 0), partSize),
Concurrency: getIntConfigValue(m.ext.GetInt(configKeyConcurrency), concurrency),
EnableLogging: getBoolConfigValue(m.ext.GetBool(configKeyEnableLogging), enableLogging),
UserAgent: getConfigValue(m.ext.GetString(configKeyUserAgent), userAgent),
Expand Down
Loading