Skip to content

Commit

Permalink
fix: Implemented requested feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Pauti committed Jun 17, 2024
1 parent a5f3d52 commit e75884c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions examples/resources/mondoo_compliance_framework/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ resource "mondoo_space" "my_space" {
org_id = var.mondoo_org
}

resource "mondoo_compliance_framework" "compliance_framework_example" {
resource "mondoo_framework_assignment" "compliance_framework_example" {
space_id = mondoo_space.my_space.id
framework_mrn = ["//policy.api.mondoo.app/frameworks/cis-controls-8",
"//policy.api.mondoo.app/frameworks/iso-27001-2022"]
enabled = false
enabled = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ resource "mondoo_space" "my_space" {
org_id = var.mondoo_org
}

resource "mondoo_custom_compliance_framework" "compliance_framework_example" {
resource "mondoo_custom_framework" "compliance_framework_example" {
space_id = mondoo_space.my_space.id
data_url = var.my_custom_framework
}
8 changes: 4 additions & 4 deletions internal/provider/compliance_framework_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type complianceFrameworkResourceModel struct {
}

func (r *complianceFrameworkResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_compliance_framework"
resp.TypeName = req.ProviderTypeName + "_framework_assignment"
}

func (r *complianceFrameworkResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
Expand Down Expand Up @@ -95,7 +95,7 @@ func (r *complianceFrameworkResource) Create(ctx context.Context, req resource.C
listFrameworks.ElementsAs(ctx, &frameworkList, true)

for _, mrn := range frameworkList {
err := r.client.UpdateComplianceFramework(ctx, string(mrn), scopeMrn, data.Enabled.ValueBool())
err := r.client.UpdateFramework(ctx, string(mrn), scopeMrn, data.Enabled.ValueBool())
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to update Compliance Framework, got error: %s", err))
return
Expand Down Expand Up @@ -142,7 +142,7 @@ func (r *complianceFrameworkResource) Update(ctx context.Context, req resource.U
listFrameworks.ElementsAs(ctx, &frameworkList, true)

for _, mrn := range frameworkList {
err := r.client.UpdateComplianceFramework(ctx, string(mrn), scopeMrn, data.Enabled.ValueBool())
err := r.client.UpdateFramework(ctx, string(mrn), scopeMrn, data.Enabled.ValueBool())
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to update Compliance Framework, got error: %s", err))
return
Expand Down Expand Up @@ -173,7 +173,7 @@ func (r *complianceFrameworkResource) Delete(ctx context.Context, req resource.D
listFrameworks.ElementsAs(ctx, &frameworkList, true)

for _, mrn := range frameworkList {
err := r.client.UpdateComplianceFramework(ctx, string(mrn), scopeMrn, false)
err := r.client.UpdateFramework(ctx, string(mrn), scopeMrn, false)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to update Compliance Framework, got error: %s", err))
return
Expand Down
10 changes: 5 additions & 5 deletions internal/provider/custom_compliance_framework_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type customComplianceFrameworkResourceModel struct {
}

func (r *customComplianceFrameworkResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_custom_compliance_framework"
resp.TypeName = req.ProviderTypeName + "_custom_framework"
}

type Framework struct {
Expand Down Expand Up @@ -132,13 +132,13 @@ func (r *customComplianceFrameworkResource) Create(ctx context.Context, req reso
return
}

err = r.client.UploadComplianceFramework(ctx, spaceMrn, content)
err = r.client.UploadFramework(ctx, spaceMrn, content)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to upload Compliance Framework, got error: %s", err))
return
}

framework, err := r.client.GetComplianceFramework(ctx, spaceMrn, data.SpaceId.ValueString(), uid)
framework, err := r.client.GetFramework(ctx, spaceMrn, data.SpaceId.ValueString(), uid)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to get Compliance Framework, got error: %s", err))
return
Expand Down Expand Up @@ -188,7 +188,7 @@ func (r *customComplianceFrameworkResource) Update(ctx context.Context, req reso
return
}

err = r.client.UploadComplianceFramework(ctx, spaceMrn, content)
err = r.client.UploadFramework(ctx, spaceMrn, content)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to upload Compliance Framework, got error: %s", err))
return
Expand All @@ -209,7 +209,7 @@ func (r *customComplianceFrameworkResource) Delete(ctx context.Context, req reso
}

// Do GraphQL request to API to update the resource.
err := r.client.DeleteComplianceFramework(ctx, data.Mrn.ValueString())
err := r.client.DeleteFramework(ctx, data.Mrn.ValueString())
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to delete Compliance Framework, got error: %s", err))
return
Expand Down
8 changes: 4 additions & 4 deletions internal/provider/gql.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ func (c *ExtendedGqlClient) SetScimGroupMapping(ctx context.Context, orgMrn stri
return c.Mutate(ctx, &setScimGroupMappingMutation, setScimGroupMappingInput, nil)
}

func (c *ExtendedGqlClient) UploadComplianceFramework(ctx context.Context, spaceMrn string, content []byte) error {
func (c *ExtendedGqlClient) UploadFramework(ctx context.Context, spaceMrn string, content []byte) error {
// Define the mutation struct according to the provided query
var uploadMutation struct {
UploadFramework bool `graphql:"uploadFramework(input: $input)"`
Expand All @@ -381,7 +381,7 @@ type ComplianceFrameworkPayload struct {
ScopeMrn mondoov1.String
}

func (c *ExtendedGqlClient) GetComplianceFramework(ctx context.Context, spaceMrn string, spaceId string, uid string) (*ComplianceFrameworkPayload, error) {
func (c *ExtendedGqlClient) GetFramework(ctx context.Context, spaceMrn string, spaceId string, uid string) (*ComplianceFrameworkPayload, error) {
// Define the query struct according to the provided query
var getFrameworkQuery struct {
ComplianceFramework ComplianceFrameworkPayload `graphql:"complianceFramework(input: $input)"`
Expand All @@ -406,7 +406,7 @@ func (c *ExtendedGqlClient) GetComplianceFramework(ctx context.Context, spaceMrn
return &getFrameworkQuery.ComplianceFramework, nil
}

func (c *ExtendedGqlClient) UpdateComplianceFramework(ctx context.Context, frameworkMrn string, scopeMrn string, enabled bool) error {
func (c *ExtendedGqlClient) UpdateFramework(ctx context.Context, frameworkMrn string, scopeMrn string, enabled bool) error {
var updateMutation struct {
ApplyFramework bool `graphql:"applyFrameworkMutation(input: $input)"`
}
Expand All @@ -426,7 +426,7 @@ func (c *ExtendedGqlClient) UpdateComplianceFramework(ctx context.Context, frame
}
}

func (c *ExtendedGqlClient) DeleteComplianceFramework(ctx context.Context, mrn string) error {
func (c *ExtendedGqlClient) DeleteFramework(ctx context.Context, mrn string) error {
// Define the mutation struct according to the provided query
var deleteMutation struct {
DeleteFramework bool `graphql:"deleteFramework(input: $input)"`
Expand Down

0 comments on commit e75884c

Please sign in to comment.