2019-01-09 16:54:15 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"github.com/docker/docker/pkg/reexec"
|
2019-02-08 04:08:10 +00:00
|
|
|
crictl2 "github.com/kubernetes-sigs/cri-tools/cmd/crictl"
|
2019-01-09 16:54:15 +00:00
|
|
|
"github.com/rancher/k3s/pkg/cli/agent"
|
|
|
|
"github.com/rancher/k3s/pkg/cli/cmds"
|
2019-02-08 04:08:10 +00:00
|
|
|
"github.com/rancher/k3s/pkg/cli/crictl"
|
2019-06-30 16:30:25 +00:00
|
|
|
"github.com/rancher/k3s/pkg/cli/ctr"
|
2021-01-21 21:09:15 +00:00
|
|
|
"github.com/rancher/k3s/pkg/cli/etcdsnapshot"
|
2019-01-09 16:54:15 +00:00
|
|
|
"github.com/rancher/k3s/pkg/cli/kubectl"
|
|
|
|
"github.com/rancher/k3s/pkg/cli/server"
|
2020-08-30 03:30:07 +00:00
|
|
|
"github.com/rancher/k3s/pkg/configfilearg"
|
2019-01-09 16:54:15 +00:00
|
|
|
"github.com/rancher/k3s/pkg/containerd"
|
2019-06-30 16:30:25 +00:00
|
|
|
ctr2 "github.com/rancher/k3s/pkg/ctr"
|
2019-01-09 16:54:15 +00:00
|
|
|
kubectl2 "github.com/rancher/k3s/pkg/kubectl"
|
|
|
|
"github.com/sirupsen/logrus"
|
2020-08-29 19:46:55 +00:00
|
|
|
"github.com/urfave/cli"
|
2019-01-09 16:54:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
reexec.Register("containerd", containerd.Main)
|
|
|
|
reexec.Register("kubectl", kubectl2.Main)
|
2019-02-08 04:08:10 +00:00
|
|
|
reexec.Register("crictl", crictl2.Main)
|
2019-06-30 16:30:25 +00:00
|
|
|
reexec.Register("ctr", ctr2.Main)
|
2019-01-09 16:54:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
cmd := os.Args[0]
|
|
|
|
os.Args[0] = filepath.Base(os.Args[0])
|
|
|
|
if reexec.Init() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
os.Args[0] = cmd
|
|
|
|
|
|
|
|
app := cmds.NewApp()
|
2020-08-29 19:46:55 +00:00
|
|
|
app.Commands = []cli.Command{
|
2019-01-09 16:54:15 +00:00
|
|
|
cmds.NewServerCommand(server.Run),
|
|
|
|
cmds.NewAgentCommand(agent.Run),
|
|
|
|
cmds.NewKubectlCommand(kubectl.Run),
|
2019-02-08 04:08:10 +00:00
|
|
|
cmds.NewCRICTL(crictl.Run),
|
2019-06-30 16:30:25 +00:00
|
|
|
cmds.NewCtrCommand(ctr.Run),
|
2021-05-13 20:36:33 +00:00
|
|
|
cmds.NewEtcdSnapshotCommand(etcdsnapshot.Run,
|
|
|
|
cmds.NewEtcdSnapshotSubcommands(
|
|
|
|
etcdsnapshot.Delete,
|
|
|
|
etcdsnapshot.List,
|
2021-05-17 17:55:13 +00:00
|
|
|
etcdsnapshot.Prune,
|
|
|
|
etcdsnapshot.Run),
|
2021-05-13 20:36:33 +00:00
|
|
|
),
|
2019-01-09 16:54:15 +00:00
|
|
|
}
|
|
|
|
|
2020-08-30 03:30:07 +00:00
|
|
|
err := app.Run(configfilearg.MustParse(os.Args))
|
2019-01-09 16:54:15 +00:00
|
|
|
if err != nil {
|
|
|
|
logrus.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|