fleet/orbit/pkg/update/swift_dialog.go
Jordan Montgomery 2029cc98d9
Revert "Always install Escrowbuddy and Swift Dialog (#28742)" (#29264)
This reverts commit a5bd50716d which was
this PR: https://github.com/fleetdm/fleet/pull/28742

It was determined that the behavior changes here conflict with other
changes being asked for by `customer-starchik`. Design to review and
come up with a different strategy for improving the behavior this change
originally was intended to fix

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.
- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- For Orbit and Fleet Desktop changes:
- [x] Make sure fleetd is compatible with the latest released version of
Fleet (see [Must
rule](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/workflows/fleetd-development-and-release-strategy.md)).
- [x] Orbit runs on macOS, Linux and Windows. Check if the orbit
feature/bugfix should only apply to one platform (`runtime.GOOS`).
- [x] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.
- [x] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).
- [x] For unreleased bug fixes in a release candidate, confirmed that
the fix is not expected to adversely impact load test results or alerted
the release DRI if additional load testing is needed.
2025-05-19 13:23:05 -04:00

71 lines
2.5 KiB
Go

package update
import (
"github.com/fleetdm/fleet/v4/server/fleet"
"github.com/rs/zerolog/log"
)
type SwiftDialogDownloader struct {
UpdateRunner *Runner
}
type SwiftDialogDownloaderOptions struct {
// UpdateRunner is the wrapped Runner where swiftDialog will be set as a target. It is responsible for
// actually ensuring that swiftDialog is installed and updated via the designated TUF server.
UpdateRunner *Runner
}
func ApplySwiftDialogDownloaderMiddleware(
runner *Runner,
) fleet.OrbitConfigReceiver {
return &SwiftDialogDownloader{UpdateRunner: runner}
}
func (s *SwiftDialogDownloader) Run(cfg *fleet.OrbitConfig) error {
log.Debug().Msg("running swiftDialog installer middleware")
if cfg == nil {
log.Debug().Msg("SwiftDialogDownloader received nil config")
return nil
}
if s.UpdateRunner == nil {
log.Debug().Msg("SwiftDialogDownloader received nil UpdateRunner, this probably indicates that updates are turned off. Skipping any actions related to swiftDialog")
return nil
}
// TODO: we probably want to ensure that swiftDialog is always installed if we're going to be
// using it offline.
if !cfg.Notifications.NeedsMDMMigration && !cfg.Notifications.RenewEnrollmentProfile && !cfg.Notifications.RunSetupExperience {
log.Debug().Msg("skipping swiftDialog update")
return nil
}
updaterHasTarget := s.UpdateRunner.HasRunnerOptTarget("swiftDialog")
runnerHasLocalHash := s.UpdateRunner.HasLocalHash("swiftDialog")
if !updaterHasTarget || !runnerHasLocalHash {
log.Info().Msg("refreshing the update runner config with swiftDialog targets and hashes")
log.Debug().Msgf("updater has target: %t, runner has local hash: %t", updaterHasTarget, runnerHasLocalHash)
s.UpdateRunner.AddRunnerOptTarget("swiftDialog")
s.UpdateRunner.updater.SetTargetInfo("swiftDialog", SwiftDialogMacOSTarget)
// we don't want to keep swiftDialog as a target if we failed to update the
// cached hashes in the runner.
if err := s.UpdateRunner.StoreLocalHash("swiftDialog"); err != nil {
log.Debug().Msgf("removing swiftDialog from target options, error updating local hashes: %s", err)
s.UpdateRunner.RemoveRunnerOptTarget("swiftDialog")
s.UpdateRunner.updater.RemoveTargetInfo("swiftDialog")
return err
}
if cfg.Notifications.RunSetupExperience {
// Then update immediately, since we need to get swiftDialog quickly to show the setup
// experience
_, err := s.UpdateRunner.UpdateAction()
if err != nil {
return err
}
}
}
return nil
}