-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: create datadome_endpoint resource #31
base: feat/INT-4354/endpoint-management
Are you sure you want to change the base?
Conversation
Read(ctx context.Context) ([]T, error) | ||
type API[T any, I comparable] interface { | ||
Create(ctx context.Context, params T) (*I, error) | ||
Read(ctx context.Context, id I) (*T, error) |
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.
question: Now we are returning only one element?
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.
Yes, we do.
We were returning a list of elements due to the design of the custom_rules (and also trusted proxies): it does not have a route to return a resource by its ID.
The standard way (i.e. recommended by Hashicorp) is to call a route that retrieve a resource by its ID.
So I have changed the signature of the Read
method to only return a single element, and I have moved the logic to find a custom_rule by its ID in the Read
method (the logic moved from this file to this one)
@@ -116,7 +123,7 @@ func (c *Client) Create(ctx context.Context, params CustomRule) (*int, error) { | |||
req, err := http.NewRequestWithContext( | |||
ctx, | |||
"POST", | |||
fmt.Sprintf("%s/custom-rules", c.HostURL), | |||
c.HostURL, |
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.
kudos: way cleaner!
return fmt.Errorf("status: %d, body: %s", res.StatusCode, body) | ||
} | ||
|
||
log.Printf("[DEBUG] %s\n", body) |
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.
question: should we keep this print here?
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 agree that the logs are not that useful.
I think that we should get rid of those logs and add terraform logs instead in a new ticket.
WDYT?
return nil, err | ||
} | ||
|
||
log.Printf("[DEBUG] %+v\n", params) |
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.
question: same doubt here
Description
datadome_endpoint
to the Terraform Provider with its Schema (empty CRUD functions for now)ClientEndpoint
for endpoint managementendpoint.md
documentation about thedatadome_endpoint
resource and its fieldsClient
toClientCustomRule
in order to create a new client for endpointsRead
function of theClientCustomRule
in order to pass the ID of the custom rule we want to fetchHttpRequest
structure to do not be specific to the CustomRules onlyproviderConfigure
function to provide 2 clients:ClientCustomRule
andClientEndpoint
How to test?
The documentation
endpoint.md
fileYou should have a preview of the documentation
Acceptance Tests
The aim of this test is to validate that the custom_rule management feature was not impacted by the changes (i.e. renaming, different metadata).