-
Notifications
You must be signed in to change notification settings - Fork 0
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
[wip] update ns1/ns1-go to v2 #30
base: v0.6.16-ens
Are you sure you want to change the base?
Conversation
31c698a
to
eee9aa2
Compare
client := meta.(*nsone.APIClient) | ||
mj := nsone.Apikey{} | ||
client := meta.(*nsone.Client) | ||
mj := account.APIKey{} |
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.
i think mj
is short for monitoring job. not a big deal at all, but maybe this should be a
or ak
for apikey. but again, nbd
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.
resolved
client := meta.(*nsone.APIClient) | ||
mj, err := client.GetApikey(d.Id()) | ||
client := meta.(*nsone.Client) | ||
mj, _, err := client.APIKeys.Get(d.Id()) |
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.
same here regarding mj
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.
resolved
eee9aa2
to
b89ce86
Compare
@@ -264,17 +269,25 @@ func recordToResourceData(d *schema.ResourceData, r *nsone.Record) error { | |||
for regionName, region := range r.Regions { | |||
newRegion := make(map[string]interface{}) | |||
newRegion["name"] = regionName | |||
if len(region.Meta.GeoRegion) > 0 { | |||
newRegion["georegion"] = region.Meta.GeoRegion[0] | |||
// TODO: support as FeedPtr |
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.
Could we do a switch on region.Meta.Georegion.(type)
and check if either data.FeedPtr
or []string
?
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.
That seems nasty to have to do to every metadata field tho...
but im not sure of a cleaner way
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.
that's exactly what I'm working on now
n.RateLimitStrategySleep() | ||
httpClient := &http.Client{} | ||
n := nsone.NewClient(httpClient, nsone.SetAPIKey(d.Get("apikey").(string))) | ||
// FIXME: n.Debug() |
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.
i wasnt sure what to do here either. v1
prints requests and responses when debug is enabled.
we can add a logger that logs every request with the following if that is what users would want.
// Adds logging to each http request.
doer := nsone.Decorate(httpClient, nsone.Logging(log.New(os.Stdout, "", log.LstdFlags)))
client := nsone.NewClient(doer, nsone.SetAPIKey(k))
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.
this should also be tied to terraform's debug state
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.
Sorry, trying to find docs on terraform debug state now. We can add whatever logs to the requests/responses that we want with the decorator. my guess is that it should be logging both requests and responses. is their any documentation on the debug state?
httpClient := &http.Client{} | ||
n := nsone.NewClient(httpClient, nsone.SetAPIKey(d.Get("apikey").(string))) | ||
// FIXME: n.Debug() | ||
// n.RateLimitStrategySleep() |
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.
This should still be applicable for v2
. if users would like to have it
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.
I got a divide by zero panic that I haven't had a change to investigate. I absolutely want to re-enable it.
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.
Ah, im going to check that out now
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.
@josephholsten I made a PR for the fix: ns1/ns1-go#24
The client was applying the rate limit func before checking the actual response code. I was able to reproduce divide by zero when i didnt set the apikey as an env var and received a 401(without rate limiting headers).
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.
i merged in the rate limiting fix, so this should work now
b89ce86
to
e7b492a
Compare
df.Name = d.Get("name").(string) | ||
config := make(map[string]string) | ||
func resourceDataToDataFeed(d *schema.ResourceData) *data.Feed { | ||
config := make(data.Config) |
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.
- investigate using the
data.NewFeed()
constructor
1ce7797
to
43aa452
Compare
a9afb26
to
7125f20
Compare
OK, all tests are passing again |
Limits blocks only have the "name" attribute as their primary key, so hashLimits() needn't use a buffer to concatenate.
Notable changes: - update to import gopkg.in/ns1/ns1-go.v2/rest - update to use rest.NewClient() - update to use rest.*Service types for CRUD calls - update to use gopkg.in/ns1/ns1-go.v2/rest/model/* packages for structs - dramatic rewriting to support data.Meta
7125f20
to
e0289fa
Compare
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.
"LGTM"
we changed a bunch, so this will probably take a bit