-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1611 from bschaatsbergen/google-compute-ssl-cert-…
…support Add `google_compute_ssl_certificate` resource
- Loading branch information
Showing
21 changed files
with
441 additions
and
1 deletion.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
enumeration/remote/google/google_compute_ssl_certificate_enumerator.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package google | ||
|
||
import ( | ||
remoteerror "github.com/snyk/driftctl/enumeration/remote/error" | ||
"github.com/snyk/driftctl/enumeration/remote/google/repository" | ||
"github.com/snyk/driftctl/enumeration/resource" | ||
"github.com/snyk/driftctl/enumeration/resource/google" | ||
) | ||
|
||
type GoogleComputeSslCertificateEnumerator struct { | ||
repository repository.AssetRepository | ||
factory resource.ResourceFactory | ||
} | ||
|
||
func NewGoogleComputeSslCertificateEnumerator(repo repository.AssetRepository, factory resource.ResourceFactory) *GoogleComputeSslCertificateEnumerator { | ||
return &GoogleComputeSslCertificateEnumerator{ | ||
repository: repo, | ||
factory: factory, | ||
} | ||
} | ||
|
||
func (e *GoogleComputeSslCertificateEnumerator) SupportedType() resource.ResourceType { | ||
return google.GoogleComputeSslCertificateResourceType | ||
} | ||
|
||
func (e *GoogleComputeSslCertificateEnumerator) Enumerate() ([]*resource.Resource, error) { | ||
sslCertificates, err := e.repository.SearchAllSslCertificates() | ||
if err != nil { | ||
return nil, remoteerror.NewResourceListingError(err, string(e.SupportedType())) | ||
} | ||
|
||
results := make([]*resource.Resource, 0, len(sslCertificates)) | ||
for _, res := range sslCertificates { | ||
results = append( | ||
results, | ||
e.factory.CreateAbstractResource( | ||
string(e.SupportedType()), | ||
trimResourceName(res.GetName()), | ||
map[string]interface{}{}, | ||
), | ||
) | ||
} | ||
|
||
return results, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 39 additions & 1 deletion
40
enumeration/remote/google/repository/mock_AssetRepository.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
enumeration/resource/google/google_compute_ssl_certificate.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package google | ||
|
||
const GoogleComputeSslCertificateResourceType = "google_compute_ssl_certificate" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
pkg/iac/terraform/state/test/google_compute_ssl_certificate/results.golden.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[ | ||
{ | ||
"Id": "projects/driftctl/global/sslCertificates/my-certificate-6cb457f7", | ||
"Type": "google_compute_ssl_certificate", | ||
"Attrs": { | ||
"certificate": "-----BEGIN CERTIFICATE-----\nMIIDjjCCAnYCCQCtS+GNvuG/2zANBgkqhkiG9w0BAQsFADCBiDELMA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+8MkXUtZBAUhJUFYL+ZXBbh7lhg6yMDqkkDmraYumotMYwseuUz25PX9oglPyGB7\nmDwRDxz1VYpQ+TUtEwibv0FR6NXLOwZLorZVuZAxlzPJQNCHLAPQALd18CEVX6lq\nrmo=\n-----END CERTIFICATE-----\n", | ||
"certificate_id": 8486823339612136543, | ||
"creation_timestamp": "2023-01-11T07:50:08.574-08:00", | ||
"description": "", | ||
"id": "projects/driftctl/global/sslCertificates/my-certificate-6cb457f7", | ||
"name": "my-certificate-6cb457f7", | ||
"private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAxiYkTAwMy27FJzinPPrKc1kn5tjdS6Mf7ky/DZKszTSgq+RV\nZSVSmXDi7rJgMz7NFFiahuQ5m7HXTqHysn2p2ddr/wA58FB/vrieXv9HIJit9I57\nyDajKy87NmsLeV8A9j1tmWwIodvdrJTrlybfylflWbT91KFH6dhpfaiWxaSP6dqn\npvLnTcqekOl0ii+MljuIz7mzf6CSxkarWl8D1tsIAFrVnxm0wOaOMWzCrvOq9Qzw\nfXtkIHbgTy52CU42bRAuh5BDpP3NR7fSBONMQrvkwAuRTcjkL+oa0g8iVH1FJz4s\neUoMnrdDHvrtZDENxdam8P21gOJh4CJP8GmXWwIDAQABAoIBAGvNPnwdJizbY+mV\nue7EJragr8O5ApRu+CVGnb69qMOvuSYrgIYZyxltwBjK9OmMZjiGh/ORYQIivBes\npgSTt3+r4raGIf9rXESf3pGiYskKJ8HgbtmbWCRbeuR9Um3C0RwmiWUp0Hx2yOBm\n2NGQNbq5HS8z99DhueUwdxwFR5nYmvxwwZLvtNXNa6cS2DHRcKql8T6eEmTApi9n\nnx5MQZaeSZNoU4l8Cx0SW0DyHqNuWmmPHL8ICpYxlrrUB3+c4cdj6KKcjBniLZ7l\njP/FBzNbGUZa5JGAC52BcLbTLEIkxidIw4g2CwM1Ihdt+kSuimaV7w5bIpLdvp3G\nfRFacRECgYEA9SVAi9d6fcR279t7LgTs+s+QkcyR7dHyKdBMTjP5F13r3fGpLUMo\n0oMk58ZqTfvWCR/bkQcj1KilauNjagUvy93Un530stWRWZp7DdSX0YhI7LlTfZwR\nIh3V/Zzkd7dqkdEI7pTqD3BT8T7l/mG6fJC7ETCAwAglIWjZpdbtcfMCgYEAzuwt\n9u/DfLQCeWxJDYddys41pVKG70tlI65yIrERgp6ojjoEr8cA9I5vDqALg0Gv/R5w\nSdBUWLgvVi94HdUAX2Zjae6ljD2gTw0o6/wRYwvS+zt/V33JyTmcXacZMnZosTm2\nIxFul2HspAuieTm6db5MmtcjryxMsFNKR/OBtvkCgYA12G/cB4FtPIkPWDsvOX+/\n+3V6wN9QyGuTiaApETtmSYf0YQ9S1MyTqKCjlC5nYKh7qpa0vUe+fyiOWNHOSMNd\n2STJxo0n9scNUmQy/n42VOQHsxFGptAQmVMWeK6qKQxsaOi4VtcuevLFK5ajEF5A\n3B1qwieVhnR5aSldRt8yxwKBgCBoLOq3sk4dgyWxJ9/Oi4nvsccqnadsj3J/J7D3\nOl7SqmNcAs/kwumKRSptNmBgMUfbNIra7drXPdKprI4/hcdrKba1gYftPuYikX4k\nBDUW7Pwb3V2+fZPeSfcA7JlSoiLffv8PA9sBoyYuDEwgFmvKWgUGHLian4geA0wx\nfudBAoGBAKQZb9n3PvJfwSUhXqw+zv9PF+Av9GpPq7iGtg1JV3B2u++I/E8+Orrg\nT2K9DJL+VocN7WPcxxNLlB1CsD7/Kqwbc7P7q9NBpCrZ8SurhOv3YcFSfG+qTDAn\n+b83SrGV7SObUg8NS/vAu9LfYAyz3PllfteXaIvV/e9DMumXFKD1\n-----END RSA PRIVATE KEY-----\n", | ||
"project": "driftctl", | ||
"self_link": "https://www.googleapis.com/compute/v1/projects/driftctl/global/sslCertificates/my-certificate-6cb457f7" | ||
} | ||
} | ||
] |
37 changes: 37 additions & 0 deletions
37
pkg/iac/terraform/state/test/google_compute_ssl_certificate/terraform.tfstate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"version": 4, | ||
"terraform_version": "1.3.7", | ||
"serial": 5, | ||
"lineage": "4c753da3-3a2d-b3e1-7dda-9434691ff386", | ||
"outputs": {}, | ||
"resources": [ | ||
{ | ||
"mode": "managed", | ||
"type": "google_compute_ssl_certificate", | ||
"name": "default", | ||
"provider": "provider[\"registry.terraform.io/hashicorp/google\"]", | ||
"instances": [ | ||
{ | ||
"schema_version": 0, | ||
"attributes": { | ||
"certificate": "-----BEGIN CERTIFICATE-----\nMIIDjjCCAnYCCQCtS+GNvuG/2zANBgkqhkiG9w0BAQsFADCBiDELMAkGA1UEBhMC\nTkwxFjAUBgNVBAgMDU5vcnRoLUhvbGxhbmQxEjAQBgNVBAcMCUFtc3RlcmRhbTER\nMA8GA1UECgwIRHJpZnRDVEwxFDASBgNVBAMMC2V4YW1wbGUuY29tMSQwIgYJKoZI\nhvcNAQkBFhVkcmlmdGN0bEBkcmlmdGN0bC5jb20wHhcNMjMwMTExMTU1MDAyWhcN\nMjQwMTExMTU1MDAyWjCBiDELMAkGA1UEBhMCTkwxFjAUBgNVBAgMDU5vcnRoLUhv\nbGxhbmQxEjAQBgNVBAcMCUFtc3RlcmRhbTERMA8GA1UECgwIRHJpZnRDVEwxFDAS\nBgNVBAMMC2V4YW1wbGUuY29tMSQwIgYJKoZIhvcNAQkBFhVkcmlmdGN0bEBkcmlm\ndGN0bC5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDGJiRMDAzL\nbsUnOKc8+spzWSfm2N1Lox/uTL8NkqzNNKCr5FVlJVKZcOLusmAzPs0UWJqG5Dmb\nsddOofKyfanZ12v/ADnwUH++uJ5e/0cgmK30jnvINqMrLzs2awt5XwD2PW2ZbAih\n292slOuXJt/KV+VZtP3UoUfp2Gl9qJbFpI/p2qem8udNyp6Q6XSKL4yWO4jPubN/\noJLGRqtaXwPW2wgAWtWfGbTA5o4xbMKu86r1DPB9e2QgduBPLnYJTjZtEC6HkEOk\n/c1Ht9IE40xCu+TAC5FNyOQv6hrSDyJUfUUnPix5Sgyet0Me+u1kMQ3F1qbw/bWA\n4mHgIk/waZdbAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAENAaZXP5ECfGEw/rnRM\n5zfEudp+Y6H/ldGiaOr2E3t8qKOvDCbvV20dz1qvAbns3ol/dVByYRgQwc6GxWdz\nwhCDNUAj/22erTriAQbHfgPAa7Oi9LwBCmUmXqqA/KYOeWNXz9VrsUzCKlSIL7kX\noGuS1CmwNOSvE6AWpixS4epGUy4D721tIV90URhQGKvJmM3/KJe6ktiYxJ08mPLJ\n+8MkXUtZBAUhJUFYL+ZXBbh7lhg6yMDqkkDmraYumotMYwseuUz25PX9oglPyGB7\nmDwRDxz1VYpQ+TUtEwibv0FR6NXLOwZLorZVuZAxlzPJQNCHLAPQALd18CEVX6lq\nrmo=\n-----END CERTIFICATE-----\n", | ||
"certificate_id": 8486823339612136543, | ||
"creation_timestamp": "2023-01-11T07:50:08.574-08:00", | ||
"description": "", | ||
"id": "projects/driftctl/global/sslCertificates/my-certificate-6cb457f7", | ||
"name": "my-certificate-6cb457f7", | ||
"name_prefix": null, | ||
"private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAxiYkTAwMy27FJzinPPrKc1kn5tjdS6Mf7ky/DZKszTSgq+RV\nZSVSmXDi7rJgMz7NFFiahuQ5m7HXTqHysn2p2ddr/wA58FB/vrieXv9HIJit9I57\nyDajKy87NmsLeV8A9j1tmWwIodvdrJTrlybfylflWbT91KFH6dhpfaiWxaSP6dqn\npvLnTcqekOl0ii+MljuIz7mzf6CSxkarWl8D1tsIAFrVnxm0wOaOMWzCrvOq9Qzw\nfXtkIHbgTy52CU42bRAuh5BDpP3NR7fSBONMQrvkwAuRTcjkL+oa0g8iVH1FJz4s\neUoMnrdDHvrtZDENxdam8P21g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ian4geA0wx\nfudBAoGBAKQZb9n3PvJfwSUhXqw+zv9PF+Av9GpPq7iGtg1JV3B2u++I/E8+Orrg\nT2K9DJL+VocN7WPcxxNLlB1CsD7/Kqwbc7P7q9NBpCrZ8SurhOv3YcFSfG+qTDAn\n+b83SrGV7SObUg8NS/vAu9LfYAyz3PllfteXaIvV/e9DMumXFKD1\n-----END RSA PRIVATE KEY-----\n", | ||
"project": "driftctl", | ||
"self_link": "https://www.googleapis.com/compute/v1/projects/driftctl/global/sslCertificates/my-certificate-6cb457f7", | ||
"timeouts": null | ||
}, | ||
"sensitive_attributes": [], | ||
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxMjAwMDAwMDAwMDAwLCJkZWxldGUiOjEyMDAwMDAwMDAwMDB9fQ==", | ||
"create_before_destroy": true | ||
} | ||
] | ||
} | ||
], | ||
"check_results": null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package google | ||
|
||
const GoogleComputeSslCertificateResourceType = "google_compute_ssl_certificate" |
33 changes: 33 additions & 0 deletions
33
pkg/resource/google/google_compute_ssl_certificate_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package google_test | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/snyk/driftctl/test" | ||
"github.com/snyk/driftctl/test/acceptance" | ||
) | ||
|
||
func TestAcc_Google_ComputeSslCertificate(t *testing.T) { | ||
acceptance.Run(t, acceptance.AccTestCase{ | ||
TerraformVersion: "0.15.5", | ||
Paths: []string{"./testdata/acc/google_compute_ssl_certificate"}, | ||
Args: []string{ | ||
"scan", | ||
"--to", "gcp+tf", | ||
}, | ||
Checks: []acceptance.AccCheck{ | ||
{ | ||
// New resources are not visible immediately through GCP API after an apply operation. | ||
ShouldRetry: acceptance.LinearBackoff(10 * time.Minute), | ||
Check: func(result *test.ScanResult, stdout string, err error) { | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
result.AssertInfrastructureIsInSync() | ||
result.AssertManagedCount(1) | ||
}, | ||
}, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
pkg/resource/google/testdata/acc/google_compute_ssl_certificate/.driftignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!google_compute_ssl_certificate |
Oops, something went wrong.