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

Expand API with new Machine, Interface, and Tags interfaces #85

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

seanhoughton
Copy link

This PR adds a bunch of functionality. I haven't spent any time adding unit tests for the new functions or learning how the unit testing framework is set up, but it would be great if you could take a look and offer any suggestions or critiques before I spend any time on that.

This PR also adds a go module setup.

@jujubot
Copy link
Contributor

jujubot commented Jan 31, 2020

Can one of the admins verify this patch?

1 similar comment
@jujubot
Copy link
Contributor

jujubot commented Jan 31, 2020

Can one of the admins verify this patch?

@mitechie
Copy link

Thanks, we'll see if we can get a look across things.

!!build!!

if err != nil {
return nil, err
}
for retry := 0; retry < NumberOfRetries; retry++ {
Copy link
Member

Choose a reason for hiding this comment

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

Curious, what dies the hashicorp retryable client offer?

httpClient := retryablehttp.NewClient()

// Need to re-sign the request before each retry
httpClient.RequestLogHook = func(logger retryablehttp.Logger, request *http.Request, count int) {
Copy link
Member

Choose a reason for hiding this comment

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

We'd need to adapt a github.com/juju/loggo logger as the log writer implementation

return s.definition
}

func (s *tag) Machines() ([]Machine, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Another way of doing this is to keep the tag object as a pure domain object and have the api to get machines for a given tag as a method on the controller (or even as a method on the machine). A tag is really just a snippet of domain information. Same with AddToMachine() etc; they perhaps are better done as AddTag() and RemoveTag() methods on the machine entity.

@@ -0,0 +1,150 @@
package gomaasapi
Copy link
Member

Choose a reason for hiding this comment

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

Needs a copyright header

@@ -378,6 +439,19 @@ func (c *controller) Machines(args MachinesArgs) ([]Machine, error) {
return result, nil
}

func (c *controller) GetMachine(systemID string) (Machine, error) {
Copy link
Member

Choose a reason for hiding this comment

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

public methods/structs etc should have a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants