Skip to content

Commit 0940348

Browse files
Merge pull request #102 from avinetworks/AV-112569
AV-112569 Update 18.2.13 for terraform registry and new terraform plugin
2 parents fab174d + 899f5e0 commit 0940348

File tree

3,740 files changed

+19093
-779035
lines changed

Some content is hidden

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

3,740 files changed

+19093
-779035
lines changed

Diff for: .golangci.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
issues:
22
max-per-linter: 0
33
max-same-issues: 0
4+
exclude:
5+
- SA1019
46

57
run:
68
deadline: 5m
9+
skip-files:
10+
- avi/resource_avi_rest_dependants.go
711

812
linters:
913
disable-all: true
1014
enable:
1115
- deadcode
1216
- errcheck
13-
# - gofmt
17+
- gofmt
1418
- goimports
1519
- golint
1620
- gosimple
@@ -30,4 +34,4 @@ linters:
3034

3135
linters-settings:
3236
errcheck:
33-
ignore: github.com/hashicorp/terraform-plugin-sdk/helper/schema:ForceNew|Set,fmt:.*,io:Close
37+
ignore: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema:ForceNew|Set,fmt:.*,io:Close

Diff for: .travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ install:
1616
# packages that live there.
1717
# See: https://github.com/golang/go/issues/12933
1818
- bash scripts/gogetcookie.sh
19-
- go get github.com/hashicorp/terraform@v0.12.24
19+
- go get github.com/hashicorp/terraform-plugin-sdk/v2
2020
- go get github.com/kardianos/govendor
2121
- go get github.com/avinetworks/sdk/go/clients
2222
- go get github.com/avinetworks/sdk/go/session

Diff for: GNUmakefile

+9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
TEST?=$$(go list ./... | grep -v 'vendor')
22
GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
3+
AVI_PROVIDER_NAMESPACE=vmware.com/avi/avi
34

45
default: build
56

67
build: fmtcheck
78
go install
89

10+
build13: GOOS=$(shell go env GOOS)
11+
build13: GOARCH=$(shell go env GOARCH)
12+
build13: DESTINATION=$(HOME)/.terraform.d/plugins/$(AVI_PROVIDER_NAMESPACE)/18.2.13/$(GOOS)_$(GOARCH)
13+
build13: fmtcheck
14+
@echo "==> Installing plugin to $(DESTINATION)"
15+
@mkdir -p $(DESTINATION)
16+
go build -o $(DESTINATION)/terraform-provider-avi_v18.2.13
17+
918
test: fmtcheck
1019
go test -i $(TEST) || exit 1
1120
echo $(TEST) | \

Diff for: README.md

