Skip to content

Commit

Permalink
Merge pull request #276 from jeremmfr/main
Browse files Browse the repository at this point in the history
Release v1.20.0
  • Loading branch information
jeremmfr authored Sep 7, 2021
2 parents fa7bda6 + ec053aa commit d2b0c79
Show file tree
Hide file tree
Showing 167 changed files with 8,715 additions and 3,070 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
fi
- name: Check if too many level in list of arguments for resource or data_source
run: |
if [[ $(grep -r "^ \{3,\}\(\*\|-\)" website/docs/* | wc -l) -gt 0 ]] ; then \
if [[ $(grep -r "^ \{3,\}\(\*\|-\) " website/docs/* | wc -l) -gt 0 ]] ; then \
echo "Too many level of arugments in docs" ; grep -nr "^ \{3,\}\(\*\|-\)" website/docs/* ; exit 1 ; \
fi
- name: Check link for pages in sidebar
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.41
version: v1.42
args: -c .golangci.yml -v

markdown-lint:
Expand Down
13 changes: 9 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ run:
linters:
enable-all: true
disable:
- maligned # deprecated 1.38
# maligned # deprecated 1.38 but govet-fieldalignment not usuable
- interfacer # deprecated 1.38
- scopelint # deprecated 1.39
- golint # deprecated 1.41
Expand All @@ -19,12 +19,17 @@ linters:
- cyclop
- forcetypeassert
linters-settings:
gocyclo:
# minimal code complexity to report, 30 by default
min-complexity: 90
gocognit:
# minimal code complexity to report, 30 by default
min-complexity: 180
gocyclo:
# minimal code complexity to report, 30 by default
min-complexity: 90
govet:
enable-all: true
disable:
- fieldalignment
- shadow
issues:
exclude-rules:
- text: "Use of ssh InsecureIgnoreHostKey"
Expand Down
4 changes: 3 additions & 1 deletion .markdownlint.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
MD013: false
MD013:
code_blocks: false
line_length: 100
MD014: false
41 changes: 40 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,49 @@
<!-- markdownlint-disable-file MD041 -->
<!-- markdownlint-disable-file MD013 MD041 -->
## upcoming release

ENHANCEMENTS:

BUG FIXES:

## 1.20.0 (September 07, 2021)

FEATURES:

* add `junos_eventoptions_generate_event` resource (Fixes [#267](https://github.com/jeremmfr/terraform-provider-junos/issues/267))
* add `junos_security_dynamic_address_feed_server` resource (Fixes parts of [#273](https://github.com/jeremmfr/terraform-provider-junos/issues/273))
* add `junos_security_dynamic_address_name` resource (Fixes parts of [#273](https://github.com/jeremmfr/terraform-provider-junos/issues/273))

ENHANCEMENTS:

* resource/`junos_chassis_cluster`: add `preempt_delay`, `preempt_limit` and `preempt_period` arguments inside `redundancy_group` block list argument (Fixes [#270](https://github.com/jeremmfr/terraform-provider-junos/issues/270))
* resource/`junos_firewall_filter`: arguments with type list of string in block `term.*.from` are now unordered
* resource/`junos_interface_logical`: add `dad_disable` argument inside `family_inet6` block argument (Fixes [#263](https://github.com/jeremmfr/terraform-provider-junos/issues/263))
* data-source/`junos_interface`, `junos_interface_logical`: `vrrp_group.*.authentication_key` is now a sensitive argument (like resource)
* data-source/`junos_interface_logical`: add `dad_disable` attributes as for the resource
* resource/`junos_interface_logical`: lists of string for `security_inbound_protocols` and `security_inbound_services` are now unordered
* resource/`junos_policyoptions_policy_statement`: arguments with type list of string (except `policy`) in block `term.*.from` and `term.*.to` are now unordered
* resource/`junos_security`: list of string for `ike_traceoptions.0.flag` is now unordered
* resource/`junos_security`: add validation on `name` argument inside `file` block inside `ike_traceoptions` block
* resource/`junos_security_global_policy`: arguments with type list of string in block `policy` are now unordered
* resource/`junos_security_nat_source`: arguments with type list of string in block `rule.*.match` are now unordered
* resource/`junos_security_policy`: arguments with type list of string in block `policy` are now unordered
* resource/`junos_security_screen`: lists of string for `tcp.0.syn_flood.0.whitelist.*.destination_address`, `tcp.0.syn_flood.0.whitelist.*.source_address` and `udp.0.flood.0.whitelist` are now unordered
* resource/`junos_security_screen_whitelist`: list of string for `address` is now unordered
* resource/`junos_security_zone`: lists of string for `inbound_protocols` and `inbound_services` are now unordered
* resource/`junos_system`: arguments with type list of string are now unordered (except `authentication_order`, `name_server` and `ssh.0.authentication_order`)
* resource/`junos_system`: add `ntp` block argument (Fixes [#261](https://github.com/jeremmfr/terraform-provider-junos/issues/261))
* resource/`junos_system`: add `netconf_traceoptions` block argument inside `services` block argument (Fixes [#262](https://github.com/jeremmfr/terraform-provider-junos/issues/262))
* resource/`*`: sets of string are now ordered before adding to Junos config to avoid unnecessary diff in commits
* docs: rewrite style for argument name and type
* docs: add attributes reference on resource

BUG FIXES:

* resource/`junos_security`: fix reading `size` argument inside `file` block inside `ike_traceoptions` block when number match a multiple of 1024 (example 1k, 1m, 1g)
* resource/`junos_security`: fix string format for `idp_security_package.0.automatic_start_time` to `YYYY-MM-DD.HH:MM:SS` to avoid unnecessary diff for Terraform when timezone of Junos device change
* resource/`junos_chassis_cluster`: fix possible crash in certain conditions when import this resource
* resource/`*`: add validation to some arguments which cannot contain a space character and thus avoid bugs when reading these arguments

## 1.19.0 (July 30, 2021)

FEATURES:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- markdownlint-disable-file MD033 MD041 -->
<!-- markdownlint-disable-file MD013 MD033 MD041 -->
<div>
<img src="https://www.juniper.net/assets/img/products/junos-os.png" alt="Junos logo" title="Junos" align="right" height="50" />
<img src="https://cdn.rawgit.com/hashicorp/terraform-website/master/content/source/assets/images/og-image.png" alt="Terraform logo" title="Terraform" align="right" height="50" />
<a href="https://www.juniper.net"><img src="https://www.juniper.net/assets/img/products/junos-os.png" alt="Junos logo" title="Junos" align="right" height="50" /></a>
<a href="https://www.terraform.io"><img src="https://cdn.rawgit.com/hashicorp/terraform-website/master/content/source/assets/images/product-icons/terraform-icon-color.svg" alt="Terraform logo" title="Terraform" align="right" height="50" /></a>
</div>

# terraform-provider-junos
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.15

require (
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-sdk/v2 v2.7.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.7.1
github.com/jeremmfr/go-netconf v0.3.2
github.com/jeremmfr/junosdecode v1.0.0
github.com/jeremmfr/junosdecode v1.1.0
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97
)
10 changes: 4 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
Expand Down Expand Up @@ -199,8 +198,8 @@ github.com/hashicorp/terraform-json v0.12.0 h1:8czPgEEWWPROStjkWPUnTQDXmpmZPlkQA
github.com/hashicorp/terraform-json v0.12.0/go.mod h1:pmbq9o4EuL43db5+0ogX10Yofv1nozM+wskr/bGFJpI=
github.com/hashicorp/terraform-plugin-go v0.3.0 h1:AJqYzP52JFYl9NABRI7smXI1pNjgR5Q/y2WyVJ/BOZA=
github.com/hashicorp/terraform-plugin-go v0.3.0/go.mod h1:dFHsQMaTLpON2gWhVWT96fvtlc/MF1vSy3OdMhWBzdM=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.7.0 h1:SuI59MqNjYDrL7EfqHX9V6P/24isgqYx/FdglwVs9bg=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.7.0/go.mod h1:grseeRo9g3yNkYW09iFlV8LG78jTa1ssBgouogQg/RU=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.7.1 h1:vpzKKP2dIFb9n89AG8Wxl758/5JSZWZH0OuKdlq0M38=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.7.1/go.mod h1:o3pdss6ynDZW9FfiZ+rETUH5LEVufrXdhwLU+5OiRo0=
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
Expand All @@ -213,8 +212,8 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOl
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/junosdecode v1.0.0 h1:fk6YD/FM4yk+dcATCswulteHRf2S+PQkznj3YxoAvgI=
github.com/jeremmfr/junosdecode v1.0.0/go.mod h1:kGZxoTprXFZZ+xKMY5d4KB1UN0w3M3DScaN6ELs31Go=
github.com/jeremmfr/junosdecode v1.1.0 h1:Os8QeOzyL+BPuDZJMjyJgz4QPOgA8EChgKB2Ih5wwCc=
github.com/jeremmfr/junosdecode v1.1.0/go.mod h1:nTY0XbZC2ePbZdV0wuUboSMtGrJxtpwWVYfHjrS2Oqw=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE=
github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74=
Expand Down Expand Up @@ -275,7 +274,6 @@ github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k
github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce/go.mod h1:uFMI8w+ref4v2r9jz+c9i1IfIttS/OkmLfrk1jne5hs=
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down
5 changes: 3 additions & 2 deletions junos/data_source_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ func dataSourceInterface() *schema.Resource {
Computed: true,
},
"authentication_key": {
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Computed: true,
Sensitive: true,
},
"authentication_type": {
Type: schema.TypeString,
Expand Down
13 changes: 9 additions & 4 deletions junos/data_source_interface_logical.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ func dataSourceInterfaceLogical() *schema.Resource {
Computed: true,
},
"authentication_key": {
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Computed: true,
Sensitive: true,
},
"authentication_type": {
Type: schema.TypeString,
Expand Down Expand Up @@ -298,6 +299,10 @@ func dataSourceInterfaceLogical() *schema.Resource {
},
},
},
"dad_disable": {
Type: schema.TypeBool,
Optional: true,
},
"filter_input": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -342,12 +347,12 @@ func dataSourceInterfaceLogical() *schema.Resource {
Computed: true,
},
"security_inbound_protocols": {
Type: schema.TypeList,
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"security_inbound_services": {
Type: schema.TypeList,
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
Expand Down
5 changes: 5 additions & 0 deletions junos/data_source_interface_logical_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ resource junos_interface_logical testacc_datainterfaceL {
cidr_ip = "192.0.2.1/25"
}
}
family_inet6 {
address {
cidr_ip = "2001:db8::1/64"
}
}
}
`
}
Expand Down
13 changes: 12 additions & 1 deletion junos/func_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net"
"os"
"sort"
"strconv"
"strings"

Expand Down Expand Up @@ -234,7 +235,7 @@ func validateFilePermission() schema.SchemaValidateDiagFunc {

fileMode, err := strconv.ParseInt(v, 8, 64)

if err != nil || fileMode > 0777 || fileMode < 0 {
if err != nil || fileMode > 0o777 || fileMode < 0 {
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: fmt.Sprintf("bad mode for file - must be three octal digits: %s", v),
Expand All @@ -256,6 +257,16 @@ func stringInSlice(str string, list []string) bool {
return false
}

func sortSetOfString(list []interface{}) []string {
s := make([]string, 0)
for _, e := range list {
s = append(s, e.(string))
}
sort.Strings(s)

return s
}

func copyAndRemoveItemMapList(identifier string,
m map[string]interface{}, list []map[string]interface{}) []map[string]interface{} {
if m[identifier] == nil {
Expand Down
3 changes: 3 additions & 0 deletions junos/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func Provider() *schema.Provider {
"junos_bridge_domain": resourceBridgeDomain(),
"junos_chassis_cluster": resourceChassisCluster(),
"junos_eventoptions_destination": resourceEventoptionsDestination(),
"junos_eventoptions_generate_event": resourceEventoptionsGenerateEvent(),
"junos_eventoptions_policy": resourceEventoptionsPolicy(),
"junos_evpn": resourceEvpn(),
"junos_firewall_filter": resourceFirewallFilter(),
Expand All @@ -125,6 +126,8 @@ func Provider() *schema.Provider {
"junos_routing_options": resourceRoutingOptions(),
"junos_security": resourceSecurity(),
"junos_security_address_book": resourceSecurityAddressBook(),
"junos_security_dynamic_address_feed_server": resourceSecurityDynamicAddressFeedServer(),
"junos_security_dynamic_address_name": resourceSecurityDynamicAddressName(),
"junos_security_global_policy": resourceSecurityGlobalPolicy(),
"junos_security_idp_custom_attack": resourceSecurityIdpCustomAttack(),
"junos_security_idp_custom_attack_group": resourceSecurityIdpCustomAttackGroup(),
Expand Down
6 changes: 6 additions & 0 deletions junos/resource_bgp_neighbor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,9 @@ resource junos_bgp_neighbor "testacc_bgpneighbor2" {
metric_out_minimum_igp_offset = -10
}
resource junos_bgp_group "testacc_bgpneighbor2b" {
depends_on = [
junos_routing_options.testacc_bgpneighbor
]
name = "testacc_bgpneighbor2b"
type = "internal"
}
Expand Down Expand Up @@ -435,6 +438,9 @@ resource junos_bgp_neighbor "testacc_bgpneighbor2" {
metric_out_minimum_igp = true
}
resource junos_bgp_group "testacc_bgpneighbor2b" {
depends_on = [
junos_routing_options.testacc_bgpneighbor
]
name = "testacc_bgpneighbor2b"
type = "internal"
}
Expand Down
8 changes: 4 additions & 4 deletions junos/resource_bridge_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,8 @@ func setBridgeDomain(d *schema.ResourceData, m interface{}, jnprSess *NetconfObj
setPrefix = "set routing-instances " + d.Get("routing_instance").(string) +
" bridge-domains \"" + d.Get("name").(string) + "\" "
}
for _, v := range d.Get("community_vlans").(*schema.Set).List() {
configSet = append(configSet, setPrefix+"community-vlans "+v.(string))
for _, v := range sortSetOfString(d.Get("community_vlans").(*schema.Set).List()) {
configSet = append(configSet, setPrefix+"community-vlans "+v)
}
if v := d.Get("description").(string); v != "" {
configSet = append(configSet, setPrefix+"description \""+v+"\"")
Expand All @@ -412,8 +412,8 @@ func setBridgeDomain(d *schema.ResourceData, m interface{}, jnprSess *NetconfObj
if v := d.Get("vlan_id").(int); v != 0 {
configSet = append(configSet, setPrefix+"vlan-id "+strconv.Itoa(v))
}
for _, v := range d.Get("vlan_id_list").(*schema.Set).List() {
configSet = append(configSet, setPrefix+"vlan-id-list "+v.(string))
for _, v := range sortSetOfString(d.Get("vlan_id_list").(*schema.Set).List()) {
configSet = append(configSet, setPrefix+"vlan-id-list "+v)
}
for _, v := range d.Get("vxlan").([]interface{}) {
vxlan := v.(map[string]interface{})
Expand Down
Loading

0 comments on commit d2b0c79

Please sign in to comment.