Skip to content

Commit

Permalink
fix: feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jahzielv committed Oct 18, 2024
1 parent bcf6ac5 commit 99c3101
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions orbit/pkg/setup_experience/setup_experience.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,25 @@ type SetupExperiencer struct {
// and no other parts of Orbit need access to this field (or any other parts of the
// SetupExperiencer), it's OK to not protect this with a lock.
sd *swiftdialog.SwiftDialog
steps map[string]struct{}
started bool
}

func NewSetupExperiencer(client Client, rootDirPath string) *SetupExperiencer {
return &SetupExperiencer{
OrbitClient: client,
closeChan: make(chan struct{}),
steps: make(map[string]struct{}),
rootDirPath: rootDirPath,
}
}

func (s *SetupExperiencer) Run(oc *fleet.OrbitConfig) error {
// We should only launch swiftDialog if we get the notification from Fleet.
if !oc.Notifications.RunSetupExperience {
log.Debug().Msg("skipping setup experience")
return nil
}

_, binaryPath, _ := update.LocalTargetPaths(
s.rootDirPath,
"swiftDialog",
Expand All @@ -56,11 +62,6 @@ func (s *SetupExperiencer) Run(oc *fleet.OrbitConfig) error {
return nil
}

if !oc.Notifications.RunSetupExperience {
log.Debug().Msg("skipping setup experience")
return nil
}

// Poll the status endpoint. This also releases the device if we're done.
payload, err := s.OrbitClient.GetSetupExperienceStatus()
if err != nil {
Expand Down Expand Up @@ -104,9 +105,9 @@ func (s *SetupExperiencer) Run(oc *fleet.OrbitConfig) error {
var stepsDone int
var prog uint
steps := append(payload.Software, payload.Script)
for _, r := range steps {
item := resultToListItem(r)
if s.started {
for _, step := range steps {
item := resultToListItem(step)
if _, ok := s.steps[step.Name]; ok {
err = s.sd.UpdateListItemByTitle(item.Title, item.StatusText, item.Status)
if err != nil {
log.Info().Err(err).Msg("updating list item in setup experience UI")
Expand All @@ -116,8 +117,10 @@ func (s *SetupExperiencer) Run(oc *fleet.OrbitConfig) error {
if err != nil {
log.Info().Err(err).Msg("adding list item in setup experience UI")
}
s.steps[step.Name] = struct{}{}
}
if r.Status == fleet.SetupExperienceStatusFailure || r.Status == fleet.SetupExperienceStatusSuccess {

if step.Status == fleet.SetupExperienceStatusFailure || step.Status == fleet.SetupExperienceStatusSuccess {
stepsDone++
// The swiftDialog progress bar is out of 100
for range int(float32(1) / float32(len(steps)) * 100) {
Expand Down

0 comments on commit 99c3101

Please sign in to comment.