-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement recheck cmd #1837
base: main
Are you sure you want to change the base?
implement recheck cmd #1837
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/kolide/launcher/ee/agent/flags/keys" | ||
"github.com/kolide/launcher/ee/agent/startupsettings" | ||
"github.com/kolide/launcher/pkg/launcher" | ||
"github.com/kolide/launcher/pkg/log/multislogger" | ||
) | ||
|
||
func runRecheck(_ *multislogger.MultiSlogger, _ []string) error { | ||
attachConsole() | ||
defer detachConsole() | ||
|
||
settingReader, err := startupsettings.OpenReader(context.TODO(), launcher.DefaultPath(launcher.RootDirectory)) | ||
if err != nil { | ||
return fmt.Errorf("opening startup settings reader to fetch desktop runner server url, is launcher daemon running?: %w", err) | ||
} | ||
defer settingReader.Close() | ||
|
||
desktopRunnerServerURL, err := settingReader.Get(keys.DesktopRunnerServerUrl.String()) | ||
if err != nil { | ||
return fmt.Errorf("getting desktop runner server url, is launcher daemon running?: %w", err) | ||
} | ||
|
||
response, err := http.Get(fmt.Sprintf("%s/recheck", desktopRunnerServerURL)) | ||
if err != nil { | ||
return fmt.Errorf("sending recheck request to desktop runner server, is launcher daemon running?: %w", err) | ||
} | ||
|
||
if response.Body != nil { | ||
defer response.Body.Close() | ||
} | ||
|
||
if response.StatusCode != http.StatusOK { | ||
return fmt.Errorf("recheck request failed with status code %d", response.StatusCode) | ||
} | ||
|
||
fmt.Print("recheck request sent successfully") | ||
|
||
return nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -647,3 +647,10 @@ func (fc *FlagController) LocalDevelopmentPath() string { | |
WithDefaultString(fc.cmdLineOpts.LocalDevelopmentPath), | ||
).get(nil) | ||
} | ||
|
||
func (fc *FlagController) SetDesktopRunnerServerURL(url string) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Passing this through a flag feels a little weird to me. Might be right though... Why go this way? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does feel weird. I just followed the pattern used to store other data in the sqlite db via the start up settings writer. Perhaps we should create a new table / store in the sqlite db ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like |
||
return fc.setControlServerValue(keys.DesktopRunnerServerUrl, []byte(url)) | ||
} | ||
func (fc *FlagController) DesktopRunnerServerURL() string { | ||
return NewStringFlagValue().get(fc.getControlServerValue(keys.DesktopRunnerServerUrl)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't think this is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use the attach/detach command whenever it's a command that a Windows user could be running from the command line, so I think we'd want it here?