diff --git a/config/kraftcloud.go b/config/kraftcloud.go index 072e0949c..5da3738cf 100644 --- a/config/kraftcloud.go +++ b/config/kraftcloud.go @@ -13,9 +13,9 @@ import ( "strings" ) -// GetKraftCloudLogin is a utility method which retrieves credentials of a -// KraftCloud user from the given context returning it in AuthConfig format. -func GetKraftCloudAuthConfig(ctx context.Context, flagToken string) (*AuthConfig, error) { +// GetUnikraftCloudLogin is a utility method which retrieves credentials of a +// UnikraftCloud user from the given context returning it in AuthConfig format. +func GetUnikraftCloudAuthConfig(ctx context.Context, flagToken string) (*AuthConfig, error) { auth := AuthConfig{ Endpoint: "index.unikraft.io", VerifySSL: true, @@ -70,16 +70,16 @@ func GetKraftCloudAuthConfig(ctx context.Context, flagToken string) (*AuthConfig return &auth, nil } -// GetKraftCloudTokenAuthConfig is a utility method which returns the -// token of the KraftCloud user based on an AuthConfig. -func GetKraftCloudTokenAuthConfig(auth AuthConfig) string { +// GetUnikraftCloudTokenAuthConfig is a utility method which returns the +// token of the UnikraftCloud user based on an AuthConfig. +func GetUnikraftCloudTokenAuthConfig(auth AuthConfig) string { return base64.StdEncoding.EncodeToString([]byte(auth.User + ":" + auth.Token)) } -// HydrateKraftCloudAuthInContext saturates the context with an additional -// KraftCloud-specific information. -func HydrateKraftCloudAuthInContext(ctx context.Context) (context.Context, error) { - auth, err := GetKraftCloudAuthConfig(ctx, "") +// HydrateUnikraftCloudAuthInContext saturates the context with an additional +// cloud-specific information. +func HydrateUnikraftCloudAuthInContext(ctx context.Context) (context.Context, error) { + auth, err := GetUnikraftCloudAuthConfig(ctx, "") if err != nil { return nil, err } diff --git a/internal/cli/kraft/build/builder_kraftfile_runtime.go b/internal/cli/kraft/build/builder_kraftfile_runtime.go index ced8e0e59..276e6ede6 100644 --- a/internal/cli/kraft/build/builder_kraftfile_runtime.go +++ b/internal/cli/kraft/build/builder_kraftfile_runtime.go @@ -57,8 +57,8 @@ func (*builderKraftfileRuntime) Prepare(ctx context.Context, opts *BuildOptions, ) name := opts.Project.Runtime().Name() - if opts.Platform == "kraftcloud" || (opts.Project.Runtime().Platform() != nil && opts.Project.Runtime().Platform().Name() == "kraftcloud") { - name = utils.RewrapAsKraftCloudPackage(name) + if opts.Platform == "cloud" || opts.Platform == "kraftcloud" || (opts.Project.Runtime().Platform() != nil && (opts.Project.Runtime().Platform().Name() == "cloud" || opts.Project.Runtime().Platform().Name() == "kraftcloud")) { + name = utils.RewrapAsUnikraftCloudPackage(name) } qopts := []packmanager.QueryOption{ diff --git a/internal/cli/kraft/cloud/certificate/certificate.go b/internal/cli/kraft/cloud/certificate/certificate.go index 0af8ada54..418c29348 100644 --- a/internal/cli/kraft/cloud/certificate/certificate.go +++ b/internal/cli/kraft/cloud/certificate/certificate.go @@ -27,7 +27,7 @@ func NewCmd() *cobra.Command { Use: "cert SUBCOMMAND", Aliases: []string{"certificate", "certificates", "certs", "crt", "crts"}, Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-certificate", + cmdfactory.AnnotationHelpGroup: "cloud-certificate", cmdfactory.AnnotationHelpHidden: "true", }, }) diff --git a/internal/cli/kraft/cloud/certificate/create/create.go b/internal/cli/kraft/cloud/certificate/create/create.go index 22227fd7b..a91ddc3eb 100644 --- a/internal/cli/kraft/cloud/certificate/create/create.go +++ b/internal/cli/kraft/cloud/certificate/create/create.go @@ -13,8 +13,8 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" - kccertificates "sdk.kraft.cloud/certificates" + cloud "sdk.kraft.cloud" + ukccertificates "sdk.kraft.cloud/certificates" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -24,18 +24,18 @@ import ( ) type CreateOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kccertificates.CertificatesService `noattribute:"true"` - Metro string `noattribute:"true"` - Chain string `local:"true" long:"chain" short:"C" usage:"The chain of the certificate"` - CN string `local:"true" long:"cn" short:"c" usage:"The common name of the certificate"` - Name string `local:"true" size:"name" short:"n" usage:"The name of the certificate"` - PKey string `local:"true" long:"pkey" short:"p" usage:"The private key of the certificate in PEM format"` - Token string `noattribute:"true"` + Auth *config.AuthConfig `noattribute:"true"` + Client ukccertificates.CertificatesService `noattribute:"true"` + Metro string `noattribute:"true"` + Chain string `local:"true" long:"chain" short:"C" usage:"The chain of the certificate"` + CN string `local:"true" long:"cn" short:"c" usage:"The common name of the certificate"` + Name string `local:"true" size:"name" short:"n" usage:"The name of the certificate"` + PKey string `local:"true" long:"pkey" short:"p" usage:"The private key of the certificate in PEM format"` + Token string `noattribute:"true"` } -// Create a KraftCloud certificate. -func Create(ctx context.Context, opts *CreateOptions) (*kccertificates.CreateResponseItem, error) { +// Create a UnikraftCloud certificate. +func Create(ctx context.Context, opts *CreateOptions) (*ukccertificates.CreateResponseItem, error) { var err error if opts == nil { @@ -43,15 +43,15 @@ func Create(ctx context.Context, opts *CreateOptions) (*kccertificates.CreateRes } if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return nil, fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewCertificatesClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewCertificatesClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } @@ -85,7 +85,7 @@ func Create(ctx context.Context, opts *CreateOptions) (*kccertificates.CreateRes opts.Chain = string(b) } - createResp, err := opts.Client.WithMetro(opts.Metro).Create(ctx, &kccertificates.CreateRequest{ + createResp, err := opts.Client.WithMetro(opts.Metro).Create(ctx, &ukccertificates.CreateRequest{ Chain: opts.Chain, CN: opts.CN, Name: opts.Name, @@ -116,7 +116,7 @@ func NewCmd() *cobra.Command { $ kraft cloud certificate create --name my-cert --cn '*.example.com' --pkey 'private-key.pem' --chain 'chain.pem' `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-certificate", + cmdfactory.AnnotationHelpGroup: "cloud-certificate", }, }) if err != nil { diff --git a/internal/cli/kraft/cloud/certificate/get/get.go b/internal/cli/kraft/cloud/certificate/get/get.go index ea102750d..fa7912a8b 100644 --- a/internal/cli/kraft/cloud/certificate/get/get.go +++ b/internal/cli/kraft/cloud/certificate/get/get.go @@ -12,7 +12,7 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" + cloud "sdk.kraft.cloud" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -26,7 +26,7 @@ type GetOptions struct { token string } -// Status of a KraftCloud certificate. +// Status of a UnikraftCloud certificate. func Get(ctx context.Context, opts *GetOptions, args ...string) error { if opts == nil { opts = &GetOptions{} @@ -52,7 +52,7 @@ func NewCmd() *cobra.Command { Retrieve the status of a certificate. `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-certificate", + cmdfactory.AnnotationHelpGroup: "cloud-certificate", }, }) if err != nil { @@ -76,13 +76,13 @@ func (opts *GetOptions) Pre(cmd *cobra.Command, _ []string) error { } func (opts *GetOptions) Run(ctx context.Context, args []string) error { - auth, err := config.GetKraftCloudAuthConfig(ctx, opts.token) + auth, err := config.GetUnikraftCloudAuthConfig(ctx, opts.token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } - client := kraftcloud.NewCertificatesClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*auth)), + client := cloud.NewCertificatesClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*auth)), ) certResp, err := client.WithMetro(opts.metro).Get(ctx, args[0]) diff --git a/internal/cli/kraft/cloud/certificate/list/list.go b/internal/cli/kraft/cloud/certificate/list/list.go index cd0e52345..1bbfdbcf7 100644 --- a/internal/cli/kraft/cloud/certificate/list/list.go +++ b/internal/cli/kraft/cloud/certificate/list/list.go @@ -11,7 +11,7 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" + cloud "sdk.kraft.cloud" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -39,7 +39,7 @@ func NewCmd() *cobra.Command { List all TLS certificates in your account. `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-certificate", + cmdfactory.AnnotationHelpGroup: "cloud-certificate", }, }) if err != nil { @@ -63,13 +63,13 @@ func (opts *ListOptions) Pre(cmd *cobra.Command, _ []string) error { } func (opts *ListOptions) Run(ctx context.Context, args []string) error { - auth, err := config.GetKraftCloudAuthConfig(ctx, opts.token) + auth, err := config.GetUnikraftCloudAuthConfig(ctx, opts.token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } - client := kraftcloud.NewCertificatesClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*auth)), + client := cloud.NewCertificatesClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*auth)), ) resp, err := client.WithMetro(opts.metro).List(ctx) diff --git a/internal/cli/kraft/cloud/certificate/remove/remove.go b/internal/cli/kraft/cloud/certificate/remove/remove.go index b37a40ab4..f161dd86a 100644 --- a/internal/cli/kraft/cloud/certificate/remove/remove.go +++ b/internal/cli/kraft/cloud/certificate/remove/remove.go @@ -12,7 +12,7 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" + cloud "sdk.kraft.cloud" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -28,7 +28,7 @@ type RemoveOptions struct { token string } -// Remove a KraftCloud certificate. +// Remove a UnikraftCloud certificate. func Remove(ctx context.Context, opts *RemoveOptions, args ...string) error { if opts == nil { opts = &RemoveOptions{} @@ -57,7 +57,7 @@ func NewCmd() *cobra.Command { $ kraft cloud certificate remove --all `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-certificate", + cmdfactory.AnnotationHelpGroup: "cloud-certificate", }, }) if err != nil { @@ -85,13 +85,13 @@ func (opts *RemoveOptions) Pre(cmd *cobra.Command, args []string) error { } func (opts *RemoveOptions) Run(ctx context.Context, args []string) error { - auth, err := config.GetKraftCloudAuthConfig(ctx, opts.token) + auth, err := config.GetUnikraftCloudAuthConfig(ctx, opts.token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } - client := kraftcloud.NewCertificatesClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*auth)), + client := cloud.NewCertificatesClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*auth)), ) if opts.All { diff --git a/internal/cli/kraft/cloud/cloud.go b/internal/cli/kraft/cloud/cloud.go index 24c70d49f..159aff56b 100644 --- a/internal/cli/kraft/cloud/cloud.go +++ b/internal/cli/kraft/cloud/cloud.go @@ -77,7 +77,7 @@ func NewCmd() *cobra.Command { $ kraft cloud instance remove UUID `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud", + cmdfactory.AnnotationHelpGroup: "cloud", cmdfactory.AnnotationHelpHidden: "true", }, }) @@ -89,28 +89,28 @@ func NewCmd() *cobra.Command { cmd.AddCommand(quotas.NewCmd()) cmd.AddCommand(tunnel.NewCmd()) - cmd.AddGroup(&cobra.Group{ID: "kraftcloud-img", Title: "IMAGE COMMANDS"}) + cmd.AddGroup(&cobra.Group{ID: "cloud-img", Title: "IMAGE COMMANDS"}) cmd.AddCommand(img.NewCmd()) - cmd.AddGroup(&cobra.Group{ID: "kraftcloud-instance", Title: "INSTANCE COMMANDS"}) + cmd.AddGroup(&cobra.Group{ID: "cloud-instance", Title: "INSTANCE COMMANDS"}) cmd.AddCommand(instance.NewCmd()) - cmd.AddGroup(&cobra.Group{ID: "kraftcloud-vol", Title: "VOLUME COMMANDS"}) + cmd.AddGroup(&cobra.Group{ID: "cloud-vol", Title: "VOLUME COMMANDS"}) cmd.AddCommand(volume.NewCmd()) - cmd.AddGroup(&cobra.Group{ID: "kraftcloud-scale", Title: "SCALE COMMANDS"}) + cmd.AddGroup(&cobra.Group{ID: "cloud-scale", Title: "SCALE COMMANDS"}) cmd.AddCommand(scale.NewCmd()) - cmd.AddGroup(&cobra.Group{ID: "kraftcloud-svc", Title: "SERVICE COMMANDS"}) + cmd.AddGroup(&cobra.Group{ID: "cloud-svc", Title: "SERVICE COMMANDS"}) cmd.AddCommand(service.NewCmd()) - cmd.AddGroup(&cobra.Group{ID: "kraftcloud-certificate", Title: "CERTIFICATE COMMANDS"}) + cmd.AddGroup(&cobra.Group{ID: "cloud-certificate", Title: "CERTIFICATE COMMANDS"}) cmd.AddCommand(certificate.NewCmd()) - cmd.AddGroup(&cobra.Group{ID: "kraftcloud-metro", Title: "METRO COMMANDS"}) + cmd.AddGroup(&cobra.Group{ID: "cloud-metro", Title: "METRO COMMANDS"}) cmd.AddCommand(metros.NewCmd()) - cmd.AddGroup(&cobra.Group{ID: "kraftcloud-compose", Title: "COMPOSE COMMANDS"}) + cmd.AddGroup(&cobra.Group{ID: "cloud-compose", Title: "COMPOSE COMMANDS"}) cmd.AddCommand(compose.NewCmd()) return cmd diff --git a/internal/cli/kraft/cloud/compose/build/build.go b/internal/cli/kraft/cloud/compose/build/build.go index e31104373..1da18d1f4 100644 --- a/internal/cli/kraft/cloud/compose/build/build.go +++ b/internal/cli/kraft/cloud/compose/build/build.go @@ -16,7 +16,7 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" + cloud "sdk.kraft.cloud" "kraftkit.sh/cmdfactory" "kraftkit.sh/compose" @@ -32,14 +32,14 @@ import ( ) type BuildOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Composefile string `noattribute:"true"` - Client kraftcloud.KraftCloud `noattribute:"true"` - Metro string `noattribute:"true"` - Project *compose.Project `noattribute:"true"` - Push bool `long:"push" usage:"Push the built service images"` - Runtimes []string `long:"runtime" usage:"Alternative runtime to use when packaging a service"` - Token string `noattribute:"true"` + Auth *config.AuthConfig `noattribute:"true"` + Composefile string `noattribute:"true"` + Client cloud.KraftCloud `noattribute:"true"` + Metro string `noattribute:"true"` + Project *compose.Project `noattribute:"true"` + Push bool `long:"push" usage:"Push the built service images"` + Runtimes []string `long:"runtime" usage:"Alternative runtime to use when packaging a service"` + Token string `noattribute:"true"` } func NewCmd() *cobra.Command { @@ -62,7 +62,7 @@ func NewCmd() *cobra.Command { $ kraft cloud compose build --push `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-compose", + cmdfactory.AnnotationHelpGroup: "cloud-compose", }, }) if err != nil { @@ -80,15 +80,15 @@ func Build(ctx context.Context, opts *BuildOptions, args ...string) error { } if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } @@ -172,7 +172,7 @@ func Build(ctx context.Context, opts *BuildOptions, args ...string) error { var project app.Application bopts := &build.BuildOptions{ - Platform: "kraftcloud", + Platform: "cloud", Architecture: "x86_64", NoRootfs: true, } @@ -183,7 +183,7 @@ func Build(ctx context.Context, opts *BuildOptions, args ...string) error { Format: "oci", Name: pkgName, NoPull: true, - Platform: "kraftcloud", + Platform: "cloud", Push: opts.Push, Project: project, Strategy: packmanager.StrategyOverwrite, @@ -193,21 +193,21 @@ func Build(ctx context.Context, opts *BuildOptions, args ...string) error { // runtime. if service.Build != nil { // First determine whether the context has a Kraftfile as this determines - // whether we supply an artificial project defined with KraftCloud + // whether we supply an artificial project defined with UnikraftCloud // defaults. project, err := app.NewProjectFromOptions(ctx, app.WithProjectWorkdir(service.Build.Context), app.WithProjectDefaultKraftfiles(), ) if err != nil && errors.Is(err, app.ErrNoKraftfile) { - runtime, err := runtime.NewRuntime(ctx, runtime.DefaultKraftCloudRuntime) + runtime, err := runtime.NewRuntime(ctx, runtime.DefaultUnikraftCloudRuntime) if err != nil { return fmt.Errorf("could not create runtime: %w", err) } project, err = app.NewApplicationFromOptions( app.WithRuntime(runtime), app.WithName(appName), - app.WithTargets([]*target.TargetConfig{target.DefaultKraftCloudTarget}), + app.WithTargets([]*target.TargetConfig{target.DefaultUnikraftCloudTarget}), app.WithCommand(service.Command...), app.WithWorkingDir(service.Build.Context), app.WithRootfs(filepath.Join(service.Build.Context, service.Build.Dockerfile)), @@ -248,7 +248,7 @@ func Build(ctx context.Context, opts *BuildOptions, args ...string) error { } runtimeName = found } else { - runtimeName = runtime.DefaultKraftCloudRuntime + runtimeName = runtime.DefaultUnikraftCloudRuntime } log.G(ctx). @@ -264,7 +264,7 @@ func Build(ctx context.Context, opts *BuildOptions, args ...string) error { project, err = app.NewApplicationFromOptions( app.WithRuntime(rt), app.WithName(appName), - app.WithTargets([]*target.TargetConfig{target.DefaultKraftCloudTarget}), + app.WithTargets([]*target.TargetConfig{target.DefaultUnikraftCloudTarget}), app.WithRootfs(service.Image), ) if err != nil { @@ -332,7 +332,7 @@ func (opts *BuildOptions) Run(ctx context.Context, args []string) error { return Build(ctx, opts, args...) } -// imageExists checks if an image exists in the KraftCloud registry. +// imageExists checks if an image exists in the UnikraftCloud registry. func (opts *BuildOptions) imageExists(ctx context.Context, name string) (exists bool, err error) { if name == "" { return false, fmt.Errorf("image name is empty") diff --git a/internal/cli/kraft/cloud/compose/compose.go b/internal/cli/kraft/cloud/compose/compose.go index 43222dad8..49b29a7da 100644 --- a/internal/cli/kraft/cloud/compose/compose.go +++ b/internal/cli/kraft/cloud/compose/compose.go @@ -61,7 +61,7 @@ func NewCmd() *cobra.Command { $ kraft cloud compose log nginx `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-compose", + cmdfactory.AnnotationHelpGroup: "cloud-compose", cmdfactory.AnnotationHelpHidden: "true", }, }) diff --git a/internal/cli/kraft/cloud/compose/create/create.go b/internal/cli/kraft/cloud/compose/create/create.go index 5e488c9eb..ac067e72e 100644 --- a/internal/cli/kraft/cloud/compose/create/create.go +++ b/internal/cli/kraft/cloud/compose/create/create.go @@ -35,7 +35,7 @@ func NewCmd() *cobra.Command { $ kraft cloud compose create `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-compose", + cmdfactory.AnnotationHelpGroup: "cloud-compose", }, }) if err != nil { diff --git a/internal/cli/kraft/cloud/compose/down/down.go b/internal/cli/kraft/cloud/compose/down/down.go index dc18916b5..3e7694c2f 100644 --- a/internal/cli/kraft/cloud/compose/down/down.go +++ b/internal/cli/kraft/cloud/compose/down/down.go @@ -15,7 +15,7 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" + cloud "sdk.kraft.cloud" "kraftkit.sh/cmdfactory" "kraftkit.sh/compose" @@ -25,12 +25,12 @@ import ( ) type DownOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kraftcloud.KraftCloud `noattribute:"true"` - Composefile string `noattribute:"true"` - Metro string `noattribute:"true"` - Project *compose.Project `noattribute:"true"` - Token string `noattribute:"true"` + Auth *config.AuthConfig `noattribute:"true"` + Client cloud.KraftCloud `noattribute:"true"` + Composefile string `noattribute:"true"` + Metro string `noattribute:"true"` + Project *compose.Project `noattribute:"true"` + Token string `noattribute:"true"` } func NewCmd() *cobra.Command { @@ -47,7 +47,7 @@ func NewCmd() *cobra.Command { $ kraft cloud compose down nginx component2 `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-compose", + cmdfactory.AnnotationHelpGroup: "cloud-compose", }, }) if err != nil { @@ -70,15 +70,15 @@ func (opts *DownOptions) Run(ctx context.Context, args []string) error { var err error if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } diff --git a/internal/cli/kraft/cloud/compose/list/list.go b/internal/cli/kraft/cloud/compose/list/list.go index 3a69f2f8e..8fc23fadf 100644 --- a/internal/cli/kraft/cloud/compose/list/list.go +++ b/internal/cli/kraft/cloud/compose/list/list.go @@ -41,7 +41,7 @@ func NewCmd() *cobra.Command { $ kraft cloud compose ls `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-compose", + cmdfactory.AnnotationHelpGroup: "cloud-compose", }, }) if err != nil { diff --git a/internal/cli/kraft/cloud/compose/logs/logs.go b/internal/cli/kraft/cloud/compose/logs/logs.go index 23a5b41ee..377313b69 100644 --- a/internal/cli/kraft/cloud/compose/logs/logs.go +++ b/internal/cli/kraft/cloud/compose/logs/logs.go @@ -14,7 +14,7 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" + cloud "sdk.kraft.cloud" "kraftkit.sh/cmdfactory" "kraftkit.sh/compose" @@ -24,15 +24,15 @@ import ( ) type LogsOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kraftcloud.KraftCloud `noattribute:"true"` - Composefile string `noattribute:"true"` - Follow bool `long:"follow" short:"f" usage:"Follow log output"` - Metro string `noattribute:"true"` - Output string `long:"output" short:"o" usage:"Set output format. Options: table,yaml,json,list" default:"table"` - Project *compose.Project `noattribute:"true"` - Tail int `long:"tail" short:"t" usage:"Number of lines to show from the end of the logs" default:"-1"` - Token string `noattribute:"true"` + Auth *config.AuthConfig `noattribute:"true"` + Client cloud.KraftCloud `noattribute:"true"` + Composefile string `noattribute:"true"` + Follow bool `long:"follow" short:"f" usage:"Follow log output"` + Metro string `noattribute:"true"` + Output string `long:"output" short:"o" usage:"Set output format. Options: table,yaml,json,list" default:"table"` + Project *compose.Project `noattribute:"true"` + Tail int `long:"tail" short:"t" usage:"Number of lines to show from the end of the logs" default:"-1"` + Token string `noattribute:"true"` } func NewCmd() *cobra.Command { @@ -50,7 +50,7 @@ func NewCmd() *cobra.Command { $ kraft cloud compose logs -f nginx `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-compose", + cmdfactory.AnnotationHelpGroup: "cloud-compose", }, }) if err != nil { @@ -81,15 +81,15 @@ func Logs(ctx context.Context, opts *LogsOptions, args ...string) error { var err error if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } diff --git a/internal/cli/kraft/cloud/compose/ps/ps.go b/internal/cli/kraft/cloud/compose/ps/ps.go index f08245477..55231c9d3 100644 --- a/internal/cli/kraft/cloud/compose/ps/ps.go +++ b/internal/cli/kraft/cloud/compose/ps/ps.go @@ -14,8 +14,8 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" - kcclient "sdk.kraft.cloud/client" + cloud "sdk.kraft.cloud" + ukcclient "sdk.kraft.cloud/client" "kraftkit.sh/cmdfactory" "kraftkit.sh/compose" @@ -24,13 +24,13 @@ import ( ) type PsOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kraftcloud.KraftCloud `noattribute:"true"` - Composefile string `noattribute:"true"` - Metro string `noattribute:"true"` - Output string `long:"output" short:"o" usage:"Set output format. Options: table,yaml,json,list" default:"table"` - Project *compose.Project `noattribute:"true"` - Token string `noattribute:"true"` + Auth *config.AuthConfig `noattribute:"true"` + Client cloud.KraftCloud `noattribute:"true"` + Composefile string `noattribute:"true"` + Metro string `noattribute:"true"` + Output string `long:"output" short:"o" usage:"Set output format. Options: table,yaml,json,list" default:"table"` + Project *compose.Project `noattribute:"true"` + Token string `noattribute:"true"` } func NewCmd() *cobra.Command { @@ -43,7 +43,7 @@ func NewCmd() *cobra.Command { $ kraft cloud compose ps `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-compose", + cmdfactory.AnnotationHelpGroup: "cloud-compose", }, }) if err != nil { @@ -66,15 +66,15 @@ func (opts *PsOptions) Run(ctx context.Context, args []string) error { var err error if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } @@ -127,7 +127,7 @@ func (opts *PsOptions) Run(ctx context.Context, args []string) error { } for i, instance := range instancesResp.Data.Entries { - if instance.Error != nil && *instance.Error == kcclient.APIHTTPErrorNotFound { + if instance.Error != nil && *instance.Error == ukcclient.APIHTTPErrorNotFound { instancesResp.Data.Entries[i].Message = "not deployed" } } diff --git a/internal/cli/kraft/cloud/compose/push/push.go b/internal/cli/kraft/cloud/compose/push/push.go index c5eb70094..e250f81a0 100644 --- a/internal/cli/kraft/cloud/compose/push/push.go +++ b/internal/cli/kraft/cloud/compose/push/push.go @@ -15,8 +15,8 @@ import ( "github.com/dustin/go-humanize" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" - kcinstances "sdk.kraft.cloud/instances" + cloud "sdk.kraft.cloud" + ukcinstances "sdk.kraft.cloud/instances" "kraftkit.sh/cmdfactory" "kraftkit.sh/compose" @@ -28,12 +28,12 @@ import ( ) type PushOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kcinstances.InstancesService `noattribute:"true"` - Composefile string `noattribute:"true"` - Metro string `noattribute:"true"` - Project *compose.Project `noattribute:"true"` - Token string `noattribute:"true"` + Auth *config.AuthConfig `noattribute:"true"` + Client ukcinstances.InstancesService `noattribute:"true"` + Composefile string `noattribute:"true"` + Metro string `noattribute:"true"` + Project *compose.Project `noattribute:"true"` + Token string `noattribute:"true"` } func NewCmd() *cobra.Command { @@ -47,7 +47,7 @@ func NewCmd() *cobra.Command { $ kraft cloud compose push nginx `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-compose", + cmdfactory.AnnotationHelpGroup: "cloud-compose", }, }) if err != nil { @@ -61,15 +61,15 @@ func Push(ctx context.Context, opts *PushOptions, args ...string) error { var err error if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewInstancesClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewInstancesClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } diff --git a/internal/cli/kraft/cloud/compose/start/start.go b/internal/cli/kraft/cloud/compose/start/start.go index 9c998c484..1c0279410 100644 --- a/internal/cli/kraft/cloud/compose/start/start.go +++ b/internal/cli/kraft/cloud/compose/start/start.go @@ -15,7 +15,7 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" + cloud "sdk.kraft.cloud" "kraftkit.sh/cmdfactory" "kraftkit.sh/compose" @@ -25,13 +25,13 @@ import ( ) type StartOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kraftcloud.KraftCloud `noattribute:"true"` - Composefile string `noattribute:"true"` - Metro string `noattribute:"true"` - Project *compose.Project `noattribute:"true"` - Token string `noattribute:"true"` - Wait time.Duration `local:"true" long:"wait" short:"w" usage:"Timeout to wait for the instance to start (ms/s/m/h)"` + Auth *config.AuthConfig `noattribute:"true"` + Client cloud.KraftCloud `noattribute:"true"` + Composefile string `noattribute:"true"` + Metro string `noattribute:"true"` + Project *compose.Project `noattribute:"true"` + Token string `noattribute:"true"` + Wait time.Duration `local:"true" long:"wait" short:"w" usage:"Timeout to wait for the instance to start (ms/s/m/h)"` } func NewCmd() *cobra.Command { @@ -48,7 +48,7 @@ func NewCmd() *cobra.Command { $ kraft cloud compose start nginx `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-compose", + cmdfactory.AnnotationHelpGroup: "cloud-compose", }, }) if err != nil { @@ -75,15 +75,15 @@ func (opts *StartOptions) Run(ctx context.Context, args []string) error { var err error if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } diff --git a/internal/cli/kraft/cloud/compose/stop/stop.go b/internal/cli/kraft/cloud/compose/stop/stop.go index 1c1d90a06..afb827771 100644 --- a/internal/cli/kraft/cloud/compose/stop/stop.go +++ b/internal/cli/kraft/cloud/compose/stop/stop.go @@ -15,7 +15,7 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" + cloud "sdk.kraft.cloud" "kraftkit.sh/cmdfactory" "kraftkit.sh/compose" @@ -26,15 +26,15 @@ import ( ) type StopOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kraftcloud.KraftCloud `noattribute:"true"` - Composefile string `noattribute:"true"` - DrainTimeout time.Duration `long:"drain-timeout" short:"d" usage:"Timeout for the instance to stop (ms/s/m/h)"` - Force bool `long:"force" short:"f" usage:"Force stop the instance(s)"` - Metro string `noattribute:"true"` - Project *compose.Project `noattribute:"true"` - Token string `noattribute:"true"` - Wait time.Duration `long:"wait" short:"w" usage:"Time to wait for the instance to drain all connections before it is stopped (ms/s/m/h)"` + Auth *config.AuthConfig `noattribute:"true"` + Client cloud.KraftCloud `noattribute:"true"` + Composefile string `noattribute:"true"` + DrainTimeout time.Duration `long:"drain-timeout" short:"d" usage:"Timeout for the instance to stop (ms/s/m/h)"` + Force bool `long:"force" short:"f" usage:"Force stop the instance(s)"` + Metro string `noattribute:"true"` + Project *compose.Project `noattribute:"true"` + Token string `noattribute:"true"` + Wait time.Duration `long:"wait" short:"w" usage:"Time to wait for the instance to drain all connections before it is stopped (ms/s/m/h)"` } func NewCmd() *cobra.Command { @@ -51,7 +51,7 @@ func NewCmd() *cobra.Command { $ kraft cloud compose stop nginx `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-compose", + cmdfactory.AnnotationHelpGroup: "cloud-compose", }, }) if err != nil { @@ -85,15 +85,15 @@ func (opts *StopOptions) Run(ctx context.Context, args []string) error { var err error if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } diff --git a/internal/cli/kraft/cloud/compose/up/up.go b/internal/cli/kraft/cloud/compose/up/up.go index d8da9a668..ec0e5e077 100644 --- a/internal/cli/kraft/cloud/compose/up/up.go +++ b/internal/cli/kraft/cloud/compose/up/up.go @@ -17,11 +17,11 @@ import ( "github.com/dustin/go-humanize" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" - kcclient "sdk.kraft.cloud/client" - kcinstances "sdk.kraft.cloud/instances" - kcservices "sdk.kraft.cloud/services" - kcvolumes "sdk.kraft.cloud/volumes" + cloud "sdk.kraft.cloud" + ukcclient "sdk.kraft.cloud/client" + ukcinstances "sdk.kraft.cloud/instances" + ukcservices "sdk.kraft.cloud/services" + ukcvolumes "sdk.kraft.cloud/volumes" "kraftkit.sh/cmdfactory" "kraftkit.sh/compose" @@ -37,17 +37,17 @@ import ( ) type UpOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kraftcloud.KraftCloud `noattribute:"true"` - Composefile string `noattribute:"true"` - Detach bool `local:"true" long:"detach" short:"d" usage:"Run the services in the background"` - Metro string `noattribute:"true"` - NoStart bool `noattribute:"true"` - NoBuild bool `local:"true" long:"no-build" usage:"Do not build the services before starting them"` - Project *compose.Project `noattribute:"true"` - Runtimes []string `long:"runtime" usage:"Alternative runtime to use when packaging a service"` - Token string `noattribute:"true"` - Wait time.Duration `local:"true" long:"wait" short:"w" usage:"Timeout to wait for the instance to start (ms/s/m/h)"` + Auth *config.AuthConfig `noattribute:"true"` + Client cloud.KraftCloud `noattribute:"true"` + Composefile string `noattribute:"true"` + Detach bool `local:"true" long:"detach" short:"d" usage:"Run the services in the background"` + Metro string `noattribute:"true"` + NoStart bool `noattribute:"true"` + NoBuild bool `local:"true" long:"no-build" usage:"Do not build the services before starting them"` + Project *compose.Project `noattribute:"true"` + Runtimes []string `long:"runtime" usage:"Alternative runtime to use when packaging a service"` + Token string `noattribute:"true"` + Wait time.Duration `local:"true" long:"wait" short:"w" usage:"Timeout to wait for the instance to start (ms/s/m/h)"` } func NewCmd() *cobra.Command { @@ -77,7 +77,7 @@ func NewCmd() *cobra.Command { $ kraft cloud compose up --runtime app=base:latest `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-compose", + cmdfactory.AnnotationHelpGroup: "cloud-compose", }, }) if err != nil { @@ -115,15 +115,15 @@ func Up(ctx context.Context, opts *UpOptions, args ...string) error { var err error if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } @@ -175,7 +175,7 @@ func Up(ctx context.Context, opts *UpOptions, args ...string) error { return err } - insts := []kcinstances.GetResponseItem{} + insts := []ukcinstances.GetResponseItem{} for _, serviceName := range args { service, ok := opts.Project.Services[serviceName] @@ -243,7 +243,7 @@ func Up(ctx context.Context, opts *UpOptions, args ...string) error { } // Handle the memory limit and reservation. Since these two concepts do not - // currently exist via the KraftCloud API, pick the limit if it is set as it + // currently exist via the UnikraftCloud API, pick the limit if it is set as it // represents the maximum value, otherwise check if the reservation has been // set. var memory string @@ -277,7 +277,7 @@ func Up(ctx context.Context, opts *UpOptions, args ...string) error { name = cname } - var services []kcservices.CreateRequestService + var services []ukcservices.CreateRequestService for _, port := range service.Ports { if port.Protocol != "" && port.Protocol != "tls" && port.Protocol != "tcp" { @@ -286,20 +286,20 @@ func Up(ctx context.Context, opts *UpOptions, args ...string) error { if port.Published == "443" { services = append(services, - kcservices.CreateRequestService{ + ukcservices.CreateRequestService{ Port: 443, DestinationPort: ptr(int(port.Target)), - Handlers: []kcservices.Handler{ - kcservices.HandlerHTTP, - kcservices.HandlerTLS, + Handlers: []ukcservices.Handler{ + ukcservices.HandlerHTTP, + ukcservices.HandlerTLS, }, }, - kcservices.CreateRequestService{ + ukcservices.CreateRequestService{ Port: 80, DestinationPort: ptr(int(443)), - Handlers: []kcservices.Handler{ - kcservices.HandlerHTTP, - kcservices.HandlerRedirect, + Handlers: []ukcservices.Handler{ + ukcservices.HandlerHTTP, + ukcservices.HandlerRedirect, }, }, ) @@ -310,11 +310,11 @@ func Up(ctx context.Context, opts *UpOptions, args ...string) error { } services = append(services, - kcservices.CreateRequestService{ + ukcservices.CreateRequestService{ Port: published, DestinationPort: ptr(int(port.Target)), - Handlers: []kcservices.Handler{ - kcservices.HandlerTLS, + Handlers: []ukcservices.Handler{ + ukcservices.HandlerTLS, }, }, ) @@ -383,7 +383,7 @@ func Up(ctx context.Context, opts *UpOptions, args ...string) error { Output: "table", }, instances...) } else { - instResps := kcclient.ServiceResponse[kcinstances.GetResponseItem]{} + instResps := ukcclient.ServiceResponse[ukcinstances.GetResponseItem]{} instResps.Data.Entries = insts return utils.PrintInstances(ctx, "table", instResps) } @@ -400,8 +400,8 @@ func Up(ctx context.Context, opts *UpOptions, args ...string) error { // createVolumes is used to create volumes for each service in the compose // project. These volumes are used to persist data across instances. -func createVolumes(ctx context.Context, opts *UpOptions) (map[string]*kcclient.ServiceResponse[kcvolumes.GetResponseItem], error) { - volResps := make(map[string]*kcclient.ServiceResponse[kcvolumes.GetResponseItem]) +func createVolumes(ctx context.Context, opts *UpOptions) (map[string]*ukcclient.ServiceResponse[ukcvolumes.GetResponseItem], error) { + volResps := make(map[string]*ukcclient.ServiceResponse[ukcvolumes.GetResponseItem]) for alias, volume := range opts.Project.Volumes { name := strings.ReplaceAll(volume.Name, "_", "-") @@ -412,7 +412,7 @@ func createVolumes(ctx context.Context, opts *UpOptions) (map[string]*kcclient.S } vol, err := volResp.FirstOrErr() - if err != nil && vol != nil && *vol.Error == kcclient.APIHTTPErrorNotFound { + if err != nil && vol != nil && *vol.Error == ukcclient.APIHTTPErrorNotFound { log.G(ctx).WithField("name", name).Info("creating volume") @@ -455,7 +455,7 @@ func createVolumes(ctx context.Context, opts *UpOptions) (map[string]*kcclient.S func ptr[T comparable](v T) *T { return &v } -// imageExists checks if an image exists in the KraftCloud registry. +// imageExists checks if an image exists in the UnikraftCloud registry. func (opts *UpOptions) imageExists(ctx context.Context, name string) (exists bool, err error) { if name == "" { return false, fmt.Errorf("image name is empty") diff --git a/internal/cli/kraft/cloud/deploy/deploy.go b/internal/cli/kraft/cloud/deploy/deploy.go index 0ee77615f..677faf6d6 100644 --- a/internal/cli/kraft/cloud/deploy/deploy.go +++ b/internal/cli/kraft/cloud/deploy/deploy.go @@ -29,58 +29,58 @@ import ( "kraftkit.sh/tui/selection" "kraftkit.sh/unikraft/app" - kraftcloud "sdk.kraft.cloud" - kcinstances "sdk.kraft.cloud/instances" + cloud "sdk.kraft.cloud" + ukcinstances "sdk.kraft.cloud/instances" ) type DeployOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kraftcloud.KraftCloud `noattribute:"true"` - Certificate []string `local:"true" long:"certificate" short:"C" usage:"Set the certificates to use for the service"` - Compress bool `local:"true" long:"compress" short:"z" usage:"Compress the initrd package (experimental)"` - DeployAs string `local:"true" long:"as" short:"D" usage:"Set the deployment type"` - Domain []string `local:"true" long:"domain" short:"d" usage:"Set the domain names for the service"` - DotConfig string `long:"config" short:"c" usage:"Override the path to the KConfig .config file"` - Entrypoint types.ShellCommand `local:"true" long:"entrypoint" usage:"Set the entrypoint for the instance"` - Env []string `local:"true" long:"env" short:"e" usage:"Environmental variables"` - Features []string `local:"true" long:"feature" usage:"Specify the special features to enable"` - Follow bool `local:"true" long:"follow" short:"f" usage:"Follow the logs of the instance"` - ForcePull bool `long:"force-pull" usage:"Force pulling packages before building"` - Image string `long:"image" short:"i" usage:"Set the image name to use"` - Jobs int `long:"jobs" short:"j" usage:"Allow N jobs at once"` - KernelDbg bool `long:"dbg" usage:"Build the debuggable (symbolic) kernel image instead of the stripped image"` - Kraftfile string `local:"true" long:"kraftfile" short:"K" usage:"Set the Kraftfile to use"` - Memory string `local:"true" long:"memory" short:"M" usage:"Specify the amount of memory to allocate (MiB increments)"` - Metro string `noattribute:"true"` - Name string `local:"true" long:"name" short:"n" usage:"Name of the deployment"` - NoCache bool `long:"no-cache" short:"F" usage:"Force a rebuild even if existing intermediate artifacts already exist"` - NoConfigure bool `long:"no-configure" usage:"Do not run Unikraft's configure step before building"` - NoFast bool `long:"no-fast" usage:"Do not use maximum parallelization when performing the build"` - NoFetch bool `long:"no-fetch" usage:"Do not run Unikraft's fetch step before building"` - NoStart bool `local:"true" long:"no-start" short:"S" usage:"Do not start the instance after creation"` - NoUpdate bool `long:"no-update" usage:"Do not update package index before running the build"` - Output string `local:"true" long:"output" short:"o" usage:"Set output format"` - Ports []string `local:"true" long:"port" short:"p" usage:"Specify the port mapping between external to internal"` - Project app.Application `noattribute:"true"` - Replicas uint `local:"true" long:"replicas" short:"R" usage:"Number of replicas of the instance" default:"0"` - RestartPolicy kcinstances.RestartPolicy `noattribute:"true"` - Rollout create.RolloutStrategy `noattribute:"true"` - RolloutQualifier create.RolloutQualifier `noattribute:"true"` - RolloutWait time.Duration `local:"true" long:"rollout-wait" usage:"Time to wait before performing rolling out action (ms/s/m/h)" default:"10s"` - Rootfs string `local:"true" long:"rootfs" usage:"Specify a path to use as root filesystem"` - Runtime string `local:"true" long:"runtime" usage:"Set an alternative project runtime"` - SaveBuildLog string `long:"build-log" usage:"Use the specified file to save the output from the build"` - ScaleToZero *kcinstances.ScaleToZeroPolicy `noattribute:"true"` - ScaleToZeroStateful *bool `local:"true" long:"scale-to-zero-stateful" usage:"Save state when scaling to zero"` - ScaleToZeroCooldown time.Duration `local:"true" long:"scale-to-zero-cooldown" usage:"Cooldown period before scaling to zero (ms/s/m/h)"` - ServiceNameOrUUID string `long:"service" short:"g" usage:"Attach the new deployment to an existing service"` - Strategy packmanager.MergeStrategy `noattribute:"true"` - 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)"` + Auth *config.AuthConfig `noattribute:"true"` + Client cloud.KraftCloud `noattribute:"true"` + Certificate []string `local:"true" long:"certificate" short:"C" usage:"Set the certificates to use for the service"` + Compress bool `local:"true" long:"compress" short:"z" usage:"Compress the initrd package (experimental)"` + DeployAs string `local:"true" long:"as" short:"D" usage:"Set the deployment type"` + Domain []string `local:"true" long:"domain" short:"d" usage:"Set the domain names for the service"` + DotConfig string `long:"config" short:"c" usage:"Override the path to the KConfig .config file"` + Entrypoint types.ShellCommand `local:"true" long:"entrypoint" usage:"Set the entrypoint for the instance"` + Env []string `local:"true" long:"env" short:"e" usage:"Environmental variables"` + Features []string `local:"true" long:"feature" usage:"Specify the special features to enable"` + Follow bool `local:"true" long:"follow" short:"f" usage:"Follow the logs of the instance"` + ForcePull bool `long:"force-pull" usage:"Force pulling packages before building"` + Image string `long:"image" short:"i" usage:"Set the image name to use"` + Jobs int `long:"jobs" short:"j" usage:"Allow N jobs at once"` + KernelDbg bool `long:"dbg" usage:"Build the debuggable (symbolic) kernel image instead of the stripped image"` + Kraftfile string `local:"true" long:"kraftfile" short:"K" usage:"Set the Kraftfile to use"` + Memory string `local:"true" long:"memory" short:"M" usage:"Specify the amount of memory to allocate (MiB increments)"` + Metro string `noattribute:"true"` + Name string `local:"true" long:"name" short:"n" usage:"Name of the deployment"` + NoCache bool `long:"no-cache" short:"F" usage:"Force a rebuild even if existing intermediate artifacts already exist"` + NoConfigure bool `long:"no-configure" usage:"Do not run Unikraft's configure step before building"` + NoFast bool `long:"no-fast" usage:"Do not use maximum parallelization when performing the build"` + NoFetch bool `long:"no-fetch" usage:"Do not run Unikraft's fetch step before building"` + NoStart bool `local:"true" long:"no-start" short:"S" usage:"Do not start the instance after creation"` + NoUpdate bool `long:"no-update" usage:"Do not update package index before running the build"` + Output string `local:"true" long:"output" short:"o" usage:"Set output format"` + Ports []string `local:"true" long:"port" short:"p" usage:"Specify the port mapping between external to internal"` + Project app.Application `noattribute:"true"` + Replicas uint `local:"true" long:"replicas" short:"R" usage:"Number of replicas of the instance" default:"0"` + RestartPolicy ukcinstances.RestartPolicy `noattribute:"true"` + Rollout create.RolloutStrategy `noattribute:"true"` + RolloutQualifier create.RolloutQualifier `noattribute:"true"` + RolloutWait time.Duration `local:"true" long:"rollout-wait" usage:"Time to wait before performing rolling out action (ms/s/m/h)" default:"10s"` + Rootfs string `local:"true" long:"rootfs" usage:"Specify a path to use as root filesystem"` + Runtime string `local:"true" long:"runtime" usage:"Set an alternative project runtime"` + SaveBuildLog string `long:"build-log" usage:"Use the specified file to save the output from the build"` + ScaleToZero *ukcinstances.ScaleToZeroPolicy `noattribute:"true"` + ScaleToZeroStateful *bool `local:"true" long:"scale-to-zero-stateful" usage:"Save state when scaling to zero"` + ScaleToZeroCooldown time.Duration `local:"true" long:"scale-to-zero-cooldown" usage:"Cooldown period before scaling to zero (ms/s/m/h)"` + ServiceNameOrUUID string `long:"service" short:"g" usage:"Attach the new deployment to an existing service"` + Strategy packmanager.MergeStrategy `noattribute:"true"` + 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)"` } func NewCmd() *cobra.Command { @@ -89,7 +89,7 @@ func NewCmd() *cobra.Command { Use: "deploy [ARGS] [CONTEXT] [-- [APP ARGS]]", Aliases: []string{"launch", "run"}, Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud", + cmdfactory.AnnotationHelpGroup: "cloud", }, Long: heredoc.Doc(` 'kraft cloud deploy' combines a number of kraft cloud sub-commands @@ -118,9 +118,9 @@ func NewCmd() *cobra.Command { } cmd.Flags().Var( - cmdfactory.NewEnumFlag[kcinstances.RestartPolicy]( - kcinstances.RestartPolicies(), - kcinstances.RestartPolicyNever, + cmdfactory.NewEnumFlag[ukcinstances.RestartPolicy]( + ukcinstances.RestartPolicies(), + ukcinstances.RestartPolicyNever, ), "restart", "Set the restart policy for the instance (never/always/on-failure)", @@ -145,9 +145,9 @@ func NewCmd() *cobra.Command { ) cmd.Flags().Var( - cmdfactory.NewEnumFlag[kcinstances.ScaleToZeroPolicy]( - kcinstances.ScaleToZeroPolicies(), - kcinstances.ScaleToZeroPolicyOff, + cmdfactory.NewEnumFlag[ukcinstances.ScaleToZeroPolicy]( + ukcinstances.ScaleToZeroPolicies(), + ukcinstances.ScaleToZeroPolicyOff, ), "scale-to-zero", "Scale to zero policy of the instance (on/off/idle)", @@ -171,13 +171,13 @@ func (opts *DeployOptions) Pre(cmd *cobra.Command, _ []string) error { return fmt.Errorf("could not populate metro and token: %w", err) } - opts.RestartPolicy = kcinstances.RestartPolicy(cmd.Flag("restart").Value.String()) + opts.RestartPolicy = ukcinstances.RestartPolicy(cmd.Flag("restart").Value.String()) opts.Rollout = create.RolloutStrategy(cmd.Flag("rollout").Value.String()) opts.RolloutQualifier = create.RolloutQualifier(cmd.Flag("rollout-qualifier").Value.String()) opts.Strategy = packmanager.MergeStrategy(cmd.Flag("strategy").Value.String()) if cmd.Flag("scale-to-zero").Changed { - s20v := kcinstances.ScaleToZeroPolicy(cmd.Flag("scale-to-zero").Value.String()) + s20v := ukcinstances.ScaleToZeroPolicy(cmd.Flag("scale-to-zero").Value.String()) opts.ScaleToZero = &s20v } @@ -203,13 +203,13 @@ func (opts *DeployOptions) Pre(cmd *cobra.Command, _ []string) error { func (opts *DeployOptions) Run(ctx context.Context, args []string) error { var err error - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } - opts.Client = kraftcloud.NewClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) // TODO: Preflight check: check if `--subdomain` is already taken diff --git a/internal/cli/kraft/cloud/deploy/deployer.go b/internal/cli/kraft/cloud/deploy/deployer.go index 6e538440e..d1c171e4c 100644 --- a/internal/cli/kraft/cloud/deploy/deployer.go +++ b/internal/cli/kraft/cloud/deploy/deployer.go @@ -9,9 +9,9 @@ import ( "context" "fmt" - kcclient "sdk.kraft.cloud/client" - kcinstances "sdk.kraft.cloud/instances" - kcservices "sdk.kraft.cloud/services" + ukcclient "sdk.kraft.cloud/client" + ukcinstances "sdk.kraft.cloud/instances" + ukcservices "sdk.kraft.cloud/services" ) // deployer is an interface for defining different mechanisms to perform a the @@ -31,7 +31,7 @@ type deployer interface { Deployable(context.Context, *DeployOptions, ...string) (bool, error) // Deploy performs the deployment based on the determined implementation. - Deploy(context.Context, *DeployOptions, ...string) (*kcclient.ServiceResponse[kcinstances.GetResponseItem], *kcclient.ServiceResponse[kcservices.GetResponseItem], error) + Deploy(context.Context, *DeployOptions, ...string) (*ukcclient.ServiceResponse[ukcinstances.GetResponseItem], *ukcclient.ServiceResponse[ukcservices.GetResponseItem], error) } // deployers is the list of built-in deployers which are checked diff --git a/internal/cli/kraft/cloud/deploy/deployer_image_name.go b/internal/cli/kraft/cloud/deploy/deployer_image_name.go index 783868e2e..87e69bb4a 100644 --- a/internal/cli/kraft/cloud/deploy/deployer_image_name.go +++ b/internal/cli/kraft/cloud/deploy/deployer_image_name.go @@ -10,9 +10,9 @@ import ( "fmt" "strings" - kcclient "sdk.kraft.cloud/client" - kcinstances "sdk.kraft.cloud/instances" - kcservices "sdk.kraft.cloud/services" + ukcclient "sdk.kraft.cloud/client" + ukcinstances "sdk.kraft.cloud/instances" + ukcservices "sdk.kraft.cloud/services" "kraftkit.sh/config" instancecreate "kraftkit.sh/internal/cli/kraft/cloud/instance/create" @@ -71,11 +71,11 @@ func (deployer *deployerImageName) Deployable(ctx context.Context, opts *DeployO return true, nil } -func (deployer *deployerImageName) Deploy(ctx context.Context, opts *DeployOptions, args ...string) (*kcclient.ServiceResponse[kcinstances.GetResponseItem], *kcclient.ServiceResponse[kcservices.GetResponseItem], error) { +func (deployer *deployerImageName) Deploy(ctx context.Context, opts *DeployOptions, args ...string) (*ukcclient.ServiceResponse[ukcinstances.GetResponseItem], *ukcclient.ServiceResponse[ukcservices.GetResponseItem], error) { var err error - var insts *kcclient.ServiceResponse[kcinstances.GetResponseItem] - var groups *kcclient.ServiceResponse[kcservices.GetResponseItem] + var insts *ukcclient.ServiceResponse[ukcinstances.GetResponseItem] + var groups *ukcclient.ServiceResponse[ukcservices.GetResponseItem] paramodel, err := processtree.NewProcessTree( ctx, diff --git a/internal/cli/kraft/cloud/deploy/deployer_kraftfile_runtime.go b/internal/cli/kraft/cloud/deploy/deployer_kraftfile_runtime.go index 7215c1a86..a57d14b8b 100644 --- a/internal/cli/kraft/cloud/deploy/deployer_kraftfile_runtime.go +++ b/internal/cli/kraft/cloud/deploy/deployer_kraftfile_runtime.go @@ -11,9 +11,9 @@ import ( "path/filepath" "strings" - kcclient "sdk.kraft.cloud/client" - kcinstances "sdk.kraft.cloud/instances" - kcservices "sdk.kraft.cloud/services" + ukcclient "sdk.kraft.cloud/client" + ukcinstances "sdk.kraft.cloud/instances" + ukcservices "sdk.kraft.cloud/services" "kraftkit.sh/internal/cli/kraft/cloud/instance/create" "kraftkit.sh/internal/cli/kraft/pkg" @@ -67,7 +67,7 @@ func (deployer *deployerKraftfileRuntime) Deployable(ctx context.Context, opts * return true, nil } -func (deployer *deployerKraftfileRuntime) Deploy(ctx context.Context, opts *DeployOptions, args ...string) (*kcclient.ServiceResponse[kcinstances.GetResponseItem], *kcclient.ServiceResponse[kcservices.GetResponseItem], error) { +func (deployer *deployerKraftfileRuntime) Deploy(ctx context.Context, opts *DeployOptions, args ...string) (*ukcclient.ServiceResponse[ukcinstances.GetResponseItem], *ukcclient.ServiceResponse[ukcservices.GetResponseItem], error) { var pkgName string if opts.Image != "" { @@ -104,7 +104,7 @@ func (deployer *deployerKraftfileRuntime) Deploy(ctx context.Context, opts *Depl Kraftfile: opts.Kraftfile, Name: pkgName, NoPull: true, - Platform: "kraftcloud", + Platform: "cloud", Project: opts.Project, Push: true, Rootfs: opts.Rootfs, diff --git a/internal/cli/kraft/cloud/deploy/deployer_kraftfile_unikraft.go b/internal/cli/kraft/cloud/deploy/deployer_kraftfile_unikraft.go index 2fd5d167d..72548d4bb 100644 --- a/internal/cli/kraft/cloud/deploy/deployer_kraftfile_unikraft.go +++ b/internal/cli/kraft/cloud/deploy/deployer_kraftfile_unikraft.go @@ -5,9 +5,9 @@ import ( "fmt" "strings" - kcclient "sdk.kraft.cloud/client" - kcinstances "sdk.kraft.cloud/instances" - kcservices "sdk.kraft.cloud/services" + ukcclient "sdk.kraft.cloud/client" + ukcinstances "sdk.kraft.cloud/instances" + ukcservices "sdk.kraft.cloud/services" "kraftkit.sh/internal/cli/kraft/build" ) @@ -48,7 +48,7 @@ func (deployer *deployerKraftfileUnikraft) Deployable(ctx context.Context, opts return true, nil } -func (deployer *deployerKraftfileUnikraft) Deploy(ctx context.Context, opts *DeployOptions, args ...string) (*kcclient.ServiceResponse[kcinstances.GetResponseItem], *kcclient.ServiceResponse[kcservices.GetResponseItem], error) { +func (deployer *deployerKraftfileUnikraft) Deploy(ctx context.Context, opts *DeployOptions, args ...string) (*ukcclient.ServiceResponse[ukcinstances.GetResponseItem], *ukcclient.ServiceResponse[ukcservices.GetResponseItem], error) { if err := build.Build(ctx, &build.BuildOptions{ Architecture: "x86_64", DotConfig: opts.DotConfig, @@ -60,7 +60,7 @@ func (deployer *deployerKraftfileUnikraft) Deploy(ctx context.Context, opts *Dep NoFast: opts.NoFast, NoFetch: opts.NoFetch, NoUpdate: opts.NoUpdate, - Platform: "kraftcloud", + Platform: "cloud", Rootfs: opts.Rootfs, SaveBuildLog: opts.SaveBuildLog, Workdir: opts.Workdir, diff --git a/internal/cli/kraft/cloud/deploy/deployer_rootfs.go b/internal/cli/kraft/cloud/deploy/deployer_rootfs.go index 7fcdb19c9..434771337 100644 --- a/internal/cli/kraft/cloud/deploy/deployer_rootfs.go +++ b/internal/cli/kraft/cloud/deploy/deployer_rootfs.go @@ -7,9 +7,9 @@ import ( "path/filepath" "strings" - kcclient "sdk.kraft.cloud/client" - kcinstances "sdk.kraft.cloud/instances" - kcservices "sdk.kraft.cloud/services" + ukcclient "sdk.kraft.cloud/client" + ukcinstances "sdk.kraft.cloud/instances" + ukcservices "sdk.kraft.cloud/services" "kraftkit.sh/unikraft/app" "kraftkit.sh/unikraft/runtime" @@ -55,7 +55,7 @@ func (deployer *deployerRootfs) Deployable(ctx context.Context, opts *DeployOpti opts.Rootfs = rootfs if opts.Project == nil { - rt := runtime.DefaultKraftCloudRuntime + rt := runtime.DefaultUnikraftCloudRuntime if len(opts.Runtime) > 0 { rt = opts.Runtime @@ -83,7 +83,7 @@ func (deployer *deployerRootfs) Deployable(ctx context.Context, opts *DeployOpti opts.Project, err = app.NewApplicationFromOptions( app.WithRuntime(runtime), app.WithName(opts.Name), - app.WithTargets([]*target.TargetConfig{target.DefaultKraftCloudTarget}), + app.WithTargets([]*target.TargetConfig{target.DefaultUnikraftCloudTarget}), app.WithCommand(args...), app.WithWorkingDir(opts.Workdir), app.WithRootfs(opts.Rootfs), @@ -96,6 +96,6 @@ func (deployer *deployerRootfs) Deployable(ctx context.Context, opts *DeployOpti return true, nil } -func (deployer *deployerRootfs) Deploy(ctx context.Context, opts *DeployOptions, args ...string) (*kcclient.ServiceResponse[kcinstances.GetResponseItem], *kcclient.ServiceResponse[kcservices.GetResponseItem], error) { +func (deployer *deployerRootfs) Deploy(ctx context.Context, opts *DeployOptions, args ...string) (*ukcclient.ServiceResponse[ukcinstances.GetResponseItem], *ukcclient.ServiceResponse[ukcservices.GetResponseItem], error) { return (&deployerKraftfileRuntime{}).Deploy(ctx, opts, args...) } diff --git a/internal/cli/kraft/cloud/img/img.go b/internal/cli/kraft/cloud/img/img.go index 3a539a0c3..aae303022 100644 --- a/internal/cli/kraft/cloud/img/img.go +++ b/internal/cli/kraft/cloud/img/img.go @@ -33,7 +33,7 @@ func NewCmd() *cobra.Command { $ kraft cloud image remove caddy@sha256:2ba5324141... `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-img", + cmdfactory.AnnotationHelpGroup: "cloud-img", cmdfactory.AnnotationHelpHidden: "true", }, }) diff --git a/internal/cli/kraft/cloud/img/list/list.go b/internal/cli/kraft/cloud/img/list/list.go index d08c09a7b..267b8c2c0 100644 --- a/internal/cli/kraft/cloud/img/list/list.go +++ b/internal/cli/kraft/cloud/img/list/list.go @@ -17,9 +17,9 @@ import ( gcrname "github.com/google/go-containerregistry/pkg/name" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" - kcclient "sdk.kraft.cloud/client" - kcimages "sdk.kraft.cloud/images" + cloud "sdk.kraft.cloud" + ukcclient "sdk.kraft.cloud/client" + ukcimages "sdk.kraft.cloud/images" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -54,7 +54,7 @@ func NewCmd() *cobra.Command { $ kraft cloud image list -o json `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-img", + cmdfactory.AnnotationHelpGroup: "cloud-img", }, }) if err != nil { @@ -78,13 +78,13 @@ func (opts *ListOptions) Pre(cmd *cobra.Command, _ []string) error { } func (opts *ListOptions) Run(ctx context.Context, args []string) error { - auth, err := config.GetKraftCloudAuthConfig(ctx, opts.token) + auth, err := config.GetUnikraftCloudAuthConfig(ctx, opts.token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } - client := kraftcloud.NewImagesClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*auth)), + client := cloud.NewImagesClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*auth)), ) resp, err := client.WithMetro(opts.metro).List(ctx) @@ -226,6 +226,6 @@ func isNamespacedRepository(repo string) bool { return strings.ContainsRune(repo, regNsDelimiter) } -func printRaw(ctx context.Context, resp *kcclient.ServiceResponse[kcimages.GetResponseItem]) { +func printRaw(ctx context.Context, resp *ukcclient.ServiceResponse[ukcimages.GetResponseItem]) { fmt.Fprintln(iostreams.G(ctx).Out, string(resp.RawBody())) } diff --git a/internal/cli/kraft/cloud/img/remove/remove.go b/internal/cli/kraft/cloud/img/remove/remove.go index 9439c1f92..286c75bb6 100644 --- a/internal/cli/kraft/cloud/img/remove/remove.go +++ b/internal/cli/kraft/cloud/img/remove/remove.go @@ -13,8 +13,8 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" - kcimages "sdk.kraft.cloud/images" + cloud "sdk.kraft.cloud" + ukcimages "sdk.kraft.cloud/images" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -23,11 +23,11 @@ import ( ) type RemoveOptions struct { - All bool `long:"all" usage:"Remove all images"` - Auth *config.AuthConfig `noattribute:"true"` - Client kcimages.ImagesService `noattribute:"true"` - Metro string `noattribute:"true"` - Token string `noattribute:"true"` + All bool `long:"all" usage:"Remove all images"` + Auth *config.AuthConfig `noattribute:"true"` + Client ukcimages.ImagesService `noattribute:"true"` + Metro string `noattribute:"true"` + Token string `noattribute:"true"` } func NewCmd() *cobra.Command { @@ -59,7 +59,7 @@ func NewCmd() *cobra.Command { $ kraft cloud image remove --all `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-img", + cmdfactory.AnnotationHelpGroup: "cloud-img", }, }) if err != nil { @@ -86,15 +86,15 @@ func (opts *RemoveOptions) Run(ctx context.Context, args []string) error { var err error if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewImagesClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewImagesClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } diff --git a/internal/cli/kraft/cloud/instance/create/create.go b/internal/cli/kraft/cloud/instance/create/create.go index bf4545a05..e01a42667 100644 --- a/internal/cli/kraft/cloud/instance/create/create.go +++ b/internal/cli/kraft/cloud/instance/create/create.go @@ -20,11 +20,11 @@ import ( "github.com/spf13/cobra" "k8s.io/apimachinery/pkg/api/resource" - kraftcloud "sdk.kraft.cloud" - kcclient "sdk.kraft.cloud/client" - kcimages "sdk.kraft.cloud/images" - kcinstances "sdk.kraft.cloud/instances" - kcservices "sdk.kraft.cloud/services" + cloud "sdk.kraft.cloud" + ukcclient "sdk.kraft.cloud/client" + ukcimages "sdk.kraft.cloud/images" + ukcinstances "sdk.kraft.cloud/instances" + ukcservices "sdk.kraft.cloud/services" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -35,41 +35,41 @@ import ( ) type CreateOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kraftcloud.KraftCloud `noattribute:"true"` - Certificate []string `local:"true" long:"certificate" short:"c" usage:"Set the certificates to use for the service"` - Env []string `local:"true" long:"env" short:"e" usage:"Environmental variables"` - Features []string `local:"true" long:"feature" short:"f" usage:"List of features to enable"` - Domain []string `local:"true" long:"domain" short:"d" usage:"The domain names to use for the service"` - Image string `noattribute:"true"` - Entrypoint types.ShellCommand `local:"true" long:"entrypoint" usage:"Set the entrypoint for the instance"` - Memory string `local:"true" long:"memory" short:"M" usage:"Specify the amount of memory to allocate (MiB increments)"` - Metro string `noattribute:"true"` - Name string `local:"true" long:"name" short:"n" usage:"Specify the name of the instance"` - Output string `local:"true" long:"output" short:"o" usage:"Set output format. Options: table,yaml,json,list" default:"list"` - Ports []string `local:"true" long:"port" short:"p" usage:"Specify the port mapping between external to internal"` - RestartPolicy *kcinstances.RestartPolicy `noattribute:"true"` - Replicas uint `local:"true" long:"replicas" short:"R" usage:"Number of replicas of the instance" default:"0"` - Rollout *RolloutStrategy `noattribute:"true"` - RolloutQualifier *RolloutQualifier `noattribute:"true"` - RolloutWait time.Duration `local:"true" long:"rollout-wait" usage:"Time to wait before performing rolling out action (ms/s/m/h)" default:"10s"` - ServiceNameOrUUID string `local:"true" long:"service" short:"g" usage:"Attach this instance to an existing service"` - Start bool `local:"true" long:"start" short:"S" usage:"Immediately start the instance after creation"` - ScaleToZero *kcinstances.ScaleToZeroPolicy `noattribute:"true"` - ScaleToZeroStateful *bool `local:"true" long:"scale-to-zero-stateful" usage:"Save state when scaling to zero"` - 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"` - - Services []kcservices.CreateRequestService `noattribute:"true"` + Auth *config.AuthConfig `noattribute:"true"` + Client cloud.KraftCloud `noattribute:"true"` + Certificate []string `local:"true" long:"certificate" short:"c" usage:"Set the certificates to use for the service"` + Env []string `local:"true" long:"env" short:"e" usage:"Environmental variables"` + Features []string `local:"true" long:"feature" short:"f" usage:"List of features to enable"` + Domain []string `local:"true" long:"domain" short:"d" usage:"The domain names to use for the service"` + Image string `noattribute:"true"` + Entrypoint types.ShellCommand `local:"true" long:"entrypoint" usage:"Set the entrypoint for the instance"` + Memory string `local:"true" long:"memory" short:"M" usage:"Specify the amount of memory to allocate (MiB increments)"` + Metro string `noattribute:"true"` + Name string `local:"true" long:"name" short:"n" usage:"Specify the name of the instance"` + Output string `local:"true" long:"output" short:"o" usage:"Set output format. Options: table,yaml,json,list" default:"list"` + Ports []string `local:"true" long:"port" short:"p" usage:"Specify the port mapping between external to internal"` + RestartPolicy *ukcinstances.RestartPolicy `noattribute:"true"` + Replicas uint `local:"true" long:"replicas" short:"R" usage:"Number of replicas of the instance" default:"0"` + Rollout *RolloutStrategy `noattribute:"true"` + RolloutQualifier *RolloutQualifier `noattribute:"true"` + RolloutWait time.Duration `local:"true" long:"rollout-wait" usage:"Time to wait before performing rolling out action (ms/s/m/h)" default:"10s"` + ServiceNameOrUUID string `local:"true" long:"service" short:"g" usage:"Attach this instance to an existing service"` + Start bool `local:"true" long:"start" short:"S" usage:"Immediately start the instance after creation"` + ScaleToZero *ukcinstances.ScaleToZeroPolicy `noattribute:"true"` + ScaleToZeroStateful *bool `local:"true" long:"scale-to-zero-stateful" usage:"Save state when scaling to zero"` + 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"` + + Services []ukcservices.CreateRequestService `noattribute:"true"` } -// Create a KraftCloud instance. -func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcclient.ServiceResponse[kcinstances.GetResponseItem], *kcclient.ServiceResponse[kcservices.GetResponseItem], error) { +// Create a UnikraftCloud instance. +func Create(ctx context.Context, opts *CreateOptions, args ...string) (*ukcclient.ServiceResponse[ukcinstances.GetResponseItem], *ukcclient.ServiceResponse[ukcservices.GetResponseItem], error) { var err error if opts == nil { @@ -81,19 +81,19 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcclient } if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return nil, nil, fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } if opts.RestartPolicy == nil { - opts.RestartPolicy = ptr(kcinstances.RestartPolicyNever) + opts.RestartPolicy = ptr(ukcinstances.RestartPolicyNever) } if opts.Rollout == nil { @@ -126,7 +126,7 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcclient opts.Name = strings.ReplaceAll(opts.Name, "/", "-") // Keep a reference of the image that we are going to use for the instance. - var image *kcimages.GetResponseItem + var image *ukcimages.GetResponseItem // Check if the image exists before creating the instance if opts.WaitForImage { @@ -185,16 +185,16 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcclient } } - var features []kcinstances.Feature + var features []ukcinstances.Feature for _, feature := range opts.Features { - formattedFeature := kcinstances.Feature(feature) + formattedFeature := ukcinstances.Feature(feature) if !slices.Contains(features, formattedFeature) { features = append(features, formattedFeature) } } - req := kcinstances.CreateRequest{ + req := ukcinstances.CreateRequest{ Autostart: &opts.Start, Features: features, Image: opts.Image, @@ -247,12 +247,12 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcclient log.G(ctx).Info("no ports or service specified, disabling scale to zero") opts.ScaleToZeroCooldown = 0 opts.ScaleToZeroStateful = nil - off := kcinstances.ScaleToZeroPolicyOff + off := ukcinstances.ScaleToZeroPolicyOff opts.ScaleToZero = &off } if opts.ScaleToZeroCooldown != 0 || opts.ScaleToZeroStateful != nil || opts.ScaleToZero != nil { - req.ScaleToZero = &kcinstances.ScaleToZero{} + req.ScaleToZero = &ukcinstances.ScaleToZero{} } if opts.ScaleToZeroCooldown != 0 { @@ -272,7 +272,7 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcclient if len(split) < 2 || len(split) > 3 { return nil, nil, fmt.Errorf("invalid syntax for -v|--volume: expected VOLUME:PATH[:ro]") } - volume := kcinstances.CreateRequestVolume{ + volume := ukcinstances.CreateRequestVolume{ At: &split[1], } if utils.IsUUID(split[0]) { @@ -291,8 +291,8 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcclient req.Volumes = append(req.Volumes, volume) } - var service *kcservices.GetResponseItem - var qualifiedInstancesToRolloutOver []kcinstances.GetResponseItem + var service *ukcservices.GetResponseItem + var qualifiedInstancesToRolloutOver []ukcinstances.GetResponseItem // Since an existing service has been provided, we should now // preemptively look up information about it. Based on whether there are @@ -319,7 +319,7 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcclient // Save the UUID of the service to be used in the create request // later. - req.ServiceGroup = &kcinstances.CreateRequestServiceGroup{ + req.ServiceGroup = &ukcinstances.CreateRequestServiceGroup{ UUID: &service.UUID, } @@ -330,7 +330,7 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcclient allInstanceUUIDs[i] = instance.UUID } - var instances []kcinstances.GetResponseItem + var instances []ukcinstances.GetResponseItem if len(allInstanceUUIDs) > 0 { log.G(ctx). WithField("service", opts.ServiceNameOrUUID). @@ -403,25 +403,25 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcclient } } - // TODO(nderjung): This should eventually be possible, when the KraftCloud API + // TODO(nderjung): This should eventually be possible, when the UnikraftCloud API // supports updating service. if opts.ServiceNameOrUUID != "" && len(opts.Ports) > 0 { return nil, nil, fmt.Errorf("cannot use existing --service|-g and define new --port|-p") } - // TODO(nderjung): This should eventually be possible, when the KraftCloud API + // TODO(nderjung): This should eventually be possible, when the UnikraftCloud API // supports updating service. if opts.ServiceNameOrUUID != "" && len(opts.Domain) > 0 { return nil, nil, fmt.Errorf("cannot use existing --service|-g and define new --domain|-d") } - // TODO(nderjung): This should eventually be possible, when the KraftCloud API + // TODO(nderjung): This should eventually be possible, when the UnikraftCloud API // supports updating service groups. if opts.ServiceNameOrUUID != "" && len(opts.Certificate) > 0 { return nil, nil, fmt.Errorf("cannot use existing --service-group|-g and define new --certificate|-c") } - // TODO(nderjung): This should eventually be possible, when the KraftCloud API + // TODO(nderjung): This should eventually be possible, when the UnikraftCloud API // supports updating service groups. if opts.ServiceNameOrUUID != "" && len(opts.SubDomain) > 0 { return nil, nil, fmt.Errorf("cannot use existing --service-group|-g and define new --subdomain|-s") @@ -439,28 +439,28 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcclient } port443 := 443 - opts.Services = []kcservices.CreateRequestService{ + opts.Services = []ukcservices.CreateRequestService{ { Port: 443, DestinationPort: &destPort, - Handlers: []kcservices.Handler{ - kcservices.HandlerHTTP, - kcservices.HandlerTLS, + Handlers: []ukcservices.Handler{ + ukcservices.HandlerHTTP, + ukcservices.HandlerTLS, }, }, { Port: 80, DestinationPort: &port443, - Handlers: []kcservices.Handler{ - kcservices.HandlerHTTP, - kcservices.HandlerRedirect, + Handlers: []ukcservices.Handler{ + ukcservices.HandlerHTTP, + ukcservices.HandlerRedirect, }, }, } } else { for _, port := range opts.Ports { - var service kcservices.CreateRequestService + var service ukcservices.CreateRequestService if strings.ContainsRune(port, '/') { split := strings.Split(port, "/") @@ -469,9 +469,9 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcclient } for _, handler := range strings.Split(split[1], "+") { - h := kcservices.Handler(handler) - if !slices.Contains(kcservices.Handlers(), h) { - return nil, nil, fmt.Errorf("unknown handler: %s (choice of %v)", handler, kcservices.Handlers()) + h := ukcservices.Handler(handler) + if !slices.Contains(ukcservices.Handlers(), h) { + return nil, nil, fmt.Errorf("unknown handler: %s (choice of %v)", handler, ukcservices.Handlers()) } service.Handlers = append(service.Handlers, h) @@ -512,19 +512,19 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcclient if len(opts.ServiceNameOrUUID) == 0 { if len(opts.Services) > 0 { - req.ServiceGroup = &kcinstances.CreateRequestServiceGroup{ + req.ServiceGroup = &ukcinstances.CreateRequestServiceGroup{ Services: opts.Services, } } if len(opts.SubDomain) > 0 { if req.ServiceGroup == nil { - req.ServiceGroup = &kcinstances.CreateRequestServiceGroup{ - Domains: []kcservices.CreateRequestDomain{}, + req.ServiceGroup = &ukcinstances.CreateRequestServiceGroup{ + Domains: []ukcservices.CreateRequestDomain{}, Services: opts.Services, } } else { if req.ServiceGroup.Domains == nil { - req.ServiceGroup.Domains = []kcservices.CreateRequestDomain{} + req.ServiceGroup.Domains = []ukcservices.CreateRequestDomain{} } } for _, subDomain := range opts.SubDomain { @@ -534,19 +534,19 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcclient dnsName := strings.TrimSuffix(subDomain, ".") - req.ServiceGroup.Domains = append(req.ServiceGroup.Domains, kcservices.CreateRequestDomain{ + req.ServiceGroup.Domains = append(req.ServiceGroup.Domains, ukcservices.CreateRequestDomain{ Name: dnsName, }) } } else if len(opts.Domain) > 0 { if req.ServiceGroup == nil { - req.ServiceGroup = &kcinstances.CreateRequestServiceGroup{ - Domains: []kcservices.CreateRequestDomain{}, + req.ServiceGroup = &ukcinstances.CreateRequestServiceGroup{ + Domains: []ukcservices.CreateRequestDomain{}, Services: opts.Services, } } else { if req.ServiceGroup.Domains == nil { - req.ServiceGroup.Domains = []kcservices.CreateRequestDomain{} + req.ServiceGroup.Domains = []ukcservices.CreateRequestDomain{} } } @@ -559,17 +559,17 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcclient fqdn += "." } - domainCreate := kcservices.CreateRequestDomain{ + domainCreate := ukcservices.CreateRequestDomain{ Name: fqdn, } if len(opts.Certificate) > i { if utils.IsUUID(opts.Certificate[i]) { - domainCreate.Certificate = &kcservices.CreateRequestDomainCertificate{ + domainCreate.Certificate = &ukcservices.CreateRequestDomainCertificate{ UUID: opts.Certificate[i], } } else { - domainCreate.Certificate = &kcservices.CreateRequestDomainCertificate{ + domainCreate.Certificate = &ukcservices.CreateRequestDomainCertificate{ Name: opts.Certificate[i], } } @@ -602,7 +602,7 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcclient } // Handle the rollout only after the new instance has been created. - // KraftCloud's service load balancer will temporarily handle blue-green + // UnikraftCloud's service load balancer will temporarily handle blue-green // deployments. if opts.Start && len(qualifiedInstancesToRolloutOver) > 0 { paramodel, err := processtree.NewProcessTree( @@ -619,7 +619,7 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcclient "waiting for new instance to start before performing rollout action", "", func(ctx context.Context) error { - _, err := opts.Client.Instances().WithMetro(opts.Metro).Wait(ctx, kcinstances.StateRunning, int(opts.RolloutWait.Milliseconds()), newInstance.UUID) + _, err := opts.Client.Instances().WithMetro(opts.Metro).Wait(ctx, ukcinstances.StateRunning, int(opts.RolloutWait.Milliseconds()), newInstance.UUID) return err }, ), @@ -666,7 +666,7 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcclient return nil, nil, fmt.Errorf("getting details of instance %s: %w", newInstance.UUID, err) } - var serviceResp *kcclient.ServiceResponse[kcservices.GetResponseItem] + var serviceResp *ukcclient.ServiceResponse[ukcservices.GetResponseItem] if sg := instance.ServiceGroup; sg != nil && sg.UUID != "" { serviceResp, err = opts.Client.Services().WithMetro(opts.Metro).Get(ctx, sg.UUID) @@ -714,7 +714,7 @@ func NewCmd() *cobra.Command { Create an instance on Unikraft Cloud from an image. `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-instance", + cmdfactory.AnnotationHelpGroup: "cloud-instance", }, }) if err != nil { @@ -740,18 +740,18 @@ func NewCmd() *cobra.Command { ) cmd.Flags().Var( - cmdfactory.NewEnumFlag[kcinstances.RestartPolicy]( - kcinstances.RestartPolicies(), - kcinstances.RestartPolicyNever, + cmdfactory.NewEnumFlag[ukcinstances.RestartPolicy]( + ukcinstances.RestartPolicies(), + ukcinstances.RestartPolicyNever, ), "restart", "Set the restart policy for the instance (never/always/on-failure)", ) cmd.Flags().Var( - cmdfactory.NewEnumFlag[kcinstances.ScaleToZeroPolicy]( - kcinstances.ScaleToZeroPolicies(), - kcinstances.ScaleToZeroPolicyOff, + cmdfactory.NewEnumFlag[ukcinstances.ScaleToZeroPolicy]( + ukcinstances.ScaleToZeroPolicies(), + ukcinstances.ScaleToZeroPolicyOff, ), "scale-to-zero", "Scale to zero policy of the instance (on/off/idle)", @@ -770,12 +770,12 @@ func (opts *CreateOptions) Pre(cmd *cobra.Command, _ []string) error { return fmt.Errorf("scale-to-zero-cooldown needs to be at least 1ms: %s", opts.ScaleToZeroCooldown) } - opts.RestartPolicy = ptr(kcinstances.RestartPolicy(cmd.Flag("restart").Value.String())) + opts.RestartPolicy = ptr(ukcinstances.RestartPolicy(cmd.Flag("restart").Value.String())) opts.Rollout = ptr(RolloutStrategy(cmd.Flag("rollout").Value.String())) opts.RolloutQualifier = ptr(RolloutQualifier(cmd.Flag("rollout-qualifier").Value.String())) if cmd.Flag("scale-to-zero").Changed { - s20v := kcinstances.ScaleToZeroPolicy(cmd.Flag("scale-to-zero").Value.String()) + s20v := ukcinstances.ScaleToZeroPolicy(cmd.Flag("scale-to-zero").Value.String()) opts.ScaleToZero = &s20v } diff --git a/internal/cli/kraft/cloud/instance/get/get.go b/internal/cli/kraft/cloud/instance/get/get.go index 393328576..2b37117eb 100644 --- a/internal/cli/kraft/cloud/instance/get/get.go +++ b/internal/cli/kraft/cloud/instance/get/get.go @@ -12,7 +12,7 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" + cloud "sdk.kraft.cloud" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -20,14 +20,14 @@ import ( ) type GetOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kraftcloud.KraftCloud `noattribute:"true"` - Metro string `noattribute:"true"` - Token string `noattribute:"true"` - Output string `long:"output" short:"o" usage:"Set output format. Options: table,yaml,json,list" default:"list"` + Auth *config.AuthConfig `noattribute:"true"` + Client cloud.KraftCloud `noattribute:"true"` + Metro string `noattribute:"true"` + Token string `noattribute:"true"` + Output string `long:"output" short:"o" usage:"Set output format. Options: table,yaml,json,list" default:"list"` } -// Status of a KraftCloud instance. +// Status of a UnikraftCloud instance. func Get(ctx context.Context, opts *GetOptions, args ...string) error { if opts == nil { opts = &GetOptions{} @@ -53,7 +53,7 @@ func NewCmd() *cobra.Command { Retrieve the state of an instance. `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-instance", + cmdfactory.AnnotationHelpGroup: "cloud-instance", }, }) if err != nil { @@ -77,13 +77,13 @@ func (opts *GetOptions) Pre(cmd *cobra.Command, _ []string) error { } func (opts *GetOptions) Run(ctx context.Context, args []string) error { - auth, err := config.GetKraftCloudAuthConfig(ctx, opts.Token) + auth, err := config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } - client := kraftcloud.NewInstancesClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*auth)), + client := cloud.NewInstancesClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*auth)), ) resp, err := client.WithMetro(opts.Metro).Get(ctx, args...) diff --git a/internal/cli/kraft/cloud/instance/instance.go b/internal/cli/kraft/cloud/instance/instance.go index 660521800..e68f16fee 100644 --- a/internal/cli/kraft/cloud/instance/instance.go +++ b/internal/cli/kraft/cloud/instance/instance.go @@ -31,7 +31,7 @@ func NewCmd() *cobra.Command { Aliases: []string{"inst", "instances", "vm", "vms"}, Long: "Manage instances on Unikraft Cloud.", Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-instance", + cmdfactory.AnnotationHelpGroup: "cloud-instance", cmdfactory.AnnotationHelpHidden: "true", }, }) diff --git a/internal/cli/kraft/cloud/instance/list/list.go b/internal/cli/kraft/cloud/instance/list/list.go index 9cfa04861..6d046a942 100644 --- a/internal/cli/kraft/cloud/instance/list/list.go +++ b/internal/cli/kraft/cloud/instance/list/list.go @@ -11,7 +11,7 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" + cloud "sdk.kraft.cloud" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -39,7 +39,7 @@ func NewCmd() *cobra.Command { List all instances in your account. `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-instance", + cmdfactory.AnnotationHelpGroup: "cloud-instance", }, }) if err != nil { @@ -63,13 +63,13 @@ func (opts *ListOptions) Pre(cmd *cobra.Command, _ []string) error { } func (opts *ListOptions) Run(ctx context.Context, args []string) error { - auth, err := config.GetKraftCloudAuthConfig(ctx, opts.token) + auth, err := config.GetUnikraftCloudAuthConfig(ctx, opts.token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } - client := kraftcloud.NewInstancesClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*auth)), + client := cloud.NewInstancesClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*auth)), ) resp, err := client.WithMetro(opts.metro).List(ctx) diff --git a/internal/cli/kraft/cloud/instance/logs/logs.go b/internal/cli/kraft/cloud/instance/logs/logs.go index 998252b4e..6a72ccd29 100644 --- a/internal/cli/kraft/cloud/instance/logs/logs.go +++ b/internal/cli/kraft/cloud/instance/logs/logs.go @@ -15,8 +15,8 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" - kcinstances "sdk.kraft.cloud/instances" + cloud "sdk.kraft.cloud" + ukcinstances "sdk.kraft.cloud/instances" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -28,17 +28,17 @@ import ( ) type LogOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kraftcloud.KraftCloud `noattribute:"true"` - Follow bool `local:"true" long:"follow" short:"f" usage:"Follow the logs of the instance every half second" default:"false"` - Metro string `noattribute:"true"` - NoPrefix bool `long:"no-prefix" usage:"When logging multiple machines, do not prefix each log line with the name"` - Prefix string `local:"true" long:"prefix" short:"p" usage:"Prefix the logs with a given string"` - Tail int `local:"true" long:"tail" short:"n" usage:"Show the last given lines from the logs" default:"-1"` - Token string `noattribute:"true"` + Auth *config.AuthConfig `noattribute:"true"` + Client cloud.KraftCloud `noattribute:"true"` + Follow bool `local:"true" long:"follow" short:"f" usage:"Follow the logs of the instance every half second" default:"false"` + Metro string `noattribute:"true"` + NoPrefix bool `long:"no-prefix" usage:"When logging multiple machines, do not prefix each log line with the name"` + Prefix string `local:"true" long:"prefix" short:"p" usage:"Prefix the logs with a given string"` + Tail int `local:"true" long:"tail" short:"n" usage:"Show the last given lines from the logs" default:"-1"` + Token string `noattribute:"true"` } -// Log retrieves the console output from a KraftCloud instance. +// Log retrieves the console output from a UnikraftCloud instance. func Log(ctx context.Context, opts *LogOptions, args ...string) error { if opts == nil { opts = &LogOptions{} @@ -73,7 +73,7 @@ func NewCmd() *cobra.Command { Get console output of an instance. `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-instance", + cmdfactory.AnnotationHelpGroup: "cloud-instance", }, }) if err != nil { @@ -104,15 +104,15 @@ func Logs(ctx context.Context, opts *LogOptions, args ...string) error { var err error if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } @@ -150,7 +150,7 @@ func Logs(ctx context.Context, opts *LogOptions, args ...string) error { observations.Add(instance) - var inst *kcinstances.GetResponseItem + var inst *ukcinstances.GetResponseItem // Continuously check the state in a separate thread every 1 second. go func() { @@ -195,7 +195,7 @@ func Logs(ctx context.Context, opts *LogOptions, args ...string) error { if ok { consumer.Consume(line) } else { - if inst != nil && inst.State == kcinstances.InstanceStateStopped { + if inst != nil && inst.State == ukcinstances.InstanceStateStopped { consumer.Consume( "", fmt.Sprintf("The instance has exited (%s).", inst.DescribeStopReason()), @@ -212,7 +212,7 @@ func Logs(ctx context.Context, opts *LogOptions, args ...string) error { // If we have not received anything after 1 second through any of the // other channels, check if the instance has stopped and exit if it // has. - if inst != nil && inst.State == kcinstances.InstanceStateStopped { + if inst != nil && inst.State == ukcinstances.InstanceStateStopped { consumer.Consume( "", fmt.Sprintf("The instance has exited (%s).", inst.DescribeStopReason()), diff --git a/internal/cli/kraft/cloud/instance/remove/remove.go b/internal/cli/kraft/cloud/instance/remove/remove.go index 9f535cf89..00d1f6df4 100644 --- a/internal/cli/kraft/cloud/instance/remove/remove.go +++ b/internal/cli/kraft/cloud/instance/remove/remove.go @@ -12,8 +12,8 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" - kcinstances "sdk.kraft.cloud/instances" + cloud "sdk.kraft.cloud" + ukcinstances "sdk.kraft.cloud/instances" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -22,12 +22,12 @@ import ( ) type RemoveOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kraftcloud.KraftCloud `noattribute:"true"` - All bool `long:"all" short:"a" usage:"Remove all instances"` - Stopped bool `long:"stopped" short:"s" usage:"Remove all stopped instances"` - Metro string `noattribute:"true"` - Token string `noattribute:"true"` + Auth *config.AuthConfig `noattribute:"true"` + Client cloud.KraftCloud `noattribute:"true"` + All bool `long:"all" short:"a" usage:"Remove all instances"` + Stopped bool `long:"stopped" short:"s" usage:"Remove all stopped instances"` + Metro string `noattribute:"true"` + Token string `noattribute:"true"` } func NewCmd() *cobra.Command { @@ -53,10 +53,10 @@ func NewCmd() *cobra.Command { $ kraft cloud instance remove --stopped `), Long: heredoc.Doc(` - Remove a KraftCloud instance. + Remove a UnikraftCloud instance. `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-instance", + cmdfactory.AnnotationHelpGroup: "cloud-instance", }, }) if err != nil { @@ -79,7 +79,7 @@ func (opts *RemoveOptions) Run(ctx context.Context, args []string) error { return Remove(ctx, opts, args...) } -// Remove KraftCloud instance(s). +// Remove UnikraftCloud instance(s). func Remove(ctx context.Context, opts *RemoveOptions, args ...string) error { var err error @@ -97,15 +97,15 @@ func Remove(ctx context.Context, opts *RemoveOptions, args ...string) error { } if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } @@ -143,7 +143,7 @@ func Remove(ctx context.Context, opts *RemoveOptions, args ...string) error { var stoppedUuids []string for _, instInfo := range instInfos { - if kcinstances.State(instInfo.State) == kcinstances.StateStopped { + if ukcinstances.State(instInfo.State) == ukcinstances.StateStopped { stoppedUuids = append(stoppedUuids, instInfo.UUID) } } diff --git a/internal/cli/kraft/cloud/instance/start/start.go b/internal/cli/kraft/cloud/instance/start/start.go index 5e479727f..d9e88cce0 100644 --- a/internal/cli/kraft/cloud/instance/start/start.go +++ b/internal/cli/kraft/cloud/instance/start/start.go @@ -13,7 +13,7 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" + cloud "sdk.kraft.cloud" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -22,12 +22,12 @@ import ( ) type StartOptions struct { - All bool `long:"all" short:"a" usage:"Start all instances"` - Auth *config.AuthConfig `noattribute:"true"` - Client kraftcloud.KraftCloud `noattribute:"true"` - Metro string `noattribute:"true"` - Token string `noattribute:"true"` - Wait time.Duration `local:"true" long:"wait" short:"w" usage:"Timeout to wait for the instance to start (ms/s/m/h)"` + All bool `long:"all" short:"a" usage:"Start all instances"` + Auth *config.AuthConfig `noattribute:"true"` + Client cloud.KraftCloud `noattribute:"true"` + Metro string `noattribute:"true"` + Token string `noattribute:"true"` + Wait time.Duration `local:"true" long:"wait" short:"w" usage:"Timeout to wait for the instance to start (ms/s/m/h)"` } func NewCmd() *cobra.Command { @@ -47,10 +47,10 @@ func NewCmd() *cobra.Command { $ kraft cloud instance start my-instance-431342 my-instance-other-2313 `), Long: heredoc.Doc(` - Start an instance on KraftCloud from a stopped instance. + Start an instance on UnikraftCloud from a stopped instance. `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-instance", + cmdfactory.AnnotationHelpGroup: "cloud-instance", }, }) if err != nil { @@ -73,20 +73,20 @@ func (opts *StartOptions) Run(ctx context.Context, args []string) error { return Start(ctx, opts, args...) } -// Start KraftCloud instance(s). +// Start UnikraftCloud instance(s). func Start(ctx context.Context, opts *StartOptions, args ...string) error { var err error if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } diff --git a/internal/cli/kraft/cloud/instance/stop/stop.go b/internal/cli/kraft/cloud/instance/stop/stop.go index ae1c1ce6f..8d66a7898 100644 --- a/internal/cli/kraft/cloud/instance/stop/stop.go +++ b/internal/cli/kraft/cloud/instance/stop/stop.go @@ -13,7 +13,7 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" + cloud "sdk.kraft.cloud" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -22,14 +22,14 @@ import ( ) type StopOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kraftcloud.KraftCloud `noattribute:"true"` - Wait time.Duration `local:"true" long:"wait" short:"w" usage:"Time to wait for the instance to drain all connections before it is stopped (ms/s/m/h)"` - DrainTimeout time.Duration `local:"true" long:"drain-timeout" short:"d" usage:"Timeout for the instance to stop (ms/s/m/h)"` - All bool `long:"all" short:"a" usage:"Stop all instances"` - Force bool `long:"force" short:"f" usage:"Force stop the instance(s)"` - Metro string `noattribute:"true"` - Token string `noattribute:"true"` + Auth *config.AuthConfig `noattribute:"true"` + Client cloud.KraftCloud `noattribute:"true"` + Wait time.Duration `local:"true" long:"wait" short:"w" usage:"Time to wait for the instance to drain all connections before it is stopped (ms/s/m/h)"` + DrainTimeout time.Duration `local:"true" long:"drain-timeout" short:"d" usage:"Timeout for the instance to stop (ms/s/m/h)"` + All bool `long:"all" short:"a" usage:"Stop all instances"` + Force bool `long:"force" short:"f" usage:"Force stop the instance(s)"` + Metro string `noattribute:"true"` + Token string `noattribute:"true"` } func NewCmd() *cobra.Command { @@ -55,7 +55,7 @@ func NewCmd() *cobra.Command { $ kraft cloud instance stop --wait 5s my-instance-431342 `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-instance", + cmdfactory.AnnotationHelpGroup: "cloud-instance", }, }) if err != nil { @@ -82,7 +82,7 @@ func (opts *StopOptions) Run(ctx context.Context, args []string) error { return Stop(ctx, opts, args...) } -// Stop KraftCloud instance(s). +// Stop UnikraftCloud instance(s). func Stop(ctx context.Context, opts *StopOptions, args ...string) error { var err error @@ -100,15 +100,15 @@ func Stop(ctx context.Context, opts *StopOptions, args ...string) error { } if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } diff --git a/internal/cli/kraft/cloud/metros/list/list.go b/internal/cli/kraft/cloud/metros/list/list.go index 891601a1b..277930585 100644 --- a/internal/cli/kraft/cloud/metros/list/list.go +++ b/internal/cli/kraft/cloud/metros/list/list.go @@ -13,7 +13,7 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" + cloud "sdk.kraft.cloud" "kraftkit.sh/cmdfactory" "kraftkit.sh/internal/cli/kraft/cloud/utils" @@ -29,12 +29,12 @@ type ListOptions struct { func NewCmd() *cobra.Command { cmd, err := cmdfactory.New(&ListOptions{}, cobra.Command{ - Short: "List metros on KraftCloud", + Short: "List metros on UnikraftCloud", Use: "list", Args: cobra.NoArgs, Aliases: []string{"ls"}, Long: heredoc.Doc(` - List metros on KraftCloud. + List metros on cloud. `), Example: heredoc.Doc(` # List metros available. @@ -47,7 +47,7 @@ func NewCmd() *cobra.Command { $ kraft cloud metro list --status `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-metro", + cmdfactory.AnnotationHelpGroup: "cloud-metro", }, }) if err != nil { @@ -66,7 +66,7 @@ func (opts *ListOptions) Pre(cmd *cobra.Command, _ []string) error { } func (opts *ListOptions) Run(ctx context.Context, args []string) error { - client := kraftcloud.NewMetrosClient() + client := cloud.NewMetrosClient() metros, err := client.List(ctx, opts.Status) if err != nil { diff --git a/internal/cli/kraft/cloud/metros/metros.go b/internal/cli/kraft/cloud/metros/metros.go index 7395c49a0..70c68420e 100644 --- a/internal/cli/kraft/cloud/metros/metros.go +++ b/internal/cli/kraft/cloud/metros/metros.go @@ -35,7 +35,7 @@ func NewCmd() *cobra.Command { $ kraft cloud metro list --status `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-metro", + cmdfactory.AnnotationHelpGroup: "cloud-metro", cmdfactory.AnnotationHelpHidden: "true", }, }) diff --git a/internal/cli/kraft/cloud/quotas/quotas.go b/internal/cli/kraft/cloud/quotas/quotas.go index b454b09c3..e5a64df82 100644 --- a/internal/cli/kraft/cloud/quotas/quotas.go +++ b/internal/cli/kraft/cloud/quotas/quotas.go @@ -18,7 +18,7 @@ import ( "kraftkit.sh/iostreams" "kraftkit.sh/log" - kraftcloud "sdk.kraft.cloud" + cloud "sdk.kraft.cloud" ) type QuotasOptions struct { @@ -35,7 +35,7 @@ func NewCmd() *cobra.Command { Args: cobra.NoArgs, Aliases: []string{"q", "quota"}, Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud", + cmdfactory.AnnotationHelpGroup: "cloud", }, Example: heredoc.Doc(` # View your resource quota on Unikraft Cloud @@ -66,13 +66,13 @@ func (opts *QuotasOptions) Pre(cmd *cobra.Command, _ []string) error { } func (opts *QuotasOptions) Run(ctx context.Context, _ []string) error { - auth, err := config.GetKraftCloudAuthConfig(ctx, opts.token) + auth, err := config.GetUnikraftCloudAuthConfig(ctx, opts.token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } - client := kraftcloud.NewClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*auth)), + client := cloud.NewClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*auth)), ) resp, err := client.Users().WithMetro(opts.metro).Quotas(ctx) diff --git a/internal/cli/kraft/cloud/scale/add/add.go b/internal/cli/kraft/cloud/scale/add/add.go index 861cc9e46..5f2fea0de 100644 --- a/internal/cli/kraft/cloud/scale/add/add.go +++ b/internal/cli/kraft/cloud/scale/add/add.go @@ -13,8 +13,8 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" - kcautoscale "sdk.kraft.cloud/services/autoscale" + cloud "sdk.kraft.cloud" + ukcautoscale "sdk.kraft.cloud/services/autoscale" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -22,14 +22,14 @@ import ( ) type AddOptions struct { - Adjustment string `long:"adjustment" short:"a" usage:"The adjustment of the policy. Valid options: 'percent', 'absolute', 'change'" default:"change"` - Auth *config.AuthConfig `noattribute:"true"` - Client kraftcloud.KraftCloud `noattribute:"true"` - Metric string `long:"metric" short:"m" usage:"The metric of the policy. Valid options: 'cpu'" default:"cpu"` - Metro string `noattribute:"true"` - Name string `long:"name" short:"n" usage:"The name of the policy"` - Step []string `long:"step" short:"s" usage:"The step of the policy in the format 'LOWER_BOUND:UPPER_BOUND/ADJUSTMENT'"` - Token string `noattribute:"true"` + Adjustment string `long:"adjustment" short:"a" usage:"The adjustment of the policy. Valid options: 'percent', 'absolute', 'change'" default:"change"` + Auth *config.AuthConfig `noattribute:"true"` + Client cloud.KraftCloud `noattribute:"true"` + Metric string `long:"metric" short:"m" usage:"The metric of the policy. Valid options: 'cpu'" default:"cpu"` + Metro string `noattribute:"true"` + Name string `long:"name" short:"n" usage:"The name of the policy"` + Step []string `long:"step" short:"s" usage:"The step of the policy in the format 'LOWER_BOUND:UPPER_BOUND/ADJUSTMENT'"` + Token string `noattribute:"true"` } // stepFormat holds the step format of the policy for parsing. @@ -56,7 +56,7 @@ func NewCmd() *cobra.Command { $ kraft cloud scale add my-service --name my-policy --step 0:10/1 --step 10:20/2 `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-scale", + cmdfactory.AnnotationHelpGroup: "cloud-scale", }, }) if err != nil { @@ -91,15 +91,15 @@ func (opts *AddOptions) Run(ctx context.Context, args []string) error { } if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } @@ -171,13 +171,13 @@ func (opts *AddOptions) Run(ctx context.Context, args []string) error { } } - stepPol := kcautoscale.StepPolicy{ + stepPol := ukcautoscale.StepPolicy{ Name: opts.Name, - Metric: kcautoscale.PolicyMetric(opts.Metric), - AdjustmentType: kcautoscale.AdjustmentType(opts.Adjustment), + Metric: ukcautoscale.PolicyMetric(opts.Metric), + AdjustmentType: ukcautoscale.AdjustmentType(opts.Adjustment), } for _, step := range steps { - s := kcautoscale.Step{ + s := ukcautoscale.Step{ Adjustment: step.Adjustment, } if !step.LowerEmpty { diff --git a/internal/cli/kraft/cloud/scale/get/get.go b/internal/cli/kraft/cloud/scale/get/get.go index a70818441..b1e7f7f64 100644 --- a/internal/cli/kraft/cloud/scale/get/get.go +++ b/internal/cli/kraft/cloud/scale/get/get.go @@ -14,7 +14,7 @@ import ( "github.com/spf13/cobra" "gopkg.in/yaml.v2" - kraftcloud "sdk.kraft.cloud" + cloud "sdk.kraft.cloud" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -25,12 +25,12 @@ import ( ) type GetOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kraftcloud.KraftCloud `noattribute:"true"` - Metro string `noattribute:"true"` - Output string `long:"output" short:"o" usage:"Output format" default:"list"` - Policy string `long:"policy" short:"p" usage:"Get a policy instead of a configuration"` - Token string `noattribute:"true"` + Auth *config.AuthConfig `noattribute:"true"` + Client cloud.KraftCloud `noattribute:"true"` + Metro string `noattribute:"true"` + Output string `long:"output" short:"o" usage:"Output format" default:"list"` + Policy string `long:"policy" short:"p" usage:"Get a policy instead of a configuration"` + Token string `noattribute:"true"` } func NewCmd() *cobra.Command { @@ -54,7 +54,7 @@ func NewCmd() *cobra.Command { $ kraft cloud scale get my-service --policy my-policy `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-scale", + cmdfactory.AnnotationHelpGroup: "cloud-scale", }, }) if err != nil { @@ -81,15 +81,15 @@ func (opts *GetOptions) Run(ctx context.Context, args []string) error { var err error if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } diff --git a/internal/cli/kraft/cloud/scale/initialize/initialize.go b/internal/cli/kraft/cloud/scale/initialize/initialize.go index edc0f6e28..b7f428d7f 100644 --- a/internal/cli/kraft/cloud/scale/initialize/initialize.go +++ b/internal/cli/kraft/cloud/scale/initialize/initialize.go @@ -14,9 +14,9 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" - kcinstances "sdk.kraft.cloud/instances" - kcautoscale "sdk.kraft.cloud/services/autoscale" + cloud "sdk.kraft.cloud" + ukcinstances "sdk.kraft.cloud/instances" + ukcautoscale "sdk.kraft.cloud/services/autoscale" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -25,15 +25,15 @@ import ( ) type InitOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kraftcloud.KraftCloud `noattribute:"true"` - CooldownTime time.Duration `long:"cooldown-time" short:"c" usage:"The cooldown time of the config (ms/s/m/h)" default:"1000000000"` - Master string `long:"master" short:"i" usage:"The UUID or Name of the master instance"` - MaxSize int `long:"max-size" short:"M" usage:"The maximum size of the configuration" default:"10"` - Metro string `noattribute:"true"` - MinSize string `long:"min-size" short:"m" usage:"The minimum size of the configuration"` - Token string `noattribute:"true"` - WarmupTime time.Duration `long:"warmup-time" short:"w" usage:"The warmup time of the config (ms/s/m/h)" default:"1000000000"` + Auth *config.AuthConfig `noattribute:"true"` + Client cloud.KraftCloud `noattribute:"true"` + CooldownTime time.Duration `long:"cooldown-time" short:"c" usage:"The cooldown time of the config (ms/s/m/h)" default:"1000000000"` + Master string `long:"master" short:"i" usage:"The UUID or Name of the master instance"` + MaxSize int `long:"max-size" short:"M" usage:"The maximum size of the configuration" default:"10"` + Metro string `noattribute:"true"` + MinSize string `long:"min-size" short:"m" usage:"The minimum size of the configuration"` + Token string `noattribute:"true"` + WarmupTime time.Duration `long:"warmup-time" short:"w" usage:"The warmup time of the config (ms/s/m/h)" default:"1000000000"` } func NewCmd() *cobra.Command { @@ -52,7 +52,7 @@ func NewCmd() *cobra.Command { --warmup-time 1s `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-scale", + cmdfactory.AnnotationHelpGroup: "cloud-scale", }, }) if err != nil { @@ -79,15 +79,15 @@ func (opts *InitOptions) Run(ctx context.Context, args []string) error { var err error if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } @@ -115,7 +115,7 @@ func (opts *InitOptions) Run(ctx context.Context, args []string) error { return fmt.Errorf("cooldown time must be at least 10ms") } - var master kcautoscale.CreateRequestMaster + var master ukcautoscale.CreateRequestMaster if opts.Master == "" { if config.G[config.KraftKit](ctx).NoPrompt { @@ -182,7 +182,7 @@ func (opts *InitOptions) Run(ctx context.Context, args []string) error { } } - req := kcautoscale.CreateRequest{ + req := ukcautoscale.CreateRequest{ UUID: &id, Master: master, } @@ -219,7 +219,7 @@ func (opts *InitOptions) Run(ctx context.Context, args []string) error { } type stringerInstance struct { - *kcinstances.GetResponseItem + *ukcinstances.GetResponseItem } var _ fmt.Stringer = (*stringerInstance)(nil) diff --git a/internal/cli/kraft/cloud/scale/remove/remove.go b/internal/cli/kraft/cloud/scale/remove/remove.go index 2b428331c..415fa590d 100644 --- a/internal/cli/kraft/cloud/scale/remove/remove.go +++ b/internal/cli/kraft/cloud/scale/remove/remove.go @@ -12,8 +12,8 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" - kcautoscale "sdk.kraft.cloud/services/autoscale" + cloud "sdk.kraft.cloud" + ukcautoscale "sdk.kraft.cloud/services/autoscale" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -21,10 +21,10 @@ import ( ) type RemoveOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kcautoscale.AutoscaleService `noattribute:"true"` - Metro string `noattribute:"true"` - Token string `noattribute:"true"` + Auth *config.AuthConfig `noattribute:"true"` + Client ukcautoscale.AutoscaleService `noattribute:"true"` + Metro string `noattribute:"true"` + Token string `noattribute:"true"` } func NewCmd() *cobra.Command { @@ -41,7 +41,7 @@ func NewCmd() *cobra.Command { $ kraft cloud scale remove my-service my-policy `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-scale", + cmdfactory.AnnotationHelpGroup: "cloud-scale", }, }) if err != nil { @@ -72,15 +72,15 @@ func (opts *RemoveOptions) Run(ctx context.Context, args []string) error { } if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewAutoscaleClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewAutoscaleClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } diff --git a/internal/cli/kraft/cloud/scale/reset/reset.go b/internal/cli/kraft/cloud/scale/reset/reset.go index ba4da6b1c..ff31c8ba6 100644 --- a/internal/cli/kraft/cloud/scale/reset/reset.go +++ b/internal/cli/kraft/cloud/scale/reset/reset.go @@ -12,8 +12,8 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" - kcautoscale "sdk.kraft.cloud/services/autoscale" + cloud "sdk.kraft.cloud" + ukcautoscale "sdk.kraft.cloud/services/autoscale" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -21,10 +21,10 @@ import ( ) type ResetOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kcautoscale.AutoscaleService `noattribute:"true"` - Metro string `noattribute:"true"` - Token string `noattribute:"true"` + Auth *config.AuthConfig `noattribute:"true"` + Client ukcautoscale.AutoscaleService `noattribute:"true"` + Metro string `noattribute:"true"` + Token string `noattribute:"true"` } func NewCmd() *cobra.Command { @@ -41,7 +41,7 @@ func NewCmd() *cobra.Command { $ kraft cloud scale reset my-service `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-scale", + cmdfactory.AnnotationHelpGroup: "cloud-scale", }, }) if err != nil { @@ -68,15 +68,15 @@ func (opts *ResetOptions) Run(ctx context.Context, args []string) error { var err error if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewAutoscaleClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewAutoscaleClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } diff --git a/internal/cli/kraft/cloud/scale/scale.go b/internal/cli/kraft/cloud/scale/scale.go index 2fcbc983c..6f2e13f5e 100644 --- a/internal/cli/kraft/cloud/scale/scale.go +++ b/internal/cli/kraft/cloud/scale/scale.go @@ -33,7 +33,7 @@ func NewCmd() *cobra.Command { $ kraft cloud scale add my-service my-policy `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-scale", + cmdfactory.AnnotationHelpGroup: "cloud-scale", cmdfactory.AnnotationHelpHidden: "true", }, }) diff --git a/internal/cli/kraft/cloud/service/create/create.go b/internal/cli/kraft/cloud/service/create/create.go index 5b0e12984..d57368155 100644 --- a/internal/cli/kraft/cloud/service/create/create.go +++ b/internal/cli/kraft/cloud/service/create/create.go @@ -15,8 +15,8 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" - kcservices "sdk.kraft.cloud/services" + cloud "sdk.kraft.cloud" + ukcservices "sdk.kraft.cloud/services" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -24,21 +24,21 @@ import ( ) type CreateOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kcservices.ServicesService `noattribute:"true"` - Certificate []string `local:"true" long:"certificate" short:"c" usage:"Set the certificates to use for the service"` - Domain []string `local:"true" long:"domain" short:"d" usage:"Specify the domain names of the service"` - SubDomain []string `local:"true" long:"subdomain" short:"s" usage:"Set the subdomains to use when creating the service"` - SoftLimit uint `local:"true" long:"soft-limit" short:"l" usage:"Set the soft limit for the service"` - HardLimit uint `local:"true" long:"hard-limit" short:"L" usage:"Set the hard limit for the service"` - Metro string `noattribute:"true"` - Name string `local:"true" long:"name" short:"n" usage:"Specify the name of the service"` - Output string `local:"true" long:"output" short:"o" usage:"Set output format. Options: table,yaml,json,list" default:"table"` - Token string `noattribute:"true"` + Auth *config.AuthConfig `noattribute:"true"` + Client ukcservices.ServicesService `noattribute:"true"` + Certificate []string `local:"true" long:"certificate" short:"c" usage:"Set the certificates to use for the service"` + Domain []string `local:"true" long:"domain" short:"d" usage:"Specify the domain names of the service"` + SubDomain []string `local:"true" long:"subdomain" short:"s" usage:"Set the subdomains to use when creating the service"` + SoftLimit uint `local:"true" long:"soft-limit" short:"l" usage:"Set the soft limit for the service"` + HardLimit uint `local:"true" long:"hard-limit" short:"L" usage:"Set the hard limit for the service"` + Metro string `noattribute:"true"` + Name string `local:"true" long:"name" short:"n" usage:"Specify the name of the service"` + Output string `local:"true" long:"output" short:"o" usage:"Set output format. Options: table,yaml,json,list" default:"table"` + Token string `noattribute:"true"` } -// Create a KraftCloud instance. -func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcservices.CreateResponseItem, error) { +// Create a UnikraftCloud instance. +func Create(ctx context.Context, opts *CreateOptions, args ...string) (*ukcservices.CreateResponseItem, error) { var err error if opts == nil { @@ -54,18 +54,18 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcservic } if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return nil, fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewServicesClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewServicesClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } - var services []kcservices.CreateRequestService + var services []ukcservices.CreateRequestService if len(args) == 1 && strings.HasPrefix(args[0], "443:") && strings.Count(args[0], "/") == 0 { split := strings.Split(args[0], ":") @@ -78,32 +78,32 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcservic return nil, fmt.Errorf("invalid external port: %w", err) } - services = make([]kcservices.CreateRequestService, 0, 2) + services = make([]ukcservices.CreateRequestService, 0, 2) port443 := 443 services = append(services, - kcservices.CreateRequestService{ + ukcservices.CreateRequestService{ Port: 443, DestinationPort: &destPort, - Handlers: []kcservices.Handler{ - kcservices.HandlerHTTP, - kcservices.HandlerTLS, + Handlers: []ukcservices.Handler{ + ukcservices.HandlerHTTP, + ukcservices.HandlerTLS, }, }, - kcservices.CreateRequestService{ + ukcservices.CreateRequestService{ Port: 80, DestinationPort: &port443, - Handlers: []kcservices.Handler{ - kcservices.HandlerHTTP, - kcservices.HandlerRedirect, + Handlers: []ukcservices.Handler{ + ukcservices.HandlerHTTP, + ukcservices.HandlerRedirect, }, }, ) } else { - services = make([]kcservices.CreateRequestService, 0, len(args)) + services = make([]ukcservices.CreateRequestService, 0, len(args)) for _, port := range args { - var service kcservices.CreateRequestService + var service ukcservices.CreateRequestService if strings.ContainsRune(port, '/') { split := strings.Split(port, "/") @@ -112,9 +112,9 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcservic } for _, handler := range strings.Split(split[1], "+") { - h := kcservices.Handler(handler) - if !slices.Contains(kcservices.Handlers(), h) { - return nil, fmt.Errorf("unknown handler: %s (choice of %v)", handler, kcservices.Handlers()) + h := ukcservices.Handler(handler) + if !slices.Contains(ukcservices.Handlers(), h) { + return nil, fmt.Errorf("unknown handler: %s (choice of %v)", handler, ukcservices.Handlers()) } service.Handlers = append(service.Handlers, h) @@ -153,9 +153,9 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcservic } } - req := kcservices.CreateRequest{ + req := ukcservices.CreateRequest{ Services: services, - Domains: []kcservices.CreateRequestDomain{}, + Domains: []ukcservices.CreateRequestDomain{}, } if opts.Name != "" { req.Name = &opts.Name @@ -174,17 +174,17 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcservic fqdn += "." } - domainCreate := kcservices.CreateRequestDomain{ + domainCreate := ukcservices.CreateRequestDomain{ Name: fqdn, } if len(opts.Certificate) > i { if utils.IsUUID(opts.Certificate[i]) { - domainCreate.Certificate = &kcservices.CreateRequestDomainCertificate{ + domainCreate.Certificate = &ukcservices.CreateRequestDomainCertificate{ UUID: opts.Certificate[i], } } else { - domainCreate.Certificate = &kcservices.CreateRequestDomainCertificate{ + domainCreate.Certificate = &ukcservices.CreateRequestDomainCertificate{ Name: opts.Certificate[i], } } @@ -195,7 +195,7 @@ func Create(ctx context.Context, opts *CreateOptions, args ...string) (*kcservic for _, subdomain := range opts.SubDomain { dnsName := strings.TrimSuffix(subdomain, ".") - req.Domains = append(req.Domains, kcservices.CreateRequestDomain{ + req.Domains = append(req.Domains, ukcservices.CreateRequestDomain{ Name: dnsName, }) } @@ -224,7 +224,7 @@ func NewCmd() *cobra.Command { $ kraft cloud service create -n my-service 443:8080/http+tls `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-svc", + cmdfactory.AnnotationHelpGroup: "cloud-svc", }, }) if err != nil { diff --git a/internal/cli/kraft/cloud/service/get/get.go b/internal/cli/kraft/cloud/service/get/get.go index 0596504c4..48514767d 100644 --- a/internal/cli/kraft/cloud/service/get/get.go +++ b/internal/cli/kraft/cloud/service/get/get.go @@ -12,7 +12,7 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" + cloud "sdk.kraft.cloud" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -26,7 +26,7 @@ type GetOptions struct { token string } -// State of a KraftCloud instance. +// State of a UnikraftCloud instance. func Get(ctx context.Context, opts *GetOptions, args ...string) error { if opts == nil { opts = &GetOptions{} @@ -42,14 +42,14 @@ func NewCmd() *cobra.Command { Args: cobra.ExactArgs(1), Aliases: []string{"gt"}, Example: heredoc.Doc(` - # Retrieve information about a kraftcloud service + # Retrieve information about a cloud service $ kraft cloud service get fd1684ea-7970-4994-92d6-61dcc7905f2b - # Retrieve information about a kraftcloud service + # Retrieve information about a cloud service $ kraft cloud service get my-service `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-svc", + cmdfactory.AnnotationHelpGroup: "cloud-svc", }, }) if err != nil { @@ -73,13 +73,13 @@ func (opts *GetOptions) Pre(cmd *cobra.Command, _ []string) error { } func (opts *GetOptions) Run(ctx context.Context, args []string) error { - auth, err := config.GetKraftCloudAuthConfig(ctx, opts.token) + auth, err := config.GetUnikraftCloudAuthConfig(ctx, opts.token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } - client := kraftcloud.NewServicesClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*auth)), + client := cloud.NewServicesClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*auth)), ) resp, err := client.WithMetro(opts.metro).Get(ctx, args[0]) diff --git a/internal/cli/kraft/cloud/service/list/list.go b/internal/cli/kraft/cloud/service/list/list.go index bf0382742..24c5c75e1 100644 --- a/internal/cli/kraft/cloud/service/list/list.go +++ b/internal/cli/kraft/cloud/service/list/list.go @@ -12,7 +12,7 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" + cloud "sdk.kraft.cloud" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -44,7 +44,7 @@ func NewCmd() *cobra.Command { $ kraft cloud service list -w `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-svc", + cmdfactory.AnnotationHelpGroup: "cloud-svc", }, }) if err != nil { @@ -68,13 +68,13 @@ func (opts *ListOptions) Pre(cmd *cobra.Command, _ []string) error { } func (opts *ListOptions) Run(ctx context.Context, args []string) error { - auth, err := config.GetKraftCloudAuthConfig(ctx, opts.token) + auth, err := config.GetUnikraftCloudAuthConfig(ctx, opts.token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } - client := kraftcloud.NewServicesClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*auth)), + client := cloud.NewServicesClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*auth)), ) resp, err := client.WithMetro(opts.metro).List(ctx) diff --git a/internal/cli/kraft/cloud/service/remove/remove.go b/internal/cli/kraft/cloud/service/remove/remove.go index 86a10933f..7a62faf3c 100644 --- a/internal/cli/kraft/cloud/service/remove/remove.go +++ b/internal/cli/kraft/cloud/service/remove/remove.go @@ -12,8 +12,8 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" - kcclient "sdk.kraft.cloud/client" + cloud "sdk.kraft.cloud" + ukcclient "sdk.kraft.cloud/client" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -23,12 +23,12 @@ import ( ) type RemoveOptions struct { - All bool `long:"all" short:"a" usage:"Remove all services"` - Auth *config.AuthConfig `noattribute:"true"` - Client kraftcloud.KraftCloud `noattribute:"true"` - Metro string `noattribute:"true"` - Token string `noattribute:"true"` - WaitEmpty bool `long:"wait-empty" usage:"Wait for the service to be empty before removing it"` + All bool `long:"all" short:"a" usage:"Remove all services"` + Auth *config.AuthConfig `noattribute:"true"` + Client cloud.KraftCloud `noattribute:"true"` + Metro string `noattribute:"true"` + Token string `noattribute:"true"` + WaitEmpty bool `long:"wait-empty" usage:"Wait for the service to be empty before removing it"` } func NewCmd() *cobra.Command { @@ -51,7 +51,7 @@ func NewCmd() *cobra.Command { $ kraft cloud service remove --all `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-svc", + cmdfactory.AnnotationHelpGroup: "cloud-svc", }, }) if err != nil { @@ -82,15 +82,15 @@ func Remove(ctx context.Context, opts *RemoveOptions, args ...string) error { var err error if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } @@ -135,7 +135,7 @@ func Remove(ctx context.Context, opts *RemoveOptions, args ...string) error { } sg, err := serviceResp.FirstOrErr() - if err != nil && *sg.Error == kcclient.APIHTTPErrorNotFound { + if err != nil && *sg.Error == ukcclient.APIHTTPErrorNotFound { return nil } else if err != nil { return err diff --git a/internal/cli/kraft/cloud/service/service.go b/internal/cli/kraft/cloud/service/service.go index e39bacf9a..ced34b514 100644 --- a/internal/cli/kraft/cloud/service/service.go +++ b/internal/cli/kraft/cloud/service/service.go @@ -24,16 +24,16 @@ type ServiceOptions struct{} func NewCmd() *cobra.Command { cmd, err := cmdfactory.New(&ServiceOptions{}, cobra.Command{ - Short: "Manage services on KraftCloud", + Short: "Manage services on UnikraftCloud", Use: "service SUBCOMMAND", Aliases: []string{"services", "svc"}, - Long: "Manage services on KraftCloud.", + Long: "Manage services on cloud.", Example: heredoc.Doc(` # List services in your account. $ kraft cloud service list `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-svc", + cmdfactory.AnnotationHelpGroup: "cloud-svc", cmdfactory.AnnotationHelpHidden: "true", }, }) diff --git a/internal/cli/kraft/cloud/tunnel/tunnel.go b/internal/cli/kraft/cloud/tunnel/tunnel.go index fe146aa24..808994cd7 100644 --- a/internal/cli/kraft/cloud/tunnel/tunnel.go +++ b/internal/cli/kraft/cloud/tunnel/tunnel.go @@ -16,9 +16,9 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" - kcinstances "sdk.kraft.cloud/instances" - kcservices "sdk.kraft.cloud/services" + cloud "sdk.kraft.cloud" + ukcinstances "sdk.kraft.cloud/instances" + ukcservices "sdk.kraft.cloud/services" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -119,7 +119,7 @@ func NewCmd() *cobra.Command { $ kraft cloud tunnel -p 5500 my-instance:8080 `, "`"), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud", + cmdfactory.AnnotationHelpGroup: "cloud", }, }) if err != nil { @@ -157,7 +157,7 @@ func (opts *TunnelOptions) Run(ctx context.Context, args []string) error { return fmt.Errorf("supplied number of proxy ports must match the number of ports to forward") } - auth, err := config.GetKraftCloudAuthConfig(ctx, opts.Token) + auth, err := config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } @@ -167,8 +167,8 @@ func (opts *TunnelOptions) Run(ctx context.Context, args []string) error { } var authStr string - cliInstance := kraftcloud.NewInstancesClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*auth)), + cliInstance := cloud.NewInstancesClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*auth)), ).WithMetro(opts.Metro) rawInstances := opts.instances @@ -286,35 +286,35 @@ func (opts *TunnelOptions) parseArgs(ctx context.Context, args []string) error { // runProxy runs a proxy instance with the given arguments. // Information related to the proxy instance is hardcoded, but the UUID is returned. -func (opts *TunnelOptions) runProxy(ctx context.Context, cli kcinstances.InstancesService, args []string) (string, string, error) { - var parsedPorts []kcservices.CreateRequestService +func (opts *TunnelOptions) runProxy(ctx context.Context, cli ukcinstances.InstancesService, args []string) (string, string, error) { + var parsedPorts []ukcservices.CreateRequestService for i := range opts.exposedProxyPorts { - parsedPorts = append(parsedPorts, kcservices.CreateRequestService{ + parsedPorts = append(parsedPorts, ukcservices.CreateRequestService{ Port: int(opts.exposedProxyPorts[i]), DestinationPort: ptr(int(opts.exposedProxyPorts[i])), - Handlers: []kcservices.Handler{ - kcservices.HandlerTLS, + Handlers: []ukcservices.Handler{ + ukcservices.HandlerTLS, }, }) } - parsedPorts = append(parsedPorts, kcservices.CreateRequestService{ + parsedPorts = append(parsedPorts, ukcservices.CreateRequestService{ Port: int(opts.ProxyControlPort), DestinationPort: ptr(int(opts.ProxyControlPort)), - Handlers: []kcservices.Handler{ - kcservices.HandlerTLS, + Handlers: []ukcservices.Handler{ + ukcservices.HandlerTLS, }, }) - crinstResp, err := cli.Create(ctx, kcinstances.CreateRequest{ + crinstResp, err := cli.Create(ctx, ukcinstances.CreateRequest{ Image: opts.TunnelServiceImage, MemoryMB: ptr(64), Args: args, - ServiceGroup: &kcinstances.CreateRequestServiceGroup{ + ServiceGroup: &ukcinstances.CreateRequestServiceGroup{ Services: parsedPorts, }, Autostart: ptr(true), WaitTimeoutMs: ptr(int((3 * time.Second).Milliseconds())), - Features: []kcinstances.Feature{kcinstances.FeatureDeleteOnStop}, + Features: []ukcinstances.Feature{ukcinstances.FeatureDeleteOnStop}, }) if err != nil { return "", "", fmt.Errorf("creating proxy instance: %w", err) @@ -404,7 +404,7 @@ func (opts *TunnelOptions) formatProxyArgs(authStr string) []string { } // populatePrivateIPs fetches the private IPs of the instances and replaces the instance names/uuids with the Private IPs. -func populatePrivateIPs(ctx context.Context, cli kcinstances.InstancesService, targets []string) (ips []string, err error) { +func populatePrivateIPs(ctx context.Context, cli ukcinstances.InstancesService, targets []string) (ips []string, err error) { var instancesToGet []string var indexesToGet []int for i := range targets { @@ -439,7 +439,7 @@ func populatePrivateIPs(ctx context.Context, cli kcinstances.InstancesService, t } // terminateProxy terminates the proxy instance with the given UUID. -func terminateProxy(ctx context.Context, icli kcinstances.InstancesService, instID string) error { +func terminateProxy(ctx context.Context, icli ukcinstances.InstancesService, instID string) error { delinstResp, err := icli.Delete(ctx, instID) if err != nil { return fmt.Errorf("deleting proxy instance '%s': %w", instID, err) diff --git a/internal/cli/kraft/cloud/utils/print.go b/internal/cli/kraft/cloud/utils/print.go index 40813ad65..a9ff86197 100644 --- a/internal/cli/kraft/cloud/utils/print.go +++ b/internal/cli/kraft/cloud/utils/print.go @@ -22,34 +22,34 @@ import ( "kraftkit.sh/log" "kraftkit.sh/tui" - kccerts "sdk.kraft.cloud/certificates" - kcclient "sdk.kraft.cloud/client" - kcimages "sdk.kraft.cloud/images" - kcinstances "sdk.kraft.cloud/instances" - kcservices "sdk.kraft.cloud/services" - kcautoscale "sdk.kraft.cloud/services/autoscale" - kcusers "sdk.kraft.cloud/users" - kcvolumes "sdk.kraft.cloud/volumes" + ukccerts "sdk.kraft.cloud/certificates" + ukcclient "sdk.kraft.cloud/client" + ukcimages "sdk.kraft.cloud/images" + ukcinstances "sdk.kraft.cloud/instances" + ukcservices "sdk.kraft.cloud/services" + ukcautoscale "sdk.kraft.cloud/services/autoscale" + ukcusers "sdk.kraft.cloud/users" + ukcvolumes "sdk.kraft.cloud/volumes" ) type colorFunc func(string) string var ( - instanceStateColor = map[kcinstances.InstanceState]colorFunc{ - kcinstances.InstanceStateDraining: iostreams.Yellow, - kcinstances.InstanceStateRunning: iostreams.Green, - kcinstances.InstanceStateStandby: iostreams.Cyan, - kcinstances.InstanceStateStarting: iostreams.Green, - kcinstances.InstanceStateStopped: iostreams.Red, - kcinstances.InstanceStateStopping: iostreams.Yellow, - } - instanceStateColorNil = map[kcinstances.InstanceState]colorFunc{ - kcinstances.InstanceStateDraining: nil, - kcinstances.InstanceStateRunning: nil, - kcinstances.InstanceStateStandby: nil, - kcinstances.InstanceStateStarting: nil, - kcinstances.InstanceStateStopped: nil, - kcinstances.InstanceStateStopping: nil, + instanceStateColor = map[ukcinstances.InstanceState]colorFunc{ + ukcinstances.InstanceStateDraining: iostreams.Yellow, + ukcinstances.InstanceStateRunning: iostreams.Green, + ukcinstances.InstanceStateStandby: iostreams.Cyan, + ukcinstances.InstanceStateStarting: iostreams.Green, + ukcinstances.InstanceStateStopped: iostreams.Red, + ukcinstances.InstanceStateStopping: iostreams.Yellow, + } + instanceStateColorNil = map[ukcinstances.InstanceState]colorFunc{ + ukcinstances.InstanceStateDraining: nil, + ukcinstances.InstanceStateRunning: nil, + ukcinstances.InstanceStateStandby: nil, + ukcinstances.InstanceStateStarting: nil, + ukcinstances.InstanceStateStopped: nil, + ukcinstances.InstanceStateStopping: nil, } ) @@ -84,7 +84,7 @@ func parseTime(dateTime, format, uuid string) (string, error) { // PrintInstances pretty-prints the provided set of instances or returns // an error if unable to send to stdout via the provided context. -func PrintInstances(ctx context.Context, format string, resp kcclient.ServiceResponse[kcinstances.GetResponseItem]) error { +func PrintInstances(ctx context.Context, format string, resp ukcclient.ServiceResponse[ukcinstances.GetResponseItem]) error { if format == "raw" { printRaw(ctx, resp) return nil @@ -272,7 +272,7 @@ func PrintInstances(ctx context.Context, format string, resp kcclient.ServiceRes table.AddField("", nil) } table.AddField(string(instance.RestartPolicy), nil) - if instance.State == kcinstances.InstanceStateStopped { + if instance.State == ukcinstances.InstanceStateStopped { table.AddField(fmt.Sprintf("%s (%s)", instance.DescribeStopOrigin(), instance.StopOriginCode()), nil) stopReason := instance.DescribeStopReason() switch stopReason { @@ -367,7 +367,7 @@ func PrintInstances(ctx context.Context, format string, resp kcclient.ServiceRes // PrintVolumes pretty-prints the provided set of volumes or returns // an error if unable to send to stdout via the provided context. -func PrintVolumes(ctx context.Context, format string, resp kcclient.ServiceResponse[kcvolumes.GetResponseItem]) error { +func PrintVolumes(ctx context.Context, format string, resp ukcclient.ServiceResponse[ukcvolumes.GetResponseItem]) error { if format == "raw" { printRaw(ctx, resp) return nil @@ -464,7 +464,7 @@ func PrintVolumes(ctx context.Context, format string, resp kcclient.ServiceRespo // PrintAutoscaleConfiguration pretty-prints the provided autoscale configuration or returns // an error if unable to send to stdout via the provided context. -func PrintAutoscaleConfiguration(ctx context.Context, format string, resp kcclient.ServiceResponse[kcautoscale.GetResponseItem]) error { +func PrintAutoscaleConfiguration(ctx context.Context, format string, resp ukcclient.ServiceResponse[ukcautoscale.GetResponseItem]) error { if format == "raw" { printRaw(ctx, resp) return nil @@ -554,8 +554,8 @@ func PrintAutoscaleConfiguration(ctx context.Context, format string, resp kcclie for _, policy := range aconf.Policies { name := "" switch policy.Type() { - case kcautoscale.PolicyTypeStep: - name = policy.(*kcautoscale.StepPolicy).Name + case ukcautoscale.PolicyTypeStep: + name = policy.(*ukcautoscale.StepPolicy).Name } policies = append(policies, name) } @@ -569,7 +569,7 @@ func PrintAutoscaleConfiguration(ctx context.Context, format string, resp kcclie // PrintServices pretty-prints the provided set of service or returns // an error if unable to send to stdout via the provided context. -func PrintServices(ctx context.Context, format string, resp kcclient.ServiceResponse[kcservices.GetResponseItem]) error { +func PrintServices(ctx context.Context, format string, resp ukcclient.ServiceResponse[ukcservices.GetResponseItem]) error { if format == "raw" { printRaw(ctx, resp) return nil @@ -698,7 +698,7 @@ func printBar(cs *iostreams.ColorScheme, progress, max int) string { // PrintQuotas pretty-prints the provided set of user quotas or returns // an error if unable to send to stdout via the provided context. -func PrintQuotas(ctx context.Context, auth config.AuthConfig, format string, resp kcclient.ServiceResponse[kcusers.QuotasResponseItem], imageResp *kcimages.QuotasResponseItem) error { +func PrintQuotas(ctx context.Context, auth config.AuthConfig, format string, resp ukcclient.ServiceResponse[ukcusers.QuotasResponseItem], imageResp *ukcimages.QuotasResponseItem) error { if format == "raw" { printRaw(ctx, resp) return nil @@ -957,7 +957,7 @@ func PrintQuotas(ctx context.Context, auth config.AuthConfig, format string, res // PrintCertificates pretty-prints the provided set of certificates or returns // an error if unable to send to stdout via the provided context. -func PrintCertificates(ctx context.Context, format string, resp kcclient.ServiceResponse[kccerts.GetResponseItem]) error { +func PrintCertificates(ctx context.Context, format string, resp ukcclient.ServiceResponse[ukccerts.GetResponseItem]) error { if format == "raw" { printRaw(ctx, resp) return nil @@ -1071,7 +1071,7 @@ func PrintCertificates(ctx context.Context, format string, resp kcclient.Service } // PrettyPrintInstance outputs a single instance and information about it. -func PrettyPrintInstance(ctx context.Context, instance kcinstances.GetResponseItem, service *kcservices.GetResponseItem, autoStart bool) { +func PrettyPrintInstance(ctx context.Context, instance ukcinstances.GetResponseItem, service *ukcservices.GetResponseItem, autoStart bool) { out := iostreams.G(ctx).Out var title string @@ -1196,7 +1196,7 @@ func PrettyPrintInstance(ctx context.Context, instance kcinstances.GetResponseIt } } -func printRaw[T kcclient.APIResponseDataEntry](ctx context.Context, resps ...kcclient.ServiceResponse[T]) { +func printRaw[T ukcclient.APIResponseDataEntry](ctx context.Context, resps ...ukcclient.ServiceResponse[T]) { for _, resp := range resps { fmt.Fprint(iostreams.G(ctx).Out, string(resp.RawBody())) } diff --git a/internal/cli/kraft/cloud/volume/attach/attach.go b/internal/cli/kraft/cloud/volume/attach/attach.go index dec382b83..cec2137cd 100644 --- a/internal/cli/kraft/cloud/volume/attach/attach.go +++ b/internal/cli/kraft/cloud/volume/attach/attach.go @@ -12,8 +12,8 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" - kcvolumes "sdk.kraft.cloud/volumes" + cloud "sdk.kraft.cloud" + ukcvolumes "sdk.kraft.cloud/volumes" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -22,18 +22,18 @@ import ( ) type AttachOptions struct { - At string `long:"at" usage:"The path the volume should be mounted to"` - Auth *config.AuthConfig `noattribute:"true"` - Client kcvolumes.VolumesService `noattribute:"true"` - ReadOnly bool `long:"read-only" short:"r" usage:"Mount the volume read-only"` - To string `long:"to" usage:"The instance the volume should be attached to"` + At string `long:"at" usage:"The path the volume should be mounted to"` + Auth *config.AuthConfig `noattribute:"true"` + Client ukcvolumes.VolumesService `noattribute:"true"` + ReadOnly bool `long:"read-only" short:"r" usage:"Mount the volume read-only"` + To string `long:"to" usage:"The instance the volume should be attached to"` metro string token string } -// Attach a KraftCloud persistent volume to an instance. -func Attach(ctx context.Context, opts *AttachOptions, args ...string) (*kcvolumes.AttachResponseItem, error) { +// Attach a UnikraftCloud persistent volume to an instance. +func Attach(ctx context.Context, opts *AttachOptions, args ...string) (*ukcvolumes.AttachResponseItem, error) { var err error if opts == nil { @@ -49,15 +49,15 @@ func Attach(ctx context.Context, opts *AttachOptions, args ...string) (*kcvolume } if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.token) if err != nil { return nil, fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewVolumesClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewVolumesClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } @@ -87,7 +87,7 @@ func NewCmd() *cobra.Command { $ kraft cloud volume at 77d0316a-fbbe-488d-8618-5bf7a612477a --to nginx --at /mnt/data -r `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-vol", + cmdfactory.AnnotationHelpGroup: "cloud-vol", }, }) if err != nil { diff --git a/internal/cli/kraft/cloud/volume/create/create.go b/internal/cli/kraft/cloud/volume/create/create.go index 99ac31e8a..ad0a6572f 100644 --- a/internal/cli/kraft/cloud/volume/create/create.go +++ b/internal/cli/kraft/cloud/volume/create/create.go @@ -14,8 +14,8 @@ import ( "github.com/spf13/cobra" "k8s.io/apimachinery/pkg/api/resource" - kraftcloud "sdk.kraft.cloud" - kcvolumes "sdk.kraft.cloud/volumes" + cloud "sdk.kraft.cloud" + ukcvolumes "sdk.kraft.cloud/volumes" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -24,16 +24,16 @@ import ( ) type CreateOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kcvolumes.VolumesService `noattribute:"true"` - Metro string `noattribute:"true"` - Name string `local:"true" size:"name" short:"n" usage:"Name of the volume"` - Size string `local:"true" long:"size" short:"s" usage:"Size (MiB increments or suffixes like Mi, Gi, etc.)"` - Token string `noattribute:"true"` + Auth *config.AuthConfig `noattribute:"true"` + Client ukcvolumes.VolumesService `noattribute:"true"` + Metro string `noattribute:"true"` + Name string `local:"true" size:"name" short:"n" usage:"Name of the volume"` + Size string `local:"true" long:"size" short:"s" usage:"Size (MiB increments or suffixes like Mi, Gi, etc.)"` + Token string `noattribute:"true"` } -// Create a KraftCloud persistent volume. -func Create(ctx context.Context, opts *CreateOptions) (*kcvolumes.CreateResponseItem, error) { +// Create a UnikraftCloud persistent volume. +func Create(ctx context.Context, opts *CreateOptions) (*ukcvolumes.CreateResponseItem, error) { var err error if opts == nil { @@ -41,15 +41,15 @@ func Create(ctx context.Context, opts *CreateOptions) (*kcvolumes.CreateResponse } if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return nil, fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewVolumesClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewVolumesClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } @@ -98,7 +98,7 @@ func NewCmd() *cobra.Command { $ kraft cloud volume create --size 10Mi `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-vol", + cmdfactory.AnnotationHelpGroup: "cloud-vol", }, }) if err != nil { diff --git a/internal/cli/kraft/cloud/volume/detach/detach.go b/internal/cli/kraft/cloud/volume/detach/detach.go index 560a88a60..e8cd4939c 100644 --- a/internal/cli/kraft/cloud/volume/detach/detach.go +++ b/internal/cli/kraft/cloud/volume/detach/detach.go @@ -12,8 +12,8 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" - kcvolumes "sdk.kraft.cloud/volumes" + cloud "sdk.kraft.cloud" + ukcvolumes "sdk.kraft.cloud/volumes" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -22,9 +22,9 @@ import ( ) type DetachOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kcvolumes.VolumesService `noattribute:"true"` - From string `long:"from" usage:"The instance the volume should be detached from"` + Auth *config.AuthConfig `noattribute:"true"` + Client ukcvolumes.VolumesService `noattribute:"true"` + From string `long:"from" usage:"The instance the volume should be detached from"` metro string token string @@ -44,7 +44,7 @@ func NewCmd() *cobra.Command { $ kraft cloud volume detach --from my-instance 77d0316a-fbbe-488d-8618-5bf7a612477a `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-vol", + cmdfactory.AnnotationHelpGroup: "cloud-vol", }, }) if err != nil { @@ -67,15 +67,15 @@ func (opts *DetachOptions) Run(ctx context.Context, args []string) error { var err error if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewVolumesClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewVolumesClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } diff --git a/internal/cli/kraft/cloud/volume/get/get.go b/internal/cli/kraft/cloud/volume/get/get.go index 44a650bb0..5cfa4643e 100644 --- a/internal/cli/kraft/cloud/volume/get/get.go +++ b/internal/cli/kraft/cloud/volume/get/get.go @@ -12,7 +12,7 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" + cloud "sdk.kraft.cloud" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -26,7 +26,7 @@ type GetOptions struct { token string } -// Status of a KraftCloud instance. +// Status of a UnikraftCloud instance. func Status(ctx context.Context, opts *GetOptions, args ...string) error { if opts == nil { opts = &GetOptions{} @@ -42,14 +42,14 @@ func NewCmd() *cobra.Command { Args: cobra.ExactArgs(1), Aliases: []string{"gt"}, Example: heredoc.Doc(` - # Retrieve information about a kraftcloud volume by UUID + # Retrieve information about a UnikraftCloud volume by UUID $ kraft cloud volume get fd1684ea-7970-4994-92d6-61dcc7905f2b - # Retrieve information about a kraftcloud volume by name + # Retrieve information about a UnikraftCloud volume by name $ kraft cloud volume get my-volume-431342 `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-vol", + cmdfactory.AnnotationHelpGroup: "cloud-vol", }, }) if err != nil { @@ -73,13 +73,13 @@ func (opts *GetOptions) Pre(cmd *cobra.Command, _ []string) error { } func (opts *GetOptions) Run(ctx context.Context, args []string) error { - auth, err := config.GetKraftCloudAuthConfig(ctx, opts.token) + auth, err := config.GetUnikraftCloudAuthConfig(ctx, opts.token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } - client := kraftcloud.NewVolumesClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*auth)), + client := cloud.NewVolumesClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*auth)), ) resp, err := client.WithMetro(opts.metro).Get(ctx, args[0]) diff --git a/internal/cli/kraft/cloud/volume/import/import.go b/internal/cli/kraft/cloud/volume/import/import.go index 0877be09b..c7c3785a3 100644 --- a/internal/cli/kraft/cloud/volume/import/import.go +++ b/internal/cli/kraft/cloud/volume/import/import.go @@ -18,7 +18,7 @@ import ( "github.com/dustin/go-humanize" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" + cloud "sdk.kraft.cloud" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -63,7 +63,7 @@ func NewCmd() *cobra.Command { $ kraft cloud volume import --source path/to/file --volume my-volume `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-vol", + cmdfactory.AnnotationHelpGroup: "cloud-vol", }, }) if err != nil { @@ -94,7 +94,7 @@ func (opts *ImportOptions) Run(ctx context.Context, _ []string) error { var err error if opts.Auth == nil { - if opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token); err != nil { + if opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token); err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } @@ -110,8 +110,8 @@ func (opts *ImportOptions) Run(ctx context.Context, _ []string) error { // importVolumeData imports local data to a volume. func importVolumeData(ctx context.Context, opts *ImportOptions) (retErr error) { - cli := kraftcloud.NewClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + cli := cloud.NewClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) icli := cli.Instances().WithMetro(opts.Metro) vcli := cli.Volumes().WithMetro(opts.Metro) diff --git a/internal/cli/kraft/cloud/volume/import/volimport.go b/internal/cli/kraft/cloud/volume/import/volimport.go index 6a7ec3d5d..73120062c 100644 --- a/internal/cli/kraft/cloud/volume/import/volimport.go +++ b/internal/cli/kraft/cloud/volume/import/volimport.go @@ -11,13 +11,13 @@ import ( "strconv" "time" - kcinstances "sdk.kraft.cloud/instances" - kcservices "sdk.kraft.cloud/services" - kcvolumes "sdk.kraft.cloud/volumes" + ukcinstances "sdk.kraft.cloud/instances" + ukcservices "sdk.kraft.cloud/services" + ukcvolumes "sdk.kraft.cloud/volumes" ) // volumeSanityCheck verifies that the given volume is suitable for import. -func volumeSanityCheck(ctx context.Context, cli kcvolumes.VolumesService, volID string, dataSize int64) (volUUID string, volSize int64, err error) { +func volumeSanityCheck(ctx context.Context, cli ukcvolumes.VolumesService, volID string, dataSize int64) (volUUID string, volSize int64, err error) { getvolResp, err := cli.Get(ctx, volID) if err != nil { return "", -1, fmt.Errorf("getting volume details: %w", err) @@ -35,31 +35,31 @@ func volumeSanityCheck(ctx context.Context, cli kcvolumes.VolumesService, volID } // runVolimport spawns a volume data import instance with the given volume attached. -func runVolimport(ctx context.Context, cli kcinstances.InstancesService, image, volUUID, authStr string, timeoutS uint64) (instID, fqdn string, err error) { +func runVolimport(ctx context.Context, cli ukcinstances.InstancesService, image, volUUID, authStr string, timeoutS uint64) (instID, fqdn string, err error) { args := []string{ "-p", strconv.FormatUint(uint64(volimportPort), 10), "-a", authStr, "-t", strconv.FormatUint(timeoutS, 10), } - crinstResp, err := cli.Create(ctx, kcinstances.CreateRequest{ + crinstResp, err := cli.Create(ctx, ukcinstances.CreateRequest{ Image: image, MemoryMB: ptr(128), Args: args, - ServiceGroup: &kcinstances.CreateRequestServiceGroup{ - Services: []kcservices.CreateRequestService{{ + ServiceGroup: &ukcinstances.CreateRequestServiceGroup{ + Services: []ukcservices.CreateRequestService{{ Port: int(volimportPort), DestinationPort: ptr(int(volimportPort)), - Handlers: []kcservices.Handler{kcservices.HandlerTLS}, + Handlers: []ukcservices.Handler{ukcservices.HandlerTLS}, }}, }, - Volumes: []kcinstances.CreateRequestVolume{{ + Volumes: []ukcinstances.CreateRequestVolume{{ UUID: &volUUID, At: ptr("/"), }}, Autostart: ptr(true), WaitTimeoutMs: ptr(int((3 * time.Second).Milliseconds())), - Features: []kcinstances.Feature{kcinstances.FeatureDeleteOnStop}, + Features: []ukcinstances.Feature{ukcinstances.FeatureDeleteOnStop}, }) if err != nil { return "", "", fmt.Errorf("creating volume data import instance: %w", err) diff --git a/internal/cli/kraft/cloud/volume/list/list.go b/internal/cli/kraft/cloud/volume/list/list.go index cf47e98ab..a8ff1b508 100644 --- a/internal/cli/kraft/cloud/volume/list/list.go +++ b/internal/cli/kraft/cloud/volume/list/list.go @@ -12,7 +12,7 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" + cloud "sdk.kraft.cloud" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -44,7 +44,7 @@ func NewCmd() *cobra.Command { $ kraft cloud volume list -o json `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-vol", + cmdfactory.AnnotationHelpGroup: "cloud-vol", }, }) if err != nil { @@ -68,13 +68,13 @@ func (opts *ListOptions) Pre(cmd *cobra.Command, _ []string) error { } func (opts *ListOptions) Run(ctx context.Context, args []string) error { - auth, err := config.GetKraftCloudAuthConfig(ctx, opts.token) + auth, err := config.GetUnikraftCloudAuthConfig(ctx, opts.token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } - client := kraftcloud.NewVolumesClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*auth)), + client := cloud.NewVolumesClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*auth)), ) resp, err := client.WithMetro(opts.metro).List(ctx) diff --git a/internal/cli/kraft/cloud/volume/remove/remove.go b/internal/cli/kraft/cloud/volume/remove/remove.go index c081977ed..7b2044fa1 100644 --- a/internal/cli/kraft/cloud/volume/remove/remove.go +++ b/internal/cli/kraft/cloud/volume/remove/remove.go @@ -12,7 +12,7 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" - kraftcloud "sdk.kraft.cloud" + cloud "sdk.kraft.cloud" "kraftkit.sh/cmdfactory" "kraftkit.sh/config" @@ -21,14 +21,14 @@ import ( ) type RemoveOptions struct { - Auth *config.AuthConfig `noattribute:"true"` - Client kraftcloud.KraftCloud `noattribute:"true"` - All bool `long:"all" short:"a" usage:"Remove all volumes that are not attached"` - Metro string `noattribute:"true"` - Token string `noattribute:"true"` + Auth *config.AuthConfig `noattribute:"true"` + Client cloud.KraftCloud `noattribute:"true"` + All bool `long:"all" short:"a" usage:"Remove all volumes that are not attached"` + Metro string `noattribute:"true"` + Token string `noattribute:"true"` } -// Remove a KraftCloud persistent volume. +// Remove a UnikraftCloud persistent volume. func Remove(ctx context.Context, opts *RemoveOptions, args ...string) error { if opts == nil { opts = &RemoveOptions{} @@ -57,7 +57,7 @@ func NewCmd() *cobra.Command { $ kraft cloud volume remove --all `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-vol", + cmdfactory.AnnotationHelpGroup: "cloud-vol", }, }) if err != nil { @@ -84,15 +84,15 @@ func (opts *RemoveOptions) Run(ctx context.Context, args []string) error { } if opts.Auth == nil { - opts.Auth, err = config.GetKraftCloudAuthConfig(ctx, opts.Token) + opts.Auth, err = config.GetUnikraftCloudAuthConfig(ctx, opts.Token) if err != nil { return fmt.Errorf("could not retrieve credentials: %w", err) } } if opts.Client == nil { - opts.Client = kraftcloud.NewClient( - kraftcloud.WithToken(config.GetKraftCloudTokenAuthConfig(*opts.Auth)), + opts.Client = cloud.NewClient( + cloud.WithToken(config.GetUnikraftCloudTokenAuthConfig(*opts.Auth)), ) } diff --git a/internal/cli/kraft/cloud/volume/volume.go b/internal/cli/kraft/cloud/volume/volume.go index 569e6cb8c..f378497bb 100644 --- a/internal/cli/kraft/cloud/volume/volume.go +++ b/internal/cli/kraft/cloud/volume/volume.go @@ -27,16 +27,16 @@ type VolumeOptions struct{} func NewCmd() *cobra.Command { cmd, err := cmdfactory.New(&VolumeOptions{}, cobra.Command{ - Short: "Manage persistent volumes on KraftCloud", + Short: "Manage persistent volumes on UnikraftCloud", Use: "volume SUBCOMMAND", Aliases: []string{"volumes", "vol"}, - Long: "Manage persistent volumes on KraftCloud.", + Long: "Manage persistent volumes on cloud.", Example: heredoc.Doc(` # List all volumes in your account. $ kraft cloud volume list `), Annotations: map[string]string{ - cmdfactory.AnnotationHelpGroup: "kraftcloud-vol", + cmdfactory.AnnotationHelpGroup: "cloud-vol", cmdfactory.AnnotationHelpHidden: "true", }, }) diff --git a/internal/cli/kraft/kraft.go b/internal/cli/kraft/kraft.go index 67668bdf1..60f0d767e 100644 --- a/internal/cli/kraft/kraft.go +++ b/internal/cli/kraft/kraft.go @@ -110,16 +110,16 @@ func NewCmd() *cobra.Command { cmd.AddGroup(&cobra.Group{ID: "compose", Title: "COMPOSE COMMANDS"}) cmd.AddCommand(compose.NewCmd()) - cmd.AddGroup(&cobra.Group{ID: "kraftcloud", Title: "UNIKRAFT CLOUD COMMANDS"}) + cmd.AddGroup(&cobra.Group{ID: "cloud", Title: "UNIKRAFT CLOUD COMMANDS"}) cmd.AddCommand(cloud.NewCmd()) - cmd.AddGroup(&cobra.Group{ID: "kraftcloud-img", Title: "UNIKRAFT CLOUD IMAGE COMMANDS"}) - cmd.AddGroup(&cobra.Group{ID: "kraftcloud-instance", Title: "UNIKRAFT CLOUD INSTANCE COMMANDS"}) - cmd.AddGroup(&cobra.Group{ID: "kraftcloud-vol", Title: "UNIKRAFT CLOUD VOLUME COMMANDS"}) - cmd.AddGroup(&cobra.Group{ID: "kraftcloud-svc", Title: "UNIKRAFT CLOUD SERVICE COMMANDS"}) - cmd.AddGroup(&cobra.Group{ID: "kraftcloud-scale", Title: "UNIKRAFT CLOUD AUTOSCALE COMMANDS"}) - cmd.AddGroup(&cobra.Group{ID: "kraftcloud-certificate", Title: "UNIKRAFT CLOUD CERTIFICATE COMMANDS"}) - cmd.AddGroup(&cobra.Group{ID: "kraftcloud-compose", Title: "UNIKRAFT CLOUD COMPOSE COMMANDS"}) + cmd.AddGroup(&cobra.Group{ID: "cloud-img", Title: "UNIKRAFT CLOUD IMAGE COMMANDS"}) + cmd.AddGroup(&cobra.Group{ID: "cloud-instance", Title: "UNIKRAFT CLOUD INSTANCE COMMANDS"}) + cmd.AddGroup(&cobra.Group{ID: "cloud-vol", Title: "UNIKRAFT CLOUD VOLUME COMMANDS"}) + cmd.AddGroup(&cobra.Group{ID: "cloud-svc", Title: "UNIKRAFT CLOUD SERVICE COMMANDS"}) + cmd.AddGroup(&cobra.Group{ID: "cloud-scale", Title: "UNIKRAFT CLOUD AUTOSCALE COMMANDS"}) + cmd.AddGroup(&cobra.Group{ID: "cloud-certificate", Title: "UNIKRAFT CLOUD CERTIFICATE COMMANDS"}) + cmd.AddGroup(&cobra.Group{ID: "cloud-compose", Title: "UNIKRAFT CLOUD COMPOSE COMMANDS"}) cmd.AddGroup(&cobra.Group{ID: "misc", Title: "MISCELLANEOUS COMMANDS"}) cmd.AddCommand(login.NewCmd()) @@ -177,8 +177,8 @@ func Main(args []string) int { ctx = config.WithConfigManager(ctx, copts.ConfigManager) } - // Hydrate KraftCloud configuration - if newCtx, err := config.HydrateKraftCloudAuthInContext(ctx); err == nil { + // Hydrate UnikraftCloud configuration + if newCtx, err := config.HydrateUnikraftCloudAuthInContext(ctx); err == nil { ctx = newCtx } diff --git a/internal/cli/kraft/pkg/packager_kraftfile_runtime.go b/internal/cli/kraft/pkg/packager_kraftfile_runtime.go index a16cdb6f7..8b4a43913 100644 --- a/internal/cli/kraft/pkg/packager_kraftfile_runtime.go +++ b/internal/cli/kraft/pkg/packager_kraftfile_runtime.go @@ -62,8 +62,8 @@ func (p *packagerKraftfileRuntime) Pack(ctx context.Context, opts *PkgOptions, a runtimeName = opts.Project.Runtime().Name() } - if opts.Platform == "kraftcloud" || (opts.Project.Runtime().Platform() != nil && opts.Project.Runtime().Platform().Name() == "kraftcloud") { - runtimeName = utils.RewrapAsKraftCloudPackage(runtimeName) + if opts.Platform == "cloud" || opts.Platform == "kraftcloud" || (opts.Project.Runtime().Platform() != nil && (opts.Project.Runtime().Platform().Name() == "cloud" || opts.Project.Runtime().Platform().Name() == "kraftcloud")) { + runtimeName = utils.RewrapAsUnikraftCloudPackage(runtimeName) } targets := opts.Project.Targets() diff --git a/internal/cli/kraft/pkg/pkg.go b/internal/cli/kraft/pkg/pkg.go index 6f2860998..eb5df4416 100644 --- a/internal/cli/kraft/pkg/pkg.go +++ b/internal/cli/kraft/pkg/pkg.go @@ -49,7 +49,7 @@ type PkgOptions struct { NoKConfig bool `local:"true" long:"no-kconfig" usage:"Do not include target .config as metadata"` NoPull bool `local:"true" long:"no-pull" usage:"Do not pull package dependencies before packaging"` Output string `local:"true" long:"output" short:"o" usage:"Save the package at the following output"` - Platform string `local:"true" long:"plat" short:"p" usage:"Filter the creation of the package by platform of known targets (fc/qemu/xen/kraftcloud)"` + Platform string `local:"true" long:"plat" short:"p" usage:"Filter the creation of the package by platform of known targets (fc/qemu/xen/cloud)"` Project app.Application `noattribute:"true"` Push bool `local:"true" long:"push" short:"P" usage:"Push the package on if successfully packaged"` Rootfs string `local:"true" long:"rootfs" usage:"Specify a path to use as root file system (can be volume or initramfs)"` diff --git a/internal/cli/kraft/utils/kraftcloud.go b/internal/cli/kraft/utils/kraftcloud.go index 04c18d584..b465ee82d 100644 --- a/internal/cli/kraft/utils/kraftcloud.go +++ b/internal/cli/kraft/utils/kraftcloud.go @@ -4,10 +4,10 @@ import ( "strings" ) -// RewrapAsKraftCloudPackage returns the equivalent package name as a -// KraftCloud package. -func RewrapAsKraftCloudPackage(name string) string { - name = strings.Replace(name, "unikarft.org/", "index.unikraft.io/", 1) +// RewrapAsUnikraftCloudPackage returns the equivalent package name as a +// UnikraftCloud package. +func RewrapAsUnikraftCloudPackage(name string) string { + name = strings.Replace(name, "unikraft.org/", "index.unikraft.io/", 1) if strings.HasPrefix(name, "unikraft.io") { name = "index." + name diff --git a/tools/github-action/main.go b/tools/github-action/main.go index 55e72f6f3..89fa220c0 100644 --- a/tools/github-action/main.go +++ b/tools/github-action/main.go @@ -88,7 +88,7 @@ func (opts *GithubAction) Run(ctx context.Context, args []string) (err error) { workspace = "/github/workspace" } - if newCtx, err := config.HydrateKraftCloudAuthInContext(ctx); err == nil { + if newCtx, err := config.HydrateUnikraftCloudAuthInContext(ctx); err == nil { ctx = newCtx } diff --git a/unikraft/app/application.go b/unikraft/app/application.go index 40fa4ab93..13bdfa54b 100644 --- a/unikraft/app/application.go +++ b/unikraft/app/application.go @@ -565,8 +565,8 @@ func (app *application) Configure(ctx context.Context, tc target.Target, extra k values.OverrideBy(tc.Platform().KConfig()) values.OverrideBy(tc.KConfig()) - // This is a special exception used for KraftCloud-centric platform targets. - if tc.Platform().Name() == "kraftcloud" { + // This is a special exception used for Unikraft Cloud-centric platform targets. + if tc.Platform().Name() == "cloud" || tc.Platform().Name() == "kraftcloud" { values.Set("CONFIG_KVM_DEBUG_VGA_CONSOLE", kconfig.No) values.Set("CONFIG_KVM_KERNEL_VGA_CONSOLE", kconfig.No) } @@ -766,14 +766,14 @@ func (app *application) Build(ctx context.Context, tc target.Target, opts ...Bui make.WithProgressFunc(bopts.onProgress), } - // This is a special exception used for KraftCloud-centric platform targets. + // This is a special exception used for UnikraftCloud-centric platform targets. // This includes using the ability to rename the kernal image to represent // this as a platform (see [0] for additional details) and setting specific // KConfig options. // // [0]: https://github.com/unikraft/unikraft/pull/1169 - if tc.Platform().Name() == "kraftcloud" { - mopts = append(mopts, make.WithVar("UK_IMAGE_NAME_OVERWRITE", fmt.Sprintf("%s_kraftcloud-%s", tc.Name(), tc.Architecture().Name()))) + if tc.Platform().Name() == "cloud" || tc.Platform().Name() == "kraftcloud" { + mopts = append(mopts, make.WithVar("UK_IMAGE_NAME_OVERWRITE", fmt.Sprintf("%s_cloud-%s", tc.Name(), tc.Architecture().Name()))) } bopts.mopts = append(bopts.mopts, mopts...) @@ -846,10 +846,10 @@ func (app *application) Components(ctx context.Context, targets ...target.Target components = append(components, library) } - // Add KraftCloud-specific libraries when a target with this name is provided. + // Add UnikraftCloud-specific libraries when a target with this name is provided. var ukp *lib.LibraryConfig for _, targ := range targets { - if targ.Platform().String() != "kraftcloud" { + if targ.Platform().String() != "cloud" || targ.Platform().String() != "kraftcloud" { continue } @@ -874,7 +874,7 @@ func (app *application) Components(ctx context.Context, targets ...target.Target "version": "stable", }) if err != nil { - return nil, fmt.Errorf("could not add kraftcloud internal libraries: %w", err) + return nil, fmt.Errorf("could not add cloud internal libraries: %w", err) } ukp = &lukp diff --git a/unikraft/bin/kernel b/unikraft/bin/kernel new file mode 100644 index 000000000..39c8d60e0 Binary files /dev/null and b/unikraft/bin/kernel differ diff --git a/unikraft/plat/platform.go b/unikraft/plat/platform.go index 6d32e5846..2d8511c97 100644 --- a/unikraft/plat/platform.go +++ b/unikraft/plat/platform.go @@ -95,7 +95,7 @@ func (pc PlatformConfig) KConfig() kconfig.KeyValueMap { // The following are built-in assumptions given the naming conventions used // within the Unikraft core. switch pc.Name() { - case "fc", "firecracker", "kraftcloud": + case "fc", "firecracker", "cloud", "kraftcloud": values.Set("CONFIG_PLAT_KVM", kconfig.Yes) values.Set("CONFIG_KVM_VMM_FIRECRACKER", kconfig.Yes) case "kvm", "qemu": diff --git a/unikraft/runtime/runtime_pack.go b/unikraft/runtime/runtime_pack.go index 0cbd73413..a49ed58c9 100644 --- a/unikraft/runtime/runtime_pack.go +++ b/unikraft/runtime/runtime_pack.go @@ -23,9 +23,9 @@ import ( var _ pack.Package = (*Runtime)(nil) const ( - PrebuiltRegistry = "unikraft.org" - DefaultRuntime = "unikraft.org/base:latest" - DefaultKraftCloudRuntime = "index.unikraft.io/official/base:latest" + PrebuiltRegistry = "unikraft.org" + DefaultRuntime = "unikraft.org/base:latest" + DefaultUnikraftCloudRuntime = "index.unikraft.io/official/base:latest" ) // NewRuntime prepares a pre-built unikernel application for use. diff --git a/unikraft/target/target.go b/unikraft/target/target.go index d3d667916..f25f6345e 100644 --- a/unikraft/target/target.go +++ b/unikraft/target/target.go @@ -17,10 +17,10 @@ import ( "kraftkit.sh/unikraft/plat" ) -// DefaultKraftCloudTarget is the default target for KraftCloud. -var DefaultKraftCloudTarget *TargetConfig = NewTargetFromOptions( +// DefaultUnikraftCloudTarget is the default target for UnikraftCloud. +var DefaultUnikraftCloudTarget *TargetConfig = NewTargetFromOptions( WithArchitecture(arch.NewArchitectureFromOptions(arch.WithName("x86_64"))), - WithPlatform(plat.NewPlatformFromOptions(plat.WithName("kraftcloud"))), + WithPlatform(plat.NewPlatformFromOptions(plat.WithName("cloud"))), ).(*TargetConfig) type Target interface {