Skip to content

Commit

Permalink
feat(cloud): Introduce 'vcpus' flag for instance creation
Browse files Browse the repository at this point in the history
Signed-off-by: Cezar Craciunoiu <[email protected]>
  • Loading branch information
craciunoiuc committed Aug 21, 2024
1 parent 457c64b commit d256695
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/cli/kraft/cloud/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ type DeployOptions struct {
SubDomain []string `local:"true" long:"subdomain" short:"s" usage:"Set the names to use when provisioning subdomains"`
Timeout time.Duration `local:"true" long:"timeout" usage:"Set the timeout for remote procedure calls (ms/s/m/h)" default:"60s"`
Token string `noattribute:"true"`
Vcpus uint `local:"true" long:"vcpus" short:"V" usage:"Specify the number of vCPUs to allocate"`
Volumes []string `long:"volume" short:"v" usage:"Specify the volume mapping(s) in the form NAME:DEST or NAME:DEST:OPTIONS"`
Workdir string `local:"true" long:"workdir" short:"w" usage:"Set an alternative working directory (default is cwd)"`
}
Expand Down
1 change: 1 addition & 0 deletions internal/cli/kraft/cloud/deploy/deployer_image_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func (deployer *deployerImageName) Deploy(ctx context.Context, opts *DeployOptio
Start: !opts.NoStart,
SubDomain: opts.SubDomain,
Token: opts.Token,
Vcpus: opts.Vcpus,
}, deployer.args...)
if err != nil {
return fmt.Errorf("could not create instance: %w", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ func (deployer *deployerKraftfileRuntime) Deploy(ctx context.Context, opts *Depl
Start: !opts.NoStart,
SubDomain: opts.SubDomain,
Token: opts.Token,
Vcpus: opts.Vcpus,
Volumes: opts.Volumes,
WaitForImage: true,
WaitForImageTimeout: opts.Timeout,
Expand Down
4 changes: 4 additions & 0 deletions internal/cli/kraft/cloud/instance/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type CreateOptions struct {
ScaleToZeroCooldown time.Duration `local:"true" long:"scale-to-zero-cooldown" usage:"Cooldown period before scaling to zero (ms/s/m/h)"`
SubDomain []string `local:"true" long:"subdomain" short:"s" usage:"Set the subdomains to use when creating the service"`
Token string `noattribute:"true"`
Vcpus uint `local:"true" long:"vcpus" short:"V" usage:"Specify the number of vCPUs to allocate"`
Volumes []string `local:"true" long:"volume" short:"v" usage:"List of volumes to attach instance to"`
WaitForImage bool `local:"true" long:"wait-for-image" short:"w" usage:"Wait for the image to be available before creating the instance"`
WaitForImageTimeout time.Duration `local:"true" long:"wait-for-image-timeout" usage:"Time to wait before timing out when waiting for image (ms/s/m/h)" default:"60s"`
Expand Down Expand Up @@ -199,6 +200,9 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcclient
Image: opts.Image,
RestartPolicy: opts.RestartPolicy,
}
if opts.Vcpus > 0 {
req.Vcpus = ptr(int(opts.Vcpus))
}
if opts.Name != "" {
req.Name = &opts.Name
}
Expand Down

0 comments on commit d256695

Please sign in to comment.