Skip to content

Commit 9c95410

Browse files
authored
Merge pull request #197 from rawmind0/cloudprovider
Add external as allowed value on cloud_provider argument
2 parents e31e40c + 0cbcf3e commit 9c95410

File tree

13 files changed

+240
-37
lines changed

13 files changed

+240
-37
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 1.0.0-rc6 (Unreleased)
1+
## 1.0.0 (May 7, 2020)
22

33
FEATURES:
44

@@ -10,6 +10,9 @@ ENHANCEMENTS:
1010
* `upgrade_strategy` on `rke_cluster` resource
1111
* `ssh_key_path` on `bastion_host` argument
1212
* `audit_log` on `services.kube_api` argument
13+
* Add `external` as allowed value on `cloud_provider` argument
14+
* Add `nodelocal` argument to `dns` argument on `rke_cluster` resource
15+
* Updated RKE to v1.1.1
1316

1417
BUG FIXES:
1518

GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ test-compile:
8686

8787
vendor:
8888
@echo "==> Updating vendor modules..."
89-
@GO111MODULE=${GO111MODULE} go mod vendor
89+
@GO111MODULE=on go mod vendor
9090

9191
website:
9292
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/hashicorp/go-sockaddr v1.0.2 // indirect
1212
github.com/hashicorp/go-version v1.2.0
1313
github.com/hashicorp/terraform-plugin-sdk v1.8.0
14-
github.com/rancher/rke v1.1.0
14+
github.com/rancher/rke v1.1.1
1515
github.com/rancher/types v0.0.0-20200326224903-b4612bd96d9b
1616
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b
1717
github.com/sirupsen/logrus v1.4.2

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,8 @@ github.com/rancher/norman v0.0.0-20200312033725-5c74e1ee1e6d h1:XrZkPfanv6m1Ocnq
655655
github.com/rancher/norman v0.0.0-20200312033725-5c74e1ee1e6d/go.mod h1:b+483H276jRBXYosdWrNKFpxH+JYMs3UIdlV60dhdg0=
656656
github.com/rancher/rke v1.1.0 h1:A9FydBnODhdyIvSL3UbfE16WBLK/KmnUdrqQ2jBypq8=
657657
github.com/rancher/rke v1.1.0/go.mod h1:Fw4u45cKMFBTu81jAxN5wtZeMgS4862RxVixhRc5p3E=
658+
github.com/rancher/rke v1.1.1 h1:w7BJuY0pz1MA/WmkyzW0K1f6jevhW0k5AVcmHZLU/8Q=
659+
github.com/rancher/rke v1.1.1/go.mod h1:Fw4u45cKMFBTu81jAxN5wtZeMgS4862RxVixhRc5p3E=
658660
github.com/rancher/types v0.0.0-20200303162837-300a04e6f743/go.mod h1:k5LoTlUpefw0eAzFSJsZI0gf+C4WE41yrc1jm/MS1nM=
659661
github.com/rancher/types v0.0.0-20200326224903-b4612bd96d9b h1:nLJOQuk36vCXFQuD03L5Fh9xpF9n9U7/76WNGDjOjeY=
660662
github.com/rancher/types v0.0.0-20200326224903-b4612bd96d9b/go.mod h1:k5LoTlUpefw0eAzFSJsZI0gf+C4WE41yrc1jm/MS1nM=

rke/schema_rke_cluster_cloud_provider.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ import (
66
)
77

88
const (
9-
rkeClusterCloudProviderCustomName = "custom"
9+
rkeClusterCloudProviderCustomName = "custom"
10+
rkeClusterCloudProviderExternalName = "external"
1011
)
1112

