Add support for configuring update channels in packaging
This commit is contained in:
+7
-7
@@ -82,16 +82,16 @@ func main() {
|
||||
EnvVars: []string{"ORBIT_ENROLL_SECRET_PATH"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "osquery-channel",
|
||||
Usage: "Update channel of osquery to use",
|
||||
Name: "osqueryd-channel",
|
||||
Usage: "Update channel of osqueryd to use",
|
||||
Value: "stable",
|
||||
EnvVars: []string{"ORBIT_OSQUERY_CHANNEL"},
|
||||
EnvVars: []string{"ORBIT_OSQUERYD_CHANNEL"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "orbit-channel",
|
||||
Usage: "Update channel of orbit to use",
|
||||
Usage: "Update channel of Orbit to use",
|
||||
Value: "stable",
|
||||
EnvVars: []string{"ORBI_ORBIT_CHANNEL"},
|
||||
EnvVars: []string{"ORBIT_ORBIT_CHANNEL"},
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "debug",
|
||||
@@ -155,7 +155,7 @@ func main() {
|
||||
if err := updater.UpdateMetadata(); err != nil {
|
||||
log.Info().Err(err).Msg("failed to update metadata. using saved metadata.")
|
||||
}
|
||||
osquerydPath, err := updater.Get("osqueryd", c.String("osquery-channel"))
|
||||
osquerydPath, err := updater.Get("osqueryd", c.String("osqueryd-channel"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -165,7 +165,7 @@ func main() {
|
||||
updateRunner, err := update.NewRunner(updater, update.RunnerOptions{
|
||||
CheckInterval: 10 * time.Second,
|
||||
Targets: map[string]string{
|
||||
"osqueryd": c.String("osquery-channel"),
|
||||
"osqueryd": c.String("osqueryd-channel"),
|
||||
"orbit": c.String("orbit-channel"),
|
||||
},
|
||||
})
|
||||
|
||||
+12
-4
@@ -76,6 +76,18 @@ func main() {
|
||||
Usage: "Whether to notarize macOS packages",
|
||||
Destination: &opt.Notarize,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "osqueryd-channel",
|
||||
Usage: "Update channel of osqueryd to use",
|
||||
Value: "stable",
|
||||
Destination: &opt.OsquerydChannel,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "orbit-channel",
|
||||
Usage: "Update channel of Orbit to use",
|
||||
Value: "stable",
|
||||
Destination: &opt.OrbitChannel,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "debug",
|
||||
Usage: "Enable debug logging",
|
||||
@@ -99,10 +111,6 @@ func main() {
|
||||
return errors.New("--insecure and --fleet-certificate may not be provided together")
|
||||
}
|
||||
|
||||
// TODO take these from flags
|
||||
opt.OrbitChannel = "stable"
|
||||
opt.OsqueryChannel = "stable"
|
||||
|
||||
switch c.String("type") {
|
||||
case "pkg":
|
||||
return packaging.BuildPkg(opt)
|
||||
|
||||
@@ -40,7 +40,7 @@ func buildNFPM(opt Options, pkger nfpm.Packager) error {
|
||||
updateOpt.Platform = "linux"
|
||||
updateOpt.RootDirectory = orbitRoot
|
||||
updateOpt.OrbitChannel = opt.OrbitChannel
|
||||
updateOpt.OsqueryChannel = opt.OsqueryChannel
|
||||
updateOpt.OsquerydChannel = opt.OsquerydChannel
|
||||
|
||||
// TODO these should be configurable
|
||||
updateOpt.ServerURL = "https://tuf.fleetctl.com"
|
||||
@@ -176,7 +176,9 @@ WantedBy=multi-user.target
|
||||
}
|
||||
|
||||
var envTemplate = template.Must(template.New("env").Parse(`
|
||||
{{- if .Insecure }}ORBIT_INSECURE=true{{ end }}
|
||||
ORBIT_ORBIT_CHANNEL={{ .OrbitChannel }}
|
||||
ORBIT_OSQUERYD_CHANNEL={{ .OsquerydChannel }}
|
||||
{{ if .Insecure }}ORBIT_INSECURE=true{{ end }}
|
||||
{{ if .FleetURL }}ORBIT_FLEET_URL={{.FleetURL}}{{ end }}
|
||||
{{ if .FleetCertificate }}ORBIT_FLEET_CERTIFICATE=/var/lib/orbit/fleet.pem{{ end }}
|
||||
{{ if .EnrollSecret }}ORBIT_ENROLL_SECRET={{.EnrollSecret}}{{ end }}
|
||||
|
||||
@@ -44,7 +44,7 @@ func BuildPkg(opt Options) error {
|
||||
updateOpt.Platform = "macos"
|
||||
updateOpt.RootDirectory = orbitRoot
|
||||
updateOpt.OrbitChannel = opt.OrbitChannel
|
||||
updateOpt.OsqueryChannel = opt.OsqueryChannel
|
||||
updateOpt.OsquerydChannel = opt.OsquerydChannel
|
||||
|
||||
// TODO these should be configurable
|
||||
updateOpt.ServerURL = "https://tuf.fleetctl.com"
|
||||
|
||||
@@ -65,8 +65,10 @@ var macosLaunchdTemplate = template.Must(template.New("").Option("missingkey=err
|
||||
<string>/var/log/orbit/orbit.stderr.log</string>
|
||||
<key>EnvironmentVariables</key>
|
||||
<dict>
|
||||
<key>ORBIT_ORBIT_CHANNEL</key><string>{{ .OrbitChannel }}</string>
|
||||
<key>ORBIT_OSQUERYD_CHANNEL</key><string>{{ .OsquerydChannel }}</string>
|
||||
{{ if .Insecure }}<key>ORBIT_INSECURE</key><string>true</string>{{ end }}
|
||||
{{ if .FleetURL }}<key>ORBIT_FLEET_URL</key><string>{{.FleetURL}}</string>{{ end }}
|
||||
{{ if .FleetURL }}<key>ORBIT_FLEET_URL</key><string>{{ .FleetURL }}</string>{{ end }}
|
||||
{{ if .FleetCertificate }}<key>ORBIT_FLEET_CERTIFICATE</key><string>/var/lib/orbit/fleet.pem</string>{{ end }}
|
||||
{{ if .EnrollSecret }}<key>ORBIT_ENROLL_SECRET_PATH</key><string>/var/lib/orbit/secret</string>{{ end }}
|
||||
{{ if .Debug }}<key>ORBIT_DEBUG</key><string>true</string>{{ end }}
|
||||
|
||||
@@ -36,8 +36,8 @@ type Options struct {
|
||||
FleetCertificate string
|
||||
// OrbitChannel is the update channel to use for Orbit.
|
||||
OrbitChannel string
|
||||
// OsqueryChannel is the update channel to use for Osquery.
|
||||
OsqueryChannel string
|
||||
// OsquerydChannel is the update channel to use for Osquery (osqueryd).
|
||||
OsquerydChannel string
|
||||
// Debug determines whether to enable debug logging for the agent.
|
||||
Debug bool
|
||||
}
|
||||
@@ -80,7 +80,7 @@ func initializeUpdates(updateOpt update.Options) error {
|
||||
if err := updater.UpdateMetadata(); err != nil {
|
||||
return errors.Wrap(err, "failed to update metadata")
|
||||
}
|
||||
osquerydPath, err := updater.Get("osqueryd", updateOpt.OsqueryChannel)
|
||||
osquerydPath, err := updater.Get("osqueryd", updateOpt.OsquerydChannel)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to get osqueryd")
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ type Options struct {
|
||||
Platform string
|
||||
// OrbitChannel is the update channel to use for Orbit.
|
||||
OrbitChannel string
|
||||
// OsqueryChannel is the update channel to use for Osquery.
|
||||
OsqueryChannel string
|
||||
// OsquerydChannel is the update channel to use for osquery (osqueryd).
|
||||
OsquerydChannel string
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -63,7 +63,7 @@ var (
|
||||
Platform: constant.PlatformName,
|
||||
RootKeys: defaultRootKeys,
|
||||
OrbitChannel: "stable",
|
||||
OsqueryChannel: "stable",
|
||||
OsquerydChannel: "stable",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user