Skip to content

Commit

Permalink
Fix windows_cis_enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Adi Shaull committed Jan 18, 2024
1 parent c8ab384 commit b54e4ec
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 28 deletions.
5 changes: 5 additions & 0 deletions aquasec/resource_image_assurance_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -1800,6 +1800,11 @@ func expandAssurancePolicy(d *schema.ResourceData, a_type string) *client.Assura
iap.LinuxCisEnabled = linux_cis_enabled.(bool)
}

windows_cis_enabled, ok := d.GetOk("windows_cis_enabled")
if ok {
iap.WindowsCisEnabled = windows_cis_enabled.(bool)
}

openshift_hardening_enabled, ok := d.GetOk("openshift_hardening_enabled")
if ok {
iap.OpenshiftHardeningEnabled = openshift_hardening_enabled.(bool)
Expand Down
56 changes: 28 additions & 28 deletions client/assurance_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

type AssurancePolicy struct {
AssuranceType string `json:"assurance_type"`
Id int `json:"id,omitempty"`
Id int `json:"id"`
Name string `json:"name"`
Author string `json:"author"`
Registry string `json:"registry,omitempty"`
Expand Down Expand Up @@ -185,19 +185,19 @@ type KubernetesControls struct {
type KubernetesControlsArray []KubernetesControls

// GetAssurancePolicy - returns single Assurance Policy
func (cli *Client) GetAssurancePolicy(name string, at string) (*AssurancePolicy, error) {
func (cli *Client) GetAssurancePolicy(name string, assuranceType string) (*AssurancePolicy, error) {
var err error
var response AssurancePolicy
var atype string
if strings.EqualFold(at, "host") {
if strings.EqualFold(assuranceType, "host") {
atype = "host"
} else if strings.EqualFold(at, "image") {
} else if strings.EqualFold(assuranceType, "image") {
atype = "image"
} else if strings.EqualFold(at, "function") {
} else if strings.EqualFold(assuranceType, "function") {
atype = "function"
} else if strings.EqualFold(at, "kubernetes") {
} else if strings.EqualFold(assuranceType, "kubernetes") {
atype = "kubernetes"
} else if strings.EqualFold(at, "cf_application") {
} else if strings.EqualFold(assuranceType, "cf_application") {
atype = "cf_application"
}

Expand Down Expand Up @@ -238,18 +238,18 @@ func (cli *Client) GetAssurancePolicy(name string, at string) (*AssurancePolicy,
}

// CreateAssurancePolicy - creates single Aqua Assurance Policy
func (cli *Client) CreateAssurancePolicy(assurancepolicy *AssurancePolicy, at string) error {
payload, err := json.Marshal(assurancepolicy)
func (cli *Client) CreateAssurancePolicy(assurancePolicy *AssurancePolicy, assuranceType string) error {
payload, err := json.Marshal(assurancePolicy)
var atype string
if strings.EqualFold(at, "host") {
if strings.EqualFold(assuranceType, "host") {
atype = "host"
} else if strings.EqualFold(at, "image") {
} else if strings.EqualFold(assuranceType, "image") {
atype = "image"
} else if strings.EqualFold(at, "function") {
} else if strings.EqualFold(assuranceType, "function") {
atype = "function"
} else if strings.EqualFold(at, "kubernetes") {
} else if strings.EqualFold(assuranceType, "kubernetes") {
atype = "kubernetes"
} else if strings.EqualFold(at, "cf_application") {
} else if strings.EqualFold(assuranceType, "cf_application") {
atype = "cf_application"
}

Expand Down Expand Up @@ -284,24 +284,24 @@ func (cli *Client) CreateAssurancePolicy(assurancepolicy *AssurancePolicy, at st
}

// UpdateAssurancePolicy updates an existing Assurance Policy
func (cli *Client) UpdateAssurancePolicy(assurancepolicy *AssurancePolicy, at string) error {
payload, err := json.Marshal(assurancepolicy)
func (cli *Client) UpdateAssurancePolicy(assurancePolicy *AssurancePolicy, assuranceType string) error {
payload, err := json.Marshal(assurancePolicy)
if err != nil {
return err
}
var atype string
if strings.EqualFold(at, "host") {
if strings.EqualFold(assuranceType, "host") {
atype = "host"
} else if strings.EqualFold(at, "image") {
} else if strings.EqualFold(assuranceType, "image") {
atype = "image"
} else if strings.EqualFold(at, "function") {
} else if strings.EqualFold(assuranceType, "function") {
atype = "function"
} else if strings.EqualFold(at, "kubernetes") {
} else if strings.EqualFold(assuranceType, "kubernetes") {
atype = "kubernetes"
} else if strings.EqualFold(at, "cf_application") {
} else if strings.EqualFold(assuranceType, "cf_application") {
atype = "cf_application"
}
apiPath := "/api/v2/assurance_policy/" + atype + "/" + assurancepolicy.Name
apiPath := "/api/v2/assurance_policy/" + atype + "/" + assurancePolicy.Name
request := cli.gorequest
err = cli.limiter.Wait(context.Background())
if err != nil {
Expand Down Expand Up @@ -329,18 +329,18 @@ func (cli *Client) UpdateAssurancePolicy(assurancepolicy *AssurancePolicy, at st
}

// DeleteAssurancePolicy removes a Assurance Policy
func (cli *Client) DeleteAssurancePolicy(name string, at string) error {
func (cli *Client) DeleteAssurancePolicy(name string, assuranceType string) error {
request := cli.gorequest
var atype string
if strings.EqualFold(at, "host") {
if strings.EqualFold(assuranceType, "host") {
atype = "host"
} else if strings.EqualFold(at, "image") {
} else if strings.EqualFold(assuranceType, "image") {
atype = "image"
} else if strings.EqualFold(at, "function") {
} else if strings.EqualFold(assuranceType, "function") {
atype = "function"
} else if strings.EqualFold(at, "kubernetes") {
} else if strings.EqualFold(assuranceType, "kubernetes") {
atype = "kubernetes"
} else if strings.EqualFold(at, "cf_application") {
} else if strings.EqualFold(assuranceType, "cf_application") {
atype = "cf_application"
}
apiPath := "/api/v2/assurance_policy/" + atype + "/" + name
Expand Down

0 comments on commit b54e4ec

Please sign in to comment.