Skip to content

Commit

Permalink
chore: merge branch 'main' into ecdsa_ssh_keys
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed May 9, 2022
2 parents 18dedad + 3eedf3f commit 05a0822
Show file tree
Hide file tree
Showing 20 changed files with 19 additions and 550 deletions.
11 changes: 9 additions & 2 deletions cmd/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,15 @@ var updateProjectCmd = &cobra.Command{
os.Exit(1)
}

jsonPatch, _ := json.Marshal(projectFlags)
projectUpdateID, err := pClient.UpdateProject(cmdProjectName, string(jsonPatch))
var jsonPatchFromProjectFlags string
if string(jsonPatch) != "" {
jsonPatchFromProjectFlags = jsonPatch
} else {
jsonMarshalPatch, _ := json.Marshal(projectFlags)
jsonPatchFromProjectFlags = string(jsonMarshalPatch)
}

projectUpdateID, err := pClient.UpdateProject(cmdProjectName, jsonPatchFromProjectFlags)
handleError(err)
var updatedProject api.Project
err = json.Unmarshal([]byte(projectUpdateID), &updatedProject)
Expand Down
13 changes: 0 additions & 13 deletions internal/lagoon/client/_lgraphql/addBillingGroup.graphql

This file was deleted.

11 changes: 0 additions & 11 deletions internal/lagoon/client/_lgraphql/addProjectToBillingGroup.graphql

This file was deleted.

8 changes: 0 additions & 8 deletions internal/lagoon/client/_lgraphql/projectByName.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ query (
role
}
}
{{ if apiVerGreaterThanOrEqual . "1.2.0" }}
... on BillingGroup {
__typename
name
currency
billingSoftware
}
{{ end }}
}
notifications {
... on NotificationSlack {
Expand Down
50 changes: 2 additions & 48 deletions internal/lagoon/client/lgraphql/lgraphql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 0 additions & 28 deletions internal/lagoon/client/mutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,34 +205,6 @@ func (c *Client) AddNotificationToProject(ctx context.Context,
})
}

// AddBillingGroup adds a Billing Group.
func (c *Client) AddBillingGroup(ctx context.Context,
in *schema.AddBillingGroupInput, out *schema.BillingGroup) error {
req, err := c.newRequest("_lgraphql/addBillingGroup.graphql", in)
if err != nil {
return err
}
return c.client.Run(ctx, req, &struct {
Response *schema.BillingGroup `json:"addBillingGroup"`
}{
Response: out,
})
}

// AddProjectToBillingGroup adds a Project to a Billing Group.
func (c *Client) AddProjectToBillingGroup(ctx context.Context,
in *schema.ProjectBillingGroupInput, out *schema.Project) error {
req, err := c.newRequest("_lgraphql/addProjectToBillingGroup.graphql", in)
if err != nil {
return err
}
return c.client.Run(ctx, req, &struct {
Response *schema.Project `json:"addProjectToBillingGroup"`
}{
Response: out,
})
}

// DeployEnvironmentLatest deploys a latest environment.
func (c *Client) DeployEnvironmentLatest(ctx context.Context,
in *schema.DeployEnvironmentLatestInput, out *schema.DeployEnvironmentLatest) error {
Expand Down
33 changes: 0 additions & 33 deletions internal/lagoon/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ type Importer interface {
context.Context, *schema.ProjectGroupsInput, *schema.Project) error
AddNotificationToProject(context.Context,
*schema.AddNotificationToProjectInput, *schema.Project) error
AddBillingGroup(
context.Context, *schema.AddBillingGroupInput, *schema.BillingGroup) error
AddProjectToBillingGroup(context.Context, *schema.ProjectBillingGroupInput,
*schema.Project) error
}

// Import creates objects in the Lagoon API based on a configuration object.
Expand All @@ -70,15 +66,6 @@ func Import(ctx context.Context, i Importer, r io.Reader, keepGoing bool,

// import the config
l := log.New(os.Stderr, "import: ", 0)
// add billing groups
for _, bg := range config.BillingGroups {
if err := i.AddBillingGroup(ctx, &bg, nil); err != nil {
if !keepGoing {
return fmt.Errorf("couldn't add billing group: %w", err)
}
l.Printf("couldn't add billing group: %v", err)
}
}
// add groups
for _, group := range config.Groups {
if err := i.AddGroup(ctx, &group.AddGroupInput, nil); err != nil {
Expand Down Expand Up @@ -261,26 +248,6 @@ func Import(ctx context.Context, i Importer, r io.Reader, keepGoing bool,
l.Printf(`couldn't add Groups to Project "%s": %v`, p.Name, err)
}
}
if len(p.BillingGroups) > 1 {
return fmt.Errorf(
`project can only have one billing group: %v`, p.BillingGroups)
}
// add project to billing group
for _, bgName := range p.BillingGroups {
err = i.AddProjectToBillingGroup(ctx, &schema.ProjectBillingGroupInput{
Group: schema.GroupInput{Name: bgName},
Project: schema.ProjectInput{Name: p.Name},
}, nil)
if err != nil {
if !keepGoing {
return fmt.Errorf(
`couldn't add Project "%s" to Billing Group "%s": %w`, p.Name,
bgName, err)
}
l.Printf(`couldn't add Project "%s" to Billing Group "%s": %v`, p.Name,
bgName, err)
}
}
// add project users
for _, u := range p.Users {
err := i.AddUserToGroup(ctx, &schema.UserGroupRoleInput{
Expand Down
23 changes: 0 additions & 23 deletions internal/lagoon/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ type importCalls struct {
AddEnvironmentInputs []schema.AddEnvironmentInput
ProjectGroupsInputs []schema.ProjectGroupsInput
AddNotificationToProjectInputs []schema.AddNotificationToProjectInput
AddBillingGroupInputs []schema.AddBillingGroupInput
ProjectBillingGroupInputs []schema.ProjectBillingGroupInput
}

func TestImport(t *testing.T) {
Expand Down Expand Up @@ -179,19 +177,6 @@ func TestImport(t *testing.T) {
NotificationName: "example-slack",
},
},
AddBillingGroupInputs: []schema.AddBillingGroupInput{
{
Name: "High Cotton Billing Group",
Currency: schema.USD,
BillingSoftware: "Microsoft Billing",
},
},
ProjectBillingGroupInputs: []schema.ProjectBillingGroupInput{
{
Project: schema.ProjectInput{Name: "bananas"},
Group: schema.GroupInput{Name: "High Cotton Billing Group"},
},
},
}},
}
for name, tc := range testCases {
Expand Down Expand Up @@ -261,14 +246,6 @@ func TestImport(t *testing.T) {
importer.EXPECT().AddNotificationToProject(
ctx, &tc.expect.AddNotificationToProjectInputs[i], nil)
}
for i := range tc.expect.AddBillingGroupInputs {
importer.EXPECT().AddBillingGroup(ctx,
&tc.expect.AddBillingGroupInputs[i], nil)
}
for i := range tc.expect.ProjectBillingGroupInputs {
importer.EXPECT().AddProjectToBillingGroup(ctx,
&tc.expect.ProjectBillingGroupInputs[i], nil)
}
// open the test yaml
file, err := os.Open(tc.input)
if err != nil {
Expand Down
6 changes: 0 additions & 6 deletions internal/lagoon/testdata/exhaustive.import.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
billingGroups:
- billingSoftware: Microsoft Billing
currency: USD
name: High Cotton Billing Group
groups:
- name: abc
users:
Expand All @@ -26,8 +22,6 @@ notifications:
name: example-msteams
projects:
- autoIdle: 1
billingGroups:
- High Cotton Billing Group
branches: ^(master|develop|production)$
developmentEnvironmentsLimit: 10
envVariables:
Expand Down
Loading

0 comments on commit 05a0822

Please sign in to comment.