mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 17:08:53 +00:00
Add flags to fleetctl preview to set custom orbit and osqueryd update channels (#3683)
* Add channel options for orbit update on fleetctl preview * Add changes * Also set channels on orbit execution in preview
This commit is contained in:
parent
d7e2e33e01
commit
61b21df79e
2 changed files with 19 additions and 2 deletions
1
changes/add-fleetctl-preview-channel-opts
Normal file
1
changes/add-fleetctl-preview-channel-opts
Normal file
|
|
@ -0,0 +1 @@
|
|||
* Add options to `fleetctl preview` to set custom update channels for orbit and osqueryd.
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue