Added Create and Delete CLI Commands 58/3458/4
authorabhijit_onap <abhijit.das.gupta@huawei.com>
Thu, 14 May 2020 22:05:37 +0000 (03:35 +0530)
committerGaurav Agrawal <gaurav.agrawal@huawei.com>
Sat, 16 May 2020 06:26:19 +0000 (06:26 +0000)
Handled the POST and DELETE Request for
API's for Application Package Managment and
Application Life Cycle Management

Removed training whitespaces from files.
Ran go fmt tool on all the go files as per
recommendation by official GoLang Guidelines
for formating Go files.

Signed-off-by: abhijit_onap <abhijit.das.gupta@huawei.com>
Change-Id: I648b390cff4af806508b1a08bb1517bd83474ecb
Signed-off-by: abhijit_onap <abhijit.das.gupta@huawei.com>
21 files changed:
ocd/cli/ealt/cmd/adapter/converter.go [new file with mode: 0644]
ocd/cli/ealt/cmd/adapter/httphelper.go [new file with mode: 0644]
ocd/cli/ealt/cmd/applcm.go
ocd/cli/ealt/cmd/applcmpkg/create.go [new file with mode: 0644]
ocd/cli/ealt/cmd/applcmpkg/delete.go
ocd/cli/ealt/cmd/applcmpkg/start.go
ocd/cli/ealt/cmd/applcmpkg/terminate.go
ocd/cli/ealt/cmd/appm/create.go [new file with mode: 0644]
ocd/cli/ealt/cmd/appm/delete.go
ocd/cli/ealt/cmd/clean.go
ocd/cli/ealt/cmd/clean/all.go
ocd/cli/ealt/cmd/clean/edge.go
ocd/cli/ealt/cmd/clean/infra.go
ocd/cli/ealt/cmd/common/constant.go [new file with mode: 0644]
ocd/cli/ealt/cmd/init.go
ocd/cli/ealt/cmd/init/all.go
ocd/cli/ealt/cmd/init/infra.go
ocd/cli/ealt/cmd/root.go
ocd/cli/ealt/cmd/setup/common.go
ocd/cli/ealt/cmd/setup/install.go
ocd/cli/ealt/main.go

