diff --git a/changes/add-fleetctl-preview-channel-opts b/changes/add-fleetctl-preview-channel-opts new file mode 100644 index 0000000000..8d2a61860c --- /dev/null +++ b/changes/add-fleetctl-preview-channel-opts @@ -0,0 +1 @@ +* Add options to `fleetctl preview` to set custom update channels for orbit and osqueryd. diff --git a/cmd/fleetctl/preview.go b/cmd/fleetctl/preview.go index 9695590f11..60f1518d03 100644 --- a/cmd/fleetctl/preview.go +++ b/cmd/fleetctl/preview.go @@ -35,6 +35,8 @@ const ( tagFlagName = "tag" previewConfigFlagName = "preview-config" noHostsFlagName = "no-hosts" + orbitChannel = "orbit-channel" + osquerydChannel = "osqueryd-channel" ) func previewCommand() *cli.Command { @@ -71,6 +73,16 @@ Use the stop and reset subcommands to manage the server and dependencies once st Usage: "Start the server without adding any hosts", Value: false, }, + &cli.StringFlag{ + Name: orbitChannel, + Usage: "Use a custom orbit channel", + Value: "stable", + }, + &cli.StringFlag{ + Name: osquerydChannel, + Usage: "Use a custom osqueryd channel", + Value: "stable", + }, }, Action: func(c *cli.Context) error { if err := checkDocker(); err != nil { @@ -251,7 +263,7 @@ Use the stop and reset subcommands to manage the server and dependencies once st if !c.Bool(noHostsFlagName) { fmt.Println("Enrolling local host...") - if err := downloadOrbitAndStart(previewDir, secrets.Secrets[0].Secret, address); err != nil { + if err := downloadOrbitAndStart(previewDir, secrets.Secrets[0].Secret, address, c.String(orbitChannel), c.String(osquerydChannel)); err != nil { return fmt.Errorf("downloading orbit and osqueryd: %w", err) } @@ -605,7 +617,7 @@ func processNameMatches(pid int, expectedPrefix string) (bool, error) { return strings.HasPrefix(strings.ToLower(process.Executable()), strings.ToLower(expectedPrefix)), nil } -func downloadOrbitAndStart(destDir string, enrollSecret string, address string) error { +func downloadOrbitAndStart(destDir, enrollSecret, address, orbitChannel, osquerydChannel string) error { // Stop any current intance of orbit running, otherwise the configured enroll secret // won't match the generated in the preview run. if err := stopOrbit(destDir); err != nil { @@ -634,6 +646,8 @@ func downloadOrbitAndStart(destDir string, enrollSecret string, address string) } updateOpt.ServerURL = "https://tuf.fleetctl.com" updateOpt.RootDirectory = destDir + updateOpt.OrbitChannel = orbitChannel + updateOpt.OsquerydChannel = osquerydChannel if err := packaging.InitializeUpdates(updateOpt); err != nil { return fmt.Errorf("initialize updates: %w", err) @@ -646,6 +660,8 @@ func downloadOrbitAndStart(destDir string, enrollSecret string, address string) "--insecure", "--debug", "--enroll-secret", enrollSecret, + "--orbit-channel", updateOpt.OrbitChannel, + "--osqueryd-channel", updateOpt.OsquerydChannel, "--log-file", path.Join(destDir, "orbit.log"), ) if err := cmd.Start(); err != nil {