Skip to content

Commit

Permalink
initial support
Browse files Browse the repository at this point in the history
  • Loading branch information
chiradeep committed May 14, 2018
1 parent 5571116 commit f12cee0
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/nsacl/resources.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ resource "netscaler_nsacl" "acl5" {
aclaction = "DENY"
vlan = "2000"
}

resource "netscaler_nsacls" "allacls" {
}
1 change: 1 addition & 0 deletions netscaler/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func providerResources() map[string]*schema.Resource {
"netscaler_lbmonitor": resourceNetScalerLbmonitor(),
"netscaler_servicegroup": resourceNetScalerServicegroup(),
"netscaler_nsacl": resourceNetScalerNsacl(),
"netscaler_nsacls": resourceNetScalerNsacls(),
}
}

Expand Down
50 changes: 50 additions & 0 deletions netscaler/resource_nsacls.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package netscaler

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 resourceNetScalerNsacls() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Create: createNsaclsFunc,
Read: readNsaclsFunc,
Delete: deleteNsaclsFunc,
Schema: map[string]*schema.Schema{},
}
}

func createNsaclsFunc(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] netscaler-provider: In createNsaclsFunc")
client := meta.(*NetScalerNitroClient).client
nsacls := ns.Nsacls{}

nsaclsName := resource.PrefixedUniqueId("tf-nsacls-")
err := client.ApplyResource(netscaler.Nsacls.Type(), &nsacls)
if err != nil {
return err
}

d.SetId(nsaclsName)

return nil
}

func readNsaclsFunc(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] netscaler-provider: In readNsaclsFunc")

return nil
}

func deleteNsaclsFunc(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] netscaler-provider: In deleteNsaclsFunc")

d.SetId("")
return nil
}
63 changes: 63 additions & 0 deletions netscaler/resource_nsacls_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
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 netscaler

import (
"fmt"
"github.com/chiradeep/go-nitro/netscaler"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
"testing"
)

func TestAccNsacls_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckNsaclsDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccNsacls_basic,
},
},
})
}

func testAccCheckNsaclsDestroy(s *terraform.State) error {
nsClient := testAccProvider.Meta().(*NetScalerNitroClient).client

for _, rs := range s.RootModule().Resources {
if rs.Type != "netscaler_nsacls" {
continue
}

if rs.Primary.ID == "" {
return fmt.Errorf("No name is set")
}

}

return nil
}

const testAccNsacls_basic = `
resource "netscaler_nsacls" "foo" {
}
`

0 comments on commit f12cee0

Please sign in to comment.