launcher icon indicating copy to clipboard operation
launcher copied to clipboard

remove the invalid boolean from all the service responses

Open groob opened this issue 6 years ago • 1 comments

Right now a launcher client/server method looks something like this

func(svc) someFunc(nodeKey) (invalid bool, err err) {
    invalid, err := authenticate(nodeKey)
    if err != nil { return invalid, err}
    
    err = someOtherCall()
    if err != nil { return false, err}
    ....
    (repeated many times, invalid is always false)
}

Because invalid is only true for certain authentication errors it should not be a required return argument. after the first auth call, invalid is always false.

Instead, we can use a specific error type similar to the one in fleet:

type osqueryError struct {
	message     string
	nodeInvalid bool
}

func (e osqueryError) Error() string {
	return e.message
}

func (e osqueryError) NodeInvalid() bool {
	return e.nodeInvalid
}

removing the invalid bool from the Go methods would make this parameter something that's a transport level concern and would allow us to refactor authenticateHost calls to an endpoint middleware.

Anyway, that's my 2c. Curious if you have any strong feelings one way or another @zwass

groob avatar Oct 24 '17 19:10 groob

Also the error in CheckHealth (maybe)

screen shot 2017-10-24 at 7 53 54 pm https://github.com/kolide/fleet/pull/1582

groob avatar Oct 24 '17 23:10 groob

While we might redo some protocol and interfaces, I don't think we're going to go in this direction

directionless avatar Feb 14 '24 18:02 directionless