2021-02-26 11:12:36 +00:00
|
|
|
// GENERATED, DO NOT EDIT THIS FILE
|
|
|
|
package github
|
|
|
|
|
2021-05-11 12:32:33 +00:00
|
|
|
import (
|
2021-05-21 14:09:45 +00:00
|
|
|
"encoding/base64"
|
|
|
|
|
2021-05-11 12:32:33 +00:00
|
|
|
"github.com/cloudskiff/driftctl/pkg/resource"
|
|
|
|
)
|
2021-03-25 11:13:52 +00:00
|
|
|
|
2021-02-26 11:12:36 +00:00
|
|
|
const GithubBranchProtectionResourceType = "github_branch_protection"
|
|
|
|
|
2021-05-11 12:32:33 +00:00
|
|
|
func initGithubBranchProtectionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
2021-08-09 14:03:04 +00:00
|
|
|
resourceSchemaRepository.SetNormalizeFunc(GithubBranchProtectionResourceType, func(res *resource.Resource) {
|
2021-05-24 15:19:06 +00:00
|
|
|
val := res.Attrs
|
2021-05-11 12:32:33 +00:00
|
|
|
val.SafeDelete([]string{"repository_id"}) // Terraform provider is always returning nil
|
|
|
|
})
|
2021-08-09 14:03:04 +00:00
|
|
|
resourceSchemaRepository.SetHumanReadableAttributesFunc(GithubBranchProtectionResourceType, func(res *resource.Resource) map[string]string {
|
2021-05-21 14:09:45 +00:00
|
|
|
val := res.Attrs
|
|
|
|
attrs := make(map[string]string)
|
|
|
|
pattern := val.GetString("pattern")
|
|
|
|
repoID := val.GetString("repository_id")
|
|
|
|
if pattern != nil && *pattern != "" {
|
|
|
|
id := ""
|
|
|
|
if repoID != nil && *repoID != "" {
|
|
|
|
decodedID, err := base64.StdEncoding.DecodeString(*repoID)
|
|
|
|
if err == nil {
|
|
|
|
id = string(decodedID)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if id == "" {
|
|
|
|
attrs["Branch"] = *pattern
|
2021-08-18 13:58:28 +00:00
|
|
|
attrs["Id"] = res.ResourceId()
|
2021-05-21 14:09:45 +00:00
|
|
|
return attrs
|
|
|
|
}
|
|
|
|
attrs["Branch"] = *pattern
|
|
|
|
attrs["RepoId"] = id
|
|
|
|
return attrs
|
|
|
|
}
|
2021-08-18 13:58:28 +00:00
|
|
|
attrs["Id"] = res.ResourceId()
|
2021-05-21 14:09:45 +00:00
|
|
|
return attrs
|
|
|
|
})
|
2021-09-17 15:16:06 +00:00
|
|
|
resourceSchemaRepository.SetFlags(GithubBranchProtectionResourceType, resource.FlagDeepMode)
|
2021-05-11 12:32:33 +00:00
|
|
|
}
|