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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.27.0"
".": "0.28.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 62
configured_endpoints: 63
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [0.28.0](https://github.com/kernel/hypeman-go/compare/v0.27.0...v0.28.0) (2026-09-01)


### Features

* Add local image tagging on shared content storage ([bfd38ed](https://github.com/kernel/hypeman-go/commit/bfd38eda3b8207bde8198dcb3b1f208d4e965c86))

## [0.27.0](https://github.com/kernel/hypeman-go/compare/v0.26.1...v0.27.0) (2026-08-31)


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Or to pin the version:
<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/kernel/hypeman-go@v0.27.0'
go get -u 'github.com/kernel/hypeman-go@v0.28.0'
```

<!-- x-release-please-end -->
Expand Down
5 changes: 5 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ Methods:

# Images

Params Types:

- <a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#TagImageRequestParam">TagImageRequestParam</a>

Response Types:

- <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>
Expand All @@ -44,6 +48,7 @@ Methods:
- <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>
- <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>
- <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>
- <code title="post /images/{name}/tag">client.Images.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#ImageService.Tag">Tag</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>, 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#ImageTagParams">ImageTagParams</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>

# Instances

Expand Down
41 changes: 41 additions & 0 deletions image.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"github.com/kernel/hypeman-go/internal/apijson"
"github.com/kernel/hypeman-go/internal/apiquery"
shimjson "github.com/kernel/hypeman-go/internal/encoding/json"
"github.com/kernel/hypeman-go/internal/requestconfig"
"github.com/kernel/hypeman-go/option"
"github.com/kernel/hypeman-go/packages/param"
Expand Down Expand Up @@ -79,6 +80,18 @@ func (r *ImageService) Get(ctx context.Context, name string, opts ...option.Requ
return res, err
}

// Create or update a local image tag
func (r *ImageService) Tag(ctx context.Context, name string, body ImageTagParams, opts ...option.RequestOption) (res *Image, err error) {
opts = slices.Concat(r.Options, opts)
if name == "" {
err = errors.New("missing required name parameter")
return nil, err
}
path := fmt.Sprintf("images/%s/tag", name)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tag path skips image name escaping

High Severity

ImageService.Tag interpolates name into the path without url.PathEscape. Image names are OCI references with slashes, so the request hits the wrong route instead of a single {name} segment. Get and Delete already escape this parameter, and image_path_test.go documents that contract.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d4ef57e. Configure here.

err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}

type Image struct {
// Creation timestamp (RFC3339)
CreatedAt time.Time `json:"created_at" api:"required" format:"date-time"`
Expand Down Expand Up @@ -145,6 +158,22 @@ const (
ImageStatusFailed ImageStatus = "failed"
)

// The property Target is required.
type TagImageRequestParam struct {
// Target OCI image reference with a tag. The local tag points to the source image
// without pulling it again.
Target string `json:"target" api:"required"`
paramObj
}

func (r TagImageRequestParam) MarshalJSON() (data []byte, err error) {
type shadow TagImageRequestParam
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *TagImageRequestParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

type ImageNewParams struct {
// OCI image reference (e.g., docker.io/library/nginx:latest)
Name string `json:"name" api:"required"`
Expand Down Expand Up @@ -184,3 +213,15 @@ func (r ImageListParams) URLQuery() (v url.Values, err error) {
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}

type ImageTagParams struct {
TagImageRequest TagImageRequestParam
paramObj
}

func (r ImageTagParams) MarshalJSON() (data []byte, err error) {
return shimjson.Marshal(r.TagImageRequest)
}
func (r *ImageTagParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
31 changes: 31 additions & 0 deletions image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,34 @@ func TestImageGet(t *testing.T) {
t.Fatalf("err should be nil: %s", err.Error())
}
}

func TestImageTag(t *testing.T) {
t.Skip("Mock server tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
client := hypeman.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
_, err := client.Images.Tag(
context.TODO(),
"name",
hypeman.ImageTagParams{
TagImageRequest: hypeman.TagImageRequestParam{
Target: "docker.io/library/nginx:stable",
},
},
)
if err != nil {
var apierr *hypeman.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}
2 changes: 1 addition & 1 deletion internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

package internal

const PackageVersion = "0.27.0" // x-release-please-version
const PackageVersion = "0.28.0" // x-release-please-version
Loading