1
0
mirror of https://github.com/rancher/cli.git synced 2026-02-05 09:48:36 +01:00
Files
cli/cmd/up.go
Enrico Candino 0e8a1106be Added linter and removed deprecated and unused packages (#357)
* Create go.yml

* updated golangci config file

* renamed action file

* removed unused prompt command

* fixed SA6005 (staticcheck): used strings.EqualFold

* removed unused monitor package

* removed unused funcs and fields

* fixed SA1019 (staticcheck): removed deprecations

* added missing error checking

* fixed linter

* removed unused (and unimplemented) commands

* added error to getClusterK8sOptions

* oneliner err check in displayListServers

* removed unused docker dependency
2024-04-10 11:52:59 +02:00

49 lines
915 B
Go

package cmd
import (
"os"
"github.com/rancher/cli/cliclient"
client "github.com/rancher/rancher/pkg/client/generated/management/v3"
"github.com/urfave/cli"
)
func UpCommand() cli.Command {
return cli.Command{
Name: "up",
Usage: "apply compose config",
Action: defaultAction(apply),
Flags: []cli.Flag{
cli.StringFlag{
Name: "file,f",
Usage: "The location of compose config file",
},
},
}
}
func apply(ctx *cli.Context) error {
cf, err := lookupConfig(ctx)
if err != nil {
return err
}
c, err := cliclient.NewManagementClient(cf)
if err != nil {
return err
}
filePath := ctx.String("file")
compose, err := os.ReadFile(filePath)
if err != nil {
return err
}
globalComposeConfig := &client.ComposeConfig{
RancherCompose: string(compose),
}
if _, err := c.ManagementClient.ComposeConfig.Create(globalComposeConfig); err != nil {
return err
}
return nil
}