Skip to content

Commit

Permalink
flatten forked_from_project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
oboukili committed Apr 8, 2020
1 parent 2000866 commit cd2c249
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion gitlab/data_source_gitlab_projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ func flattenProjectLinks(links *gitlab.Links) (values map[string]string) {
return values
}

func flattenForkedFromProject(forked *gitlab.ForkParent) (values []map[string]interface{}) {
if forked != nil {
values = []map[string]interface{}{
{
"http_url_to_repo": forked.HTTPURLToRepo,
"id": forked.ID,
"name": forked.Name,
"name_with_namespace": forked.NameWithNamespace,
"path": forked.Path,
"path_with_namespace": forked.PathWithNamespace,
"web_url": forked.WebURL,
},
}
}
return values
}

func flattenGitlabBasicUser(user *gitlab.User) (values []map[string]interface{}) {
if user != nil {
values = []map[string]interface{}{
Expand Down Expand Up @@ -128,7 +145,7 @@ func flattenProjects(projects []*gitlab.Project) (values []map[string]interface{
"lfs_enabled": project.LFSEnabled,
"request_access_enabled": project.RequestAccessEnabled,
"merge_method": project.MergeMethod,
"forked_from_project": project.ForkedFromProject,
"forked_from_project": flattenForkedFromProject(project.ForkedFromProject),
"mirror": project.Mirror,
"mirror_user_id": project.MirrorUserID,
"mirror_trigger_builds": project.MirrorTriggerBuilds,
Expand Down

0 comments on commit cd2c249

Please sign in to comment.