/
stop_application.go
49 lines (43 loc) · 1.35 KB
/
stop_application.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* *******************************************************************************
* * Copyright (c) 2023 Datasance Teknoloji A.S.
* *
* * This program and the accompanying materials are made available under the
* * terms of the Eclipse Public License v. 2.0 which is available at
* * http://www.eclipse.org/legal/epl-2.0
* *
* * SPDX-License-Identifier: EPL-2.0
* *******************************************************************************
*
*/
package cmd
import (
stopapplication "github.com/datasance/potctl/internal/stop"
"github.com/datasance/potctl/pkg/util"
"github.com/spf13/cobra"
)
func newStopApplicationCommand() *cobra.Command {
opt := stopapplication.Options{}
cmd := &cobra.Command{
Use: "application NAME",
Short: "Stop an application",
Long: "Stop an application",
Example: `potctl stop application NAME`,
Args: cobra.ExactValidArgs(1),
Run: func(cmd *cobra.Command, args []string) {
var err error
if len(args) == 0 {
util.Check(util.NewInputError("Must specify an application to start"))
}
opt.Name = args[0]
opt.Namespace, err = cmd.Flags().GetString("namespace")
util.Check(err)
exe := stopapplication.NewExecutor(opt)
// Execute the command
err = exe.Execute()
util.Check(err)
util.PrintSuccess("Successfully stopped Application " + opt.Name)
},
}
return cmd
}