-
Notifications
You must be signed in to change notification settings - Fork 112
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
Add V2 exported services config support #399
Conversation
17dc7f7
to
bbc841b
Compare
bbc841b
to
6559cb7
Compare
15c102b
to
8cd6162
Compare
8cd6162
to
6f06e0c
Compare
@absolutelightning looks like I cannot add you as a reviewer |
@absolutelightning I confirmed with IT that your team should now all have reviewer capabilities |
Sure I will review tomorrow. |
services := d.Get("services").([]interface{}) | ||
if len(services) > 0 { | ||
data["services"] = services | ||
} |
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.
Should we return if data["services"]
is blank?
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.
no, because NamespaceExportedServices and PartitionExportedServices do not explicitly set services
Kind: kind, | ||
} | ||
var consumers []map[string]any | ||
peerConsumers := d.Get("peer_consumers").([]interface{}) |
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.
All the Get calls with d.Get
will fail of user has not given the key in schema. From the documentation
// Get returns the data for the given key, or nil if the key doesn't exist
// in the schema.
Since these are optional keys we need to add nil checks everywhere.
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.
refactored to in-line the loop - this pattern is used with optional keys everywhere
} | ||
|
||
func v2MulticlusterRead(client *api.Client, gvk *GVK, resourceName string, q *api.QueryOptions) (map[string]interface{}, error) { | ||
endpoint := strings.ToLower(fmt.Sprintf("/api/%s/%s/%s/%s", gvk.Group, gvk.Version, gvk.Kind, resourceName)) |
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.
Are we converting the resourceName
to lower case as well?
Is this intended?
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.
We had an ADR about this to make all resource names lower case https://docs.google.com/document/d/1F8EZ76l9FaMnupJ4jCAw_42RLWPGO7oOZHfLs4TLutg/edit
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.
Thank you for adding this @skpratt ! I had few questions below but nothing blocking on my side
@@ -74,7 +74,7 @@ func TestAccConsulACLBindingRule_basic(t *testing.T) { | |||
}, | |||
{ | |||
Config: testResourceACLBindingRuleConfig_wrongType, | |||
ExpectError: regexp.MustCompile(`Invalid Binding Rule: unknown BindType "foobar"`), | |||
ExpectError: regexp.MustCompile(`unknown BindType "foobar"`), |
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.
Is the change to this check related to introducing v2 exported services?
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.
The error message changed slightly with the version updates in .github/workflows/test.yaml, and the test started to fail
} | ||
|
||
func v2MulticlusterRead(client *api.Client, gvk *GVK, resourceName string, q *api.QueryOptions) (map[string]interface{}, error) { | ||
endpoint := strings.ToLower(fmt.Sprintf("/api/%s/%s/%s/%s", gvk.Group, gvk.Version, gvk.Kind, resourceName)) |
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.
We had an ADR about this to make all resource names lower case https://docs.google.com/document/d/1F8EZ76l9FaMnupJ4jCAw_42RLWPGO7oOZHfLs4TLutg/edit
c1a68b7
to
8fdc405
Compare
uses the small api module change merged here: hashicorp/consul#20737