1213
var (
1314
rkeClusterCloudProviderList = []string{
1415
rkeClusterCloudProviderAwsName,
1516
rkeClusterCloudProviderAzureName,
1617
rkeClusterCloudProviderCustomName,
18+
rkeClusterCloudProviderExternalName,
1719
rkeClusterCloudProviderOpenstackName,
1820
rkeClusterCloudProviderVsphereName,
1921
}

rke/schema_rke_cluster_dns.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,37 @@ var (
2121

2222
//Schemas
2323

24+
func rkeClusterDNSNodelocalFields() map[string]*schema.Schema {
25+
s := map[string]*schema.Schema{
26+
"ip_address": {
27+
Type: schema.TypeString,
28+
Optional: true,
29+
},
30+
"node_selector": {
31+
Type: schema.TypeMap,
32+
Optional: true,
33+
Description: "Node selector key pair",
34+
},
35+
}
36+
return s
37+
}
38+
2439
func rkeClusterDNSFields() map[string]*schema.Schema {
2540
s := map[string]*schema.Schema{
2641
"node_selector": {
2742
Type: schema.TypeMap,
2843
Optional: true,
2944
Description: "NodeSelector key pair",
3045
},
46+
"nodelocal": {
47+
Type: schema.TypeList,
48+
Optional: true,
49+
MaxItems: 1,
50+
Description: "Nodelocal dns",
51+
Elem: &schema.Resource{
52+
Schema: rkeClusterDNSNodelocalFields(),
53+
},
54+
},
3155
"provider": {
3256
Type: schema.TypeString,
3357
Optional: true,

rke/structure_rke_cluster_dns.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,33 @@ import (
66

77
// Flatteners
88

9+
func flattenRKEClusterDNSNodelocal(in *rancher.Nodelocal) []interface{} {
10+
obj := make(map[string]interface{})
11+
if in == nil {
12+
return nil
13+
}
14+
15+
if len(in.IPAddress) > 0 {
16+
obj["ip_address"] = in.IPAddress
17+
}
18+
19+
if len(in.NodeSelector) > 0 {
20+
obj["node_selector"] = toMapInterface(in.NodeSelector)
21+
}
22+
23+
return []interface{}{obj}
24+
}
25+
926
func flattenRKEClusterDNS(in *rancher.DNSConfig) []interface{} {
1027
obj := make(map[string]interface{})
1128
if in == nil {
1229
return []interface{}{}
1330
}
1431

32+
if in.Nodelocal != nil {
33+
obj["nodelocal"] = flattenRKEClusterDNSNodelocal(in.Nodelocal)
34+
}
35+
1536
if len(in.NodeSelector) > 0 {
1637
obj["node_selector"] = toMapInterface(in.NodeSelector)
1738
}
@@ -33,13 +54,35 @@ func flattenRKEClusterDNS(in *rancher.DNSConfig) []interface{} {
3354

3455
// Expanders
3556

57+
func expandRKEClusterDNSNodelocal(p []interface{}) *rancher.Nodelocal {
58+
obj := &rancher.Nodelocal{}
59+
if len(p) == 0 || p[0] == nil {
60+
return nil
61+
}
62+
in := p[0].(map[string]interface{})
63+
64+
if v, ok := in["ip_address"].(string); ok && len(v) > 0 {
65+
obj.IPAddress = v
66+
}
67+
68+
if v, ok := in["node_selector"].(map[string]interface{}); ok && len(v) > 0 {
69+
obj.NodeSelector = toMapString(v)
70+
}
71+
72+
return obj
73+
}
74+
3675
func expandRKEClusterDNS(p []interface{}) *rancher.DNSConfig {
3776
obj := &rancher.DNSConfig{}
3877
if len(p) == 0 || p[0] == nil {
3978
return obj
4079
}
4180
in := p[0].(map[string]interface{})
4281

82+
if v, ok := in["nodelocal"].([]interface{}); ok && len(v) > 0 {
83+
obj.Nodelocal = expandRKEClusterDNSNodelocal(v)
84+
}
85+
4386
if v, ok := in["node_selector"].(map[string]interface{}); ok && len(v) > 0 {
4487
obj.NodeSelector = toMapString(v)
4588
}

rke/structure_rke_cluster_dns_test.go

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,31 @@ import (
88
)
99

1010
var (
11-
testRKEClusterDNSConf *rancher.DNSConfig
12-
testRKEClusterDNSInterface []interface{}
11+
testRKEClusterDNSNodelocalConf *rancher.Nodelocal
12+
testRKEClusterDNSNodelocalInterface []interface{}
13+
testRKEClusterDNSConf *rancher.DNSConfig
14+
testRKEClusterDNSInterface []interface{}
1315
)
1416

1517
func init() {
18+
testRKEClusterDNSNodelocalConf = &rancher.Nodelocal{
19+
NodeSelector: map[string]string{
20+
"sel1": "value1",
21+
"sel2": "value2",
22+
},
23+
IPAddress: "ip_address",
24+
}
25+
testRKEClusterDNSNodelocalInterface = []interface{}{
26+
map[string]interface{}{
27+
"node_selector": map[string]interface{}{
28+
"sel1": "value1",
29+
"sel2": "value2",
30+
},
31+
"ip_address": "ip_address",
32+
},
33+
}
1634
testRKEClusterDNSConf = &rancher.DNSConfig{
35+
Nodelocal: testRKEClusterDNSNodelocalConf,
1736
NodeSelector: map[string]string{
1837
"sel1": "value1",
1938
"sel2": "value2",
@@ -24,6 +43,7 @@ func init() {
2443
}
2544
testRKEClusterDNSInterface = []interface{}{
2645
map[string]interface{}{
46+
"nodelocal": testRKEClusterDNSNodelocalInterface,
2747
"node_selector": map[string]interface{}{
2848
"sel1": "value1",
2949
"sel2": "value2",
@@ -35,6 +55,27 @@ func init() {
3555
}
3656
}
3757

58+
func TestFlattenRKEClusterDNSNodelocal(t *testing.T) {
59+
60+
cases := []struct {
61+
Input *rancher.Nodelocal
62+
ExpectedOutput []interface{}
63+
}{
64+
{
65+
testRKEClusterDNSNodelocalConf,
66+
testRKEClusterDNSNodelocalInterface,
67+
},
68+
}
69+
70+
for _, tc := range cases {
71+
output := flattenRKEClusterDNSNodelocal(tc.Input)
72+
if !reflect.DeepEqual(output, tc.ExpectedOutput) {
73+
t.Fatalf("Unexpected output from flattener.\nExpected: %#v\nGiven: %#v",
74+
tc.ExpectedOutput, output)
75+
}
76+
}
77+
}
78+
3879
func TestFlattenRKEClusterDNS(t *testing.T) {
3980

4081
cases := []struct {
@@ -56,6 +97,27 @@ func TestFlattenRKEClusterDNS(t *testing.T) {
5697
}
5798
}
5899

100+
func TestExpandRKEClusterDNSNodelocal(t *testing.T) {
101+
102+
cases := []struct {
103+
Input []interface{}
104+
ExpectedOutput *rancher.Nodelocal
105+
}{
106+
{
107+
testRKEClusterDNSNodelocalInterface,
108+
testRKEClusterDNSNodelocalConf,
109+
},
110+
}
111+
112+
for _, tc := range cases {
113+
output := expandRKEClusterDNSNodelocal(tc.Input)
114+
if !reflect.DeepEqual(output, tc.ExpectedOutput) {
115+
t.Fatalf("Unexpected output from expander.\nExpected: %#v\nGiven: %#v",
116+
tc.ExpectedOutput, output)
117+
}
118+
}
119+
}
120+
59121
func TestExpandRKEClusterDNS(t *testing.T) {
60122

61123
cases := []struct {

vendor/github.com/rancher/rke/data/bindata.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)