Skip to content

Commit 8b5543e

Browse files
feat: Add strict metadata tags across mutable resources
1 parent c4a0fbb commit 8b5543e

18 files changed

Lines changed: 203 additions & 38 deletions

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 45
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fhypeman-ef3a9825726e97be4c61ca3886bc1ddc04088aa179c1fbf25c73a515df604aa5.yml
3-
openapi_spec_hash: 349c7b6c17298c8dbdfd0750badf5608
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fhypeman-48572ed071402410249daca70dfcdd151ce9e0bf3674ccce98107ac4e0f9a800.yml
3+
openapi_spec_hash: 15415b3d8b119a94b7d7a71673af0237
44
config_hash: 1fbc2955725b2b29a941f009ff2a2ce9

api.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Response Types:
1717
Methods:
1818

1919
- <code title="post /images">client.Images.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#ImageService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#ImageNewParams">ImageNewParams</a>) (\*<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#Image">Image</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
20-
- <code title="get /images">client.Images.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#ImageService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) (\*[]<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#Image">Image</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
20+
- <code title="get /images">client.Images.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#ImageService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#ImageListParams">ImageListParams</a>) (\*[]<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#Image">Image</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
2121
- <code title="delete /images/{name}">client.Images.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#ImageService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, name <a href="https://pkg.go.dev/builtin#string">string</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>
2222
- <code title="get /images/{name}">client.Images.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#ImageService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, name <a href="https://pkg.go.dev/builtin#string">string</a>) (\*<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#Image">Image</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
2323

@@ -91,7 +91,7 @@ Response Types:
9191
Methods:
9292

9393
- <code title="post /volumes">client.Volumes.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#VolumeService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#VolumeNewParams">VolumeNewParams</a>) (\*<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#Volume">Volume</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
94-
- <code title="get /volumes">client.Volumes.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#VolumeService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) (\*[]<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#Volume">Volume</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
94+
- <code title="get /volumes">client.Volumes.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#VolumeService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#VolumeListParams">VolumeListParams</a>) (\*[]<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#Volume">Volume</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
9595
- <code title="delete /volumes/{id}">client.Volumes.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#VolumeService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>
9696
- <code title="post /volumes/from-archive">client.Volumes.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#VolumeService.NewFromArchive">NewFromArchive</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/builtin#io.Reader">io.Reader</a>, params <a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#VolumeNewFromArchiveParams">VolumeNewFromArchiveParams</a>) (\*<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#Volume">Volume</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
9797
- <code title="get /volumes/{id}">client.Volumes.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#VolumeService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) (\*<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#Volume">Volume</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
@@ -108,7 +108,7 @@ Methods:
108108

109109
- <code title="post /devices">client.Devices.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#DeviceService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#DeviceNewParams">DeviceNewParams</a>) (\*<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#Device">Device</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
110110
- <code title="get /devices/{id}">client.Devices.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#DeviceService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) (\*<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#Device">Device</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
111-
- <code title="get /devices">client.Devices.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#DeviceService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) (\*[]<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#Device">Device</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
111+
- <code title="get /devices">client.Devices.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#DeviceService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#DeviceListParams">DeviceListParams</a>) (\*[]<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#Device">Device</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
112112
- <code title="delete /devices/{id}">client.Devices.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#DeviceService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>
113113
- <code title="get /devices/available">client.Devices.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#DeviceService.ListAvailable">ListAvailable</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) (\*[]<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#AvailableDevice">AvailableDevice</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
114114

@@ -130,7 +130,7 @@ Response Types:
130130
Methods:
131131

132132
- <code title="post /ingresses">client.Ingresses.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#IngressService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#IngressNewParams">IngressNewParams</a>) (\*<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#Ingress">Ingress</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
133-
- <code title="get /ingresses">client.Ingresses.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#IngressService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) (\*[]<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#Ingress">Ingress</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
133+
- <code title="get /ingresses">client.Ingresses.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#IngressService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#IngressListParams">IngressListParams</a>) (\*[]<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#Ingress">Ingress</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
134134
- <code title="delete /ingresses/{id}">client.Ingresses.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#IngressService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>
135135
- <code title="get /ingresses/{id}">client.Ingresses.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#IngressService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) (\*<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#Ingress">Ingress</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
136136

@@ -162,7 +162,7 @@ Response Types:
162162
Methods:
163163

164164
- <code title="post /builds">client.Builds.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#BuildService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#BuildNewParams">BuildNewParams</a>) (\*<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#Build">Build</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
165-
- <code title="get /builds">client.Builds.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#BuildService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) (\*[]<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#Build">Build</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
165+
- <code title="get /builds">client.Builds.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#BuildService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#BuildListParams">BuildListParams</a>) (\*[]<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#Build">Build</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
166166
- <code title="delete /builds/{id}">client.Builds.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#BuildService.Cancel">Cancel</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>
167167
- <code title="get /builds/{id}/events">client.Builds.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#BuildService.Events">Events</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#BuildEventsParams">BuildEventsParams</a>) (\*<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#BuildEvent">BuildEvent</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
168168
- <code title="get /builds/{id}">client.Builds.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#BuildService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) (\*<a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#Build">Build</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

