-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mgrpxy start, stop and restart commands
- Loading branch information
Showing
14 changed files
with
297 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package restart | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared/kubernetes" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
) | ||
|
||
func kubernetesRestart( | ||
globalFlags *types.GlobalFlags, | ||
flags *restartFlags, | ||
cmd *cobra.Command, | ||
args []string, | ||
) error { | ||
return kubernetes.Restart(kubernetes.ProxyFilter) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package restart | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared/podman" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
) | ||
|
||
func podmanRestart( | ||
globalFlags *types.GlobalFlags, | ||
flags *restartFlags, | ||
cmd *cobra.Command, | ||
args []string, | ||
) error { | ||
return podman.RestartService(podman.ProxyService) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package restart | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
"github.com/uyuni-project/uyuni-tools/shared/utils" | ||
) | ||
|
||
type restartFlags struct { | ||
Backend string | ||
} | ||
|
||
// NewCommand to restart server. | ||
func NewCommand(globalFlags *types.GlobalFlags) *cobra.Command { | ||
restartCmd := &cobra.Command{ | ||
Use: "restart", | ||
Short: "restart the proxy", | ||
Long: "Restart the proxy", | ||
Args: cobra.ExactArgs(0), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
var flags restartFlags | ||
return utils.CommandHelper(globalFlags, cmd, args, &flags, restart) | ||
}, | ||
} | ||
restartCmd.SetUsageTemplate(restartCmd.UsageTemplate()) | ||
|
||
utils.AddBackendFlag(restartCmd) | ||
|
||
return restartCmd | ||
} | ||
|
||
func restart(globalFlags *types.GlobalFlags, flags *restartFlags, cmd *cobra.Command, args []string) error { | ||
fn, err := shared.ChooseProxyPodmanOrKubernetes(cmd.Flags(), podmanRestart, kubernetesRestart) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return fn(globalFlags, flags, cmd, args) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package start | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared/kubernetes" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
) | ||
|
||
func kubernetesStart( | ||
globalFlags *types.GlobalFlags, | ||
flags *startFlags, | ||
cmd *cobra.Command, | ||
args []string, | ||
) error { | ||
return kubernetes.Start(kubernetes.ProxyFilter) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package start | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared/podman" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
) | ||
|
||
func podmanStart( | ||
globalFlags *types.GlobalFlags, | ||
flags *startFlags, | ||
cmd *cobra.Command, | ||
args []string, | ||
) error { | ||
return podman.StartService(podman.ProxyService) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package start | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
"github.com/uyuni-project/uyuni-tools/shared/utils" | ||
) | ||
|
||
type startFlags struct { | ||
Backend string | ||
} | ||
|
||
// NewCommand starts the server. | ||
func NewCommand(globalFlags *types.GlobalFlags) *cobra.Command { | ||
startCmd := &cobra.Command{ | ||
Use: "start", | ||
Short: "start the proxy", | ||
Long: "Start the proxy", | ||
Args: cobra.ExactArgs(0), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
var flags startFlags | ||
return utils.CommandHelper(globalFlags, cmd, args, &flags, start) | ||
}, | ||
} | ||
startCmd.SetUsageTemplate(startCmd.UsageTemplate()) | ||
|
||
if utils.KubernetesBuilt { | ||
utils.AddBackendFlag(startCmd) | ||
} | ||
|
||
return startCmd | ||
} | ||
|
||
func start(globalFlags *types.GlobalFlags, flags *startFlags, cmd *cobra.Command, args []string) error { | ||
fn, err := shared.ChooseProxyPodmanOrKubernetes(cmd.Flags(), podmanStart, kubernetesStart) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return fn(globalFlags, flags, cmd, args) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package stop | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared/kubernetes" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
) | ||
|
||
func kubernetesStop( | ||
globalFlags *types.GlobalFlags, | ||
flags *stopFlags, | ||
cmd *cobra.Command, | ||
args []string, | ||
) error { | ||
return kubernetes.Stop(kubernetes.ProxyFilter) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package stop | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared/podman" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
) | ||
|
||
func podmanStop( | ||
globalFlags *types.GlobalFlags, | ||
flags *stopFlags, | ||
cmd *cobra.Command, | ||
args []string, | ||
) error { | ||
return podman.StopService(podman.ProxyService) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package stop | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
"github.com/uyuni-project/uyuni-tools/shared/utils" | ||
) | ||
|
||
type stopFlags struct { | ||
Backend string | ||
} | ||
|
||
// NewCommand to stop server. | ||
func NewCommand(globalFlags *types.GlobalFlags) *cobra.Command { | ||
stopCmd := &cobra.Command{ | ||
Use: "stop", | ||
Short: "stop the proxy", | ||
Long: "Stop the proxy", | ||
Args: cobra.ExactArgs(0), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
var flags stopFlags | ||
return utils.CommandHelper(globalFlags, cmd, args, &flags, stop) | ||
}, | ||
} | ||
|
||
stopCmd.SetUsageTemplate(stopCmd.UsageTemplate()) | ||
|
||
utils.AddBackendFlag(stopCmd) | ||
|
||
return stopCmd | ||
} | ||
|
||
func stop(globalFlags *types.GlobalFlags, flags *stopFlags, cmd *cobra.Command, args []string) error { | ||
fn, err := shared.ChooseProxyPodmanOrKubernetes(cmd.Flags(), podmanStop, kubernetesStop) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return fn(globalFlags, flags, cmd, args) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Add mgrpxy start, stop and restart commands |