-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to remove applied profile
This lets profiles be removed (mostly by removing mounts so far), allowing them to be reapplied from a fresh state. Signed-off-by: Alexander Scheel <[email protected]>
- Loading branch information
Showing
4 changed files
with
86 additions
and
1 deletion.
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
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,49 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/cipherboy/devbao/pkg/bao" | ||
|
||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func BuildProfileRemoveCommand() *cli.Command { | ||
c := &cli.Command{ | ||
Name: "remove", | ||
Aliases: []string{"r"}, | ||
ArgsUsage: "<name> <profile>", | ||
Usage: "remove a profile from the given instance", | ||
|
||
Action: RunProfileRemoveCommand, | ||
} | ||
|
||
return c | ||
} | ||
|
||
func RunProfileRemoveCommand(cCtx *cli.Context) error { | ||
if len(cCtx.Args().Slice()) != 2 { | ||
return fmt.Errorf("missing required positional argument: instance name and policy\nUsage: devbao policy remove <name> <profile>") | ||
} | ||
|
||
name := cCtx.Args().First() | ||
policy := cCtx.Args().Get(1) | ||
|
||
node, err := bao.LoadNode(name) | ||
if err != nil { | ||
return fmt.Errorf("failed to load node: %w", err) | ||
} | ||
|
||
client, err := node.GetClient() | ||
if err != nil { | ||
return fmt.Errorf("failed to get client for node %v: %w", name, err) | ||
} | ||
|
||
warnings, err := bao.PolicyRemove(client, policy) | ||
for index, warning := range warnings { | ||
fmt.Fprintf(os.Stderr, " - [warning %d]: %v\n", index, warning) | ||
} | ||
|
||
return err | ||
} |
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