Skip to content

Commit e7f1993

Browse files
authored
Support overriding the platform id for terraform provider (#5843)
1 parent 8cecb99 commit e7f1993

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

providers/terraform/provider/detector.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ func (s *Service) detect(asset *inventory.Asset, _ *connection.Connection) error
6161
return err
6262
}
6363
platformID := "//platformid.api.mondoo.app/runtime/terraform/domain/" + domain + "/org/" + org + "/repo/" + repo
64-
asset.Connections[0].PlatformId = platformID
65-
asset.PlatformIds = []string{platformID}
64+
if len(asset.PlatformIds) == 0 {
65+
asset.PlatformIds = []string{platformID}
66+
}
67+
asset.Connections[0].PlatformId = asset.PlatformIds[0]
6668
asset.Name = "Terraform Static Analysis " + org + "/" + repo
6769
return nil
6870
}
@@ -74,8 +76,10 @@ func (s *Service) detect(asset *inventory.Asset, _ *connection.Connection) error
7476
h.Write([]byte(absPath))
7577
hash := hex.EncodeToString(h.Sum(nil))
7678
platformID := "//platformid.api.mondoo.app/runtime/terraform/hash/" + hash
77-
asset.Connections[0].PlatformId = platformID
78-
asset.PlatformIds = []string{platformID}
79+
if len(asset.PlatformIds) == 0 {
80+
asset.PlatformIds = []string{platformID}
81+
}
82+
asset.Connections[0].PlatformId = asset.PlatformIds[0]
7983
asset.Name = "Terraform Static Analysis " + parseNameFromPath(projectPath)
8084
return nil
8185
}

0 commit comments

Comments
 (0)