+115-58
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,59 @@
11
Terraform Provider
22
==================
3-
- [![Build Status](https://travis-ci.org/vmware/terraform-provider-avi.svg?branch=master)](https://travis-ci.org/vmware/terraform-provider-avi)
43
- [![Gitter chat](https://badges.gitter.im/hashicorp-terraform/Lobby.png)](https://gitter.im/hashicorp-terraform/Lobby)
54
- Website: https://www.terraform.io
65
- Mailing list: [Google Groups](http://groups.google.com/group/terraform-tool)
76

87
<img src="https://cdn.rawgit.com/hashicorp/terraform-website/master/content/source/assets/images/logo-text.svg" width="600px">
98

9+
Integrating Terraform with Avi Vantage
10+
--------------------------------------
11+
Please refer [this](https://avinetworks.com/docs/20.1/integrating-terraform-with-avi-vantage) article.
12+
13+
Developing the Provider or Use Locally Built Provider
14+
----------------------------------------------------
15+
If you wish to work on the provider or want to use the locally built provider,
16+
you'll first need [Go](http://www.golang.org) and [Terraform](https://www.terraform.io) installed on your machine.
17+
You'll also need to correctly setup a [GOPATH](http://golang.org/doc/code.html#GOPATH), as well as adding `$GOPATH/bin`
18+
to your `$PATH`.
19+
1020
Requirements
1121
------------
1222

13-
- [Terraform](https://www.terraform.io/downloads.html) 0.10.x
14-
- [Go](https://golang.org/doc/install) 1.8 (to build the provider plugin)
23+
- [Terraform](https://www.terraform.io/downloads.html) 0.12.x/0.13+ (0.11.x or lower is incompatible)
24+
- [Go](https://golang.org/doc/install) 1.13 (to build the provider plugin)
1525

16-
Usage
17-
---------------------
26+
Building The Provider (Terraform v0.12+)
27+
----------------------------------------
1828

19-
Create Avi Provider in terraform plan
29+
Clone repository to: `$GOPATH/src/github.com/vmware/terraform-provider-avi`
2030

31+
```sh
32+
$ mkdir -p $GOPATH/src/github.com/vmware; cd $GOPATH/src/github.com/vmware
33+
$ git clone https://github.com/vmware/terraform-provider-avi.git
2134
```
22-
# For example, restrict template version in 0.1.x
23-
provider "avi" {
24-
avi_username = "admin"
25-
avi_tenant = "admin"
26-
avi_password = "something"
27-
avi_controller= "42.42.42.42"
28-
}
29-
```
30-
31-
Create Avi Pool Example. Here Pool depends on read only tenant data source and another health monitor defined as resource in the terraform plan
3235

33-
```
34-
resource "avi_pool" "testpool" {
35-
name= "pool-42",
36-
health_monitor_refs= ["${avi_healthmonitor.test_hm_1.id}"]
37-
tenant_ref= "${data.avi_tenant.default_tenant.id}"
38-
cloud_ref= "${data.avi_cloud.default_cloud.id}"
39-
application_persistence_profile_ref= "${avi_applicationpersistenceprofile.test_applicationpersistenceprofile.id}"
40-
servers {
41-
ip= {
42-
type= "V4",
43-
addr= "10.90.64.66",
44-
}
45-
port= 8080
46-
}
47-
fail_action= {
48-
type= "FAIL_ACTION_CLOSE_CONN"
49-
}
50-
}
36+
Enter the provider directory and build the provider.
5137

38+
```sh
39+
$ cd $GOPATH/src/github.com/vmware/terraform-provider-avi
40+
$ make
5241
```
53-
54-
Reference existing resources as readonly or data sources
42+
For Terraform v0.12.x to use a locally built version of a provider add following to ~/.terraformrc on Linux/Unix.
5543

5644
```
57-
data "avi_applicationprofile" "system_http_profile" {
58-
name= "System-HTTP"
45+
providers {
46+
"avi" = "$GOPATH/bin/terraform-provider-avi"
5947
}
60-
61-
application_profile_ref= "${data.avi_applicationprofile.system_https_profile.id}"
62-
48+
```
49+
Or copy provider binary in ~./.terraform/plugins/linux_amd64/
50+
```shell
51+
$ mkdir -p ~./.terraform/plugins/linux_amd64/
52+
$ cp $GOPATH/bin/terraform-provider-avi ~./.terraform/plugins/linux_amd64/
6353
```
6454

65-
66-
Building The Provider
67-
---------------------
55+
Building The Provider (Terraform v0.13+)
56+
----------------------------------------
6857

6958
Clone repository to: `$GOPATH/src/github.com/vmware/terraform-provider-avi`
7059

@@ -77,36 +66,104 @@ Enter the provider directory and build the provider
7766

7867
```sh
7968
$ cd $GOPATH/src/github.com/vmware/terraform-provider-avi
69+
$ make build13
70+
```
71+
This will put the provider binary in the ~/.terraform.d/plugins/vmware.com/avi/avi/<provider_version>/$(GOOS)_$(GOARCH)
72+
directory.
73+
74+
For Terraform v0.13+, to use a locally built version of a provider you must add the following snippet to every
75+
terraform plan.
76+
```
77+
terraform {
78+
required_providers {
79+
avi = {
80+
source = "vmware.com/avi/avi"
81+
version = "<provider_version>"
82+
}
83+
}
84+
}
85+
```
8086

87+
------
88+
Usage
89+
------
8190

82-
$ make
91+
Create Avi Provider in terraform plan
92+
93+
```
94+
provider "avi" {
95+
avi_username = "admin"
96+
avi_tenant = "admin"
97+
avi_password = "password"
98+
avi_controller = "x.x.x.x"
99+
avi_version = "20.1.4"
100+
}
83101
```
84102

85-
Using the provider
86-
----------------------
87-
## Fill in for each provider
103+
Create Avi Pool Example. Here Pool depends on read only tenant data source and another health monitor defined as
104+
resource in the terraform plan
105+
106+
```
107+
data "avi_tenant" "default_tenant" {
108+
name= "admin"
109+
}
110+
data "avi_cloud" "default_cloud" {
111+
name= "Default-Cloud"
112+
}
113+
114+
resource "avi_applicationpersistenceprofile" "test_applicationpersistenceprofile" {
115+
name = "terraform-app-pers-profile"
116+
tenant_ref = data.avi_tenant.default_tenant.id
117+
persistence_type = "PERSISTENCE_TYPE_CLIENT_IP_ADDRESS"
118+
}
119+
120+
resource "avi_healthmonitor" "test_hm_1" {
121+
name = "terraform-monitor"
122+
type = "HEALTH_MONITOR_HTTP"
123+
tenant_ref = data.avi_tenant.default_tenant.id
124+
}
125+
126+
resource "avi_pool" "testpool" {
127+
name= "pool-42"
128+
health_monitor_refs = [avi_healthmonitor.test_hm_1.id]
129+
tenant_ref = data.avi_tenant.default_tenant.id
130+
cloud_ref = data.avi_cloud.default_cloud.id
131+
application_persistence_profile_ref= avi_applicationpersistenceprofile.test_applicationpersistenceprofile.id
132+
servers {
133+
ip {
134+
type = "V4"
135+
addr = "10.90.64.66"
136+
}
137+
port= 8080
138+
}
139+
fail_action {
140+
type = "FAIL_ACTION_CLOSE_CONN"
141+
}
142+
}
143+
```
88144

89-
Developing the Provider
90-
---------------------------
145+
Reference existing resources as readonly or data sources
91146

92-
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (version 1.8+ is *required*). You'll also need to correctly setup a [GOPATH](http://golang.org/doc/code.html#GOPATH), as well as adding `$GOPATH/bin` to your `$PATH`.
147+
```
148+
data "avi_applicationprofile" "system_http_profile" {
149+
name= "System-HTTP"
150+
}
93151
94-
To compile the provider, run `make build`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.
152+
application_profile_ref= data.avi_applicationprofile.system_https_profile.id
95153
96-
```sh
97-
$ make bin
98-
...
99-
$ $GOPATH/bin/terraform-provider-avi
100-
...
101154
```
155+
-----------------
102156

157+
Test The Provider
158+
-----------------
103159
In order to test the provider, you can simply run `make test`.
104160

105161
```sh
106162
$ make test
107163
```
108164

109-
In order to run the full suite of Acceptance tests, run `make testacc`.
165+
In order to run the full suite of Acceptance tests, run `make testacc`.
166+
Running the tests for a provider requires version 0.12.26 or higher of the Terraform CLI.
110167

111168
*Note:* Acceptance tests create real resources, and often cost money to run.
112169

Diff for: avi/data_source_avi_actiongroupconfig_test.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
// Copyright 2019 VMware, Inc.
2+
// SPDX-License-Identifier: Mozilla Public License 2.0
3+
14
package avi
25

36
import (
4-
"github.com/hashicorp/terraform/helper/resource"
57
"testing"
8+
9+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
610
)
711

812
func TestAVIDataSourceActionGroupConfigBasic(t *testing.T) {
@@ -31,11 +35,11 @@ data "avi_tenant" "default_tenant"{
3135
name= "admin"
3236
}
3337
resource "avi_actiongroupconfig" "testActionGroupConfig" {
34-
name = "test-System-Alert-Level-High-abc"
35-
tenant_ref = data.avi_tenant.default_tenant.id
36-
level = "ALERT_HIGH"
3738
autoscale_trigger_notification = false
3839
external_only = false
40+
tenant_ref = data.avi_tenant.default_tenant.id
41+
name = "test-System-Alert-Level-High-abc"
42+
level = "ALERT_HIGH"
3943
}
4044
4145
data "avi_actiongroupconfig" "testActionGroupConfig" {

Diff for: avi/data_source_avi_alertconfig_test.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
// Copyright 2019 VMware, Inc.
2+
// SPDX-License-Identifier: Mozilla Public License 2.0
3+
14
package avi
25

36
import (
4-
"github.com/hashicorp/terraform/helper/resource"
57
"testing"
8+
9+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
610
)
711

812
func TestAVIDataSourceAlertConfigBasic(t *testing.T) {
@@ -15,10 +19,10 @@ func TestAVIDataSourceAlertConfigBasic(t *testing.T) {
1519
Check: resource.ComposeTestCheckFunc(
1620
resource.TestCheckResourceAttr(
1721
"avi_alertconfig.testAlertConfig", "name", "test-System-CC-Alert-abc"),
18-
resource.TestCheckResourceAttr(
19-
"avi_alertconfig.testAlertConfig", "enabled", "true"),
2022
resource.TestCheckResourceAttr(
2123
"avi_alertconfig.testAlertConfig", "expiry_time", "86400"),
24+
resource.TestCheckResourceAttr(
25+
"avi_alertconfig.testAlertConfig", "enabled", "true"),
2226
resource.TestCheckResourceAttr(
2327
"avi_alertconfig.testAlertConfig", "rolling_window", "300"),
2428
resource.TestCheckResourceAttr(
@@ -40,11 +44,11 @@ data "avi_actiongroupconfig" "system_actiongroupconfig" {
4044
name= "System-Alert-Level-Medium"
4145
}
4246
resource "avi_alertconfig" "testAlertConfig" {
47+
category = "REALTIME"
48+
expiry_time = "86400"
4349
name = "test-System-CC-Alert-abc"
4450
enabled = true
4551
tenant_ref = data.avi_tenant.default_tenant.id
46-
category = "REALTIME"
47-
expiry_time = "86400"
4852
summary = "System-CC-Alert System Alert Triggered"
4953
rolling_window = "300"
5054
source = "EVENT_LOGS"

Diff for: avi/data_source_avi_alertemailconfig_test.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
// Copyright 2019 VMware, Inc.
2+
// SPDX-License-Identifier: Mozilla Public License 2.0
3+
14
package avi
25

36
import (
4-
"github.com/hashicorp/terraform/helper/resource"
57
"testing"
8+
9+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
610
)
711

812
func TestAVIDataSourceAlertEmailConfigBasic(t *testing.T) {
@@ -27,11 +31,11 @@ data "avi_tenant" "default_tenant"{
2731
name= "admin"
2832
}
2933
resource "avi_alertemailconfig" "testAlertEmailConfig" {
30-
name = "test-aec-abc"
31-
tenant_ref = data.avi_tenant.default_tenant.id
34+
to_emails = "[email protected]"
3235
cc_emails = "[email protected]"
36+
tenant_ref = data.avi_tenant.default_tenant.id
37+
name = "test-aec-abc"
3338
description = "test alert email"
34-
to_emails = "[email protected]"
3539
}
3640
3741
data "avi_alertemailconfig" "testAlertEmailConfig" {

0 commit comments

Comments
 (0)