Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

James-Pickett
Copy link
Contributor

No description provided.

Comment on lines +15 to +16
attachConsole()
defer detachConsole()
Copy link
Contributor Author

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?

Copy link
Contributor

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?

mockKnapsack.On("DesktopUpdateInterval").Return(time.Millisecond * 250)
mockKnapsack.On("DesktopMenuRefreshInterval").Return(time.Millisecond * 250)
mockKnapsack.On("KolideServerURL").Return("somewhere-over-the-rainbow.example.com")
mockKnapsack.On("DesktopEnabled").Return(true)
mockKnapsack.On("Slogger").Return(slogger)
mockKnapsack.On("InModernStandby").Return(false)
mockKnapsack.On("SetDesktopRunnerServerURL", mock.Anything).Return(nil)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so much mocking to use the settings writer .... wonder if it's time to create an interface for it that we can pass as a dependency, it would be easier to mock

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 go for it

@James-Pickett James-Pickett marked this pull request as ready for review August 15, 2024 21:30
@@ -647,3 +647,10 @@ func (fc *FlagController) LocalDevelopmentPath() string {
WithDefaultString(fc.cmdLineOpts.LocalDevelopmentPath),
).get(nil)
}

func (fc *FlagController) SetDesktopRunnerServerURL(url string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 ... runtime_values or something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like runtime_values

authedMux.Handle(MessageEndpoint, http.HandlerFunc(rs.sendMessage))
authMuxHandler := rs.authMiddleware(authedMux)

unauthedMux.Handle(RecheckEndpoint, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very clean

@RebeccaMahany RebeccaMahany added the features-improvements Features and Improvements label Aug 29, 2024
Comment on lines +15 to +16
attachConsole()
defer detachConsole()
Copy link
Contributor

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?

@@ -647,3 +647,10 @@ func (fc *FlagController) LocalDevelopmentPath() string {
WithDefaultString(fc.cmdLineOpts.LocalDevelopmentPath),
).get(nil)
}

func (fc *FlagController) SetDesktopRunnerServerURL(url string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like runtime_values

mockKnapsack.On("DesktopUpdateInterval").Return(time.Millisecond * 250)
mockKnapsack.On("DesktopMenuRefreshInterval").Return(time.Millisecond * 250)
mockKnapsack.On("KolideServerURL").Return("somewhere-over-the-rainbow.example.com")
mockKnapsack.On("DesktopEnabled").Return(true)
mockKnapsack.On("Slogger").Return(slogger)
mockKnapsack.On("InModernStandby").Return(false)
mockKnapsack.On("SetDesktopRunnerServerURL", mock.Anything).Return(nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 go for it

authedMux.Handle(MessageEndpoint, http.HandlerFunc(rs.sendMessage))
authMuxHandler := rs.authMiddleware(authedMux)

unauthedMux.Handle(RecheckEndpoint, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we want to rate limit this endpoint to avoid kicking off a bunch of simultaneous rechecks? Found https://www.alexedwards.net/blog/how-to-rate-limit-http-requests for a fairly quick implementation, but also feeling like it's probably overkill.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
features-improvements Features and Improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants