From fc47d58f2d9886103796cb5fcc3ddfbb94af8975 Mon Sep 17 00:00:00 2001 From: Taimoor Ahmad Date: Mon, 27 Nov 2023 17:00:31 -0500 Subject: [PATCH] formatting --- src/cmd/terraform.go | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/cmd/terraform.go b/src/cmd/terraform.go index da9a4c66..4224a77c 100644 --- a/src/cmd/terraform.go +++ b/src/cmd/terraform.go @@ -310,8 +310,7 @@ func exportServices(c *opslevel.Client, shell *os.File, directory string) { func exportTeams(c *opslevel.Client, config *os.File, shell *os.File) { shell.WriteString("# Teams\n") - teamConfig := `resource "opslevel_team" "%s" { -%s + teamConfig := `resource "opslevel_team" "%s" {%s } ` resp, err := c.ListTeams(nil) @@ -322,31 +321,31 @@ func exportTeams(c *opslevel.Client, config *os.File, shell *os.File) { aliases := flattenAliases(team.Aliases) if len(aliases) > 0 { - teamBody += fmt.Sprintf(" aliases = [\"%s\"]\n", aliases) + teamBody += fmt.Sprintf("\n aliases = [\"%s\"]", aliases) } - teamBody += fmt.Sprintf(" name = \"%s\"\n", team.Name) + teamBody += fmt.Sprintf("\n name = \"%s\"", team.Name) - if team.Group.Alias != "" { - teamBody += fmt.Sprintf(" group = \"%s\"\n", team.Group.Alias) + if len(team.Group.Alias) > 0 { + teamBody += fmt.Sprintf("\n group = \"%s\"", team.Group.Alias) } membersOutput := "" for _, member := range team.Memberships.Nodes { - memberConfig := ` member { + memberConfig := ` + member { email = "%s" role = "%s" - } -` + }` membersOutput += fmt.Sprintf(memberConfig, member.User.Email, member.Role) } if len(membersOutput) > 0 { teamBody += membersOutput } - if team.ParentTeam.Alias != "" { - teamBody += fmt.Sprintf(" parent = [\"%s\"]\n", team.ParentTeam.Alias) + if len(team.ParentTeam.Alias) > 0 { + teamBody += fmt.Sprintf("\n parent = [\"%s\"]", team.ParentTeam.Alias) } - responsibilities := buildMultilineStringArg("responsibilities", team.Responsibilities) - if len(responsibilities) > 0 { - teamBody += fmt.Sprintf(" %s", responsibilities) + if len(team.Responsibilities) > 0 { + responsibilities := buildMultilineStringArg("responsibilities", team.Responsibilities) + teamBody += fmt.Sprintf("\n %s", responsibilities) } config.WriteString(templateConfig(