Skip to content

Commit

Permalink
only write out identifier to flags file if non-default
Browse files Browse the repository at this point in the history
  • Loading branch information
zackattack01 committed Aug 16, 2024
1 parent 6cf90e4 commit 0002586
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/launcher/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/peterbourgon/ff/v3"
)

const defaultLauncherIdentifier string = "kolide-k2"
const DefaultLauncherIdentifier string = "kolide-k2"

// Options is the set of options that may be configured for Launcher.
type Options struct {
Expand Down Expand Up @@ -259,7 +259,7 @@ func ParseOptions(subcommandName string, args []string) (*Options, error) {
flIAmBreakingEELicense = flagset.Bool("i-am-breaking-ee-license", false, "Skip license check before running localserver (default: false)")
flDelayStart = flagset.Duration("delay_start", 0*time.Second, "How much time to wait before starting launcher")
flLocalDevelopmentPath = flagset.String("localdev_path", "", "Path to local launcher build")
flPackageIdentifier = flagset.String("identifier", defaultLauncherIdentifier, "packaging identifier used to determine service names, paths, etc. (default: kolide-k2)")
flPackageIdentifier = flagset.String("identifier", DefaultLauncherIdentifier, "packaging identifier used to determine service names, paths, etc. (default: kolide-k2)")

// deprecated options, kept for any kind of config file compatibility
_ = flagset.String("debug_log_file", "", "DEPRECATED")
Expand Down
2 changes: 1 addition & 1 deletion pkg/launcher/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func getArgsAndResponse() (map[string]string, *Options) {
WatchdogDelaySec: 120,
WatchdogMemoryLimitMB: 600,
WatchdogUtilizationLimitPercent: 50,
Identifier: defaultLauncherIdentifier,
Identifier: DefaultLauncherIdentifier,
}

return args, opts
Expand Down
9 changes: 8 additions & 1 deletion pkg/packaging/packaging.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"text/template"

"github.com/kolide/kit/fsutil"
"github.com/kolide/launcher/pkg/launcher"
"github.com/kolide/launcher/pkg/packagekit"

"go.opencensus.io/trace"
Expand Down Expand Up @@ -124,7 +125,13 @@ func (p *PackageOptions) Build(ctx context.Context, packageWriter io.Writer, tar
"root_directory": p.canonicalizeRootDir(p.rootDir),
"osqueryd_path": p.canonicalizePath(filepath.Join(p.binDir, "osqueryd")),
"enroll_secret_path": p.canonicalizePath(filepath.Join(p.confDir, "secret")),
"identifier": p.Identifier,
}

// to avoid writing additional flags without a real need (newly introduced flags
// can cause issues with rolling back), we only set the identifier in the flags file
// if it is not the default value
if p.Identifier != launcher.DefaultLauncherIdentifier {
launcherMapFlags["identifier"] = p.Identifier
}

launcherBoolFlags := []string{}
Expand Down

0 comments on commit 0002586

Please sign in to comment.