diff --git a/ocd/cli/ealt/cmd/adapter/converter.go b/ocd/cli/ealt/cmd/adapter/converter.go
new file mode 100644 (file)
index 0000000..6586a46
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+Copyright 2020 Huawei Technologies Co., Ltd.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package adapter
+
+import (
+       "ealt/cmd/common"
+       "encoding/json"
+       "fmt"
+       "log"
+       "strings"
+)
+
+func BuilderRequest(valueArgs []string, command string) error {
+
+       var URIString string
+
+       switch command {
+       case "NewAppCreateCommand":
+               //Onboard Command
+               //ealtedge/mepm/app_pkgm/v1/app_packages/
+               //read the file from the system.
+               URIString = common.AppmUri
+               var packageName string
+               var body []byte
+               body = jsonEmptyBodyFormat()
+               packageName = strings.TrimSpace(valueArgs[0])
+               HttpMultiPartPostRequestBuilder(URIString, body, packageName)
+               fmt.Println(packageName)
+
+       case "NewAppDeleteCommand":
+               //The Delete Application Package URI
+               //ealtedge/mepm/app_pkgm/v1/app_packages/{{ID}}
+               var body []byte
+               URIString = common.AppmUri + strings.TrimSpace(valueArgs[0])
+               body = jsonEmptyBodyFormat()
+               fmt.Println(URIString)
+               HttpDeleteRequestBuilder(URIString, body)
+
+               fmt.Println(URIString)
+
+       case "NewApplcmCreateCommand":
+               //appLCM application Creation URI
+               //ealtedge/mepm/app_lcm/v1/app_instances
+               var body []byte
+
+               URIString = common.ApplcmUri
+               body, err := json.Marshal(map[string]string{
+                       "appDId":                strings.TrimSpace(valueArgs[0]),
+                       "appInstancename":       strings.TrimSpace(valueArgs[1]),
+                       "appInstanceDescriptor": strings.TrimSpace(valueArgs[2]),
+               })
+
+               if err != nil {
+                       log.Fatalln(err)
+               }
+               fmt.Println(URIString)
+               HttpPostRequestBuilder(URIString, body)
+
+       case "NewApplcmDeleteCommand":
+               //appLCM Delete Application URI
+               ///ealtedge/mepm/app_lcm/v1/app_instances/{appInstanceId}
+               var body []byte
+               URIString = common.ApplcmUri + strings.TrimSpace(valueArgs[0])
+               body = jsonEmptyBodyFormat()
+               fmt.Println(URIString)
+               HttpDeleteRequestBuilder(URIString, body)
+
+       case "NewApplcmStartCommand":
+               //applcm application instantiate uri
+               //ealtedge/mepm/app_lcm/v1/app_instances/{appInstanceId}/instantiate
+               var body []byte
+
+               URIString = common.ApplcmUri + strings.TrimSpace(valueArgs[0]) + common.InstantiateUri
+               body = jsonEmptyBodyFormat()
+               fmt.Println(URIString)
+               HttpPostRequestBuilder(URIString, body)
+
+       case "NewApplcmTerminateCommand":
+               //applcm application terminate uri
+               //ealtedge/mepm/app_lcm/v1/app_instances/{appInstanceId}/terminate
+               var body []byte
+               URIString = common.ApplcmUri + strings.TrimSpace(valueArgs[0]) + common.TerminateUri
+               body = jsonEmptyBodyFormat()
+               fmt.Println(URIString)
+               HttpPostRequestBuilder(URIString, body)
+
+       }
+
+       return nil
+}
+
+func jsonEmptyBodyFormat() []byte {
+       var jsonstr []byte
+       jsonstr = []byte(`{"":""}`)
+       return jsonstr
+}
diff --git a/ocd/cli/ealt/cmd/adapter/httphelper.go b/ocd/cli/ealt/cmd/adapter/httphelper.go
new file mode 100644 (file)
index 0000000..2f34d7c
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+Copyright 2020 Huawei Technologies Co., Ltd.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package adapter
+
+import (
+       "bytes"
+       "ealt/cmd/common"
+       "encoding/json"
+       "fmt"
+       "io"
+       "io/ioutil"
+       "log"
+       "mime/multipart"
+       "net/http"
+       "os"
+       "strings"
+)
+
+var MECMClusterIP = os.Getenv("MECMClusterIP")
+var APPLCMPort = os.Getenv("MECMClusterPort")
+var ONBOARDPACKAGEPATH = os.Getenv("ONBOARDPACKAGEPATH")
+var client = http.Client{}
+
+func httpEndPointBuider(uri string) string {
+
+       return "http://" + strings.TrimSpace(MECMClusterIP) + strings.TrimSpace(APPLCMPort) + uri
+
+}
+
+func HttpDeleteRequestBuilder(uri string, body []byte) {
+
+       uri = httpEndPointBuider(uri)
+       request, err := http.NewRequest(http.MethodDelete, uri, bytes.NewBuffer(body))
+       request.Header.Set("Content-Type", "application/json")
+
+       if err != nil {
+               log.Fatalln(err)
+       }
+
+       response, err := client.Do(request)
+       if err != nil {
+               log.Fatalln(err)
+       }
+       defer response.Body.Close()
+
+       output, err := ioutil.ReadAll(response.Body)
+
+       if err != nil {
+               log.Fatalln(err)
+       }
+
+       fmt.Println(string(output))
+
+}
+
+func HttpPostRequestBuilder(uri string, body []byte) error {
+
+       uri = httpEndPointBuider(uri)
+       request, err := http.NewRequest(http.MethodPost, uri, bytes.NewBuffer(body))
+       request.Header.Set("Content-Type", "application/json")
+
+       fmt.Println(request)
+
+       if err != nil {
+               log.Fatalln(err)
+       }
+
+       response, err := client.Do(request)
+       if err != nil {
+               log.Fatalln(err)
+       }
+       defer response.Body.Close()
+
+       output, err := ioutil.ReadAll(response.Body)
+
+       if err != nil {
+               log.Fatalln(err)
+       }
+
+       fmt.Println(string(output))
+       return nil
+}
+
+func HttpMultiPartPostRequestBuilder(uri string, body []byte, file string) error {
+
+       filepath := getFilePathWithName(file)
+       uri = httpEndPointBuider(uri)
+
+       request, err := fileUploadRequest(uri, "file", filepath)
+
+       response, err := client.Do(request)
+       if err != nil {
+               log.Fatalln(err)
+       }
+
+       var result map[string]interface{}
+       json.NewDecoder(response.Body).Decode(&result)
+       fmt.Println(result)
+
+       return nil
+}
+
+func getFilePathWithName(file string) string {
+
+       return ONBOARDPACKAGEPATH + common.PATHSLASH + file
+}
+
+func fileUploadRequest(uri string, paramName, filepath string) (*http.Request, error) {
+
+       file, err := os.Open(filepath)
+       if err != nil {
+               return nil, err
+       }
+
+       //close the file later
+       defer file.Close()
+
+       //Buffer to store the request body as bytes
+       var requestBody bytes.Buffer
+       multiPartWriter := multipart.NewWriter(&requestBody)
+
+       fileWriter, err := multiPartWriter.CreateFormFile("file_field", filepath)
+       if err != nil {
+               log.Fatalln(err)
+       }
+
+       //Copy the actual file contents
+       _, err = io.Copy(fileWriter, file)
+       if err != nil {
+               log.Fatalln(err)
+       }
+
+       //Close multiwriter
+       multiPartWriter.Close()
+
+       request, err := http.NewRequest(http.MethodPost, uri, &requestBody)
+       if err != nil {
+               log.Fatalln(err)
+       }
+       request.Header.Set("Content-Type", "multipart/form-data")
+       return request, err
+}
index 01057b5..a5386cc 100644 (file)
@@ -26,13 +26,14 @@ import (
 // applcmCmd represents the applcm command
 var applcmCmd = &cobra.Command{
        Use:   "applcm",
-       Short: "A brief description of your command",
-       Long: `A longer description that spans multiple lines and likely contains examples
-and usage of using your command. For example:
-
-Cobra is a CLI library for Go that empowers applications.
-This application is a tool to generate the needed files
-to quickly create a Cobra application.`,
+       Short: "Commands to send request to the APPLCM Application",
+       Long: `To manage the application running on the MEP Node, APPLCM exposes
+       some API which can be used to manage the Applicaton running on the MEP Node
+       The command have following options :
+       1. Create
+       2. Start
+       3. Delete
+       4. Stop.`,
        Run: func(cmd *cobra.Command, args []string) {
                fmt.Println("applcm called")
        },
@@ -41,6 +42,10 @@ to quickly create a Cobra application.`,
 func init() {
 
        applcmCmd.AddCommand(applcmCmds.NewApplcmCreateCommand())
+       applcmCmd.AddCommand(applcmCmds.NewApplcmStartCommand())
+       applcmCmd.AddCommand(applcmCmds.NewApplcmDeleteCommand())
+       applcmCmd.AddCommand(applcmCmds.NewApplcmTerminateCommand())
+
        rootCmd.AddCommand(applcmCmd)
 
 }
diff --git a/ocd/cli/ealt/cmd/applcmpkg/create.go b/ocd/cli/ealt/cmd/applcmpkg/create.go
new file mode 100644 (file)
index 0000000..88ba1c3
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+Copyright 2020 Huawei Technologies Co., Ltd.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+package applcmpkg
+
+import (
+       "ealt/cmd/adapter"
+
+       "github.com/spf13/cobra"
+)
+
+// deployCmd represents the deploy command
+func NewApplcmCreateCommand() *cobra.Command {
+       var cmd = &cobra.Command{
+               Use:   "create",
+               Short: "To create the application instance on MEP Node",
+               Long:  `To create the application instance on MEP Node`,
+               RunE: func(cmd *cobra.Command, args []string) error {
+                       theFlags := []string{cmd.Flag("appdid").Value.String(),
+                               cmd.Flag("name").Value.String(),
+                               cmd.Flag("desc").Value.String()}
+                       err := adapter.BuilderRequest(theFlags, "NewApplcmCreateCommand")
+                       if err != nil {
+                               return err
+                       }
+                       return nil
+               },
+       }
+       cmd.Flags().StringP("appdid", "i", "", "Application  ID to be created MEP")
+       cmd.Flags().StringP("name", "n", "", "Application Instance Name")
+       cmd.Flags().StringP("desc", "d", "", "Application Instance Descriptor")
+       cmd.MarkFlagRequired("appdid")
+       cmd.MarkFlagRequired("name")
+       cmd.MarkFlagRequired("desc")
+       return cmd
+}
index 9e53156..d3104ac 100644 (file)
@@ -28,9 +28,10 @@ func NewApplcmDeleteCommand() *cobra.Command {
                Short: "Install Complete EALT Deployment Environment",
                Long:  `Install Complete EALT Deployment Environment`,
                RunE: func(cmd *cobra.Command, args []string) error {
-                       applicationIdArg := cmd.Flag("appid")
-                       applicationId := applicationIdArg.Value.String()
-                       err := adapter.BuilderRequest(applicationId, "NewApplcmDeleteCommand")
+                       var theFlags []string
+                       theFlags[0] = cmd.Flag("appid").Value.String()
+
+                       err := adapter.BuilderRequest(theFlags, "NewApplcmDeleteCommand")
                        if err != nil {
                                return err
                        }
@@ -38,7 +39,7 @@ func NewApplcmDeleteCommand() *cobra.Command {
                },
        }
 
-       cmd.Flags().StringP("appid", "i", "", "Application Package ID to be deleted from MEP")
-
+       cmd.Flags().StringP("appid", "i", "", "Application Instance ID to be started")
+       cmd.MarkFlagRequired("appid")
        return cmd
 }
index 8c81bd1..2ae47dd 100644 (file)
@@ -17,6 +17,7 @@ package applcmpkg
 
 import (
        "ealt/cmd/adapter"
+       "fmt"
 
        "github.com/spf13/cobra"
 )
@@ -28,9 +29,10 @@ func NewApplcmStartCommand() *cobra.Command {
                Short: "To start the application instance on MEP Node",
                Long:  `To start the application instance on MEP Node`,
                RunE: func(cmd *cobra.Command, args []string) error {
-                       appIdArg := cmd.Flag("appid")
-                       applicationId := appIdArg.Value.String()
-                       err := adapter.BuilderRequest(applicationId, "NewApplcmStartCommand")
+                       theFlags := []string{cmd.Flag("appid").Value.String()}
+                       //theFlags[0] = cmd.Flag("appid").Value.String()
+                       fmt.Println(theFlags[0])
+                       err := adapter.BuilderRequest(theFlags, "NewApplcmStartCommand")
                        if err != nil {
                                return err
                        }
@@ -38,5 +40,6 @@ func NewApplcmStartCommand() *cobra.Command {
                },
        }
        cmd.Flags().StringP("appid", "i", "", "Application Instance ID to be started")
+       cmd.MarkFlagRequired("appid")
        return cmd
 }
index bc1619f..20c87b9 100644 (file)
@@ -28,9 +28,9 @@ func NewApplcmTerminateCommand() *cobra.Command {
                Short: "To kill the application ",
                Long:  `Install Complete EALT Deployment Environment`,
                RunE: func(cmd *cobra.Command, args []string) error {
-                       appIdArg := cmd.Flag("appid")
-                       applicationId := appIdArg.Value.String()
-                       err := adapter.BuilderRequest(applicationId, "NewApplcmTerminateCommand")
+                       var theFlags []string
+                       theFlags[0] = cmd.Flag("appid").Value.String()
+                       err := adapter.BuilderRequest(theFlags, "NewApplcmTerminateCommand")
                        if err != nil {
                                return err
                        }
@@ -39,6 +39,7 @@ func NewApplcmTerminateCommand() *cobra.Command {
        }
 
        cmd.Flags().StringP("appid", "i", "", "Application Instance ID to be terminated")
+       cmd.MarkFlagRequired("appid")
 
        return cmd
 }
diff --git a/ocd/cli/ealt/cmd/appm/create.go b/ocd/cli/ealt/cmd/appm/create.go
new file mode 100644 (file)
index 0000000..5ea257d
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+Copyright 2020 Huawei Technologies Co., Ltd.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+package appm
+
+import (
+       "ealt/cmd/adapter"
+
+       "github.com/spf13/cobra"
+)
+
+// deployCmd represents the deploy command
+func NewAppCreateCommand() *cobra.Command {
+       var cmd = &cobra.Command{
+               Use:   "create",
+               Short: "To create the application on MEP Node",
+               Long:  `To create the application on MEP Node`,
+               RunE: func(cmd *cobra.Command, args []string) error {
+                       var theFlags []string
+                       theFlags[0] = cmd.Flag("packagefile").Value.String()
+                       err := adapter.BuilderRequest(theFlags, "NewAppCreateCommand")
+                       if err != nil {
+                               return err
+                       }
+                       return nil
+               },
+       }
+       cmd.Flags().StringP("packagefile", "f", "", "Application Package File to be onboarded to MEP")
+       cmd.MarkFlagRequired("packagefile")
+       return cmd
+}
index 8cca0da..cb79a52 100644 (file)
@@ -28,9 +28,9 @@ func NewAppDeleteCommand() *cobra.Command {
                Short: "Install Complete EALT Deployment Environment",
                Long:  `Install Complete EALT Deployment Environment`,
                RunE: func(cmd *cobra.Command, args []string) error {
-                       pkgidArg := cmd.Flag("pkgid")
-                       packageId := pkgidArg.Value.String()
-                       err := adapter.BuilderRequest(packageId, "NewAppDeleteCommand")
+                       var theFlags []string
+                       theFlags[0] = cmd.Flag("pkgid").Value.String()
+                       err := adapter.BuilderRequest(theFlags, "NewAppDeleteCommand")
                        if err != nil {
                                return err
                        }
@@ -38,7 +38,8 @@ func NewAppDeleteCommand() *cobra.Command {
                },
        }
 
-       cmd.Flags().StringP("pkgid", "i", "", "Application Package ID to be deleted from MEP")
+       cmd.Flags().StringP("packageid", "i", "", "Application Package ID to be deleted from MEP")
+       cmd.MarkFlagRequired("packageid")
 
        return cmd
 }
index daa96d8..78f3b5d 100644 (file)
@@ -16,7 +16,6 @@ limitations under the License.
 package cmd
 
 import (
-
        cleancmds "ealt/cmd/clean"
        "github.com/spf13/cobra"
 )
@@ -25,7 +24,7 @@ import (
 var cleanCmd = &cobra.Command{
        Use:   "clean",
        Short: "To uninstall ealt environment or specific component or node.",
-       Long: `To uninstall ealt environment or specific component or node.`,
+       Long:  `To uninstall ealt environment or specific component or node.`,
 }
 
 func init() {
@@ -44,4 +43,4 @@ func init() {
        //Add init subcommand to root command.
        rootCmd.AddCommand(cleanCmd)
 
-}
\ No newline at end of file
+}
index 024ce19..550281b 100644 (file)
@@ -16,7 +16,6 @@ limitations under the License.
 package init
 
 import (
-
        setup "ealt/cmd/setup"
 
        "github.com/spf13/cobra"
index 031bdac..fb11e31 100644 (file)
@@ -16,7 +16,6 @@ limitations under the License.
 package init
 
 import (
-
        setup "ealt/cmd/setup"
 
        "github.com/spf13/cobra"
index 324ec1d..453cb65 100644 (file)
@@ -25,7 +25,7 @@ func NewInfraCommand() *cobra.Command {
        var cmd = &cobra.Command{
                Use:   "infra",
                Short: "Uninstall only infrastructure components on MECM and Edge Node",
-               Long:  `Command to Uninstall only infrastructure components on MECM and Edge Node For Example : ealt clean  infra`,             
+               Long:  `Command to Uninstall only infrastructure components on MECM and Edge Node For Example : ealt clean  infra`,
                RunE: func(cmd *cobra.Command, args []string) error {
                        err := setup.EaltReset("infra")
                        if err != nil {
diff --git a/ocd/cli/ealt/cmd/common/constant.go b/ocd/cli/ealt/cmd/common/constant.go
new file mode 100644 (file)
index 0000000..64922f0
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+Copyright 2020 Huawei Technologies Co., Ltd.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package common
+
+const (
+       AppmUri   = "/ealtedge/mepm/app_pkgm/v1/app_packages/"
+       ApplcmUri = "/ealtedge/mepm/app_lcm/v1/app_instances/"
+
+       InstantiateUri = "/instantiate"
+       TerminateUri   = "/terminate"
+
+       PATHSLASH = "/"
+)
index b6c7f29..cf8fcdb 100644 (file)
@@ -16,7 +16,6 @@ limitations under the License.
 package cmd
 
 import (
-
        initCmds "ealt/cmd/init"
 
        "github.com/spf13/cobra"
@@ -35,7 +34,7 @@ var initCmd = &cobra.Command{
 
 func init() {
        //Adding the various sub-commands of init command
-       //Adding all subcommand to init 
+       //Adding all subcommand to init
        initCmd.AddCommand(initCmds.NewAllCommand())
        //ealt init infra
        initCmd.AddCommand(initCmds.NewInfraCommand())
index 1654a16..915eb5e 100644 (file)
@@ -16,7 +16,6 @@ limitations under the License.
 package init
 
 import (
-
        setup "ealt/cmd/setup"
 
        "github.com/spf13/cobra"
index 3e963ef..f25c61f 100644 (file)
@@ -25,7 +25,7 @@ func NewInfraCommand() *cobra.Command {
        var cmd = &cobra.Command{
                Use:   "infra",
                Short: "Install only infrastructure components on MECM and Edge Node",
-               Long:  `Command to install only infrastructure components on MECM and Edge Node For Example : ealt init infra`,         
+               Long:  `Command to install only infrastructure components on MECM and Edge Node For Example : ealt init infra`,
                RunE: func(cmd *cobra.Command, args []string) error {
                        err := setup.EaltInstall("infra")
                        if err != nil {
index 7299e75..8fe308f 100644 (file)
@@ -15,8 +15,7 @@
  */
 package cmd
 
-
- import (
+import (
        "fmt"
        "os"
 
@@ -47,4 +46,4 @@ func Execute() {
 }
 
 func init() {
-}
\ No newline at end of file
+}
index e0b8468..c7bfbd6 100644 (file)
@@ -18,7 +18,6 @@ limitations under the License.
 // It returns an error if the command outputs anything on the stderr.
 package setup
 
-
 import (
        "bytes"
        "fmt"
@@ -89,14 +88,14 @@ func (cm Command) ExecuteCmdShowOutput() error {
 }
 
 func runCommandAtShell(command string) (string, error) {
-    cmd := &Command{Cmd: exec.Command("sh", "-c", command)}
-    err := cmd.ExecuteCmdShowOutput()
-    if err != nil {
-            return "", err
-    }
-    errout := cmd.GetStdErr()
-    if errout != "" {
-            return "", fmt.Errorf("%s", errout)
-    }
-    return cmd.GetStdOutput(), nil
+       cmd := &Command{Cmd: exec.Command("sh", "-c", command)}
+       err := cmd.ExecuteCmdShowOutput()
+       if err != nil {
+               return "", err
+       }
+       errout := cmd.GetStdErr()
+       if errout != "" {
+               return "", fmt.Errorf("%s", errout)
+       }
+       return cmd.GetStdOutput(), nil
 }
index e9a771d..2ee636c 100644 (file)
@@ -15,10 +15,10 @@ limitations under the License.
 */
 package setup
 
-
 import (
        "fmt"
 )
+
 func EaltInstall(component string) error {
        var strEaltSetup string
        switch component {
@@ -33,7 +33,7 @@ func EaltInstall(component string) error {
        case "k8s":
                strEaltSetup = fmt.Sprintf("ansible-playbook ealt-all.yml -i ealt-inventory.ini --tags \"k8s\" --extra-vars \"operation=install\"")
        case "k3s":
-               strEaltSetup = fmt.Sprintf("ansible-playbook ealt-all.yml -i ealt-inventory.ini --tags \"k3s\" --extra-vars \"operation=install\"")             
+               strEaltSetup = fmt.Sprintf("ansible-playbook ealt-all.yml -i ealt-inventory.ini --tags \"k3s\" --extra-vars \"operation=install\"")
        default:
                fmt.Println("Provide subcommand for ealt init [all|infra|manager|edge|k8s|k3s]")
        }
@@ -61,7 +61,7 @@ func EaltReset(component string) error {
        case "k8s":
                strEaltReset = fmt.Sprintf("ansible-playbook ealt-all-uninstall.yml -i ealt-inventory.ini --tags \"k8s\" --extra-vars \"operation=uninstall\"")
        case "k3s":
-               strEaltReset = fmt.Sprintf("ansible-playbook ealt-all-uninstall.yml -i ealt-inventory.ini --tags \"k3s\" --extra-vars \"operation=uninstall\"")         
+               strEaltReset = fmt.Sprintf("ansible-playbook ealt-all-uninstall.yml -i ealt-inventory.ini --tags \"k3s\" --extra-vars \"operation=uninstall\"")
        default:
                fmt.Println("Provide subcommand for ealt clean [all|infra|manager|edge|k8s|k3s]")
        }
@@ -72,4 +72,4 @@ func EaltReset(component string) error {
        }
        fmt.Println(stdout)
        return nil
-}
\ No newline at end of file
+}
index 7060933..5991a19 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package main
 
 import "ealt/cmd"