Skip to content

Conversation

micahhausler
Copy link
Contributor

This enables callers to write testable interfaces instead of directly accessing fields on the APIClient.

For example

// defined in a caller's package
type RedfishClient interface {
    GetService() *Service
    Logout()
}

type MyType struct {
    client RedfishClient 
}

func NewMyType(endpoint string) (*MyType, error) {
    r := &MyType{}
    var err error
    r.client, err = gofish.ConnectDefault(endpoint)
    if err != nil {
        return nil, err
    }
    return r, nil
)

func main(){
    mt, _ := NewMyType("")
    fmt.Println(mt.client.GetService().Systems()[0].BIOSVersion)
    mt.client.Logout()
}

Signed-off-by: Micah Hausler mhausler@amazon.com

Signed-off-by: Micah Hausler <mhausler@amazon.com>
Copy link
Owner

@stmcginnis stmcginnis left a comment

Choose a reason for hiding this comment

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

Lint job failure is unrelated. This looks good and makes sense - thanks!

@stmcginnis stmcginnis merged commit 1a855b0 into stmcginnis:main Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants