Refacto github resources

main
Elie 2021-05-11 14:32:33 +02:00
parent c1f9e704e8
commit 233d517e0a
No known key found for this signature in database
GPG Key ID: 399AF69092C727B6
12 changed files with 275 additions and 209 deletions

View File

@ -1,93 +1,98 @@
[
{
"AllowsDeletions": true,
"AllowsForcePushes": true,
"EnforceAdmins": true,
"Id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzI=",
"Pattern": "main",
"PushRestrictions": [
"MDQ6VXNlcjYxNTQ5ODc="
],
"RepositoryId": "MDEwOlJlcG9zaXRvcnkzNDI1MzIzNzE=",
"RequireSignedCommits": false,
"RequiredPullRequestReviews": [
{
"DismissStaleReviews": true,
"DismissalRestrictions": [
"MDQ6VXNlcjYxNTQ5ODc="
],
"RequireCodeOwnerReviews": false,
"RequiredApprovingReviewCount": 1
}
],
"RequiredStatusChecks": [
{
"Contexts": [
"ci/travis"
],
"Strict": false
}
],
"CtyVal": {}
"Type": "github_branch_protection",
"Attrs": {
"allows_deletions": true,
"allows_force_pushes": true,
"enforce_admins": true,
"id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzI=",
"pattern": "main",
"push_restrictions": [
"MDQ6VXNlcjYxNTQ5ODc="
],
"require_signed_commits": false,
"required_pull_request_reviews": [
{
"dismiss_stale_reviews": true,
"dismissal_restrictions": [
"MDQ6VXNlcjYxNTQ5ODc="
],
"require_code_owner_reviews": false,
"required_approving_review_count": 1
}
],
"required_status_checks": [
{
"contexts": [
"ci/travis"
],
"strict": false
}
]
}
},
{
"AllowsDeletions": true,
"AllowsForcePushes": true,
"EnforceAdmins": true,
"Id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzQ=",
"Pattern": "main",
"PushRestrictions": [
"MDQ6VXNlcjYxNTQ5ODc="
],
"RepositoryId": "MDEwOlJlcG9zaXRvcnkzNDI1MzIzODI=",
"RequireSignedCommits": false,
"RequiredPullRequestReviews": [
{
"DismissStaleReviews": true,
"DismissalRestrictions": [
"MDQ6VXNlcjYxNTQ5ODc="
],
"RequireCodeOwnerReviews": false,
"RequiredApprovingReviewCount": 1
}
],
"RequiredStatusChecks": [
{
"Contexts": [
"ci/travis"
],
"Strict": false
}
],
"CtyVal": {}
"Type": "github_branch_protection",
"Attrs": {
"allows_deletions": true,
"allows_force_pushes": true,
"enforce_admins": true,
"id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzQ=",
"pattern": "main",
"push_restrictions": [
"MDQ6VXNlcjYxNTQ5ODc="
],
"require_signed_commits": false,
"required_pull_request_reviews": [
{
"dismiss_stale_reviews": true,
"dismissal_restrictions": [
"MDQ6VXNlcjYxNTQ5ODc="
],
"require_code_owner_reviews": false,
"required_approving_review_count": 1
}
],
"required_status_checks": [
{
"contexts": [
"ci/travis"
],
"strict": false
}
]
}
},
{
"AllowsDeletions": true,
"AllowsForcePushes": true,
"EnforceAdmins": true,
"Id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzE=",
"Pattern": "main",
"PushRestrictions": null,
"RepositoryId": "MDEwOlJlcG9zaXRvcnkzNDI1MzIzOTE=",
"RequireSignedCommits": false,
"RequiredPullRequestReviews": [
{
"DismissStaleReviews": true,
"DismissalRestrictions": [
"MDQ6VXNlcjYxNTQ5ODc="
],
"RequireCodeOwnerReviews": false,
"RequiredApprovingReviewCount": 1
}
],
"RequiredStatusChecks": [
{
"Contexts": [
"ci/travis"
],
"Strict": false
}
],
"CtyVal": {}
"Type": "github_branch_protection",
"Attrs": {
"allows_deletions": true,
"allows_force_pushes": true,
"enforce_admins": true,
"id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzE=",
"pattern": "main",
"require_signed_commits": false,
"required_pull_request_reviews": [
{
"dismiss_stale_reviews": true,
"dismissal_restrictions": [
"MDQ6VXNlcjYxNTQ5ODc="
],
"require_code_owner_reviews": false,
"required_approving_review_count": 1
}
],
"required_status_checks": [
{
"contexts": [
"ci/travis"
],
"strict": false
}
]
}
}
]

View File

