terraform-provider-databricks icon indicating copy to clipboard operation
terraform-provider-databricks copied to clipboard

[Draft] Add compliance security profile setting

Open harshshah-db opened this issue 9 months ago • 2 comments

Changes

Tests

  • [ ] make test run locally
  • [ ] relevant change in docs/ folder
  • [ ] covered with integration tests in internal/acceptance
  • [ ] relevant acceptance tests are passing
  • [ ] using Go SDK

harshshah-db avatar May 10 '24 06:05 harshshah-db

Hi @tanmay-db @alexott @nkvuong @hectorcast-db the test in this PR fails with the following error. Any idea what could be wrong? I already spent hours trying a bunch of stuff but I suspect I am not defining the compliance_standards field properly. Would appreciate any advice/insight.

=== Failed
=== FAIL: settings TestQueryCreateComplianceSecurityProfileSettingWithNoneStandard (0.00s)
    resource_compliance_security_profile_setting_test.go:82:
        	Error Trace:	/Users/harsh.shah/terraform-provider-databricks/settings/resource_compliance_security_profile_setting_test.go:82
        	Error:      	Received unexpected error:
        	            	compliance_security_profile_workspace: compliance_security_profile_workspace: compliance_standards: [compliance_standards]: not resource
        	Test:       	TestQueryCreateComplianceSecurityProfileSettingWithNoneStandard
  

harshshah-db avatar May 10 '24 06:05 harshshah-db

Hi @tanmay-db @alexott @nkvuong @hectorcast-db the test in this PR fails with the following error. Any idea what could be wrong? I already spent hours trying a bunch of stuff but I suspect I am not defining the compliance_standards field properly. Would appreciate any advice/insight.

=== Failed
=== FAIL: settings TestQueryCreateComplianceSecurityProfileSettingWithNoneStandard (0.00s)
    resource_compliance_security_profile_setting_test.go:82:
        	Error Trace:	/Users/harsh.shah/terraform-provider-databricks/settings/resource_compliance_security_profile_setting_test.go:82
        	Error:      	Received unexpected error:
        	            	compliance_security_profile_workspace: compliance_security_profile_workspace: compliance_standards: [compliance_standards]: not resource
        	Test:       	TestQueryCreateComplianceSecurityProfileSettingWithNoneStandard
  

the issue is with https://github.com/databricks/terraform-provider-databricks/blob/31df20c094cef22242ec6e43f3536ba2719e2bb8/common/reflect_resource.go#L631

basically it tries to convert https://github.com/databricks/databricks-sdk-go/blob/27d08a67df5b0d35544c663f9d47577f85ffc6e4/service/settings/model.go#L199 to a Terraform resource and crashed. []ComplianceStandard crashed, but []string does not.

@edwardfeng-db you last worked on this function, any thoughts?

nkvuong avatar May 10 '24 08:05 nkvuong

Yeah it seems kind of strange to me that this is a []ComplianceStandard instead of []string, @hectorcast-db is this autogenerated? Any idea why?

edwardfeng-db avatar May 13 '24 16:05 edwardfeng-db

@edwardfeng-db It is a ComplianceStandard because it is an enum and Go does not support enums directly. We create a new type from string

type ComplianceStandard string

We do this for all enums, so I am not sure why would cause an issue now.

hectorcast-db avatar May 14 '24 12:05 hectorcast-db

Thanks @hectorcast-db, yeah this seems like a legit bug on the terraform side, I'll try to fix this

edwardfeng-db avatar May 14 '24 17:05 edwardfeng-db

Thanks @hectorcast-db, yeah this seems like a legit bug on the terraform side, I'll try to fix this

@edwardfeng-db any ETA on the fix? This is blocking our public api launch which the customers have been asking for.

harshshah-db avatar May 14 '24 21:05 harshshah-db

@harshshah-db Hopefully today, still debugging

edwardfeng-db avatar May 15 '24 08:05 edwardfeng-db

Here's the fix - https://github.com/databricks/terraform-provider-databricks/pull/3581 Verified it works with the failing test

edwardfeng-db avatar May 15 '24 09:05 edwardfeng-db

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 82.58%. Comparing base (bd32bf3) to head (a976e1b).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3564      +/-   ##
==========================================
+ Coverage   82.57%   82.58%   +0.01%     
==========================================
  Files         188      189       +1     
  Lines       19191    19207      +16     
==========================================
+ Hits        15847    15863      +16     
  Misses       2414     2414              
  Partials      930      930              
Files Coverage Δ
settings/all_settings.go 100.00% <100.00%> (ø)
...gs/resource_compliance_security_profile_setting.go 100.00% <100.00%> (ø)

codecov-commenter avatar May 15 '24 16:05 codecov-commenter

@nkvuong and @alexott - Could you please review this again?

harshshah-db avatar May 15 '24 19:05 harshshah-db