From 0ce4f21fbeb7df010cbc5af9b1dbd8437074d111 Mon Sep 17 00:00:00 2001 From: George Nikolopoulos Date: Thu, 23 Jul 2020 11:36:03 +0300 Subject: [PATCH 1/2] Add resource nsparam with examples Signed-off-by: George Nikolopoulos --- citrixadc/provider.go | 1 + citrixadc/resource_citrixadc_nsparam.go | 261 +++++++++++++++++++ citrixadc/resource_citrixadc_nsparam_test.go | 103 ++++++++ examples/nsparam/provider.tf | 3 + examples/nsparam/resources.tf | 4 + 5 files changed, 372 insertions(+) create mode 100644 citrixadc/resource_citrixadc_nsparam.go create mode 100644 citrixadc/resource_citrixadc_nsparam_test.go create mode 100644 examples/nsparam/provider.tf create mode 100644 examples/nsparam/resources.tf diff --git a/citrixadc/provider.go b/citrixadc/provider.go index bc4fd51ca..33d9d1be2 100644 --- a/citrixadc/provider.go +++ b/citrixadc/provider.go @@ -137,6 +137,7 @@ func providerResources() map[string]*schema.Resource { "citrixadc_systemextramgmtcpu": resourceCitrixAdcSystemextramgmtcpu(), "citrixadc_netprofile": resourceCitrixAdcNetprofile(), "citrixadc_servicegroup_lbmonitor_binding": resourceCitrixAdcServicegroup_lbmonitor_binding(), + "citrixadc_nsparam": resourceCitrixAdcNsparam(), } } diff --git a/citrixadc/resource_citrixadc_nsparam.go b/citrixadc/resource_citrixadc_nsparam.go new file mode 100644 index 000000000..6dfbb02b3 --- /dev/null +++ b/citrixadc/resource_citrixadc_nsparam.go @@ -0,0 +1,261 @@ +package citrixadc + +import ( + "github.com/chiradeep/go-nitro/config/ns" + + "github.com/chiradeep/go-nitro/netscaler" + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/helper/schema" + + "log" +) + +func resourceCitrixAdcNsparam() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + Create: createNsparamFunc, + Read: readNsparamFunc, + Delete: deleteNsparamFunc, + Schema: map[string]*schema.Schema{ + "advancedanalyticsstats": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + "aftpallowrandomsourceport": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + "cip": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + "cipheader": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + "cookieversion": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + "crportrange": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + "exclusivequotamaxclient": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Computed: true, + ForceNew: true, + }, + "exclusivequotaspillover": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Computed: true, + ForceNew: true, + }, + "ftpportrange": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + "grantquotamaxclient": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Computed: true, + ForceNew: true, + }, + "grantquotaspillover": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Computed: true, + ForceNew: true, + }, + "internaluserlogin": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + "maxconn": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Computed: true, + ForceNew: true, + }, + "maxreq": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Computed: true, + ForceNew: true, + }, + "mgmthttpport": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Computed: true, + ForceNew: true, + }, + "mgmthttpsport": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Computed: true, + ForceNew: true, + }, + "pmtumin": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Computed: true, + ForceNew: true, + }, + "pmtutimeout": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Computed: true, + ForceNew: true, + }, + "proxyprotocol": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + "securecookie": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + "servicepathingressvlan": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Computed: true, + ForceNew: true, + }, + "tcpcip": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + "timezone": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + "useproxyport": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + }, + } +} + +func createNsparamFunc(d *schema.ResourceData, meta interface{}) error { + log.Printf("[DEBUG] citrixadc-provider: In createNsparamFunc") + client := meta.(*NetScalerNitroClient).client + nsparamId := resource.PrefixedUniqueId("tf-nsparam-") + nsparam := ns.Nsparam{ + Advancedanalyticsstats: d.Get("advancedanalyticsstats").(string), + Aftpallowrandomsourceport: d.Get("aftpallowrandomsourceport").(string), + Cip: d.Get("cip").(string), + Cipheader: d.Get("cipheader").(string), + Cookieversion: d.Get("cookieversion").(string), + Crportrange: d.Get("crportrange").(string), + Exclusivequotamaxclient: d.Get("exclusivequotamaxclient").(int), + Exclusivequotaspillover: d.Get("exclusivequotaspillover").(int), + Ftpportrange: d.Get("ftpportrange").(string), + Grantquotamaxclient: d.Get("grantquotamaxclient").(int), + Grantquotaspillover: d.Get("grantquotaspillover").(int), + Internaluserlogin: d.Get("internaluserlogin").(string), + Maxconn: d.Get("maxconn").(int), + Maxreq: d.Get("maxreq").(int), + Mgmthttpport: d.Get("mgmthttpport").(int), + Mgmthttpsport: d.Get("mgmthttpsport").(int), + Pmtumin: d.Get("pmtumin").(int), + Pmtutimeout: d.Get("pmtutimeout").(int), + Proxyprotocol: d.Get("proxyprotocol").(string), + Securecookie: d.Get("securecookie").(string), + Servicepathingressvlan: d.Get("servicepathingressvlan").(int), + Tcpcip: d.Get("tcpcip").(string), + Timezone: d.Get("timezone").(string), + Useproxyport: d.Get("useproxyport").(string), + } + + err := client.UpdateUnnamedResource(netscaler.Nsparam.Type(), &nsparam) + if err != nil { + return err + } + + d.SetId(nsparamId) + + err = readNsparamFunc(d, meta) + if err != nil { + log.Printf("[ERROR] netscaler-provider: ?? we just created this nsparam but we can't read it ??") + return err + } + return nil +} + +func readNsparamFunc(d *schema.ResourceData, meta interface{}) error { + log.Printf("[DEBUG] citrixadc-provider: In readNsparamFunc") + client := meta.(*NetScalerNitroClient).client + nsparamName := d.Id() + log.Printf("[DEBUG] citrixadc-provider: Reading nsparam state %s", nsparamName) + data, err := client.FindResource(netscaler.Nsparam.Type(), "") + if err != nil { + log.Printf("[WARN] citrixadc-provider: Clearing nsparam state %s", nsparamName) + d.SetId("") + return nil + } + d.Set("name", data["name"]) + d.Set("advancedanalyticsstats", data["advancedanalyticsstats"]) + d.Set("aftpallowrandomsourceport", data["aftpallowrandomsourceport"]) + d.Set("cip", data["cip"]) + d.Set("cipheader", data["cipheader"]) + d.Set("cookieversion", data["cookieversion"]) + d.Set("crportrange", data["crportrange"]) + d.Set("exclusivequotamaxclient", data["exclusivequotamaxclient"]) + d.Set("exclusivequotaspillover", data["exclusivequotaspillover"]) + d.Set("ftpportrange", data["ftpportrange"]) + d.Set("grantquotamaxclient", data["grantquotamaxclient"]) + d.Set("grantquotaspillover", data["grantquotaspillover"]) + d.Set("internaluserlogin", data["internaluserlogin"]) + d.Set("maxconn", data["maxconn"]) + d.Set("maxreq", data["maxreq"]) + d.Set("mgmthttpport", data["mgmthttpport"]) + d.Set("mgmthttpsport", data["mgmthttpsport"]) + d.Set("pmtumin", data["pmtumin"]) + d.Set("pmtutimeout", data["pmtutimeout"]) + d.Set("proxyprotocol", data["proxyprotocol"]) + d.Set("securecookie", data["securecookie"]) + d.Set("servicepathingressvlan", data["servicepathingressvlan"]) + d.Set("tcpcip", data["tcpcip"]) + d.Set("timezone", data["timezone"]) + d.Set("useproxyport", data["useproxyport"]) + + return nil + +} + +func deleteNsparamFunc(d *schema.ResourceData, meta interface{}) error { + log.Printf("[DEBUG] citrixadc-provider: In deleteNsparamFunc") + + d.SetId("") + + return nil +} diff --git a/citrixadc/resource_citrixadc_nsparam_test.go b/citrixadc/resource_citrixadc_nsparam_test.go new file mode 100644 index 000000000..6e2671e09 --- /dev/null +++ b/citrixadc/resource_citrixadc_nsparam_test.go @@ -0,0 +1,103 @@ +/* +Copyright 2016 Citrix Systems, Inc + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package citrixadc + +import ( + "fmt" + "github.com/chiradeep/go-nitro/netscaler" + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/terraform" + "testing" +) + +func TestAccNsparam_basic(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccNsparam_basic_step1, + Check: resource.ComposeTestCheckFunc( + testAccCheckNsparamExist("citrixadc_nsparam.tf_nsparam", nil, map[string]interface{}{"maxconn": "10", "useproxyport": "DISABLED"}), + ), + }, + resource.TestStep{ + Config: testAccNsparam_basic_step2, + Check: resource.ComposeTestCheckFunc( + testAccCheckNsparamExist("citrixadc_nsparam.tf_nsparam", nil, map[string]interface{}{"maxconn": "0", "useproxyport": "ENABLED"}), + ), + }, + }, + }) +} + +func testAccCheckNsparamExist(n string, id *string, expectedValues map[string]interface{}) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[n] + if !ok { + return fmt.Errorf("Not found: %s", n) + } + + if rs.Primary.ID == "" { + return fmt.Errorf("No lb vserver name is set") + } + + if id != nil { + if *id != "" && *id != rs.Primary.ID { + return fmt.Errorf("Resource ID has changed!") + } + + *id = rs.Primary.ID + } + + nsClient := testAccProvider.Meta().(*NetScalerNitroClient).client + data, err := nsClient.FindResource(netscaler.Nsparam.Type(), "") + + if err != nil { + return err + } + + if data == nil { + return fmt.Errorf("NS parameters %s not found", n) + } + + if data["proxyprotocol"] != expectedValues["proxyprotocol"] { + return fmt.Errorf("Expected value for \"proxyprotocol\" differs. Expected: \"%v\", Retrieved \"%v\"", expectedValues["proxyprotocol"], data["proxyprotocol"]) + } + + if data["maxconn"] != expectedValues["maxconn"] { + return fmt.Errorf("Expected value for \"maxconn\" differs. Expected: \"%v\", Retrieved \"%v\"", expectedValues["maxconn"], data["maxconn"]) + } + + return nil + } +} + +const testAccNsparam_basic_step1 = ` + +resource "citrixadc_nsparam" "tf_nsparam" { + maxconn = 10 + useproxyport = "DISABLED" +} +` + +const testAccNsparam_basic_step2 = ` + +resource "citrixadc_nsparam" "tf_nsparam" { + maxconn = 0 + useproxyport = "ENABLED" +} +` diff --git a/examples/nsparam/provider.tf b/examples/nsparam/provider.tf new file mode 100644 index 000000000..3d4508593 --- /dev/null +++ b/examples/nsparam/provider.tf @@ -0,0 +1,3 @@ +provider "citrixadc" { + endpoint = "http://localhost:8080" +} diff --git a/examples/nsparam/resources.tf b/examples/nsparam/resources.tf new file mode 100644 index 000000000..7d111fbf2 --- /dev/null +++ b/examples/nsparam/resources.tf @@ -0,0 +1,4 @@ +resource "citrixadc_nsparam" "tf_nsparam" { + proxyprotocol = "DISABLED" + maxconn = 10 +} From 6fe41f8cddeb49546aaea05d87235b322707401a Mon Sep 17 00:00:00 2001 From: George Nikolopoulos Date: Mon, 27 Jul 2020 18:52:36 +0300 Subject: [PATCH 2/2] Update go-nitro dependencies Signed-off-by: George Nikolopoulos --- go.mod | 2 +- go.sum | 6 ++++ .../chiradeep/go-nitro/config/ns/nsparam.go | 12 ++++---- .../chiradeep/go-nitro/netscaler/client.go | 24 +++++++++++++++- .../go-nitro/netscaler/netscaler_resource.go | 16 +++++++++++ .../chiradeep/go-nitro/netscaler/stats.go | 28 +++++++++++++++++++ vendor/modules.txt | 2 +- 7 files changed, 81 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 9fc179aa6..e21ec3f90 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/citrix/terraform-provider-citrixadc go 1.13 require ( - github.com/chiradeep/go-nitro v0.0.0-20200327171648-47dbcb679e54 + github.com/chiradeep/go-nitro v0.0.0-20200724075413-fe307aa68464 github.com/hashicorp/terraform v0.12.20 github.com/hashicorp/terraform-plugin-sdk v1.6.0 github.com/mitchellh/mapstructure v1.1.2 diff --git a/go.sum b/go.sum index 186f568ba..84e4bf8b2 100644 --- a/go.sum +++ b/go.sum @@ -87,6 +87,12 @@ github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx2 github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/chiradeep/go-nitro v0.0.0-20200327171648-47dbcb679e54 h1:wk2ukyd2A8hgCWemrDCq+pM71QMtn3wpxEQL4aNOH2I= github.com/chiradeep/go-nitro v0.0.0-20200327171648-47dbcb679e54/go.mod h1:RIyfAubyIck4tVaQrEiNGW4Y1e6CcTONDnYSX8VktH8= +github.com/chiradeep/go-nitro v0.0.0-20200522165541-e35ec60a1d1b h1:Q0m3P756l2lcBEEQmm2WWMs/OXs8WtX9D2uY9X9OY6k= +github.com/chiradeep/go-nitro v0.0.0-20200522165541-e35ec60a1d1b/go.mod h1:RIyfAubyIck4tVaQrEiNGW4Y1e6CcTONDnYSX8VktH8= +github.com/chiradeep/go-nitro v0.0.0-20200723075907-bf03b0d21306 h1:wuZCDMb2/1c5W3vSyQ1jLZbylVVIkGhW0+v53AGzQcA= +github.com/chiradeep/go-nitro v0.0.0-20200723075907-bf03b0d21306/go.mod h1:RIyfAubyIck4tVaQrEiNGW4Y1e6CcTONDnYSX8VktH8= +github.com/chiradeep/go-nitro v0.0.0-20200724075413-fe307aa68464 h1:y8Ovob0o1JKjOvh8LwhfjQSNbFvYVHSRr0t19PqcJlY= +github.com/chiradeep/go-nitro v0.0.0-20200724075413-fe307aa68464/go.mod h1:RIyfAubyIck4tVaQrEiNGW4Y1e6CcTONDnYSX8VktH8= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= diff --git a/vendor/github.com/chiradeep/go-nitro/config/ns/nsparam.go b/vendor/github.com/chiradeep/go-nitro/config/ns/nsparam.go index c02ea2025..c2675ac44 100644 --- a/vendor/github.com/chiradeep/go-nitro/config/ns/nsparam.go +++ b/vendor/github.com/chiradeep/go-nitro/config/ns/nsparam.go @@ -7,16 +7,16 @@ type Nsparam struct { Cipheader string `json:"cipheader,omitempty"` Cookieversion string `json:"cookieversion,omitempty"` Crportrange string `json:"crportrange,omitempty"` - Exclusivequotamaxclient int `json:"exclusivequotamaxclient,omitempty"` - Exclusivequotaspillover int `json:"exclusivequotaspillover,omitempty"` + Exclusivequotamaxclient int `json:"exclusivequotamaxclient"` // 0 is a valid value + Exclusivequotaspillover int `json:"exclusivequotaspillover"` // 0 is a valid value Ftpportrange string `json:"ftpportrange,omitempty"` - Grantquotamaxclient int `json:"grantquotamaxclient,omitempty"` - Grantquotaspillover int `json:"grantquotaspillover,omitempty"` + Grantquotamaxclient int `json:"grantquotamaxclient"` // 0 is a valid value + Grantquotaspillover int `json:"grantquotaspillover"` // 0 is a valid value Httpport interface{} `json:"httpport,omitempty"` Icaports interface{} `json:"icaports,omitempty"` Internaluserlogin string `json:"internaluserlogin,omitempty"` - Maxconn int `json:"maxconn,omitempty"` - Maxreq int `json:"maxreq,omitempty"` + Maxconn int `json:"maxconn"` // 0 is a valid value + Maxreq int `json:"maxreq"` // 0 is a valid value Mgmthttpport int `json:"mgmthttpport,omitempty"` Mgmthttpsport int `json:"mgmthttpsport,omitempty"` Pmtumin int `json:"pmtumin,omitempty"` diff --git a/vendor/github.com/chiradeep/go-nitro/netscaler/client.go b/vendor/github.com/chiradeep/go-nitro/netscaler/client.go index 24c84b3fa..1eb48b64c 100644 --- a/vendor/github.com/chiradeep/go-nitro/netscaler/client.go +++ b/vendor/github.com/chiradeep/go-nitro/netscaler/client.go @@ -18,6 +18,7 @@ package netscaler import ( "crypto/tls" + "crypto/x509" "fmt" "net/http" "net/url" @@ -25,6 +26,7 @@ import ( "strconv" "strings" "sync" + "io/ioutil" ) //NitroParams encapsulates options to create a NitroClient @@ -35,6 +37,8 @@ type NitroParams struct { ProxiedNs string SslVerify bool Timeout int + RootCAPath string + ServerName string } //NitroClient has methods to configure the NetScaler @@ -84,7 +88,25 @@ func NewNitroClientFromParams(params NitroParams) (*NitroClient, error) { c.sessionid = "" c.timeout = params.Timeout if params.SslVerify { - c.client = &http.Client{} + if( len(params.RootCAPath) > 0 ){ + caCert, err := ioutil.ReadFile(params.RootCAPath) + if err != nil { + return nil, fmt.Errorf("Unable to read certificate file: %v", err) + } + caCertPool := x509.NewCertPool() + if ok := caCertPool.AppendCertsFromPEM(caCert); !ok { + return nil, fmt.Errorf("Could not Append CA certificate.") + } + tr := &http.Transport{ + TLSClientConfig: &tls.Config{ + RootCAs: caCertPool, + ServerName: params.ServerName, + }, + } + c.client = &http.Client{Transport: tr} + } else { + c.client = &http.Client{} + } } else { tr := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, diff --git a/vendor/github.com/chiradeep/go-nitro/netscaler/netscaler_resource.go b/vendor/github.com/chiradeep/go-nitro/netscaler/netscaler_resource.go index 8ad707cf8..a1d26a18b 100644 --- a/vendor/github.com/chiradeep/go-nitro/netscaler/netscaler_resource.go +++ b/vendor/github.com/chiradeep/go-nitro/netscaler/netscaler_resource.go @@ -439,3 +439,19 @@ func (c *NitroClient) listStat(resourceType, resourceName string) ([]byte, error return c.doHTTPRequest("GET", url, bytes.NewBuffer([]byte{}), readResponseHandler) } + +func (c *NitroClient) listStatWithArgs(resourceType string, resourceName string, args []string) ([]byte, error) { + log.Println("[DEBUG] go-nitro: listing stat of type ", resourceType, ", name: ", resourceName, ", args:", args) + var url string + + if len(resourceName) > 0 { + url = c.statsURL + fmt.Sprintf("%s/%s", resourceType, resourceName) + } else { + url = c.statsURL + fmt.Sprintf("%s", resourceType) + } + strArgs := strings.Join(args, ",") + url = url + "?args=" + strArgs + log.Println("[TRACE] go-nitro: url is ", url) + + return c.doHTTPRequest("GET", url, bytes.NewBuffer([]byte{}), readResponseHandler) +} diff --git a/vendor/github.com/chiradeep/go-nitro/netscaler/stats.go b/vendor/github.com/chiradeep/go-nitro/netscaler/stats.go index 3878a2356..3dc65296c 100644 --- a/vendor/github.com/chiradeep/go-nitro/netscaler/stats.go +++ b/vendor/github.com/chiradeep/go-nitro/netscaler/stats.go @@ -52,3 +52,31 @@ func (c *NitroClient) FindStat(resourceType string, resourceName string) (map[st return resource.(map[string]interface{}), nil } + +func (c *NitroClient) FindStatWithArgs(resourceType string, resourceName string, args []string) (map[string]interface{}, error) { + + var data map[string]interface{} + result, err := c.listStatWithArgs(resourceType, resourceName, args) + if err != nil { + log.Printf("[WARN] go-nitro: FindStatWithArgs: No %s %s found", resourceType, resourceName) + return nil, fmt.Errorf("[INFO] go-nitro: FindStatWithArgs: No resource %s of type %s found", resourceName, resourceType) + } + if err = json.Unmarshal(result, &data); err != nil { + log.Printf("[ERROR] go-nitro: FindStatWithArgs: Failed to unmarshal Netscaler Response!") + return nil, fmt.Errorf("[ERROR] go-nitro: FindStatWithArgs: Failed to unmarshal Netscaler Response:resource %s of type %s", resourceName, resourceType) + } + rsrc, ok := data[resourceType] + if !ok || rsrc == nil { + log.Printf("[WARN] go-nitro: FindStatWithArgs No %s type with name %s found", resourceType, resourceName) + return nil, fmt.Errorf("[INFO] go-nitro: FindStatWithArgs: No resource %s of type %s found", resourceName, resourceType) + } + switch result := data[resourceType].(type) { + case map[string]interface{}: + return result, nil + case []interface{}: + return result[0].(map[string]interface{}), nil + default: + log.Printf("[WARN] go-nitro: FindStatWithArgs Unable to determine type of response") + return nil, fmt.Errorf("[INFO] go-nitro: FindStatWithArgs: Unable to determine type of response") + } +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 0ba928466..3247949cd 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -60,7 +60,7 @@ github.com/bgentry/speakeasy github.com/blang/semver # github.com/bmatcuk/doublestar v1.1.5 github.com/bmatcuk/doublestar -# github.com/chiradeep/go-nitro v0.0.0-20200327171648-47dbcb679e54 +# github.com/chiradeep/go-nitro v0.0.0-20200724075413-fe307aa68464 github.com/chiradeep/go-nitro/config/audit github.com/chiradeep/go-nitro/config/basic github.com/chiradeep/go-nitro/config/cluster