Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 36
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fhypeman-4f6187089a62f5df123ef4ee17660dd737c2b486377af2b5c5a922d454067b41.yml
openapi_spec_hash: 53e42659f7453f1abfda3236c3f7cb31
config_hash: 14135b7c88169a15762c8defb0bdfd16
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fhypeman-fbe706932aedef16a8bb04fe361b1e8659ae074ff9122f4e9e28914087a677b8.yml
openapi_spec_hash: 6ba4858b44cb317676c58f33bfa1426a
config_hash: 542144891263a3626eabcb2fd4f4f3e5
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Or to pin the version:
<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/kernel/hypeman-go@v0.9.0'
go get -u 'github.com/kernel/hypeman-go@v0.8.0'
```

<!-- x-release-please-end -->
Expand Down
51 changes: 26 additions & 25 deletions api.md

Large diffs are not rendered by default.

36 changes: 23 additions & 13 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ type Build struct {
//
// Any of "queued", "building", "pushing", "ready", "failed", "cancelled".
Status BuildStatus `json:"status,required"`
// Instance ID of the builder VM (for debugging)
BuilderInstanceID string `json:"builder_instance_id,nullable"`
// Build completion timestamp
CompletedAt time.Time `json:"completed_at,nullable" format:"date-time"`
// Build duration in milliseconds
Expand All @@ -134,19 +136,20 @@ type Build struct {
StartedAt time.Time `json:"started_at,nullable" format:"date-time"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
CreatedAt respjson.Field
Status respjson.Field
CompletedAt respjson.Field
DurationMs respjson.Field
Error respjson.Field
ImageDigest respjson.Field
ImageRef respjson.Field
Provenance respjson.Field
QueuePosition respjson.Field
StartedAt respjson.Field
ExtraFields map[string]respjson.Field
raw string
ID respjson.Field
CreatedAt respjson.Field
Status respjson.Field
BuilderInstanceID respjson.Field
CompletedAt respjson.Field
DurationMs respjson.Field
Error respjson.Field
ImageDigest respjson.Field
ImageRef respjson.Field
Provenance respjson.Field
QueuePosition respjson.Field
StartedAt respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}

Expand Down Expand Up @@ -245,6 +248,13 @@ type BuildNewParams struct {
CacheScope param.Opt[string] `json:"cache_scope,omitzero"`
// Dockerfile content. Required if not included in the source tarball.
Dockerfile param.Opt[string] `json:"dockerfile,omitzero"`
// Global cache identifier (e.g., "node", "python", "ubuntu", "browser"). When
// specified, the build will import from cache/global/{key}. Admin builds will also
// export to this location.
GlobalCacheKey param.Opt[string] `json:"global_cache_key,omitzero"`
// Set to "true" to grant push access to global cache (operator-only). Admin builds
// can populate the shared global cache that all tenant builds read from.
IsAdminBuild param.Opt[string] `json:"is_admin_build,omitzero"`
// JSON array of secret references to inject during build. Each object has "id"
// (required) for use with --mount=type=secret,id=... Example: [{"id":
// "npm_token"}, {"id": "github_token"}]
Expand Down
2 changes: 2 additions & 0 deletions build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ func TestBuildNewWithOptionalParams(t *testing.T) {
BaseImageDigest: hypeman.String("base_image_digest"),
CacheScope: hypeman.String("cache_scope"),
Dockerfile: hypeman.String("dockerfile"),
GlobalCacheKey: hypeman.String("global_cache_key"),
IsAdminBuild: hypeman.String("is_admin_build"),
Secrets: hypeman.String("secrets"),
TimeoutSeconds: hypeman.Int(0),
})
Expand Down
18 changes: 18 additions & 0 deletions packages/param/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ func Override[T ParamStruct, PtrT InferPtr[T]](v any) T {
return *pt
}

// SetJSON configures a param struct to serialize with the provided raw JSON data.
// Use this when you have existing JSON that you want to send as request parameters.
//
// var req example.NewUserParams
// var rawJSON = []byte(`{"name": "...", "age": 40}`)
// param.SetJSON(rawJSON, &req)
// res, err := client.Users.New(ctx, req)
//
// Note: The struct's existing fields will be ignored; only the provided JSON is serialized.
func SetJSON(rawJSON []byte, ptr anyParamStruct) {
ptr.setMetadata(json.RawMessage(rawJSON))
}

// IsOmitted returns true if v is the zero value of its type.
//
// If IsOmitted is true, and the field uses a `json:"...,omitzero"` tag,
Expand Down Expand Up @@ -91,6 +104,11 @@ type ParamStruct interface {
extraFields() map[string]any
}

// A pointer to ParamStruct
type anyParamStruct interface {
setMetadata(any)
}

// This is an implementation detail and should never be explicitly set.
type InferPtr[T ParamStruct] interface {
setMetadata(any)
Expand Down