blob: 1fc6d64e57123f655af7175e49705313e8da897d [file] [log] [blame]
Giorgi Lekveishvilibd6be7f2023-05-26 15:51:28 +04001package main
2
3import (
4 "os"
5
6 "github.com/giolekva/pcloud/core/installer"
7 "github.com/spf13/cobra"
8 "golang.org/x/crypto/ssh"
9)
10
11var appManagerFlags struct {
12 sshKey string
13 repoAddr string
14}
15
16func appManagerCmd() *cobra.Command {
17 cmd := &cobra.Command{
18 Use: "appmanager",
19 RunE: installCmdRun,
20 }
21 cmd.Flags().StringVar(
22 &installFlags.sshKey,
23 "ssh-key",
24 "",
25 "",
26 )
27 cmd.Flags().StringVar(
28 &installFlags.repoAddr,
29 "repo-addr",
30 "",
31 "",
32 )
33 return cmd
34}
35
36func appManagerCmdRun(cmd *cobra.Command, args []string) error {
37 sshKey, err := os.ReadFile(installFlags.sshKey)
38 if err != nil {
39 return err
40 }
41 signer, err := ssh.ParsePrivateKey(sshKey)
42 if err != nil {
43 return err
44 }
45 repo, err := cloneRepo(installFlags.repoAddr, signer)
46 if err != nil {
47 return err
48 }
49 _, err = installer.NewAppManager(repo, signer)
50 if err != nil {
51 return err
52 }
53 // TODO(gio): start server
54 return nil
55}