Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: Deprecate 'kraftcloud' and replace with 'cloud'/'ukc' #1885

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions config/kraftcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/kraft/build/builder_kraftfile_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/kraft/cloud/certificate/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
})
Expand Down
34 changes: 17 additions & 17 deletions internal/cli/kraft/cloud/certificate/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -24,34 +24,34 @@ 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 {
opts = &CreateOptions{}
}

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)),
)
}

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions internal/cli/kraft/cloud/certificate/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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{}
Expand All @@ -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 {
Expand All @@ -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])
Expand Down
10 changes: 5 additions & 5 deletions internal/cli/kraft/cloud/certificate/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions internal/cli/kraft/cloud/certificate/remove/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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{}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
18 changes: 9 additions & 9 deletions internal/cli/kraft/cloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
})
Expand All @@ -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
Expand Down
Loading
Loading