From 973df539ef0ef3f39bbedb3ad9feeb56bfe1caaf Mon Sep 17 00:00:00 2001 From: Jeremy Muriel Date: Tue, 12 Oct 2021 13:56:58 +0200 Subject: [PATCH 1/6] [website][workflows] fix deployment --- .github/workflows/releases.yml | 32 +++++++++++--------------------- .github/workflows/website.yml | 32 +++++++++++--------------------- 2 files changed, 22 insertions(+), 42 deletions(-) diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index d99d186e..b6dbb1ab 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -143,9 +143,9 @@ jobs: cp /tmp/terraform-website/content/source/layouts/inner.erb ./source/layouts/ echo "redirect 'index.html', to: 'docs/providers/junos/index.html'" >> config.rb - name: Setup ruby - uses: actions/setup-ruby@v1 + uses: ruby/setup-ruby@v1 with: - ruby-version: "2.x" + ruby-version: "2.7" - name: Install middleman working-directory: ./.terraform-website/ run: | @@ -156,25 +156,15 @@ jobs: - name: Build Website working-directory: ./.terraform-website/ run: bundle exec middleman build --verbose - - name: Download google files from S3 - uses: ItsKarma/aws-cli@v1.70.0 + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 with: - args: s3 cp s3://terraform-provider-junos.jeremm.fr/google72955f25e01c2a06.html .terraform-website/build/ - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-1 + - name: Download google files from S3 + run: aws s3 cp s3://terraform-provider-junos.jeremm.fr/google72955f25e01c2a06.html .terraform-website/build/ - name: Upload Website on S3 - uses: ItsKarma/aws-cli@v1.70.0 - with: - args: s3 sync .terraform-website/build/ s3://terraform-provider-junos.jeremm.fr/ --delete - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + run: aws s3 sync .terraform-website/build/ s3://terraform-provider-junos.jeremm.fr/ --delete - name: Invalidate Cloudfront Distribution - uses: chetan/invalidate-cloudfront-action@v1.3 - env: - PATHS: '/docs/*' - AWS_REGION: 'eu-west-1' - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - DISTRIBUTION: ${{ secrets.DISTRIBUTION_ID }} + run: aws cloudfront create-invalidation --distribution-id ${{ secrets.DISTRIBUTION_ID }} --paths "/docs/*" \ No newline at end of file diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index 12d71906..a0c19446 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -25,9 +25,9 @@ jobs: cp /tmp/terraform-website/content/source/layouts/inner.erb ./source/layouts/ echo "redirect 'index.html', to: 'docs/providers/junos/index.html'" >> config.rb - name: Setup ruby - uses: actions/setup-ruby@v1 + uses: ruby/setup-ruby@v1 with: - ruby-version: "2.x" + ruby-version: "2.7" - name: Install middleman working-directory: ./.terraform-website/ run: | @@ -38,25 +38,15 @@ jobs: - name: Build Website working-directory: ./.terraform-website/ run: bundle exec middleman build --verbose - - name: Download google files from S3 - uses: ItsKarma/aws-cli@v1.70.0 + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 with: - args: s3 cp s3://terraform-provider-junos.jeremm.fr/google72955f25e01c2a06.html .terraform-website/build/ - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-1 + - name: Download google files from S3 + run: aws s3 cp s3://terraform-provider-junos.jeremm.fr/google72955f25e01c2a06.html .terraform-website/build/ - name: Upload Website on S3 - uses: ItsKarma/aws-cli@v1.70.0 - with: - args: s3 sync .terraform-website/build/ s3://terraform-provider-junos.jeremm.fr/ --delete - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + run: aws s3 sync .terraform-website/build/ s3://terraform-provider-junos.jeremm.fr/ --delete - name: Invalidate Cloudfront Distribution - uses: chetan/invalidate-cloudfront-action@v1.3 - env: - PATHS: '/docs/*' - AWS_REGION: 'eu-west-1' - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - DISTRIBUTION: ${{ secrets.DISTRIBUTION_ID }} + run: aws cloudfront create-invalidation --distribution-id ${{ secrets.DISTRIBUTION_ID }} --paths "/docs/*" From eafc3bbfa934edfa02c9ea1ed2cbdbc44577e3db Mon Sep 17 00:00:00 2001 From: Jeremy Muriel Date: Thu, 21 Oct 2021 08:47:12 +0200 Subject: [PATCH 2/6] r/*: fix missing identifier value in the errors 'multiple blocks... ... with the same identifier' Fixes parts of #292 --- CHANGELOG.md | 2 ++ junos/func_resource_bgp.go | 6 +++--- junos/resource_chassis_cluster.go | 2 +- junos/resource_eventoptions_destination.go | 2 +- junos/resource_eventoptions_policy.go | 12 +++++++----- junos/resource_firewall_filter.go | 2 +- ...esource_forwardingoptions_sampling_instance.go | 4 ++-- junos/resource_group_dual_system.go | 8 +++++--- junos/resource_interface_logical.go | 15 ++++++++++----- junos/resource_ospf_area.go | 2 +- junos/resource_policyoptions_as_path_group.go | 2 +- junos/resource_policyoptions_policy_statement.go | 5 +++-- junos/resource_security_address_book.go | 10 +++++----- ...source_security_dynamic_address_feed_server.go | 2 +- junos/resource_security_dynamic_address_name.go | 2 +- junos/resource_security_global_policy.go | 2 +- junos/resource_security_idp_custom_attack.go | 2 +- junos/resource_security_idp_policy.go | 4 ++-- junos/resource_security_ipsec_vpn.go | 2 +- junos/resource_security_nat_destination.go | 2 +- junos/resource_security_nat_source.go | 2 +- junos/resource_security_nat_static.go | 2 +- junos/resource_security_policy.go | 2 +- junos/resource_security_screen.go | 2 +- ..._utm_profile_web_filtering_juniper_enhanced.go | 8 +++++--- junos/resource_security_zone.go | 10 +++++----- junos/resource_services.go | 3 ++- junos/resource_services_rpm_probe.go | 2 +- ...ource_services_security_intelligence_policy.go | 2 +- ...urce_services_security_intelligence_profile.go | 2 +- ...rvices_user_identification_ad_access_domain.go | 2 +- ...user_identification_device_identity_profile.go | 2 +- junos/resource_snmp_community.go | 2 +- junos/resource_static_route.go | 3 ++- junos/resource_system.go | 2 +- junos/resource_system_syslog_file.go | 2 +- 36 files changed, 76 insertions(+), 60 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9abd7fc4..708bb715 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ ENHANCEMENTS: BUG FIXES: +* r/`*`: fix missing identifier value in the errors `multiple blocks with the same identifier` (Fixes parts of #292) + ## 1.21.0 (October 12, 2021) FEATURES: diff --git a/junos/func_resource_bgp.go b/junos/func_resource_bgp.go index a4077108..e3493aa5 100644 --- a/junos/func_resource_bgp.go +++ b/junos/func_resource_bgp.go @@ -574,11 +574,11 @@ func setBgpOptsFamily(setPrefix, familyType string, familyOptsList []interface{} if bchk.StringInSlice(familyOptsM["nlri_type"].(string), familyNlriTypeList) { switch familyType { case evpnWord: - return fmt.Errorf("multiple family_evpn blocks with the same nlri_type") + return fmt.Errorf("multiple blocks family_evpn with the same nlri_type %s", familyOptsM["nlri_type"].(string)) case inetWord: - return fmt.Errorf("multiple family_inet blocks with the same nlri_type") + return fmt.Errorf("multiple blocks family_inet with the same nlri_type %s", familyOptsM["nlri_type"].(string)) case inet6Word: - return fmt.Errorf("multiple family_inet6 blocks with the same nlri_type") + return fmt.Errorf("multiple blocks family_inet6 with the same nlri_type %s", familyOptsM["nlri_type"].(string)) } } familyNlriTypeList = append(familyNlriTypeList, familyOptsM["nlri_type"].(string)) diff --git a/junos/resource_chassis_cluster.go b/junos/resource_chassis_cluster.go index e2cf042b..7a40034f 100644 --- a/junos/resource_chassis_cluster.go +++ b/junos/resource_chassis_cluster.go @@ -365,7 +365,7 @@ func setChassisCluster(d *schema.ResourceData, m interface{}, jnprSess *NetconfO for _, v2 := range redundancyGroup["interface_monitor"].([]interface{}) { interfaceMonitor := v2.(map[string]interface{}) if bchk.StringInSlice(interfaceMonitor["name"].(string), interfaceMonitorNameList) { - return fmt.Errorf("multiple interface_monitor blocks with the same name") + return fmt.Errorf("multiple blocks interface_monitor with the same name %s", interfaceMonitor["name"].(string)) } interfaceMonitorNameList = append(interfaceMonitorNameList, interfaceMonitor["name"].(string)) configSet = append(configSet, setChassisluster+"redundancy-group "+strconv.Itoa(i)+ diff --git a/junos/resource_eventoptions_destination.go b/junos/resource_eventoptions_destination.go index 0b8e68fe..db4f8071 100644 --- a/junos/resource_eventoptions_destination.go +++ b/junos/resource_eventoptions_destination.go @@ -255,7 +255,7 @@ func setEventoptionsDestination(d *schema.ResourceData, m interface{}, jnprSess for _, v := range d.Get("archive_site").([]interface{}) { archiveSite := v.(map[string]interface{}) if bchk.StringInSlice(archiveSite["url"].(string), archiveSiteURLList) { - return fmt.Errorf("multiple archive_site blocks with the same url") + return fmt.Errorf("multiple blocks archive_site with the same url %s", archiveSite["url"].(string)) } archiveSiteURLList = append(archiveSiteURLList, archiveSite["url"].(string)) configSet = append(configSet, setPrefix+"archive-sites \""+archiveSite["url"].(string)+"\"") diff --git a/junos/resource_eventoptions_policy.go b/junos/resource_eventoptions_policy.go index 3e243594..44a9e8c7 100644 --- a/junos/resource_eventoptions_policy.go +++ b/junos/resource_eventoptions_policy.go @@ -691,7 +691,7 @@ func setEventoptionsPolicy(d *schema.ResourceData, m interface{}, jnprSess *Netc for _, v2 := range then["event_script"].([]interface{}) { eventScript := v2.(map[string]interface{}) if bchk.StringInSlice(eventScript["filename"].(string), eventScriptFilenameList) { - return fmt.Errorf("multiple event_script blocks with the same filename") + return fmt.Errorf("multiple blocks event_script with the same filename %s", eventScript["filename"].(string)) } eventScriptFilenameList = append(eventScriptFilenameList, eventScript["filename"].(string)) setPrefixThenEventScript := setPrefix + "then event-script \"" + eventScript["filename"].(string) + "\" " @@ -700,7 +700,7 @@ func setEventoptionsPolicy(d *schema.ResourceData, m interface{}, jnprSess *Netc for _, v3 := range eventScript["arguments"].([]interface{}) { arguments := v3.(map[string]interface{}) if bchk.StringInSlice(arguments["name"].(string), argumentsNameList) { - return fmt.Errorf("multiple arguments blocks with the same name") + return fmt.Errorf("multiple blocks arguments with the same name %s", arguments["name"].(string)) } argumentsNameList = append(argumentsNameList, arguments["name"].(string)) configSet = append(configSet, setPrefixThenEventScript+ @@ -785,7 +785,8 @@ func setEventoptionsPolicy(d *schema.ResourceData, m interface{}, jnprSess *Netc setPrefixThenUpload := setPrefix + "then upload filename \"" + upload["filename"].(string) + "\" " + "destination \"" + upload["destination"].(string) + "\" " if bchk.StringInSlice(setPrefixThenUpload, uploadFileDestList) { - return fmt.Errorf("multiple upload blocks with the same filename and destination") + return fmt.Errorf("multiple blocks upload with the same filename %s and destination %s", + upload["filename"].(string), upload["destination"].(string)) } uploadFileDestList = append(uploadFileDestList, setPrefixThenUpload) configSet = append(configSet, setPrefixThenUpload) @@ -813,7 +814,8 @@ func setEventoptionsPolicy(d *schema.ResourceData, m interface{}, jnprSess *Netc setAttriMatch := setPrefix + "attributes-match \"" + attriMatch["from"].(string) + "\" " + attriMatch["compare"].(string) + " \"" + attriMatch["to"].(string) + "\"" if bchk.StringInSlice(setAttriMatch, attriMatchList) { - return fmt.Errorf("multiple attributes_match blocks with the same from, compare and to") + return fmt.Errorf("multiple blocks attributes_match with the same from %s, compare %s and to %s", + attriMatch["from"].(string), attriMatch["compare"].(string), attriMatch["to"].(string)) } attriMatchList = append(attriMatchList, setAttriMatch) configSet = append(configSet, setAttriMatch) @@ -822,7 +824,7 @@ func setEventoptionsPolicy(d *schema.ResourceData, m interface{}, jnprSess *Netc for _, v := range d.Get("within").([]interface{}) { within := v.(map[string]interface{}) if bchk.IntInSlice(within["time_interval"].(int), withinTimeInterval) { - return fmt.Errorf("multiple within blocks with the same time_interval") + return fmt.Errorf("multiple blocks within with the same time_interval %d", within["time_interval"].(int)) } withinTimeInterval = append(withinTimeInterval, within["time_interval"].(int)) setPrefixWithin := setPrefix + "within " + strconv.Itoa(within["time_interval"].(int)) + " " diff --git a/junos/resource_firewall_filter.go b/junos/resource_firewall_filter.go index 8b37af1b..d94a55e0 100644 --- a/junos/resource_firewall_filter.go +++ b/junos/resource_firewall_filter.go @@ -466,7 +466,7 @@ func setFirewallFilter(d *schema.ResourceData, m interface{}, jnprSess *NetconfO for _, v := range d.Get("term").([]interface{}) { term := v.(map[string]interface{}) if bchk.StringInSlice(term["name"].(string), termNameList) { - return fmt.Errorf("multiple term blocks with the same name") + return fmt.Errorf("multiple blocks term with the same name %s", term["name"].(string)) } termNameList = append(termNameList, term["name"].(string)) setPrefixTerm := setPrefix + " term " + term["name"].(string) diff --git a/junos/resource_forwardingoptions_sampling_instance.go b/junos/resource_forwardingoptions_sampling_instance.go index 4625b309..4a6166e5 100644 --- a/junos/resource_forwardingoptions_sampling_instance.go +++ b/junos/resource_forwardingoptions_sampling_instance.go @@ -952,7 +952,7 @@ func setForwardingoptionsSamplingInstanceOutput( for _, vFS := range output["flow_server"].([]interface{}) { flowServer := vFS.(map[string]interface{}) if bchk.StringInSlice(flowServer["hostname"].(string), flowServerHostnameList) { - return fmt.Errorf("multiple flow_server blocks with the same hostname") + return fmt.Errorf("multiple blocks flow_server with the same hostname %s", flowServer["hostname"].(string)) } flowServerHostnameList = append(flowServerHostnameList, flowServer["hostname"].(string)) setPrefixFlowServer := setPrefix + "flow-server " + flowServer["hostname"].(string) + " " @@ -1021,7 +1021,7 @@ func setForwardingoptionsSamplingInstanceOutput( for _, vIF := range output["interface"].([]interface{}) { interFace := vIF.(map[string]interface{}) if bchk.StringInSlice(interFace["name"].(string), interfaceNameList) { - return fmt.Errorf("multiple interface blocks with the same name") + return fmt.Errorf("multiple blocks interface with the same name %s", interFace["name"].(string)) } interfaceNameList = append(interfaceNameList, interFace["name"].(string)) setPrefixInterface := setPrefix + "interface " + interFace["name"].(string) + " " diff --git a/junos/resource_group_dual_system.go b/junos/resource_group_dual_system.go index 26942b12..b565e49b 100644 --- a/junos/resource_group_dual_system.go +++ b/junos/resource_group_dual_system.go @@ -399,7 +399,8 @@ func setGroupDualSystem(d *schema.ResourceData, m interface{}, jnprSess *Netconf for _, v2 := range interfaceFxp0["family_inet_address"].([]interface{}) { familyInetAddress := v2.(map[string]interface{}) if bchk.StringInSlice(familyInetAddress["cidr_ip"].(string), familyInetAddressCIDRIPList) { - return fmt.Errorf("multiple family_inet_address blocks with the same cidr_ip") + return fmt.Errorf("multiple blocks family_inet_address with the same cidr_ip %s", + familyInetAddress["cidr_ip"].(string)) } familyInetAddressCIDRIPList = append(familyInetAddressCIDRIPList, familyInetAddress["cidr_ip"].(string)) configSet = append(configSet, setPrefix+"interfaces fxp0 unit 0 family inet address "+ @@ -421,7 +422,8 @@ func setGroupDualSystem(d *schema.ResourceData, m interface{}, jnprSess *Netconf for _, v2 := range interfaceFxp0["family_inet6_address"].([]interface{}) { familyInet6Address := v2.(map[string]interface{}) if bchk.StringInSlice(familyInet6Address["cidr_ip"].(string), familyInet6AddressCIDRIPList) { - return fmt.Errorf("multiple family_inet6_address blocks with the same cidr_ip") + return fmt.Errorf("multiple blocks family_inet6_address with the same cidr_ip %s", + familyInet6Address["cidr_ip"].(string)) } familyInet6AddressCIDRIPList = append(familyInet6AddressCIDRIPList, familyInet6Address["cidr_ip"].(string)) configSet = append(configSet, setPrefix+"interfaces fxp0 unit 0 family inet6 address "+ @@ -446,7 +448,7 @@ func setGroupDualSystem(d *schema.ResourceData, m interface{}, jnprSess *Netconf for _, v2 := range routingOptions["static_route"].([]interface{}) { staticRoute := v2.(map[string]interface{}) if bchk.StringInSlice(staticRoute["destination"].(string), staticRouteDestList) { - return fmt.Errorf("multiple static_route blocks with the same destination") + return fmt.Errorf("multiple blocks static_route with the same destination %s", staticRoute["destination"].(string)) } staticRouteDestList = append(staticRouteDestList, staticRoute["destination"].(string)) for _, v3 := range staticRoute["next_hop"].([]interface{}) { diff --git a/junos/resource_interface_logical.go b/junos/resource_interface_logical.go index 7e6cd5ca..8e94ff50 100644 --- a/junos/resource_interface_logical.go +++ b/junos/resource_interface_logical.go @@ -1347,10 +1347,12 @@ func setFamilyAddress(inetAddress map[string]interface{}, setPrefix string, fami addressMap := address.(map[string]interface{}) if bchk.StringInSlice(addressMap["cidr_ip"].(string), addressCIDRIPList) { if family == inetWord { - return configSet, fmt.Errorf("multiple family_inet blocks with the same cidr_ip") + return configSet, fmt.Errorf("multiple blocks family_inet with the same cidr_ip %s", + addressMap["cidr_ip"].(string)) } if family == inet6Word { - return configSet, fmt.Errorf("multiple family_inet6 blocks with the same cidr_ip") + return configSet, fmt.Errorf("multiple blocks family_inet6 with the same cidr_ip %s", + addressMap["cidr_ip"].(string)) } } addressCIDRIPList = append(addressCIDRIPList, addressMap["cidr_ip"].(string)) @@ -1375,7 +1377,8 @@ func setFamilyAddress(inetAddress map[string]interface{}, setPrefix string, fami return configSet, fmt.Errorf("ConflictsWith no_accept_data and accept_data") } if bchk.IntInSlice(vrrpGroupMap["identifier"].(int), vrrpGroupIDList) { - return configSet, fmt.Errorf("multiple vrrp_group blocks with the same identifier") + return configSet, fmt.Errorf("multiple blocks vrrp_group with the same identifier %d", + vrrpGroupMap["identifier"].(int)) } vrrpGroupIDList = append(vrrpGroupIDList, vrrpGroupMap["identifier"].(int)) var setNameAddVrrp string @@ -1440,7 +1443,8 @@ func setFamilyAddress(inetAddress map[string]interface{}, setPrefix string, fami for _, trackInterface := range vrrpGroupMap["track_interface"].([]interface{}) { trackInterfaceMap := trackInterface.(map[string]interface{}) if bchk.StringInSlice(trackInterfaceMap["interface"].(string), trackInterfaceList) { - return configSet, fmt.Errorf("multiple track_interface blocks with the same interface") + return configSet, fmt.Errorf("multiple blocks track_interface with the same interface %s", + trackInterfaceMap["interface"].(string)) } trackInterfaceList = append(trackInterfaceList, trackInterfaceMap["interface"].(string)) configSet = append(configSet, setNameAddVrrp+" track interface "+trackInterfaceMap["interface"].(string)+ @@ -1450,7 +1454,8 @@ func setFamilyAddress(inetAddress map[string]interface{}, setPrefix string, fami for _, trackRoute := range vrrpGroupMap["track_route"].([]interface{}) { trackRouteMap := trackRoute.(map[string]interface{}) if bchk.StringInSlice(trackRouteMap["route"].(string), trackRouteList) { - return configSet, fmt.Errorf("multiple track_route blocks with the same interface") + return configSet, fmt.Errorf("multiple blocks track_route with the same interface %s", + trackRouteMap["route"].(string)) } trackRouteList = append(trackRouteList, trackRouteMap["route"].(string)) configSet = append(configSet, setNameAddVrrp+" track route "+trackRouteMap["route"].(string)+ diff --git a/junos/resource_ospf_area.go b/junos/resource_ospf_area.go index 8063229a..0855b91b 100644 --- a/junos/resource_ospf_area.go +++ b/junos/resource_ospf_area.go @@ -314,7 +314,7 @@ func setOspfArea(d *schema.ResourceData, m interface{}, jnprSess *NetconfObject) for _, v := range d.Get("interface").([]interface{}) { ospfInterface := v.(map[string]interface{}) if bchk.StringInSlice(ospfInterface["name"].(string), interfaceNameList) { - return fmt.Errorf("multiple interface blocks with the same name") + return fmt.Errorf("multiple blocks interface with the same name %s", ospfInterface["name"].(string)) } interfaceNameList = append(interfaceNameList, ospfInterface["name"].(string)) setPrefixInterface := setPrefix + "interface " + ospfInterface["name"].(string) + " " diff --git a/junos/resource_policyoptions_as_path_group.go b/junos/resource_policyoptions_as_path_group.go index 127974a1..1919b24c 100644 --- a/junos/resource_policyoptions_as_path_group.go +++ b/junos/resource_policyoptions_as_path_group.go @@ -251,7 +251,7 @@ func setPolicyoptionsAsPathGroup(d *schema.ResourceData, m interface{}, jnprSess for _, v := range d.Get("as_path").([]interface{}) { asPath := v.(map[string]interface{}) if bchk.StringInSlice(asPath["name"].(string), asPathNameList) { - return fmt.Errorf("multiple as_path blocks with the same name") + return fmt.Errorf("multiple blocks as_path with the same name %s", asPath["name"].(string)) } asPathNameList = append(asPathNameList, asPath["name"].(string)) configSet = append(configSet, setPrefix+ diff --git a/junos/resource_policyoptions_policy_statement.go b/junos/resource_policyoptions_policy_statement.go index a8683aac..e5e184ad 100644 --- a/junos/resource_policyoptions_policy_statement.go +++ b/junos/resource_policyoptions_policy_statement.go @@ -673,7 +673,7 @@ func setPolicyStatement(d *schema.ResourceData, m interface{}, jnprSess *Netconf for _, term := range d.Get("term").([]interface{}) { termMap := term.(map[string]interface{}) if bchk.StringInSlice(termMap["name"].(string), termNameList) { - return fmt.Errorf("multiple term blocks with the same name") + return fmt.Errorf("multiple blocks term with the same name %s", termMap["name"].(string)) } termNameList = append(termNameList, termMap["name"].(string)) setPrefixTerm := setPrefix + " term " + termMap["name"].(string) @@ -947,7 +947,8 @@ func setPolicyStatementOptsThen(setPrefix string, opts map[string]interface{}) ( community := v.(map[string]interface{}) setCommunityActVal := "community " + community["action"].(string) + " " + community["value"].(string) if bchk.StringInSlice(setCommunityActVal, communityList) { - return configSet, fmt.Errorf("multiple community blocks with the same action and value") + return configSet, fmt.Errorf("multiple blocks community with the same action %s and value %s", + community["action"].(string), community["value"].(string)) } communityList = append(communityList, setCommunityActVal) configSet = append(configSet, setPrefixThen+setCommunityActVal) diff --git a/junos/resource_security_address_book.go b/junos/resource_security_address_book.go index c2481fec..045f6183 100644 --- a/junos/resource_security_address_book.go +++ b/junos/resource_security_address_book.go @@ -375,7 +375,7 @@ func setSecurityAddressBook(d *schema.ResourceData, m interface{}, jnprSess *Net for _, v := range d.Get("network_address").([]interface{}) { address := v.(map[string]interface{}) if bchk.StringInSlice(address["name"].(string), addressNameList) { - return fmt.Errorf("multiple address with the same name") + return fmt.Errorf("multiple addresses with the same name %s", address["name"].(string)) } addressNameList = append(addressNameList, address["name"].(string)) setPrefixAddr := setPrefix + " address " + address["name"].(string) + " " @@ -387,7 +387,7 @@ func setSecurityAddressBook(d *schema.ResourceData, m interface{}, jnprSess *Net for _, v := range d.Get("wildcard_address").([]interface{}) { address := v.(map[string]interface{}) if bchk.StringInSlice(address["name"].(string), addressNameList) { - return fmt.Errorf("multiple address with the same name") + return fmt.Errorf("multiple addresses with the same name %s", address["name"].(string)) } addressNameList = append(addressNameList, address["name"].(string)) setPrefixAddr := setPrefix + " address " + address["name"].(string) @@ -399,7 +399,7 @@ func setSecurityAddressBook(d *schema.ResourceData, m interface{}, jnprSess *Net for _, v := range d.Get("dns_name").([]interface{}) { address := v.(map[string]interface{}) if bchk.StringInSlice(address["name"].(string), addressNameList) { - return fmt.Errorf("multiple address with the same name") + return fmt.Errorf("multiple addresses with the same name %s", address["name"].(string)) } addressNameList = append(addressNameList, address["name"].(string)) setPrefixAddr := setPrefix + " address " + address["name"].(string) @@ -411,7 +411,7 @@ func setSecurityAddressBook(d *schema.ResourceData, m interface{}, jnprSess *Net for _, v := range d.Get("range_address").([]interface{}) { address := v.(map[string]interface{}) if bchk.StringInSlice(address["name"].(string), addressNameList) { - return fmt.Errorf("multiple address with the same name") + return fmt.Errorf("multiple addresses with the same name %s", address["name"].(string)) } addressNameList = append(addressNameList, address["name"].(string)) setPrefixAddr := setPrefix + " address " + address["name"].(string) @@ -423,7 +423,7 @@ func setSecurityAddressBook(d *schema.ResourceData, m interface{}, jnprSess *Net for _, v := range d.Get("address_set").([]interface{}) { addressSet := v.(map[string]interface{}) if bchk.StringInSlice(addressSet["name"].(string), addressNameList) { - return fmt.Errorf("multiple address or address_set with the same name") + return fmt.Errorf("multiple addresses or address-sets with the same name %s", addressSet["name"].(string)) } addressNameList = append(addressNameList, addressSet["name"].(string)) setPrefixAddrSet := setPrefix + " address-set " + addressSet["name"].(string) diff --git a/junos/resource_security_dynamic_address_feed_server.go b/junos/resource_security_dynamic_address_feed_server.go index 62f9193b..e43ea332 100644 --- a/junos/resource_security_dynamic_address_feed_server.go +++ b/junos/resource_security_dynamic_address_feed_server.go @@ -298,7 +298,7 @@ func setSecurityDynamicAddressFeedServer(d *schema.ResourceData, m interface{}, for _, fn := range d.Get("feed_name").([]interface{}) { feedName := fn.(map[string]interface{}) if bchk.StringInSlice(feedName["name"].(string), feedNameList) { - return fmt.Errorf("multiple feed_name blocks with the same name") + return fmt.Errorf("multiple blocks feed_name with the same name %s", feedName["name"].(string)) } feedNameList = append(feedNameList, feedName["name"].(string)) setPrefixFeedName := setPrefix + "feed-name " + feedName["name"].(string) + " " diff --git a/junos/resource_security_dynamic_address_name.go b/junos/resource_security_dynamic_address_name.go index 85e6e76e..a24d8875 100644 --- a/junos/resource_security_dynamic_address_name.go +++ b/junos/resource_security_dynamic_address_name.go @@ -303,7 +303,7 @@ func setSecurityDynamicAddressName(d *schema.ResourceData, m interface{}, jnprSe for _, pro := range profileCategory["property"].([]interface{}) { property := pro.(map[string]interface{}) if bchk.StringInSlice(property["name"].(string), propertyNameList) { - return fmt.Errorf("multiple property blocks with the same name") + return fmt.Errorf("multiple blocks property with the same name %s", property["name"].(string)) } propertyNameList = append(propertyNameList, property["name"].(string)) for _, str := range property["string"].([]interface{}) { diff --git a/junos/resource_security_global_policy.go b/junos/resource_security_global_policy.go index e5746308..8b54a105 100644 --- a/junos/resource_security_global_policy.go +++ b/junos/resource_security_global_policy.go @@ -345,7 +345,7 @@ func setSecurityGlobalPolicy(d *schema.ResourceData, m interface{}, jnprSess *Ne for _, v := range d.Get("policy").([]interface{}) { policy := v.(map[string]interface{}) if bchk.StringInSlice(policy["name"].(string), policyNameList) { - return fmt.Errorf("multiple policy blocks with the same name") + return fmt.Errorf("multiple blocks policy with the same name %s", policy["name"].(string)) } policyNameList = append(policyNameList, policy["name"].(string)) setPrefixPolicy := setPrefix + policy["name"].(string) diff --git a/junos/resource_security_idp_custom_attack.go b/junos/resource_security_idp_custom_attack.go index bc4feb35..9d472cbd 100644 --- a/junos/resource_security_idp_custom_attack.go +++ b/junos/resource_security_idp_custom_attack.go @@ -1027,7 +1027,7 @@ func setSecurityIdpCustomAttack(d *schema.ResourceData, m interface{}, jnprSess return fmt.Errorf("missing one attack type in member %s for attack_type_chain", attackChainMember["name"].(string)) } if bchk.StringInSlice(attackChainMember["name"].(string), memberNameList) { - return fmt.Errorf("multiple member blocks with the same name") + return fmt.Errorf("multiple blocks member with the same name %s", attackChainMember["name"].(string)) } memberNameList = append(memberNameList, attackChainMember["name"].(string)) for _, v3 := range attackChainMember["attack_type_anomaly"].([]interface{}) { diff --git a/junos/resource_security_idp_policy.go b/junos/resource_security_idp_policy.go index 9a16ec13..77c332de 100644 --- a/junos/resource_security_idp_policy.go +++ b/junos/resource_security_idp_policy.go @@ -472,7 +472,7 @@ func setSecurityIdpPolicy(d *schema.ResourceData, m interface{}, jnprSess *Netco for _, e := range d.Get("exempt_rule").([]interface{}) { eM := e.(map[string]interface{}) if bchk.StringInSlice(eM["name"].(string), exemptRuleNameList) { - return fmt.Errorf("multiple exempt_rule blocks with the same name") + return fmt.Errorf("multiple blocks exempt_rule with the same name %s", eM["name"].(string)) } exemptRuleNameList = append(exemptRuleNameList, eM["name"].(string)) sets, err := setSecurityIdpPolicyExemptRule(setPrefix, eM) @@ -485,7 +485,7 @@ func setSecurityIdpPolicy(d *schema.ResourceData, m interface{}, jnprSess *Netco for _, e := range d.Get("ips_rule").([]interface{}) { eM := e.(map[string]interface{}) if bchk.StringInSlice(eM["name"].(string), ipsRuleNameList) { - return fmt.Errorf("multiple ips_rule blocks with the same name") + return fmt.Errorf("multiple blocks ips_rule with the same name %s", eM["name"].(string)) } ipsRuleNameList = append(ipsRuleNameList, eM["name"].(string)) sets, err := setSecurityIdpPolicyIpsRule(setPrefix, eM) diff --git a/junos/resource_security_ipsec_vpn.go b/junos/resource_security_ipsec_vpn.go index 81ef8165..c11991c7 100644 --- a/junos/resource_security_ipsec_vpn.go +++ b/junos/resource_security_ipsec_vpn.go @@ -406,7 +406,7 @@ func setIpsecVpn(d *schema.ResourceData, m interface{}, jnprSess *NetconfObject) for _, v := range d.Get("traffic_selector").([]interface{}) { tS := v.(map[string]interface{}) if bchk.StringInSlice(tS["name"].(string), trafficSelectorName) { - return fmt.Errorf("multiple traffic_selector blocks with the same name") + return fmt.Errorf("multiple blocks traffic_selector with the same name %s", tS["name"].(string)) } trafficSelectorName = append(trafficSelectorName, tS["name"].(string)) configSet = append(configSet, "set security ipsec vpn "+d.Get("name").(string)+" traffic-selector "+ diff --git a/junos/resource_security_nat_destination.go b/junos/resource_security_nat_destination.go index 0719a06f..a5e9258f 100644 --- a/junos/resource_security_nat_destination.go +++ b/junos/resource_security_nat_destination.go @@ -331,7 +331,7 @@ func setSecurityNatDestination(d *schema.ResourceData, m interface{}, jnprSess * for _, v := range d.Get("rule").([]interface{}) { rule := v.(map[string]interface{}) if bchk.StringInSlice(rule["name"].(string), ruleNameList) { - return fmt.Errorf("multiple rule blocks with the same name") + return fmt.Errorf("multiple blocks rule with the same name %s", rule["name"].(string)) } ruleNameList = append(ruleNameList, rule["name"].(string)) setPrefixRule := setPrefix + " rule " + rule["name"].(string) diff --git a/junos/resource_security_nat_source.go b/junos/resource_security_nat_source.go index b1cc01ff..251128d6 100644 --- a/junos/resource_security_nat_source.go +++ b/junos/resource_security_nat_source.go @@ -372,7 +372,7 @@ func setSecurityNatSource(d *schema.ResourceData, m interface{}, jnprSess *Netco for _, v := range d.Get("rule").([]interface{}) { rule := v.(map[string]interface{}) if bchk.StringInSlice(rule["name"].(string), ruleNameList) { - return fmt.Errorf("multiple rule blocks with the same name") + return fmt.Errorf("multiple blocks rule with the same name %s", rule["name"].(string)) } ruleNameList = append(ruleNameList, rule["name"].(string)) setPrefixRule := setPrefix + " rule " + rule["name"].(string) diff --git a/junos/resource_security_nat_static.go b/junos/resource_security_nat_static.go index 22132175..4e1af092 100644 --- a/junos/resource_security_nat_static.go +++ b/junos/resource_security_nat_static.go @@ -388,7 +388,7 @@ func setSecurityNatStatic(d *schema.ResourceData, m interface{}, jnprSess *Netco for _, v := range d.Get("rule").([]interface{}) { rule := v.(map[string]interface{}) if bchk.StringInSlice(rule["name"].(string), ruleNameList) { - return fmt.Errorf("multiple rule blocks with the same name") + return fmt.Errorf("multiple blocks rule with the same name %s", rule["name"].(string)) } ruleNameList = append(ruleNameList, rule["name"].(string)) setPrefixRule := setPrefix + " rule " + rule["name"].(string) diff --git a/junos/resource_security_policy.go b/junos/resource_security_policy.go index 6e1d326c..2007f499 100644 --- a/junos/resource_security_policy.go +++ b/junos/resource_security_policy.go @@ -397,7 +397,7 @@ func setSecurityPolicy(d *schema.ResourceData, m interface{}, jnprSess *NetconfO for _, v := range d.Get("policy").([]interface{}) { policy := v.(map[string]interface{}) if bchk.StringInSlice(policy["name"].(string), policyNameList) { - return fmt.Errorf("multiple policy blocks with the same name") + return fmt.Errorf("multiple blocks policy with the same name %s", policy["name"].(string)) } policyNameList = append(policyNameList, policy["name"].(string)) setPrefixPolicy := setPrefix + policy["name"].(string) diff --git a/junos/resource_security_screen.go b/junos/resource_security_screen.go index 946e448e..4ee00330 100644 --- a/junos/resource_security_screen.go +++ b/junos/resource_security_screen.go @@ -1152,7 +1152,7 @@ func setSecurityScreenTCP(tcp map[string]interface{}, setPrefix string) ([]strin whitelist["name"].(string)) } if bchk.StringInSlice(whitelist["name"].(string), whitelistNameList) { - return configSet, fmt.Errorf("multiple whitelist blocks with the same name") + return configSet, fmt.Errorf("multiple blocks whitelist with the same name %s", whitelist["name"].(string)) } whitelistNameList = append(whitelistNameList, whitelist["name"].(string)) for _, destination := range sortSetOfString(whitelist["destination_address"].(*schema.Set).List()) { diff --git a/junos/resource_security_utm_profile_web_filtering_juniper_enhanced.go b/junos/resource_security_utm_profile_web_filtering_juniper_enhanced.go index cfa8b8cc..2e5e098b 100644 --- a/junos/resource_security_utm_profile_web_filtering_juniper_enhanced.go +++ b/junos/resource_security_utm_profile_web_filtering_juniper_enhanced.go @@ -402,7 +402,7 @@ func setUtmProfileWebFEnhanced(d *schema.ResourceData, m interface{}, jnprSess * for _, v := range d.Get("category").([]interface{}) { category := v.(map[string]interface{}) if bchk.StringInSlice(category["name"].(string), categoryNameList) { - return fmt.Errorf("multiple category blocks with the same name") + return fmt.Errorf("multiple blocks category with the same name %s", category["name"].(string)) } categoryNameList = append(categoryNameList, category["name"].(string)) setPrefixCategory := setPrefix + "category \"" + category["name"].(string) + "\" " @@ -411,7 +411,8 @@ func setUtmProfileWebFEnhanced(d *schema.ResourceData, m interface{}, jnprSess * for _, r := range category["reputation_action"].([]interface{}) { reputation := r.(map[string]interface{}) if bchk.StringInSlice(reputation["site_reputation"].(string), reputationActionSiteList) { - return fmt.Errorf("multiple reputation_action blocks with the same site_reputation") + return fmt.Errorf("multiple blocks reputation_action with the same site_reputation %s", + reputation["site_reputation"].(string)) } reputationActionSiteList = append(reputationActionSiteList, reputation["site_reputation"].(string)) configSet = append(configSet, setPrefixCategory+"reputation-action "+ @@ -471,7 +472,8 @@ func setUtmProfileWebFEnhanced(d *schema.ResourceData, m interface{}, jnprSess * for _, v := range d.Get("site_reputation_action").([]interface{}) { siteReputation := v.(map[string]interface{}) if bchk.StringInSlice(siteReputation["site_reputation"].(string), siteReputationNameList) { - return fmt.Errorf("multiple site_reputation_action blocks with the same site_reputation") + return fmt.Errorf("multiple blocks site_reputation_action with the same site_reputation %s", + siteReputation["site_reputation"].(string)) } siteReputationNameList = append(siteReputationNameList, siteReputation["site_reputation"].(string)) configSet = append(configSet, setPrefix+"site-reputation-action "+ diff --git a/junos/resource_security_zone.go b/junos/resource_security_zone.go index a0dab7aa..8b68535f 100644 --- a/junos/resource_security_zone.go +++ b/junos/resource_security_zone.go @@ -442,7 +442,7 @@ func setSecurityZone(d *schema.ResourceData, m interface{}, jnprSess *NetconfObj for _, v := range d.Get("address_book").([]interface{}) { addressBook := v.(map[string]interface{}) if bchk.StringInSlice(addressBook["name"].(string), addressNameList) { - return fmt.Errorf("multiple address with the same name") + return fmt.Errorf("multiple addresses with the same name %s", addressBook["name"].(string)) } addressNameList = append(addressNameList, addressBook["name"].(string)) configSet = append(configSet, setPrefix+" address-book address "+ @@ -455,7 +455,7 @@ func setSecurityZone(d *schema.ResourceData, m interface{}, jnprSess *NetconfObj for _, v := range d.Get("address_book_dns").([]interface{}) { addressBook := v.(map[string]interface{}) if bchk.StringInSlice(addressBook["name"].(string), addressNameList) { - return fmt.Errorf("multiple address with the same name") + return fmt.Errorf("multiple addresses with the same name %s", addressBook["name"].(string)) } addressNameList = append(addressNameList, addressBook["name"].(string)) setLine := setPrefix + " address-book address " + addressBook["name"].(string) + @@ -475,7 +475,7 @@ func setSecurityZone(d *schema.ResourceData, m interface{}, jnprSess *NetconfObj for _, v := range d.Get("address_book_range").([]interface{}) { addressBook := v.(map[string]interface{}) if bchk.StringInSlice(addressBook["name"].(string), addressNameList) { - return fmt.Errorf("multiple address with the same name") + return fmt.Errorf("multiple addresses with the same name %s", addressBook["name"].(string)) } addressNameList = append(addressNameList, addressBook["name"].(string)) configSet = append(configSet, setPrefix+" address-book address "+ @@ -489,7 +489,7 @@ func setSecurityZone(d *schema.ResourceData, m interface{}, jnprSess *NetconfObj for _, v := range d.Get("address_book_wildcard").([]interface{}) { addressBook := v.(map[string]interface{}) if bchk.StringInSlice(addressBook["name"].(string), addressNameList) { - return fmt.Errorf("multiple address with the same name") + return fmt.Errorf("multiple addresses with the same name %s", addressBook["name"].(string)) } addressNameList = append(addressNameList, addressBook["name"].(string)) configSet = append(configSet, setPrefix+" address-book address "+ @@ -502,7 +502,7 @@ func setSecurityZone(d *schema.ResourceData, m interface{}, jnprSess *NetconfObj for _, v := range d.Get("address_book_set").([]interface{}) { addressBookSet := v.(map[string]interface{}) if bchk.StringInSlice(addressBookSet["name"].(string), addressNameList) { - return fmt.Errorf("multiple address or address-set with the same name") + return fmt.Errorf("multiple addresses or address-sets with the same name %s", addressBookSet["name"].(string)) } addressNameList = append(addressNameList, addressBookSet["name"].(string)) if len(addressBookSet["address"].(*schema.Set).List()) == 0 && diff --git a/junos/resource_services.go b/junos/resource_services.go index 056de69d..a23ee129 100644 --- a/junos/resource_services.go +++ b/junos/resource_services.go @@ -1011,7 +1011,8 @@ func setServicesSecurityIntell(d *schema.ResourceData, secuIntel interface{}) ([ for _, v := range secuIntelM["default_policy"].([]interface{}) { defPolicy := v.(map[string]interface{}) if bchk.StringInSlice(defPolicy["category_name"].(string), defaultPolicyCatNameList) { - return configSet, fmt.Errorf("multiple default_policy blocks with the same category_name") + return configSet, fmt.Errorf("multiple blocks default_policy with the same category_name %s", + defPolicy["category_name"].(string)) } defaultPolicyCatNameList = append(defaultPolicyCatNameList, defPolicy["category_name"].(string)) configSet = append(configSet, setPrefix+"default-policy "+ diff --git a/junos/resource_services_rpm_probe.go b/junos/resource_services_rpm_probe.go index 352d3abb..c709678d 100644 --- a/junos/resource_services_rpm_probe.go +++ b/junos/resource_services_rpm_probe.go @@ -516,7 +516,7 @@ func setServicesRpmProbe(d *schema.ResourceData, m interface{}, jnprSess *Netcon for _, t := range d.Get("test").([]interface{}) { test := t.(map[string]interface{}) if bchk.StringInSlice(test["name"].(string), testNameList) { - return fmt.Errorf("multiple test blocks with the same name") + return fmt.Errorf("multiple blocks test with the same name %s", test["name"].(string)) } testNameList = append(testNameList, test["name"].(string)) setPrefixTest := setPrefix + "test \"" + test["name"].(string) + "\" " diff --git a/junos/resource_services_security_intelligence_policy.go b/junos/resource_services_security_intelligence_policy.go index 989e5cf7..03a940c4 100644 --- a/junos/resource_services_security_intelligence_policy.go +++ b/junos/resource_services_security_intelligence_policy.go @@ -252,7 +252,7 @@ func setServicesSecurityIntellPolicy(d *schema.ResourceData, m interface{}, jnpr for _, v := range d.Get("category").([]interface{}) { category := v.(map[string]interface{}) if bchk.StringInSlice(category["name"].(string), categoryNameList) { - return fmt.Errorf("multiple category blocks with the same name") + return fmt.Errorf("multiple blocks category with the same name %s", category["name"].(string)) } categoryNameList = append(categoryNameList, category["name"].(string)) configSet = append(configSet, diff --git a/junos/resource_services_security_intelligence_profile.go b/junos/resource_services_security_intelligence_profile.go index 258e6297..8708e025 100644 --- a/junos/resource_services_security_intelligence_profile.go +++ b/junos/resource_services_security_intelligence_profile.go @@ -314,7 +314,7 @@ func setServicesSecurityIntellProfile(d *schema.ResourceData, m interface{}, jnp for _, v := range d.Get("rule").([]interface{}) { rule := v.(map[string]interface{}) if bchk.StringInSlice(rule["name"].(string), ruleNameList) { - return fmt.Errorf("multiple rule blocks with the same name") + return fmt.Errorf("multiple blocks rule with the same name %s", rule["name"].(string)) } ruleNameList = append(ruleNameList, rule["name"].(string)) setPrefixRule := setPrefix + "rule \"" + rule["name"].(string) + "\" " diff --git a/junos/resource_services_user_identification_ad_access_domain.go b/junos/resource_services_user_identification_ad_access_domain.go index b6867840..49f44ea2 100644 --- a/junos/resource_services_user_identification_ad_access_domain.go +++ b/junos/resource_services_user_identification_ad_access_domain.go @@ -329,7 +329,7 @@ func setServicesUserIdentAdAccessDomain(d *schema.ResourceData, m interface{}, j for _, v := range d.Get("domain_controller").([]interface{}) { domainController := v.(map[string]interface{}) if bchk.StringInSlice(domainController["name"].(string), domainControllerNameList) { - return fmt.Errorf("multiple domain_controller blocks with the same name") + return fmt.Errorf("multiple blocks domain_controller with the same name %s", domainController["name"].(string)) } domainControllerNameList = append(domainControllerNameList, domainController["name"].(string)) configSet = append(configSet, setPrefix+"domain-controller "+domainController["name"].(string)+ diff --git a/junos/resource_services_user_identification_device_identity_profile.go b/junos/resource_services_user_identification_device_identity_profile.go index d03e3901..d4b6db05 100644 --- a/junos/resource_services_user_identification_device_identity_profile.go +++ b/junos/resource_services_user_identification_device_identity_profile.go @@ -265,7 +265,7 @@ func setServicesUserIdentDeviceIdentityProfile(d *schema.ResourceData, m interfa for _, v := range d.Get("attribute").([]interface{}) { attribute := v.(map[string]interface{}) if bchk.StringInSlice(attribute["name"].(string), attributeNameList) { - return fmt.Errorf("multiple attribute blocks with the same name") + return fmt.Errorf("multiple blocks attribute with the same name %s", attribute["name"].(string)) } attributeNameList = append(attributeNameList, attribute["name"].(string)) for _, v2 := range sortSetOfString(attribute["value"].(*schema.Set).List()) { diff --git a/junos/resource_snmp_community.go b/junos/resource_snmp_community.go index 1865f9bd..4d1a7e75 100644 --- a/junos/resource_snmp_community.go +++ b/junos/resource_snmp_community.go @@ -292,7 +292,7 @@ func setSnmpCommunity(d *schema.ResourceData, m interface{}, jnprSess *NetconfOb routingInstance["name"].(string)) } if bchk.StringInSlice(routingInstance["name"].(string), routingInstanceNameList) { - return fmt.Errorf("multiple routing_instance blocks with the same name") + return fmt.Errorf("multiple blocks routing_instance with the same name %s", routingInstance["name"].(string)) } routingInstanceNameList = append(routingInstanceNameList, routingInstance["name"].(string)) configSet = append(configSet, setPrefix+"routing-instance "+routingInstance["name"].(string)) diff --git a/junos/resource_static_route.go b/junos/resource_static_route.go index 8d99f4f8..45b68a0e 100644 --- a/junos/resource_static_route.go +++ b/junos/resource_static_route.go @@ -507,7 +507,8 @@ func setStaticRoute(d *schema.ResourceData, m interface{}, jnprSess *NetconfObje for _, qualifiedNextHop := range d.Get("qualified_next_hop").([]interface{}) { qualifiedNextHopMap := qualifiedNextHop.(map[string]interface{}) if bchk.StringInSlice(qualifiedNextHopMap["next_hop"].(string), qualifiedNextHopList) { - return fmt.Errorf("multiple qualified_next_hop blocks with the same next_hop") + return fmt.Errorf("multiple blocks qualified_next_hop with the same next_hop %s", + qualifiedNextHopMap["next_hop"].(string)) } qualifiedNextHopList = append(qualifiedNextHopList, qualifiedNextHopMap["next_hop"].(string)) configSet = append(configSet, setPrefix+" qualified-next-hop "+qualifiedNextHopMap["next_hop"].(string)) diff --git a/junos/resource_system.go b/junos/resource_system.go index 4d87424f..60452da1 100644 --- a/junos/resource_system.go +++ b/junos/resource_system.go @@ -966,7 +966,7 @@ func setSystem(d *schema.ResourceData, m interface{}, jnprSess *NetconfObject) e for _, v2 := range archivalConfig["archive_site"].([]interface{}) { archiveSite := v2.(map[string]interface{}) if bchk.StringInSlice(archiveSite["url"].(string), archiveSiteURLList) { - return fmt.Errorf("multiple archive_site blocks with the same url") + return fmt.Errorf("multiple blocks archive_site with the same url %s", archiveSite["url"].(string)) } archiveSiteURLList = append(archiveSiteURLList, archiveSite["url"].(string)) configSet = append(configSet, setPrefix+"archival configuration archive-sites \""+archiveSite["url"].(string)+"\"") diff --git a/junos/resource_system_syslog_file.go b/junos/resource_system_syslog_file.go index 290420f8..9c21334f 100644 --- a/junos/resource_system_syslog_file.go +++ b/junos/resource_system_syslog_file.go @@ -494,7 +494,7 @@ func setSystemSyslogFile(d *schema.ResourceData, m interface{}, jnprSess *Netcon for _, v2 := range archive["sites"].([]interface{}) { sites := v2.(map[string]interface{}) if bchk.StringInSlice(sites["url"].(string), sitesURLList) { - return fmt.Errorf("multiple sites blocks with the same url") + return fmt.Errorf("multiple blocks sites with the same url %s", sites["url"].(string)) } sitesURLList = append(sitesURLList, sites["url"].(string)) setPrefixArchiveSite := setPrefixArchive + " archive-sites " + sites["url"].(string) From 19be65e00ed7e8dfff303103d78b99c58f2b60fa Mon Sep 17 00:00:00 2001 From: Jeremy Muriel Date: Thu, 21 Oct 2021 13:33:18 +0200 Subject: [PATCH 3/6] module go-netconf updated to enhance RPCError display with the `error-path` and `error-info>bad-element` values if set Fixes parts of #292 --- CHANGELOG.md | 1 + go.mod | 2 +- go.sum | 5 ++--- junos/netconf.go | 34 +++++++++++----------------------- 4 files changed, 15 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 708bb715..9eaa79a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ENHANCEMENTS: BUG FIXES: +* module go-netconf updated to enhance RPCError display with the `error-path` and `error-info>bad-element` values if set (Fixes parts of #292) * r/`*`: fix missing identifier value in the errors `multiple blocks with the same identifier` (Fixes parts of #292) ## 1.21.0 (October 12, 2021) diff --git a/go.mod b/go.mod index 7167f9ca..c3486e0d 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.16 require ( github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/terraform-plugin-sdk/v2 v2.8.0 - github.com/jeremmfr/go-netconf v0.3.2 + github.com/jeremmfr/go-netconf v0.4.0 github.com/jeremmfr/go-utils v0.3.0 github.com/jeremmfr/junosdecode v1.1.0 golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 diff --git a/go.sum b/go.sum index 44c7c86b..fe443bf8 100644 --- a/go.sum +++ b/go.sum @@ -203,8 +203,8 @@ github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/jeremmfr/go-netconf v0.3.2 h1:9U55VX6sYCfy8JgjUxjmesoaon4cWa/jVVxFzQnTmAA= -github.com/jeremmfr/go-netconf v0.3.2/go.mod h1:AHzLyFRHXf4z7N2KK5+UYjX1bljd23tfuNq+YYRr+nA= +github.com/jeremmfr/go-netconf v0.4.0 h1:MYrbA5keH7bsBpgcTA0MVvIg6oiA2bgdsJkdE2F3I7Y= +github.com/jeremmfr/go-netconf v0.4.0/go.mod h1:Nd1B4xd6miAKQzNxe0m3wddyLdAeKK+N04MOAiVhE0c= github.com/jeremmfr/go-utils v0.3.0 h1:f69G5Z6EnHO2bNEW+aeWB22P/4/plS1DZ2UZK7gd+WI= github.com/jeremmfr/go-utils v0.3.0/go.mod h1:K0lGadiSvg9OKGJnW4Bs3t18/VApp/6x2+BV93Sts2M= github.com/jeremmfr/junosdecode v1.1.0 h1:Os8QeOzyL+BPuDZJMjyJgz4QPOgA8EChgKB2Ih5wwCc= @@ -325,7 +325,6 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= diff --git a/junos/netconf.go b/junos/netconf.go index 466811bf..508fbbab 100644 --- a/junos/netconf.go +++ b/junos/netconf.go @@ -14,7 +14,7 @@ import ( ) const ( - warningSeverity string = "warning" + errorSeverity string = "error" rpcCommand = "%s" rpcConfigStringSet = "" + @@ -55,16 +55,9 @@ type netconfAuthMethod struct { Ciphers []string } -type commitError struct { - Path string `xml:"error-path"` - Element string `xml:"error-info>bad-element"` - Message string `xml:"error-message"` - Severity string `xml:"error-severity"` -} - type commitResults struct { - XMLName xml.Name `xml:"commit-results"` - Errors []commitError `xml:"rpc-error"` + XMLName xml.Name `xml:"commit-results"` + Errors []netconf.RPCError `xml:"rpc-error"` } // netconfNewSession establishes a new connection to a NetconfObject device that we will use @@ -193,7 +186,7 @@ func (j *NetconfObject) netconfCommand(cmd string) (string, error) { } if reply.Errors != nil { for _, m := range reply.Errors { - return "", errors.New(m.Message) + return "", errors.New(m.Error()) } } if reply.Data == "" || strings.Count(reply.Data, "") <= 2 { @@ -214,7 +207,7 @@ func (j *NetconfObject) netconfCommandXML(cmd string) (string, error) { } if reply.Errors != nil { for _, m := range reply.Errors { - return "", errors.New(m.Message) + return "", errors.New(m.Error()) } } @@ -298,10 +291,10 @@ func (j *NetconfObject) netconfCommit(logMessage string) (_warn []error, _err er if reply.Errors != nil { warnings := make([]error, 0) for _, m := range reply.Errors { - if m.Severity != warningSeverity { - return warnings, errors.New(m.Message) + if m.Severity == errorSeverity { + return warnings, errors.New(m.Error()) } - warnings = append(warnings, errors.New(m.Message)) + warnings = append(warnings, errors.New(m.Error())) } return warnings, nil @@ -317,15 +310,10 @@ func (j *NetconfObject) netconfCommit(logMessage string) (_warn []error, _err er if errs.Errors != nil { warnings := make([]error, 0) for _, m := range errs.Errors { - if m.Severity != warningSeverity { - message := fmt.Sprintf("[%s]\n %s\nError: %s", - strings.Trim(m.Path, "[\r\n]"), - strings.Trim(m.Element, "[\r\n]"), - strings.Trim(m.Message, "[\r\n]")) - - return []error{}, errors.New(message) + if m.Severity == errorSeverity { + return []error{}, errors.New(m.Error()) } - warnings = append(warnings, errors.New(m.Message)) + warnings = append(warnings, errors.New(m.Error())) } return warnings, nil From 4a8f777d4fa7852bcc791d2177ca20ecbdc64df1 Mon Sep 17 00:00:00 2001 From: Jeremy Muriel Date: Fri, 22 Oct 2021 08:54:29 +0200 Subject: [PATCH 4/6] add dependabot.yml --- .github/dependabot.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..acdeb539 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + commit-message: + prefix: "workflows:" + schedule: + interval: daily + assignees: + - "jeremmfr" + reviewers: + - "jeremmfr" From 66daa5a71481764d084b050b6d92e5c0de4cb6c0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Oct 2021 06:57:54 +0000 Subject: [PATCH 5/6] workflows: bump actions/setup-go from 1 to 2.1.4 Bumps [actions/setup-go](https://github.com/actions/setup-go) from 1 to 2.1.4. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/v1...v2.1.4) --- updated-dependencies: - dependency-name: actions/setup-go dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/go.yml | 6 +++--- .github/workflows/linters.yml | 4 ++-- .github/workflows/releases.yml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 6dba4a46..a2287590 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -6,7 +6,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Go 1.16 - uses: actions/setup-go@v1 + uses: actions/setup-go@v2.1.4 with: go-version: 1.16 id: go @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Go 1.17 - uses: actions/setup-go@v1 + uses: actions/setup-go@v2.1.4 with: go-version: 1.17 id: go @@ -38,7 +38,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Go 1.17 - uses: actions/setup-go@v1 + uses: actions/setup-go@v2.1.4 with: go-version: 1.17 id: go diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index 19b212aa..ff12572b 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -30,7 +30,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Go 1.17 - uses: actions/setup-go@v2 + uses: actions/setup-go@v2.1.4 with: go-version: 1.17 id: go @@ -64,7 +64,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Go 1.17 - uses: actions/setup-go@v2 + uses: actions/setup-go@v2.1.4 with: go-version: 1.17 id: go diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index b6dbb1ab..1aa1c63c 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -41,7 +41,7 @@ jobs: goarch: arm64 steps: - name: Set up Go 1.17 - uses: actions/setup-go@v1 + uses: actions/setup-go@v2.1.4 with: go-version: 1.17 id: go From a2fdfee20398d4c47e455a080922cecccad74b63 Mon Sep 17 00:00:00 2001 From: Jeremy Muriel Date: Fri, 22 Oct 2021 19:09:49 +0200 Subject: [PATCH 6/6] Release v1.21.1 --- CHANGELOG.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9eaa79a0..113a7256 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,12 @@ ENHANCEMENTS: BUG FIXES: -* module go-netconf updated to enhance RPCError display with the `error-path` and `error-info>bad-element` values if set (Fixes parts of #292) -* r/`*`: fix missing identifier value in the errors `multiple blocks with the same identifier` (Fixes parts of #292) +## 1.21.1 (October 22, 2021) + +BUG FIXES: + +* module go-netconf updated to enhance RPCError display with the `error-path` and `error-info>bad-element` values if set (Fixes parts of [#292](https://github.com/jeremmfr/terraform-provider-junos/issues/292)) +* r/`*`: fix missing identifier value in the errors `multiple blocks with the same identifier` (Fixes parts of [#292](https://github.com/jeremmfr/terraform-provider-junos/issues/292)) ## 1.21.0 (October 12, 2021)