Skip to content

Commit 1a1d84b

Browse files
release: 0.7.0 (#17)
* chore(internal): codegen related update * release: 0.7.0 --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
1 parent f67ad7b commit 1a1d84b

File tree

9 files changed

+561
-10
lines changed

9 files changed

+561
-10
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.6.1"
2+
".": "0.7.0"
33
}

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Changelog
22

3+
## 0.7.0 (2025-12-23)
4+
5+
Full Changelog: [v0.6.1...v0.7.0](https://github.com/onkernel/hypeman-cli/compare/v0.6.1...v0.7.0)
6+
7+
### Features
8+
9+
* add cp command for file copy to/from instances ([#18](https://github.com/onkernel/hypeman-cli/issues/18)) ([f67ad7b](https://github.com/onkernel/hypeman-cli/commit/f67ad7bcb6fbbe0a9409574fababab862da87840))
10+
11+
12+
### Chores
13+
14+
* **internal:** codegen related update ([a6c6588](https://github.com/onkernel/hypeman-cli/commit/a6c6588d42a6981b65f5144d033f040afc29a959))
15+
316
## 0.6.1 (2025-12-11)
417

518
Full Changelog: [v0.6.0...v0.6.1](https://github.com/onkernel/hypeman-cli/compare/v0.6.0...v0.6.1)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ require (
1515
github.com/onkernel/hypeman-go v0.8.0
1616
github.com/tidwall/gjson v1.18.0
1717
github.com/tidwall/pretty v1.2.1
18+
github.com/tidwall/sjson v1.2.5
1819
github.com/urfave/cli-docs/v3 v3.0.0-alpha6
1920
github.com/urfave/cli/v3 v3.3.2
2021
golang.org/x/sys v0.38.0
@@ -60,7 +61,6 @@ require (
6061
github.com/russross/blackfriday/v2 v2.1.0 // indirect
6162
github.com/sirupsen/logrus v1.9.3 // indirect
6263
github.com/tidwall/match v1.1.1 // indirect
63-
github.com/tidwall/sjson v1.2.5 // indirect
6464
github.com/vbatts/tar-split v0.12.2 // indirect
6565
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
6666
go.opentelemetry.io/auto/sdk v1.1.0 // indirect

pkg/cmd/cmd.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ func init() {
7474
&runCmd,
7575
&psCmd,
7676
&logsCmd,
77-
&rmCmd,
78-
&stopCmd,
79-
&startCmd,
80-
&standbyCmd,
81-
&restoreCmd,
82-
&ingressCmd,
83-
{
77+
&rmCmd,
78+
&stopCmd,
79+
&startCmd,
80+
&standbyCmd,
81+
&restoreCmd,
82+
&ingressCmd,
83+
{
8484
Name: "health",
8585
Category: "API RESOURCE",
8686
Commands: []*cli.Command{

pkg/cmd/util.go

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cmd
4+
5+
import (
6+
"bytes"
7+
"encoding/base64"
8+
"encoding/json"
9+
"fmt"
10+
"io"
11+
"log"
12+
"net/http"
13+
"net/http/httputil"
14+
"os"
15+
"reflect"
16+
"strings"
17+
18+
"github.com/onkernel/hypeman-go/option"
19+
20+
"github.com/tidwall/sjson"
21+
"github.com/urfave/cli/v3"
22+
)
23+
24+
25+
type fileReader struct {
26+
Value io.Reader
27+
Base64Encoded bool
28+
}
29+
30+
func (f *fileReader) Set(filename string) error {
31+
reader, err := os.Open(filename)
32+
if err != nil {
33+
return fmt.Errorf("failed to read file %q: %w", filename, err)
34+
}
35+
f.Value = reader
36+
return nil
37+
}
38+
39+
func (f *fileReader) String() string {
40+
if f.Value == nil {
41+
return ""
42+
}
43+
buf := new(bytes.Buffer)
44+
buf.ReadFrom(f.Value)
45+
if f.Base64Encoded {
46+
return base64.StdEncoding.EncodeToString(buf.Bytes())
47+
}
48+
return buf.String()
49+
}
50+
51+
func (f *fileReader) Get() any {
52+
return f.String()
53+
}
54+
55+
func unmarshalWithReaders(data []byte, v any) error {
56+
var fields map[string]json.RawMessage
57+
if err := json.Unmarshal(data, &fields); err != nil {
58+
return err
59+
}
60+
61+
rv := reflect.ValueOf(v).Elem()
62+
rt := rv.Type()
63+
64+
for i := 0; i < rv.NumField(); i++ {
65+
fv := rv.Field(i)
66+
ft := rt.Field(i)
67+
68+
jsonKey := ft.Tag.Get("json")
69+
if jsonKey == "" {
70+
jsonKey = ft.Name
71+
} else if idx := strings.Index(jsonKey, ","); idx != -1 {
72+
jsonKey = jsonKey[:idx]
73+
}
74+
75+
rawVal, ok := fields[jsonKey]
76+
if !ok {
77+
continue
78+
}
79+
80+
if ft.Type == reflect.TypeOf((*io.Reader)(nil)).Elem() {
81+
var s string
82+
if err := json.Unmarshal(rawVal, &s); err != nil {
83+
return fmt.Errorf("field %s: %w", ft.Name, err)
84+
}
85+
fv.Set(reflect.ValueOf(strings.NewReader(s)))
86+
} else {
87+
ptr := fv.Addr().Interface()
88+
if err := json.Unmarshal(rawVal, ptr); err != nil {
89+
return fmt.Errorf("field %s: %w", ft.Name, err)
90+
}
91+
}
92+
}
93+
94+
return nil
95+
}
96+
97+
func unmarshalStdinWithFlags(cmd *cli.Command, flags map[string]string, target any) error {
98+
var data []byte
99+
if isInputPiped() {
100+
var err error
101+
if data, err = io.ReadAll(os.Stdin); err != nil {
102+
return err
103+
}
104+
}
105+
106+
// Merge CLI flags into the body
107+
for flag, path := range flags {
108+
if cmd.IsSet(flag) {
109+
var err error
110+
data, err = sjson.SetBytes(data, path, cmd.Value(flag))
111+
if err != nil {
112+
return err
113+
}
114+
}
115+
}
116+
117+
if data != nil {
118+
if err := unmarshalWithReaders(data, target); err != nil {
119+
return fmt.Errorf("failed to unmarshal JSON: %w", err)
120+
}
121+
}
122+
123+
return nil
124+
}
125+
126+
func debugMiddleware(debug bool) option.Middleware {
127+
return func(r *http.Request, mn option.MiddlewareNext) (*http.Response, error) {
128+
if debug {
129+
logger := log.Default()
130+
131+
if reqBytes, err := httputil.DumpRequest(r, true); err == nil {
132+
logger.Printf("Request Content:\n%s\n", reqBytes)
133+
}
134+
135+
resp, err := mn(r)
136+
if err != nil {
137+
return resp, err
138+
}
139+
140+
if respBytes, err := httputil.DumpResponse(resp, true); err == nil {
141+
logger.Printf("Response Content:\n%s\n", respBytes)
142+
}
143+
144+
return resp, err
145+
}
146+
147+
return mn(r)
148+
}
149+
}

pkg/cmd/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
package cmd
44

5-
const Version = "0.6.1" // x-release-please-version
5+
const Version = "0.7.0" // x-release-please-version

0 commit comments

Comments
 (0)