build.go

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ func (r *BuildService) New(ctx context.Context, body BuildNewParams, opts ...opt
5353
}
5454

5555
// List builds
56-
func (r *BuildService) List(ctx context.Context, opts ...option.RequestOption) (res *[]Build, err error) {
56+
func (r *BuildService) List(ctx context.Context, query BuildListParams, opts ...option.RequestOption) (res *[]Build, err error) {
5757
opts = slices.Concat(r.Options, opts)
5858
path := "builds"
59-
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
59+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
6060
return
6161
}
6262

@@ -128,8 +128,10 @@ type Build struct {
128128
// Digest of built image (only when status is ready)
129129
ImageDigest string `json:"image_digest" api:"nullable"`
130130
// Full image reference (only when status is ready)
131-
ImageRef string `json:"image_ref" api:"nullable"`
132-
Provenance BuildProvenance `json:"provenance"`
131+
ImageRef string `json:"image_ref" api:"nullable"`
132+
// User-defined key-value metadata tags.
133+
Metadata map[string]string `json:"metadata"`
134+
Provenance BuildProvenance `json:"provenance"`
133135
// Position in build queue (only when status is queued)
134136
QueuePosition int64 `json:"queue_position" api:"nullable"`
135137
// Build start timestamp
@@ -145,6 +147,7 @@ type Build struct {
145147
Error respjson.Field
146148
ImageDigest respjson.Field
147149
ImageRef respjson.Field
150+
Metadata respjson.Field
148151
Provenance respjson.Field
149152
QueuePosition respjson.Field
150153
StartedAt respjson.Field
@@ -262,6 +265,8 @@ type BuildNewParams struct {
262265
IsAdminBuild param.Opt[string] `json:"is_admin_build,omitzero"`
263266
// Memory limit for builder VM in MB (default 2048)
264267
MemoryMB param.Opt[int64] `json:"memory_mb,omitzero"`
268+
// JSON object of metadata tags. Example: {"team":"backend","env":"staging"}
269+
Metadata param.Opt[string] `json:"metadata,omitzero"`
265270
// JSON array of secret references to inject during build. Each object has "id"
266271
// (required) for use with --mount=type=secret,id=... Example: [{"id":
267272
// "npm_token"}, {"id": "github_token"}]
@@ -289,6 +294,20 @@ func (r BuildNewParams) MarshalMultipart() (data []byte, contentType string, err
289294
return buf.Bytes(), writer.FormDataContentType(), nil
290295
}
291296

297+
type BuildListParams struct {
298+
// Filter builds by metadata key-value pairs.
299+
Metadata map[string]string `query:"metadata,omitzero" json:"-"`
300+
paramObj
301+
}
302+
303+
// URLQuery serializes [BuildListParams]'s query parameters as `url.Values`.
304+
func (r BuildListParams) URLQuery() (v url.Values, err error) {
305+
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
306+
ArrayFormat: apiquery.ArrayQueryFormatComma,
307+
NestedFormat: apiquery.NestedQueryFormatBrackets,
308+
})
309+
}
310+
292311
type BuildEventsParams struct {
293312
// Continue streaming new events after initial output
294313
Follow param.Opt[bool] `query:"follow,omitzero" json:"-"`

build_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func TestBuildNewWithOptionalParams(t *testing.T) {
3838
ImageName: hypeman.String("image_name"),
3939
IsAdminBuild: hypeman.String("is_admin_build"),
4040
MemoryMB: hypeman.Int(0),
41+
Metadata: hypeman.String("metadata"),
4142
Secrets: hypeman.String("secrets"),
4243
TimeoutSeconds: hypeman.Int(0),
4344
})
@@ -50,7 +51,7 @@ func TestBuildNewWithOptionalParams(t *testing.T) {
5051
}
5152
}
5253

53-
func TestBuildList(t *testing.T) {
54+
func TestBuildListWithOptionalParams(t *testing.T) {
5455
t.Skip("Mock server tests are disabled")
5556
baseURL := "http://localhost:4010"
5657
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
@@ -63,7 +64,12 @@ func TestBuildList(t *testing.T) {
6364
option.WithBaseURL(baseURL),
6465
option.WithAPIKey("My API Key"),
6566
)
66-
_, err := client.Builds.List(context.TODO())
67+
_, err := client.Builds.List(context.TODO(), hypeman.BuildListParams{
68+
Metadata: map[string]string{
69+
"team": "backend",
70+
"env": "staging",
71+
},
72+
})
6773
if err != nil {
6874
var apierr *hypeman.Error
6975
if errors.As(err, &apierr) {

0 commit comments

Comments
 (0)