Skip to content

Commit

Permalink
adding vendor sync changes
Browse files Browse the repository at this point in the history
  • Loading branch information
RavinderReddyF5 committed Sep 29, 2023
1 parent be9ca2f commit 72c12b6
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 37 deletions.
44 changes: 32 additions & 12 deletions bigip/resource_bigip_ltm_cipher_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ package bigip
import (
"context"
"fmt"
"log"
"os"
"strings"

bigip "github.com/f5devcentral/go-bigip"
"github.com/f5devcentral/go-bigip/f5teem"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"log"
)

func resourceBigipLtmCipherGroup() *schema.Resource {
Expand Down Expand Up @@ -67,15 +72,32 @@ func resourceBigipLtmCipherGroupCreate(ctx context.Context, d *schema.ResourceDa

cipherGrouptmp := &bigip.CipherGroupReq{}
cipherGrouptmp.Name = name
cipherGroup, err := getCipherGroupConfig(d, cipherGrouptmp)
if err != nil {
return diag.FromErr(fmt.Errorf("reading input config failed(%s): %s", name, err))
}
cipherGroup := getCipherGroupConfig(d, cipherGrouptmp)

log.Printf("[INFO] cipherGroup config :%+v", cipherGroup)
err = client.AddLtmCipherGroup(cipherGroup)
err := client.AddLtmCipherGroup(cipherGroup)
if err != nil {
return diag.FromErr(fmt.Errorf("error creating cipher rule (%s): %s", name, err))
}
if !client.Teem {
id := uuid.New()
uniqueID := id.String()
assetInfo := f5teem.AssetInfo{
Name: "Terraform-provider-bigip",
Version: client.UserAgent,
Id: uniqueID,
}
apiKey := os.Getenv("TEEM_API_KEY")
teemDevice := f5teem.AnonymousClient(assetInfo, apiKey)
f := map[string]interface{}{
"Terraform Version": client.UserAgent,
}
tsVer := strings.Split(client.UserAgent, "/")
err = teemDevice.Report(f, "bigip_ltm_cipher_group", tsVer[3])
if err != nil {
log.Printf("[ERROR]Sending Telemetry data failed:%v", err)
}
}
d.SetId(name)
return resourceBigipLtmCipherGroupRead(ctx, d, meta)
}
Expand All @@ -101,10 +123,8 @@ func resourceBigipLtmCipherGroupUpdate(ctx context.Context, d *schema.ResourceDa
name := d.Id()
cipherGrouptmp := &bigip.CipherGroupReq{}
cipherGrouptmp.Name = name
cipherGroupconfig, err := getCipherGroupConfig(d, cipherGrouptmp)
if err != nil {
return diag.FromErr(fmt.Errorf("reading input config failed(%s): %s", name, err))
}
cipherGroupconfig := getCipherGroupConfig(d, cipherGrouptmp)

if err := client.ModifyLtmCipherGroup(name, cipherGroupconfig); err != nil {
return diag.FromErr(fmt.Errorf("error modifying cipher group %s: %v", name, err))
}
Expand All @@ -127,7 +147,7 @@ func resourceBigipLtmCipherGroupDelete(ctx context.Context, d *schema.ResourceDa
return nil
}

func getCipherGroupConfig(d *schema.ResourceData, cipherGroup *bigip.CipherGroupReq) (*bigip.CipherGroupReq, error) {
func getCipherGroupConfig(d *schema.ResourceData, cipherGroup *bigip.CipherGroupReq) *bigip.CipherGroupReq {
cipherGroup.Ordering = d.Get("ordering").(string)
if p, ok := d.GetOk("allow"); ok {
for _, r := range p.(*schema.Set).List() {
Expand All @@ -139,5 +159,5 @@ func getCipherGroupConfig(d *schema.ResourceData, cipherGroup *bigip.CipherGroup
cipherGroup.Require = append(cipherGroup.Require, r.(string))
}
}
return cipherGroup, nil
return cipherGroup
}
6 changes: 4 additions & 2 deletions bigip/resource_bigip_ltm_cipher_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import (

const testCipherGroupConfigTC1 = `
resource "bigip_ltm_cipher_group" "test-cipher-group" {
name = "/Common/test-cipher-group-01"
//cipher = "aes"
name = "/Common/test-cipher-group-01"
allow = ["/Common/f5-aes"]
require = ["/Common/f5-quic"]
ordering = "speed"
}
`

Expand Down
17 changes: 6 additions & 11 deletions bigip/resource_bigip_ltm_cipher_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,10 @@ func resourceBigipLtmCipherRuleCreate(ctx context.Context, d *schema.ResourceDat

cipherRuletmp := &bigip.CipherRuleReq{}
cipherRuletmp.Name = name
cipherRule, err := getCipherRuleConfig(d, cipherRuletmp)
if err != nil {
return diag.FromErr(fmt.Errorf("reading input config failed(%s): %s", name, err))
}
cipherRule := getCipherRuleConfig(d, cipherRuletmp)

log.Printf("[INFO] cipherRule config :%+v", cipherRule)
err = client.AddLtmCipherRule(cipherRule)
err := client.AddLtmCipherRule(cipherRule)
if err != nil {
return diag.FromErr(fmt.Errorf("error creating cipher rule (%s): %s", name, err))
}
Expand Down Expand Up @@ -123,10 +121,7 @@ func resourceBigipLtmCipherRuleUpdate(ctx context.Context, d *schema.ResourceDat
name := d.Id()
cipherRuletmp := &bigip.CipherRuleReq{}
cipherRuletmp.Name = name
cipheRuleconfig, err := getCipherRuleConfig(d, cipherRuletmp)
if err != nil {
return diag.FromErr(fmt.Errorf("reading input config failed(%s): %s", name, err))
}
cipheRuleconfig := getCipherRuleConfig(d, cipherRuletmp)
if err := client.ModifyLtmCipherRule(name, cipheRuleconfig); err != nil {
return diag.FromErr(fmt.Errorf("error modifying cipher rule %s: %v", name, err))
}
Expand All @@ -145,10 +140,10 @@ func resourceBigipLtmCipherRuleDelete(ctx context.Context, d *schema.ResourceDat
d.SetId("")
return nil
}
func getCipherRuleConfig(d *schema.ResourceData, cipherRule *bigip.CipherRuleReq) (*bigip.CipherRuleReq, error) {
func getCipherRuleConfig(d *schema.ResourceData, cipherRule *bigip.CipherRuleReq) *bigip.CipherRuleReq {
cipherRule.Cipher = d.Get("cipher").(string)
cipherRule.DhGroups = d.Get("dh_groups").(string)
cipherRule.SignatureAlgorithms = d.Get("signature_algorithms").(string)
cipherRule.Description = d.Get("description").(string)
return cipherRule, nil
return cipherRule
}
7 changes: 4 additions & 3 deletions bigip/resource_bigip_ltm_cipher_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ package bigip

import (
"fmt"
"testing"

bigip "github.com/f5devcentral/go-bigip"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"testing"
)

const testCipherRuleConfigTC1 = `
resource "bigip_ltm_cipher_rule" "test-cipher-rule" {
name = "/Common/test-cipher-rule"
cipher = "aes"
name = "/Common/test-cipher-rule"
cipher = "aes"
}
`

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ require (
github.com/Azure/azure-storage-blob-go v0.13.0
github.com/Azure/go-autorest/autorest v0.11.18
github.com/Azure/go-autorest/autorest/adal v0.9.13
github.com/f5devcentral/go-bigip v0.0.0-20230825175646-ebe63e33298c
github.com/f5devcentral/go-bigip/f5teem v0.0.0-20230825175646-ebe63e33298c
github.com/f5devcentral/go-bigip v0.0.0-20230929101300-4ca00e7ed5fc
github.com/f5devcentral/go-bigip/f5teem v0.0.0-20230929101300-4ca00e7ed5fc
github.com/google/uuid v1.3.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.25.0
github.com/stretchr/testify v1.8.4
Expand Down
9 changes: 5 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,10 @@ github.com/envoyproxy/go-control-plane v0.10.3/go.mod h1:fJJn/j26vwOu972OllsvAgJ
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/envoyproxy/protoc-gen-validate v0.6.7/go.mod h1:dyJXwwfPK2VSqiB9Klm1J6romD608Ba7Hij42vrOBCo=
github.com/envoyproxy/protoc-gen-validate v0.9.1/go.mod h1:OKNgG7TCp5pF4d6XftA0++PMirau2/yoOwVac3AbF2w=
github.com/f5devcentral/go-bigip v0.0.0-20230825175646-ebe63e33298c h1:T9+v2O4pFkDjASOoPhSOoBKU5BhqIDg1ndZg1sGjLxs=
github.com/f5devcentral/go-bigip v0.0.0-20230825175646-ebe63e33298c/go.mod h1:JZj/iVxDmEnGPyEwuNj7x0fuH2CtUBbD2J48MMp/SE8=
github.com/f5devcentral/go-bigip/f5teem v0.0.0-20230825175646-ebe63e33298c h1:CxHMUixpOiK00IvO1ql2hEa5QPLfiV+/zy/izf98eGM=
github.com/f5devcentral/go-bigip/f5teem v0.0.0-20230825175646-ebe63e33298c/go.mod h1:r7o5I22EvO+fps2u10bz4ZUlTlNHopQSWzVcW19hK3U=
github.com/f5devcentral/go-bigip v0.0.0-20230929101300-4ca00e7ed5fc h1:jWmvlICHswmQEL4qUc6CxIsQy2Guxwk4uE6jJWiE5/o=
github.com/f5devcentral/go-bigip v0.0.0-20230929101300-4ca00e7ed5fc/go.mod h1:0Lkr0fBU6O1yBxF2mt9JFwXpaFbIb/wAY7oM3dMJDdA=
github.com/f5devcentral/go-bigip/f5teem v0.0.0-20230929101300-4ca00e7ed5fc h1:tlODenRp43vLPGE20j+fgrDPNNH2MJ6HyqDcLKjYOmo=
github.com/f5devcentral/go-bigip/f5teem v0.0.0-20230929101300-4ca00e7ed5fc/go.mod h1:r7o5I22EvO+fps2u10bz4ZUlTlNHopQSWzVcW19hK3U=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
Expand Down Expand Up @@ -749,6 +749,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
Expand Down
6 changes: 3 additions & 3 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ github.com/apparentlymart/go-textseg/v13/textseg
# github.com/davecgh/go-spew v1.1.1
## explicit
github.com/davecgh/go-spew/spew
# github.com/f5devcentral/go-bigip v0.0.0-20230825175646-ebe63e33298c
## explicit
# github.com/f5devcentral/go-bigip v0.0.0-20230929101300-4ca00e7ed5fc
## explicit; go 1.20
github.com/f5devcentral/go-bigip
# github.com/f5devcentral/go-bigip/f5teem v0.0.0-20230825175646-ebe63e33298c
# github.com/f5devcentral/go-bigip/f5teem v0.0.0-20230929101300-4ca00e7ed5fc
## explicit; go 1.13
github.com/f5devcentral/go-bigip/f5teem
# github.com/fatih/color v1.13.0
Expand Down

0 comments on commit 72c12b6

Please sign in to comment.