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

Add V2 exported services config support #399

Merged
merged 5 commits into from
Mar 21, 2024

Conversation

skpratt
Copy link
Collaborator

@skpratt skpratt commented Feb 27, 2024

uses the small api module change merged here: hashicorp/consul#20737

@skpratt skpratt force-pushed the v2-exported-services-config-v1-api branch 2 times, most recently from 17dc7f7 to bbc841b Compare February 27, 2024 05:33
@skpratt skpratt force-pushed the v2-exported-services-config-v1-api branch from bbc841b to 6559cb7 Compare February 27, 2024 05:34
@skpratt skpratt force-pushed the v2-exported-services-config-v1-api branch from 15c102b to 8cd6162 Compare March 5, 2024 18:30
@skpratt skpratt force-pushed the v2-exported-services-config-v1-api branch from 8cd6162 to 6f06e0c Compare March 5, 2024 18:32
@skpratt skpratt marked this pull request as ready for review March 6, 2024 15:42
@skpratt skpratt requested a review from remilapeyre March 6, 2024 15:42
@skpratt
Copy link
Collaborator Author

skpratt commented Mar 6, 2024

@absolutelightning looks like I cannot add you as a reviewer

@skpratt
Copy link
Collaborator Author

skpratt commented Mar 19, 2024

@absolutelightning I confirmed with IT that your team should now all have reviewer capabilities

@absolutelightning
Copy link
Contributor

@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
}
Copy link
Contributor

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?

Copy link
Collaborator Author

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{})
Copy link
Contributor

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.

Copy link
Collaborator Author

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))
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we converting the resourceNameto lower case as well?
Is this intended?

Copy link
Contributor

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

Copy link
Contributor

@dhiaayachi dhiaayachi left a 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"`),
Copy link
Contributor

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?

Copy link
Collaborator Author

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))
Copy link
Contributor

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

@skpratt skpratt force-pushed the v2-exported-services-config-v1-api branch from c1a68b7 to 8fdc405 Compare March 21, 2024 07:58
@skpratt skpratt merged commit a982e05 into main Mar 21, 2024
1 check passed
@skpratt skpratt deleted the v2-exported-services-config-v1-api branch April 1, 2024 21:24
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.

3 participants