@ -1,16 +1,20 @@
[
{
"Etag": "W/\"2d1cae5b1a58be39bd09bad91fb225b3b589ddc47ff101cf4b8a86d3d8b6f65d\"",
"Id": "driftctl-test:driftctl-acceptance-tester",
"Role": "admin",
"Username": "driftctl-acceptance-tester",
"CtyVal": {}
"Type": "github_membership",
"Attrs": {
"id": "driftctl-test:driftctl-acceptance-tester",
"role": "admin",
"username": "driftctl-acceptance-tester"
}
},
{
"Etag": "W/\"d2a4eb901334f41629f5ead98a4b6e02489ae2f13b2152630f00e4dfa6488586\"",
"Id": "driftctl-test:eliecharra",
"Role": "admin",
"Username": "eliecharra",
"CtyVal": {}
"Type": "github_membership",
"Attrs": {
"id": "driftctl-test:eliecharra",
"role": "admin",
"username": "eliecharra"
}
}
]

View File

@ -1,76 +1,66 @@
[
{
"AllowMergeCommit": true,
"AllowRebaseMerge": true,
"AllowSquashMerge": true,
"ArchiveOnDestroy": null,
"Archived": false,
"AutoInit": null,
"DefaultBranch": "main",
"DeleteBranchOnMerge": false,
"Description": "this is a private repo",
"Etag": "W/\"04420b05933b55f136bb12b9c8d1748e67e143b290d72ecadd0fd2d4f4a3048a\"",
"FullName": "driftctl-test/private-repo",
"GitCloneUrl": "git://github.com/driftctl-test/private-repo.git",
"GitignoreTemplate": null,
"HasDownloads": false,
"HasIssues": false,
"HasProjects": false,
"HasWiki": false,
"HomepageUrl": "",
"HtmlUrl": "https://github.com/driftctl-test/private-repo",
"HttpCloneUrl": "https://github.com/driftctl-test/private-repo.git",
"Id": "private-repo",
"IsTemplate": false,
"LicenseTemplate": null,
"Name": "private-repo",
"NodeId": "MDEwOlJlcG9zaXRvcnkzMzkwNzY5NjQ=",
"Private": true,
"RepoId": 339076964,
"SshCloneUrl": "git@github.com:driftctl-test/private-repo.git",
"SvnUrl": "https://github.com/driftctl-test/private-repo",
"Topics": null,
"Visibility": "private",
"VulnerabilityAlerts": false,
"Pages": [],
"Template": [],
"CtyVal": {}
"Type": "github_repository",
"Attrs": {
"allow_merge_commit": true,
"allow_rebase_merge": true,
"allow_squash_merge": true,
"archived": false,
"default_branch": "main",
"delete_branch_on_merge": false,
"description": "this is a private repo",
"full_name": "driftctl-test/private-repo",
"git_clone_url": "git://github.com/driftctl-test/private-repo.git",
"has_downloads": false,
"has_issues": false,
"has_projects": false,
"has_wiki": false,
"homepage_url": "",
"html_url": "https://github.com/driftctl-test/private-repo",
"http_clone_url": "https://github.com/driftctl-test/private-repo.git",
"id": "private-repo",
"is_template": false,
"name": "private-repo",
"node_id": "MDEwOlJlcG9zaXRvcnkzMzkwNzY5NjQ=",
"private": true,
"repo_id": 339076964,
"ssh_clone_url": "git@github.com:driftctl-test/private-repo.git",
"svn_url": "https://github.com/driftctl-test/private-repo",
"visibility": "private",
"vulnerability_alerts": false
}
},
{
"AllowMergeCommit": true,
"AllowRebaseMerge": true,
"AllowSquashMerge": true,
"ArchiveOnDestroy": null,
"Archived": false,
"AutoInit": null,
"DefaultBranch": "main",
"DeleteBranchOnMerge": false,
"Description": "",
"Etag": "W/\"3e7a2583fb97097c8acbcb4c289e46fc0db70341071c5f55972bbd3270a2b957\"",
"FullName": "driftctl-test/public-repo",
"GitCloneUrl": "git://github.com/driftctl-test/public-repo.git",
"GitignoreTemplate": null,
"HasDownloads": false,
"HasIssues": false,
"HasProjects": false,
"HasWiki": false,
"HomepageUrl": "",
"HtmlUrl": "https://github.com/driftctl-test/public-repo",
"HttpCloneUrl": "https://github.com/driftctl-test/public-repo.git",
"Id": "public-repo",
"IsTemplate": false,
"LicenseTemplate": null,
"Name": "public-repo",
"NodeId": "MDEwOlJlcG9zaXRvcnkzMzkwNzY5Nzg=",
"Private": false,
"RepoId": 339076978,
"SshCloneUrl": "git@github.com:driftctl-test/public-repo.git",
"SvnUrl": "https://github.com/driftctl-test/public-repo",
"Topics": null,
"Visibility": "public",
"VulnerabilityAlerts": false,
"Pages": [],
"Template": [],
"CtyVal": {}
"Type": "github_repository",
"Attrs": {
"allow_merge_commit": true,
"allow_rebase_merge": true,
"allow_squash_merge": true,
"archived": false,
"default_branch": "main",
"delete_branch_on_merge": false,
"description": "",
"full_name": "driftctl-test/public-repo",
"git_clone_url": "git://github.com/driftctl-test/public-repo.git",
"has_downloads": false,
"has_issues": false,
"has_projects": false,
"has_wiki": false,
"homepage_url": "",
"html_url": "https://github.com/driftctl-test/public-repo",
"http_clone_url": "https://github.com/driftctl-test/public-repo.git",
"id": "public-repo",
"is_template": false,
"name": "public-repo",
"node_id": "MDEwOlJlcG9zaXRvcnkzMzkwNzY5Nzg=",
"private": false,
"repo_id": 339076978,
"ssh_clone_url": "git@github.com:driftctl-test/public-repo.git",
"svn_url": "https://github.com/driftctl-test/public-repo",
"visibility": "public",
"vulnerability_alerts": false
}
}
]

