forked from bpicode/fritzctl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manifest_plan.go
29 lines (25 loc) · 879 Bytes
/
manifest_plan.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
package cmd
import (
"github.com/bpicode/fritzctl/fritz"
"github.com/bpicode/fritzctl/manifest"
"github.com/spf13/cobra"
)
var planManifestCmd = &cobra.Command{
Use: "plan [manifest file]",
Short: "Plan a given manifest (dry-run)",
Long: "Plan/dry-run a given manifest against the state of the FRITZ!Box. No changes will be applied.",
Example: "fritzctl manifest plan /path/to/manifest.yml",
RunE: plan,
}
func init() {
manifestCmd.AddCommand(planManifestCmd)
}
func plan(cmd *cobra.Command, args []string) error {
assertStringSliceHasAtLeast(args, 1, "insufficient input: path to input manifest expected.")
target := parseManifest(args[0])
api := fritz.HomeAutomation(clientLogin())
src := obtainSourcePlan(api)
err := manifest.DryRunner().Apply(src, target)
assertNoError(err, "plan (dry-run) of manifest was not successful:", err)
return nil
}