Modified to support Prod and Dev Mode
[ealt-edge.git] / ocd / cli / ealt / cmd / init / edge.go
1 /*
2 Copyright 2020 Huawei Technologies Co., Ltd.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8     http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16 package init
17
18 import (
19         "fmt"
20         "strings"
21
22         setup "ealt/cmd/setup"
23
24         "github.com/spf13/cobra"
25 )
26
27 func NewEdgeCommand() *cobra.Command {
28         var cmd = &cobra.Command{
29                 Use:   "edge",
30                 Short: "Install Edge Node",
31                 Long:  `Command to Install Edge Node only For Example : ealt init edge`,
32                 RunE: func(cmd *cobra.Command, args []string) error {
33                         fmt.Println("Installation of Edge components")
34                         setupModeFlag := strings.ToLower(cmd.Flag("mode").Value.String())
35                         var err error
36                         if setupModeFlag == "dev" {
37                                 err = setup.EaltInstall("edge")
38                         } else if setupModeFlag == "prod" {
39                                 err = setup.EaltInstall("ssledge")
40                         }
41                         if err != nil {
42                                 return err
43                         }
44                         return nil
45                 },
46         }
47         cmd.Flags().StringP("mode", "m", "dev", "Deployment Mode")
48         return cmd
49 }