Skip to content

Commit

Permalink
Merge "CLI: Add placeholders for backup and restore subcommands"
Browse files Browse the repository at this point in the history
  • Loading branch information
sf-project-io authored and Gerrit Code Review committed Jan 8, 2024
2 parents 1120411 + 85bc1e5 commit b7c00a2
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 2 deletions.
49 changes: 49 additions & 0 deletions cli/cmd/backup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
Copyright © 2023 Red Hat
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 cmd

/*
"backup" subcommand creates a backup of a deployment.
*/

import (
"errors"
"os"

"github.com/spf13/cobra"
ctrl "sigs.k8s.io/controller-runtime"
)

func backupCmd(kmd *cobra.Command, args []string) {
err := errors.New("backup is not supported yet")
ctrl.Log.Error(err, "Command error")
os.Exit(1)
}

func MkBackupCmd() *cobra.Command {

var (
backupCmd = &cobra.Command{
Use: "backup",
Short: "Create a backup of a deployment",
Long: `This isn't implemented yet, this subcommand is a placeholder.`,
Run: backupCmd,
}
)

return backupCmd
}
49 changes: 49 additions & 0 deletions cli/cmd/restore.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
Copyright © 2023 Red Hat
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 cmd

/*
"restore" subcommand restores a deployment to an existing backup.
*/

import (
"errors"
"os"

"github.com/spf13/cobra"
ctrl "sigs.k8s.io/controller-runtime"
)

func restoreCmd(kmd *cobra.Command, args []string) {
err := errors.New("backup is not supported yet")
ctrl.Log.Error(err, "Command error")
os.Exit(1)
}

func MkRestoreCmd() *cobra.Command {

var (
restoreCmd = &cobra.Command{
Use: "restore",
Short: "Restore a deployment to a previous backup",
Long: `This isn't implemented yet, this subcommand is a placeholder.`,
Run: restoreCmd,
}
)

return restoreCmd
}
12 changes: 10 additions & 2 deletions doc/reference/cli/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ deployments, beyond what can be defined in a custom resource manifest.
1. [Running the CLI](#running-the-cli)
1. [Global Flags](#global-flags)
1. [Configuration File](#configuration-file)
1. [Running the Operator](#running-the-operator)
1. [Subcommands](#subcommands)
1. [Apply](#apply)
1. [Operator](#apply)
1. [Backup](#backup)
1. [Restore](#restore)

## Running the CLI

Expand Down Expand Up @@ -118,4 +119,11 @@ Flags:
|----------|------|-------|----|----|
|--metrics-bind-address |string | The address the metric endpoint binds to. | Yes | :8080 |
|--health-probe-bind-address |string | The address the probe endpoint binds to. | Yes | :8081 |
|--leader-elect |boolean | Enable leader election for controller manager. | Yes | false |
|--leader-elect |boolean | Enable leader election for controller manager. | Yes | false |
### Backup

Not implemented yet

### Restore

Not implemented yet
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ func main() {
rootCmd.AddCommand(operatorCmd)
subcommands := []*cobra.Command{
cmd.MkApplyCmd(),
cmd.MkBackupCmd(),
cmd.MkRestoreCmd(),
}
for _, c := range subcommands {
rootCmd.AddCommand(c)
Expand Down

0 comments on commit b7c00a2

Please sign in to comment.