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 go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/google/go-containerregistry v0.20.7
github.com/gorilla/websocket v1.5.3
github.com/itchyny/json2yaml v0.1.4
github.com/kernel/hypeman-go v0.14.0
github.com/kernel/hypeman-go v0.15.0
github.com/knadh/koanf/parsers/yaml v1.1.0
github.com/knadh/koanf/providers/env v1.1.0
github.com/knadh/koanf/providers/file v1.2.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 h1:8Tjv8EJ+pM1xP8mK6egEbD1OgnV
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2/go.mod h1:pkJQ2tZHJ0aFOVEEot6oZmaVEZcRme73eIFmhiVuRWs=
github.com/itchyny/json2yaml v0.1.4 h1:/pErVOXGG5iTyXHi/QKR4y3uzhLjGTEmmJIy97YT+k8=
github.com/itchyny/json2yaml v0.1.4/go.mod h1:6iudhBZdarpjLFRNj+clWLAkGft+9uCcjAZYXUH9eGI=
github.com/kernel/hypeman-go v0.14.0 h1:FeeVJly5TzkAYZdxuSfn/8Sz5qZZtUlPQQvUQOAOhg4=
github.com/kernel/hypeman-go v0.14.0/go.mod h1:guRrhyP9QW/ebUS1UcZ0uZLLJeGAAhDNzSi68U4M9hI=
github.com/kernel/hypeman-go v0.15.0 h1:igcd8tArES1FMbuzEGjQ9HqPF3Zwi6yAvHoE4dkKx4Y=
github.com/kernel/hypeman-go v0.15.0/go.mod h1:guRrhyP9QW/ebUS1UcZ0uZLLJeGAAhDNzSi68U4M9hI=
github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0=
github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo=
Expand Down
18 changes: 5 additions & 13 deletions pkg/cmd/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,14 @@ func handleFork(ctx context.Context, cmd *cli.Command) error {
opts = append(opts, debugMiddlewareOption)
}

params := instanceForkParams{
params := hypeman.InstanceForkParams{
Name: targetName,
}
if cmd.IsSet("from-running") {
fromRunning := cmd.Bool("from-running")
params.FromRunning = &fromRunning
params.FromRunning = hypeman.Opt(cmd.Bool("from-running"))
}
if targetState != "" {
params.TargetState = &targetState
params.TargetState = hypeman.InstanceForkParamsTargetState(targetState)
}

fmt.Fprintf(os.Stderr, "Forking %s to %s...\n", source, targetName)
Expand All @@ -77,8 +76,8 @@ func handleFork(ctx context.Context, cmd *cli.Command) error {
opts = append(opts, option.WithResponseBodyInto(&raw))
}

var forked hypeman.Instance
if err := client.Post(ctx, fmt.Sprintf("instances/%s/fork", sourceID), params, &forked, opts...); err != nil {
forked, err := client.Instances.Fork(ctx, sourceID, params, opts...)
if err != nil {
return err
}

Expand All @@ -87,7 +86,6 @@ func handleFork(ctx context.Context, cmd *cli.Command) error {
return ShowJSON(os.Stdout, "instance fork", obj, format, transform)
}

// Output instance ID (useful for scripting)
fmt.Println(forked.ID)
fmt.Fprintf(os.Stderr, "Forked %s as %s (state: %s)\n", source, forked.Name, forked.State)
return nil
Expand All @@ -107,9 +105,3 @@ func normalizeForkTargetState(state string) (string, error) {
return "", fmt.Errorf("invalid target state: %s (must be Stopped, Standby, or Running)", state)
}
}

type instanceForkParams struct {
Name string `json:"name"`
FromRunning *bool `json:"from_running,omitempty"`
TargetState *string `json:"target_state,omitempty"`
}