View File

@ -1,44 +1,48 @@
[
{
"CreateDefaultMaintainer": false,
"Description": "test",
"Etag": "W/\"04b608322c60381373485f1154b7670f1daeb6bdfa9062f7eba05739171fcac0\"",
"Id": "4556715",
"LdapDn": "",
"MembersCount": 1,
"Name": "team1",
"NodeId": "MDQ6VGVhbTQ1NTY3MTU=",
"ParentTeamId": null,
"Privacy": "closed",
"Slug": "team1",
"CtyVal": {}
"Type": "github_team",
"Attrs": {
"create_default_maintainer": false,
"description": "test",
"id": "4556715",
"ldap_dn": "",
"members_count": 1,
"name": "team1",
"node_id": "MDQ6VGVhbTQ1NTY3MTU=",
"privacy": "closed",
"slug": "team1"
}
},
{
"CreateDefaultMaintainer": false,
"Description": "test 2",
"Etag": "W/\"1af373c3f173859e7f06690e8e353c21a9a1a90224963e8f162546f1022af224\"",
"Id": "4556719",
"LdapDn": "",
"MembersCount": 1,
"Name": "team2",
"NodeId": "MDQ6VGVhbTQ1NTY3MTk=",
"ParentTeamId": null,
"Privacy": "secret",
"Slug": "team2",
"CtyVal": {}
"Type": "github_team",
"Attrs": {
"create_default_maintainer": false,
"description": "test 2",
"id": "4556719",
"ldap_dn": "",
"members_count": 1,
"name": "team2",
"node_id": "MDQ6VGVhbTQ1NTY3MTk=",
"privacy": "secret",
"slug": "team2"
}
},
{
"CreateDefaultMaintainer": false,
"Description": "test parent team",
"Etag": "W/\"d6fded1b23237d988a0914455547a2e66789bb625fc0a519babe993429facd37\"",
"Id": "4556747",
"LdapDn": "",
"MembersCount": 1,
"Name": "new team with parent",
"NodeId": "MDQ6VGVhbTQ1NTY3NDc=",
"ParentTeamId": 4556715,
"Privacy": "closed",
"Slug": "new-team-with-parent",
"CtyVal": {}
"Type": "github_team",
"Attrs": {
"create_default_maintainer": false,
"description": "test parent team",
"id": "4556747",
"ldap_dn": "",
"members_count": 1,
"name": "new team with parent",
"node_id": "MDQ6VGVhbTQ1NTY3NDc=",
"parent_team_id": 4556715,
"privacy": "closed",
"slug": "new-team-with-parent"
}
}
]

View File

@ -1,18 +1,22 @@
[
{
"Etag": "W/\"7d708fe20649b975d112449eb87681183b03ec1eee387e9cad2559fcc6b1fb3b\"",
"Id": "4564046:wbeuil",
"Role": "member",
"TeamId": "4564046",
"Username": "wbeuil",
"CtyVal": {}
"Id": "4564046:driftctl-acceptance-tester",
"Type": "github_team_membership",
"Attrs": {
"id": "4564046:driftctl-acceptance-tester",
"role": "maintainer",
"team_id": "4564046",
"username": "driftctl-acceptance-tester"
}
},
{
"Etag": "W/\"1ecb16111126288558af7851ad1fb6eb99a57393235bd0600bf39c85dcd98563\"",
"Id": "4564046:driftctl-acceptance-tester",
"Role": "maintainer",
"TeamId": "4564046",
"Username": "driftctl-acceptance-tester",
"CtyVal": {}
"Id": "4564046:wbeuil",
"Type": "github_team_membership",
"Attrs": {
"id": "4564046:wbeuil",
"role": "member",
"team_id": "4564046",
"username": "wbeuil"
}
}
]

