Skip to content

Commit

Permalink
fix: type assertion
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Theuermann <[email protected]>
  • Loading branch information
mati007thm committed Dec 2, 2024
1 parent a464241 commit 2a5f48f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
6 changes: 3 additions & 3 deletions examples/resources/mondoo_exception/resource.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
provider "mondoo" {
space = "eu-pensive-diffie-562318"
space = "eu-heuristic-hawking-332652"
}

resource "mondoo_exception" "exception" {
valid_until = "2024-12-03"
# valid_until = "2024-12-03"
justification = "This is a test exception"
action ="DISABLE"
# check_mrns = ["//policy.api.mondoo.app/queries/mondoo-http-security-x-content-type-options-nosniff"]
check_mrns = ["//policy.api.mondoo.app/queries/mondoo-http-security-x-content-type-options-nosniff"]
check_mrns = ["//policy.api.mondoo.app/queries/mondoo-http-security-content-security-policy"]
}
14 changes: 4 additions & 10 deletions internal/provider/exception_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,11 @@ func (r *exceptionResource) Create(ctx context.Context, req resource.CreateReque
}
ctx = tflog.SetField(ctx, "scope_mrn", scope.MRN())

checks := make([]string, 0)
checkMrns := data.CheckMrns.Elements()
for _, check := range checkMrns {
checks = append(checks, check.(types.String).ValueString())
}
checks := []string{}
data.CheckMrns.ElementsAs(ctx, &checks, false)

vulnerabilities := make([]string, 0)
vulnerabilityMrns := data.VulnerabilityMrns.Elements()
for _, vulnerability := range vulnerabilityMrns {
vulnerabilities = append(vulnerabilities, vulnerability.(types.String).ValueString())
}
vulnerabilities := []string{}
data.VulnerabilityMrns.ElementsAs(ctx, &vulnerabilities, false)

// Format ValidUntil to RFC3339 if provided
var validUntilStr string
Expand Down
17 changes: 17 additions & 0 deletions internal/provider/gql.go
Original file line number Diff line number Diff line change
Expand Up @@ -975,3 +975,20 @@ func (c *ExtendedGqlClient) ApplyException(

return c.Mutate(ctx, &applyException, input, nil)
}

// ListExceptionGroup

Check failure on line 979 in internal/provider/gql.go

View workflow job for this annotation

GitHub Actions / Build

Comment should end in a period (godot)
func (c *ExtendedGqlClient) ListExceptionGroup(ctx context.Context, scopeMrn string) ([]mondoov1.ExceptionGroupsInput, error) {
var q struct {
ExceptionGroups []mondoov1.ExceptionGroupsInput `graphql:"exceptionGroups(scopeMrn: $scopeMrn)"`
}
variables := map[string]interface{}{
"scopeMrn": mondoov1.String(scopeMrn),
}

err := c.Query(ctx, &q, variables)
if err != nil {
return nil, err
}

return q.ExceptionGroups, nil
}

0 comments on commit 2a5f48f

Please sign in to comment.