Skip to content

Commit e5fa378

Browse files
authored
feat(cloudauth): component version (#539)
1 parent cb99f38 commit e5fa378

4 files changed

+15
-0
lines changed

sysdig/common.go

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const (
4848
SchemaMonitorCloudMetrics = "monitor_cloud_metrics"
4949
SchemaType = "type"
5050
SchemaInstance = "instance"
51+
SchemaVersion = "version"
5152
SchemaCloudConnectorMetadata = "cloud_connector_metadata"
5253
SchemaTrustedRoleMetadata = "trusted_role_metadata"
5354
SchemaEventBridgeMetadata = "event_bridge_metadata"

sysdig/resource_sysdig_secure_cloud_auth_account.go

+7
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ var (
3333
Type: schema.TypeString,
3434
Required: true,
3535
},
36+
SchemaVersion: {
37+
Type: schema.TypeString,
38+
Optional: true,
39+
},
3640
SchemaCloudConnectorMetadata: {
3741
Type: schema.TypeString,
3842
Optional: true,
@@ -373,6 +377,8 @@ func constructAccountComponents(data *schema.ResourceData) []*cloudauth.AccountC
373377
component.Type = cloudauth.Component(cloudauth.Component_value[value.(string)])
374378
case SchemaInstance:
375379
component.Instance = value.(string)
380+
case SchemaVersion:
381+
component.Version = value.(string)
376382
case SchemaCloudConnectorMetadata:
377383
component.Metadata = &cloudauth.AccountComponent_CloudConnectorMetadata{CloudConnectorMetadata: &cloudauth.CloudConnectorMetadata{}}
378384
err = protojson.Unmarshal([]byte(value.(string)), component.GetCloudConnectorMetadata())
@@ -484,6 +490,7 @@ func componentsToResourceData(components []*cloudauth.AccountComponent) []map[st
484490
resourceData := map[string]interface{}{}
485491
resourceData[SchemaType] = component.GetType().String()
486492
resourceData[SchemaInstance] = component.GetInstance()
493+
resourceData[SchemaVersion] = component.GetVersion()
487494

488495
switch component.GetType() {
489496
case cloudauth.Component_COMPONENT_CLOUD_CONNECTOR:

sysdig/resource_sysdig_secure_cloud_auth_account_component.go

+6
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ func cloudauthAccountComponentFromResourceData(data *schema.ResourceData) *v2.Cl
175175
AccountComponent: cloudauth.AccountComponent{
176176
Type: cloudauth.Component(cloudauth.Component_value[data.Get(SchemaType).(string)]),
177177
Instance: data.Get(SchemaInstance).(string),
178+
Version: data.Get(SchemaVersion).(string),
178179
},
179180
}
180181
// XXX: naive but simple approach to read resource data, and check for the metadata schema type passed (only one of the types will be passed)
@@ -243,6 +244,11 @@ func cloudauthAccountComponentToResourceData(data *schema.ResourceData, cloudAcc
243244
return err
244245
}
245246

247+
err = data.Set(SchemaVersion, cloudAccountComponent.GetVersion())
248+
if err != nil {
249+
return err
250+
}
251+
246252
// XXX: naive but simple approach to read accountComponent object from cloudauth, and check for the metadata proto type (only one of the types will be returned)
247253
// then, populate the respective appropriate metadata schema in resource data.
248254
switch cloudAccountComponent.GetType() {

sysdig/resource_sysdig_secure_cloud_auth_account_component_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ resource "sysdig_secure_cloud_auth_account_component" "azure_service_principal"
7171
account_id = sysdig_secure_cloud_auth_account.azure_sample.id
7272
type = "COMPONENT_SERVICE_PRINCIPAL"
7373
instance = "secure-posture"
74+
version = "v1.0.0"
7475
service_principal_metadata = jsonencode({
7576
azure = {
7677
active_directory_service_principal = {

0 commit comments

Comments
 (0)