View File

@ -1,7 +1,10 @@
// GENERATED, DO NOT EDIT THIS FILE
package github
import "github.com/zclconf/go-cty/cty"
import (
"github.com/cloudskiff/driftctl/pkg/resource"
"github.com/zclconf/go-cty/cty"
)
const GithubBranchProtectionResourceType = "github_branch_protection"
@ -38,3 +41,9 @@ func (r *GithubBranchProtection) TerraformType() string {
func (r *GithubBranchProtection) CtyValue() *cty.Value {
return r.CtyVal
}
func initGithubBranchProtectionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(GithubBranchProtectionResourceType, func(val *resource.Attributes) {
val.SafeDelete([]string{"repository_id"}) // Terraform provider is always returning nil
})
}

View File

@ -1,7 +1,10 @@
// GENERATED, DO NOT EDIT THIS FILE
package github
import "github.com/zclconf/go-cty/cty"
import (
"github.com/cloudskiff/driftctl/pkg/resource"
"github.com/zclconf/go-cty/cty"
)
const GithubMembershipResourceType = "github_membership"
@ -24,3 +27,9 @@ func (r *GithubMembership) TerraformType() string {
func (r *GithubMembership) CtyValue() *cty.Value {
return r.CtyVal
}
func initGithubMembershipMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(GithubMembershipResourceType, func(val *resource.Attributes) {
val.SafeDelete([]string{"etag"})
})
}

View File

@ -1,6 +1,9 @@
package github
import "github.com/zclconf/go-cty/cty"
import (
"github.com/cloudskiff/driftctl/pkg/resource"
"github.com/zclconf/go-cty/cty"
)
const GithubRepositoryResourceType = "github_repository"
@ -66,3 +69,10 @@ func (r *GithubRepository) TerraformType() string {
func (r *GithubRepository) CtyValue() *cty.Value {
return r.CtyVal
}
func initGithubRepositoryMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(GithubRepositoryResourceType, func(val *resource.Attributes) {
val.SafeDelete([]string{"auto_init"})
val.SafeDelete([]string{"etag"})
})
}

View File

@ -1,7 +1,10 @@
// GENERATED, DO NOT EDIT THIS FILE
package github
import "github.com/zclconf/go-cty/cty"
import (
"github.com/cloudskiff/driftctl/pkg/resource"
"github.com/zclconf/go-cty/cty"
)
const GithubTeamResourceType = "github_team"
@ -31,3 +34,12 @@ func (r *GithubTeam) TerraformType() string {
func (r *GithubTeam) CtyValue() *cty.Value {
return r.CtyVal
}
func initGithubTeamMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(GithubTeamResourceType, func(val *resource.Attributes) {
if defaultMaintainer, exist := val.Get("create_default_maintainer"); !exist || defaultMaintainer == nil {
(*val)["create_default_maintainer"] = false
}
val.SafeDelete([]string{"etag"})
})
}

View File

@ -1,7 +1,10 @@
// GENERATED, DO NOT EDIT THIS FILE
package github
import "github.com/zclconf/go-cty/cty"
import (
"github.com/cloudskiff/driftctl/pkg/resource"
"github.com/zclconf/go-cty/cty"
)
const GithubTeamMembershipResourceType = "github_team_membership"
@ -25,3 +28,9 @@ func (r *GithubTeamMembership) TerraformType() string {
func (r *GithubTeamMembership) CtyValue() *cty.Value {
return r.CtyVal
}
func initGithubTeamMembershipMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(GithubTeamMembershipResourceType, func(val *resource.Attributes) {
val.SafeDelete([]string{"etag"})
})
}

View File

@ -3,5 +3,9 @@ package github
import "github.com/cloudskiff/driftctl/pkg/resource"
func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) {
initGithubBranchProtectionMetaData(resourceSchemaRepository)
initGithubMembershipMetaData(resourceSchemaRepository)
initGithubRepositoryMetaData(resourceSchemaRepository)
initGithubTeamMetaData(resourceSchemaRepository)
initGithubTeamMembershipMetaData(resourceSchemaRepository)
}

View File

@ -71,6 +71,12 @@ var refactoredResources = []string{
// "aws_sqs_queue_policy",
// "aws_subnet",
// "aws_vpc",
"github_branch_protection",
"github_membership",
"github_repository",
"github_team",
"github_team_membership",
}
func IsRefactoredResource(typ string) bool {