From aa63c6dd4d22433035a6b20069344ab249384fbe Mon Sep 17 00:00:00 2001 From: Jeremy Muriel Date: Fri, 8 Jul 2022 11:30:05 +0200 Subject: [PATCH 1/2] r/routing_instance: add router_id argument --- CHANGELOG.md | 2 ++ docs/data-sources/routing_instance.md | 2 ++ docs/resources/routing_instance.md | 2 ++ junos/data_source_routing_instance.go | 7 +++++++ junos/resource_routing_instance.go | 15 +++++++++++++++ junos/resource_routing_instance_test.go | 2 ++ 6 files changed, 30 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cead0838..cc4234d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ENHANCEMENTS: +* resource/`junos_routing_instance`: add `router_id` argument (Fixes #405) + BUG FIXES: ## 1.28.0 (May 30, 2022) diff --git a/docs/data-sources/routing_instance.md b/docs/data-sources/routing_instance.md index b82e5f9d..d4ca0a70 100644 --- a/docs/data-sources/routing_instance.md +++ b/docs/data-sources/routing_instance.md @@ -42,6 +42,8 @@ The following attributes are exported: List of interfaces in routing-instance. - **route_distinguisher** (String) Route distinguisher for this instance. +- **router_id** (String) + Router identifier. - **vrf_export** (List of String) Export policy for VRF instance RIBs. - **vrf_import** (List of String) diff --git a/docs/resources/routing_instance.md b/docs/resources/routing_instance.md index 266e5f36..0d6da666 100644 --- a/docs/resources/routing_instance.md +++ b/docs/resources/routing_instance.md @@ -42,6 +42,8 @@ The following arguments are supported: Import policy for instance RIBs - **route_distinguisher** (Optional, String) Route distinguisher for this instance. +- **router_id** (Optional, String) + Router identifier. - **vrf_export** (Optional, List of String) Export policy for VRF instance RIBs. - **vrf_import** (Optional, List of String) diff --git a/junos/data_source_routing_instance.go b/junos/data_source_routing_instance.go index 608b23da..e94f4ef4 100644 --- a/junos/data_source_routing_instance.go +++ b/junos/data_source_routing_instance.go @@ -48,6 +48,10 @@ func dataSourceRoutingInstance() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "router_id": { + Type: schema.TypeString, + Computed: true, + }, "vrf_export": { Type: schema.TypeList, Computed: true, @@ -126,6 +130,9 @@ func fillRoutingInstanceDataSource(d *schema.ResourceData, instanceOptions insta if tfErr := d.Set("route_distinguisher", instanceOptions.routeDistinguisher); tfErr != nil { panic(tfErr) } + if tfErr := d.Set("router_id", instanceOptions.routerID); tfErr != nil { + panic(tfErr) + } if tfErr := d.Set("type", instanceOptions.instanceType); tfErr != nil { panic(tfErr) } diff --git a/junos/resource_routing_instance.go b/junos/resource_routing_instance.go index 8620cd11..2342f774 100644 --- a/junos/resource_routing_instance.go +++ b/junos/resource_routing_instance.go @@ -18,6 +18,7 @@ type instanceOptions struct { instanceType string name string routeDistinguisher string + routerID string vrfTarget string vrfTargetExport string vrfTargetImport string @@ -99,6 +100,11 @@ func resourceRoutingInstance() *schema.Resource { ValidateFunc: validation.StringMatch(regexp.MustCompile( `^(\d|\.)+L?:\d+$`), "must have valid route distinguisher. Use format 'x:y'"), }, + "router_id": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.IsIPv4Address, + }, "vrf_export": { Type: schema.TypeList, Optional: true, @@ -394,6 +400,9 @@ func setRoutingInstance(d *schema.ResourceData, clt *Client, junSess *junosSessi if v := d.Get("as").(string); v != "" { configSet = append(configSet, setPrefix+"routing-options autonomous-system "+v) } + if v := d.Get("router_id").(string); v != "" { + configSet = append(configSet, setPrefix+"routing-options router-id "+v) + } if v := d.Get("description").(string); v != "" { configSet = append(configSet, setPrefix+"description \""+v+"\"") } @@ -442,6 +451,8 @@ func readRoutingInstance(instance string, clt *Client, junSess *junosSession) (i case strings.HasPrefix(itemTrim, "routing-options instance-import "): confRead.instanceImport = append(confRead.instanceImport, strings.TrimPrefix(itemTrim, "routing-options instance-import ")) + case strings.HasPrefix(itemTrim, "routing-options router-id "): + confRead.routerID = strings.TrimPrefix(itemTrim, "routing-options router-id ") case strings.HasPrefix(itemTrim, "vrf-export "): confRead.vrfExport = append(confRead.vrfExport, strings.Trim(strings.TrimPrefix(itemTrim, "vrf-export "), "\"")) case strings.HasPrefix(itemTrim, "vrf-import "): @@ -474,6 +485,7 @@ func delRoutingInstanceOpts(d *schema.ResourceData, clt *Client, junSess *junosS setPrefix+"routing-options autonomous-system", setPrefix+"routing-options instance-export", setPrefix+"routing-options instance-import", + setPrefix+"routing-options router-id", setPrefix+"vtep-source-interface", ) if !d.Get("configure_type_singly").(bool) { @@ -514,6 +526,9 @@ func fillRoutingInstanceData(d *schema.ResourceData, instanceOptions instanceOpt if tfErr := d.Set("instance_import", instanceOptions.instanceImport); tfErr != nil { panic(tfErr) } + if tfErr := d.Set("router_id", instanceOptions.routerID); tfErr != nil { + panic(tfErr) + } if tfErr := d.Set("vtep_source_interface", instanceOptions.vtepSourceIf); tfErr != nil { panic(tfErr) } diff --git a/junos/resource_routing_instance_test.go b/junos/resource_routing_instance_test.go index 8be6d81f..d8eda3fd 100644 --- a/junos/resource_routing_instance_test.go +++ b/junos/resource_routing_instance_test.go @@ -80,6 +80,7 @@ resource "junos_routing_instance" "testacc_routingInst" { description = "testacc routingInst" instance_export = [junos_policyoptions_policy_statement.testacc_routingInst2.name] instance_import = [junos_policyoptions_policy_statement.testacc_routingInst2.name] + router_id = "192.0.2.65" } resource "junos_policyoptions_community" "testacc_routingInst2" { name = "testacc_routingInst2" @@ -148,6 +149,7 @@ resource "junos_routing_instance" "testacc_routingInst" { description = "testacc routingInst" instance_export = [junos_policyoptions_policy_statement.testacc_routingInst2.name] instance_import = [junos_policyoptions_policy_statement.testacc_routingInst2.name] + router_id = "192.0.2.65" } resource "junos_policyoptions_community" "testacc_routingInst2" { name = "testacc_routingInst2" From 066278bf6897bdefc7930a3dd05d16d964977321 Mon Sep 17 00:00:00 2001 From: Jeremy Muriel Date: Wed, 13 Jul 2022 09:07:15 +0200 Subject: [PATCH 2/2] Release v1.29.0 --- .github/workflows/releases.yml | 2 +- CHANGELOG.md | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index f476d3d9..fc69ce8b 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -43,7 +43,7 @@ jobs: - name: Set up Go 1.18 uses: actions/setup-go@v3 with: - go-version: ^1.18.1 + go-version: ^1.18.4 check-latest: true id: go - name: Show version diff --git a/CHANGELOG.md b/CHANGELOG.md index cc4234d0..dbcbc19a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,14 @@ ENHANCEMENTS: -* resource/`junos_routing_instance`: add `router_id` argument (Fixes #405) - BUG FIXES: +## 1.29.0 (July 13, 2022) + +ENHANCEMENTS: + +* resource/`junos_routing_instance`: add `router_id` argument (Fixes [#405](https://github.com/jeremmfr/terraform-provider-junos/issues/405)) + ## 1.28.0 (May 30, 2022) FEATURES: