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

Route table #26

Merged
merged 22 commits into from
Aug 21, 2018
Merged

Route table #26

merged 22 commits into from
Aug 21, 2018

Conversation

thetonymaster
Copy link
Contributor

No description provided.

@thetonymaster thetonymaster mentioned this pull request Aug 17, 2018
@katbyte katbyte added this to the 0.4.0 milestone Aug 18, 2018
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Hi @thetonymaster,

Thank you for this PR. I've left some comments inline (mostly minor cosmetic/stylistic) with my main concern being the additional logic in resource_arm_subnet.go. Is this due to AzureStack behaving differently or a pre-existing bug in AzureRM and should be back ported? It would be great to get a acceptance test to check & test for this.

Also I see you've split the datasource out into a separate PR (#28). I would suggest including the datasource in this PR but its not a big deal. However I see that the datasource docs were included in this PR and they should be in whichever PR contains the datasource.

return &schema.Resource{
Create: resourceArmRouteTableCreate,
Read: resourceArmRouteTableRead,
Update: resourceArmRouteTableCreate,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we change this to resourceArmRouteTableCreateUpdate?

}

err = future.WaitForCompletionRef(ctx, client.Client)
if err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

very minor this could become:

if err = future.WaitForCompletionRef(ctx, client.Client); err != nil {

}

err = future.WaitForCompletionRef(ctx, client.Client)
if err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above: if err = future.WaitForCompletionRef(ctx, client.Client); err != nil {

return nil
}

func expandRouteTableRoutes(d *schema.ResourceData) ([]network.Route, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function never returns an error, so error can be removed from the return values.

addressPrefix := data["address_prefix"].(string)
nextHopType := data["next_hop_type"].(string)

properties := network.RoutePropertiesFormat{
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can all be simplified to:

route := network.Route{
			Name: utils.String(data["name"].(string)),
			RoutePropertiesFormat: &network.RoutePropertiesFormat{
				AddressPrefix: utils.String(data["address_prefix"].(string)),
				NextHopType:   network.RouteNextHopType(data["next_hop_type"].(string)),
			},
		}

		if v := data["next_hop_in_ip_address"].(string); v != "" {
			route.RoutePropertiesFormat.NextHopIPAddress = &v
		}

resource.TestCheckResourceAttr(resourceName, "route.1.next_hop_type", "VnetLocal"),
),
},
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

There was an import test for this, so could we add a import test step here?

func testAccAzureStackRouteTable_singleRoute(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurestack_resource_group" "test" {
name = "acctestRG-%d"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we align the assignments here (and below) like the above tests?

@@ -238,6 +237,35 @@ func resourceArmSubnetDelete(d *schema.ResourceData, meta interface{}) error {

azureStackLockByName(routeTableName, routeTableResourceName)
defer azureStackUnlockByName(routeTableName, routeTableResourceName)

// Get the subnet to dissasociate the route table, if we don't do this
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is different then the AzureRM code. Is this logic required for stack and not AzureRM? Could we get a test for this behaviour?

page_title: "Azure Resource Manager: azurestack_route_table"
sidebar_current: "docs-azurestack-data-source-route-table"
description: |-
Manages information about a Route Table
Copy link
Collaborator

Choose a reason for hiding this comment

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

As this is a data source this should be Gets


# Data Source: azurestack_route_table

Manages information about a Route Table
Copy link
Collaborator

Choose a reason for hiding this comment

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

As this is a data source this should be Gets

@thetonymaster
Copy link
Contributor Author

@katbyte I enabled the route table tests on the subnet test file, don't know if this enough since the problem comes up when the subnet has a route table. Anyway, please let me know. I also included the data source on this PR and closed the other one.

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Hi @thetonymaster,

Thank you for the changes, it mostly LGTM aside from some minor style issues and the tabbing on the tests. Hope you don't mind but I have committed some fixes so we can get this merged today.

@katbyte katbyte merged commit 8f3304d into hashicorp:master Aug 21, 2018
katbyte added a commit that referenced this pull request Aug 21, 2018
@katbyte
Copy link
Collaborator

katbyte commented Aug 21, 2018

tests pass:
screen shot 2018-08-21 at 16 25 34

@ghost
Copy link

ghost commented Jun 27, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Jun 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants