Skip to content

Commit d70bb7e

Browse files
committed
init/updateFortiOSTerraform: 1.17.0
Signed-off-by: -HQCM <hq-devops-admin@fortinet.com>
1 parent 0f3f2ca commit d70bb7e

2,858 files changed

Lines changed: 29290 additions & 564692 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.goreleaser.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ before:
44
hooks:
55
# this is just an example and not a requirement for provider building/publishing
66
- go mod tidy
7+
project_name: terraform-provider-fortios
78
builds:
89
- env:
910
# goreleaser does not work with CGO, it could also complicate

CHANGELOG.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,42 @@
1-
## 1.17.0 (Unreleased)
1+
## 1.18.0 (Unreleased)
22

33

4+
## 1.17.0 (Jun 22, 2023)
5+
BUG FIXES:
6+
7+
* Fix issue of can't update admin user (#248);
8+
* Fix issue of no option to not use HTTP proxy (#253);
9+
* Fix crash issue with insufficient permissions (#257);
10+
* Fix type change issue (#258)
11+
* Fix issue of configuration been destroyed after second apply (#265);
12+
* Fix range issue (#284)
13+
* Remove extra quotes in the conversion of argument from block to string;
14+
* Fix duplicate argument issue;
15+
16+
IMPROVEMENTS:
17+
18+
* Support FortiOS v6.4.11, v6.4.12, v7.0.7, v7.0.8, v7.0.9, v7.0.10, v7.0.11, v7.2.3, v7.2.4, v7.4.0;
19+
* Update mergeable arguments with type changes;
20+
* Update version check function;
21+
* Add variable get_all_tables to determine whether get all table or complex items when refresh the state file;
22+
* Support username/password login;
23+
24+
FEATURES:
25+
26+
* **New Resource:** `fortios_antivirus_exemptlist`
27+
* **New Resource:** `fortios_endpointcontrol_fctemsoverride`
28+
* **New Resource:** `fortios_firewall_internetservicesubapp`
29+
* **New Resource:** `fortios_router_extcommunitylist`
30+
* **New Resource:** `fortios_switchcontrolleracl_ingress`
31+
* **New Resource:** `fortios_switchcontrolleracl_group`
32+
* **New Resource:** `fortios_system_deviceupgrade`
33+
* **New Resource:** `fortios_system_evpn`
34+
* **New Resource:** `fortios_system_fabricvpn`
35+
* **New Resource:** `fortios_system_pcpserver`
36+
* **New Resource:** `fortios_system_sdnproxy`
37+
* **New Resource:** `fortios_system_ssofortigatecloudadmin`
38+
* **New Resource:** `fortios_vpn_kmipserver`
39+
440
## 1.16.0 (Oct 7, 2022)
541
BUG FIXES:
642

fortios/client.go

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ import (
1111
"time"
1212

1313
fmgclient "github.com/fortinetdev/forti-sdk-go/fortimanager/sdkcore"
14-
"github.com/fortinetdev/forti-sdk-go/fortios/auth"
15-
forticlient "github.com/fortinetdev/forti-sdk-go/fortios/sdkcore"
14+
"github.com/terraform-providers/terraform-provider-fortios/sdk/auth"
15+
forticlient "github.com/terraform-providers/terraform-provider-fortios/sdk/sdkcore"
1616
)
1717

1818
// Config gets the authentication information from the given metadata
1919
type Config struct {
2020
Hostname string
2121
Token string
22+
Username string
23+
Password string
2224
Insecure *bool
2325
CABundle string
2426
CABundleContent string
@@ -102,7 +104,7 @@ func bFortiManagerHostnameExist(c *Config) bool {
102104
func createFortiOSClient(fClient *FortiClient, c *Config) error {
103105
config := &tls.Config{}
104106

105-
auth := auth.NewAuth(c.Hostname, c.Token, c.CABundle, c.CABundleContent, c.PeerAuth, c.CaCert, c.ClientCert, c.ClientKey, c.Vdom, c.HTTPProxy)
107+
auth := auth.NewAuth(c.Hostname, c.Token, c.Username, c.Password, c.CABundle, c.CABundleContent, c.PeerAuth, c.CaCert, c.ClientCert, c.ClientKey, c.Vdom, c.HTTPProxy)
106108

107109
if auth.Hostname == "" {
108110
_, err := auth.GetEnvHostname()
@@ -118,6 +120,26 @@ func createFortiOSClient(fClient *FortiClient, c *Config) error {
118120
}
119121
}
120122

123+
if auth.Username == "" {
124+
_, err := auth.GetEnvUsername()
125+
if err != nil {
126+
return fmt.Errorf("Error reading Username")
127+
}
128+
}
129+
130+
if auth.Password == "" {
131+
_, err := auth.GetEnvPassword()
132+
if err != nil {
133+
return fmt.Errorf("Error reading Password")
134+
}
135+
}
136+
137+
if auth.Token == "" {
138+
if auth.Username == "" || auth.Password == "" {
139+
return fmt.Errorf("Please provider a valid API Token or Username and Password.")
140+
}
141+
}
142+
121143
if auth.CABundle == "" {
122144
auth.GetEnvCABundle()
123145
}
@@ -146,7 +168,7 @@ func createFortiOSClient(fClient *FortiClient, c *Config) error {
146168
return fmt.Errorf("Error reading ClientKey")
147169
}
148170
}
149-
if auth.HTTPProxy == "" {
171+
if auth.HTTPProxy == "ENV" {
150172
_, err := auth.GetEnvHTTPProxy()
151173
if err != nil {
152174
return fmt.Errorf("Error reading HTTP proxy")
@@ -245,6 +267,16 @@ func createFortiOSClient(fClient *FortiClient, c *Config) error {
245267
return fmt.Errorf("connection error: %v", err)
246268
}
247269

270+
err = fc.CheckUP()
271+
if err != nil {
272+
return err
273+
}
274+
275+
err = fc.UpdateDeviceVersion()
276+
if err != nil {
277+
return fmt.Errorf("Can not update device version: %v", err)
278+
}
279+
248280
fClient.Client = fc
249281

250282
return nil

fortios/config.go

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,21 +179,36 @@ func convintflist2str(v interface{}) interface{} {
179179
return res
180180
}
181181

182-
func i2ss2arrFortiAPIUpgrade(v string, splitv string) bool {
183-
splitv = strings.ReplaceAll(splitv, "v", "")
184-
182+
func i2ss2arrFortiAPIUpgrade(v string, new_version_map map[string][]string) bool {
185183
v1, err := version.NewVersion(v)
186184
if err != nil {
187185
return false
188186
}
189187

190-
v2, err := version.NewVersion(splitv)
191-
if err != nil {
192-
return false
193-
}
194-
195-
if v1.GreaterThanOrEqual(v2) {
196-
return true
188+
for operator, version_list := range new_version_map {
189+
if operator == "=" {
190+
for _, cur_version := range version_list {
191+
if cur_version == v {
192+
return true
193+
}
194+
}
195+
} else if operator == ">=" {
196+
min_version, err := version.NewVersion(version_list[0])
197+
if err != nil {
198+
continue
199+
}
200+
if v1.GreaterThanOrEqual(min_version) {
201+
return true
202+
}
203+
} else if operator == "<=" {
204+
max_version, err := version.NewVersion(version_list[0])
205+
if err != nil {
206+
continue
207+
}
208+
if v1.LessThanOrEqual(max_version) {
209+
return true
210+
}
211+
}
197212
}
198213

199214
return false

fortios/data_source_firewall_address.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ func dataSourceFirewallAddress() *schema.Resource {
4444
Type: schema.TypeString,
4545
Computed: true,
4646
},
47+
"route_tag": &schema.Schema{
48+
Type: schema.TypeInt,
49+
Computed: true,
50+
},
4751
"sub_type": &schema.Schema{
4852
Type: schema.TypeString,
4953
Computed: true,
@@ -160,6 +164,22 @@ func dataSourceFirewallAddress() *schema.Resource {
160164
Type: schema.TypeString,
161165
Computed: true,
162166
},
167+
"hw_vendor": &schema.Schema{
168+
Type: schema.TypeString,
169+
Computed: true,
170+
},
171+
"hw_model": &schema.Schema{
172+
Type: schema.TypeString,
173+
Computed: true,
174+
},
175+
"os": &schema.Schema{
176+
Type: schema.TypeString,
177+
Computed: true,
178+
},
179+
"sw_version": &schema.Schema{
180+
Type: schema.TypeString,
181+
Computed: true,
182+
},
163183
"comment": &schema.Schema{
164184
Type: schema.TypeString,
165185
Computed: true,
@@ -310,6 +330,10 @@ func dataSourceFlattenFirewallAddressType(v interface{}, d *schema.ResourceData,
310330
return v
311331
}
312332

333+
func dataSourceFlattenFirewallAddressRouteTag(v interface{}, d *schema.ResourceData, pre string) interface{} {
334+
return v
335+
}
336+
313337
func dataSourceFlattenFirewallAddressSubType(v interface{}, d *schema.ResourceData, pre string) interface{} {
314338
return v
315339
}
@@ -481,6 +505,22 @@ func dataSourceFlattenFirewallAddressTagType(v interface{}, d *schema.ResourceDa
481505
return v
482506
}
483507

508+
func dataSourceFlattenFirewallAddressHwVendor(v interface{}, d *schema.ResourceData, pre string) interface{} {
509+
return v
510+
}
511+
512+
func dataSourceFlattenFirewallAddressHwModel(v interface{}, d *schema.ResourceData, pre string) interface{} {
513+
return v
514+
}
515+
516+
func dataSourceFlattenFirewallAddressOs(v interface{}, d *schema.ResourceData, pre string) interface{} {
517+
return v
518+
}
519+
520+
func dataSourceFlattenFirewallAddressSwVersion(v interface{}, d *schema.ResourceData, pre string) interface{} {
521+
return v
522+
}
523+
484524
func dataSourceFlattenFirewallAddressComment(v interface{}, d *schema.ResourceData, pre string) interface{} {
485525
return v
486526
}
@@ -670,6 +710,12 @@ func dataSourceRefreshObjectFirewallAddress(d *schema.ResourceData, o map[string
670710
}
671711
}
672712

713+
if err = d.Set("route_tag", dataSourceFlattenFirewallAddressRouteTag(o["route-tag"], d, "route_tag")); err != nil {
714+
if !fortiAPIPatch(o["route-tag"]) {
715+
return fmt.Errorf("Error reading route_tag: %v", err)
716+
}
717+
}
718+
673719
if err = d.Set("sub_type", dataSourceFlattenFirewallAddressSubType(o["sub-type"], d, "sub_type")); err != nil {
674720
if !fortiAPIPatch(o["sub-type"]) {
675721
return fmt.Errorf("Error reading sub_type: %v", err)
@@ -820,6 +866,30 @@ func dataSourceRefreshObjectFirewallAddress(d *schema.ResourceData, o map[string
820866
}
821867
}
822868

869+
if err = d.Set("hw_vendor", dataSourceFlattenFirewallAddressHwVendor(o["hw-vendor"], d, "hw_vendor")); err != nil {
870+
if !fortiAPIPatch(o["hw-vendor"]) {
871+
return fmt.Errorf("Error reading hw_vendor: %v", err)
872+
}
873+
}
874+
875+
if err = d.Set("hw_model", dataSourceFlattenFirewallAddressHwModel(o["hw-model"], d, "hw_model")); err != nil {
876+
if !fortiAPIPatch(o["hw-model"]) {
877+
return fmt.Errorf("Error reading hw_model: %v", err)
878+
}
879+
}
880+
881+
if err = d.Set("os", dataSourceFlattenFirewallAddressOs(o["os"], d, "os")); err != nil {
882+
if !fortiAPIPatch(o["os"]) {
883+
return fmt.Errorf("Error reading os: %v", err)
884+
}
885+
}
886+
887+
if err = d.Set("sw_version", dataSourceFlattenFirewallAddressSwVersion(o["sw-version"], d, "sw_version")); err != nil {
888+
if !fortiAPIPatch(o["sw-version"]) {
889+
return fmt.Errorf("Error reading sw_version: %v", err)
890+
}
891+
}
892+
823893
if err = d.Set("comment", dataSourceFlattenFirewallAddressComment(o["comment"], d, "comment")); err != nil {
824894
if !fortiAPIPatch(o["comment"]) {
825895
return fmt.Errorf("Error reading comment: %v", err)

fortios/data_source_firewall_address6.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ func dataSourceFirewallAddress6() *schema.Resource {
4040
Type: schema.TypeString,
4141
Computed: true,
4242
},
43+
"route_tag": &schema.Schema{
44+
Type: schema.TypeInt,
45+
Computed: true,
46+
},
4347
"macaddr": &schema.Schema{
4448
Type: schema.TypeList,
4549
Computed: true,
@@ -251,6 +255,10 @@ func dataSourceFlattenFirewallAddress6Type(v interface{}, d *schema.ResourceData
251255
return v
252256
}
253257

258+
func dataSourceFlattenFirewallAddress6RouteTag(v interface{}, d *schema.ResourceData, pre string) interface{} {
259+
return v
260+
}
261+
254262
func dataSourceFlattenFirewallAddress6Macaddr(v interface{}, d *schema.ResourceData, pre string) []map[string]interface{} {
255263
if v == nil {
256264
return nil
@@ -564,6 +572,12 @@ func dataSourceRefreshObjectFirewallAddress6(d *schema.ResourceData, o map[strin
564572
}
565573
}
566574

575+
if err = d.Set("route_tag", dataSourceFlattenFirewallAddress6RouteTag(o["route-tag"], d, "route_tag")); err != nil {
576+
if !fortiAPIPatch(o["route-tag"]) {
577+
return fmt.Errorf("Error reading route_tag: %v", err)
578+
}
579+
}
580+
567581
if err = d.Set("macaddr", dataSourceFlattenFirewallAddress6Macaddr(o["macaddr"], d, "macaddr")); err != nil {
568582
if !fortiAPIPatch(o["macaddr"]) {
569583
return fmt.Errorf("Error reading macaddr: %v", err)

0 commit comments

Comments
 (0)