Skip to content

Commit

Permalink
Updated to account for negative quota
Browse files Browse the repository at this point in the history
  • Loading branch information
CGoodwin90 committed Oct 23, 2023
1 parent 86e5fb4 commit bbb125b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 26 deletions.
50 changes: 25 additions & 25 deletions cmd/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,23 @@ var addOrgCmd = &cobra.Command{
if err != nil {
return err
}
organizationQuotaProject, err := cmd.Flags().GetUint("project-quota")
organizationQuotaProject, err := cmd.Flags().GetInt("project-quota")
if err != nil {
return err
}
organizationQuotaGroup, err := cmd.Flags().GetUint("group-quota")
organizationQuotaGroup, err := cmd.Flags().GetInt("group-quota")
if err != nil {
return err
}
organizationQuotaNotification, err := cmd.Flags().GetUint("notification-quota")
organizationQuotaNotification, err := cmd.Flags().GetInt("notification-quota")
if err != nil {
return err
}
organizationQuotaEnvironment, err := cmd.Flags().GetUint("environment-quota")
organizationQuotaEnvironment, err := cmd.Flags().GetInt("environment-quota")
if err != nil {
return err
}
organizationQuotaRoute, err := cmd.Flags().GetUint("route-quota")
organizationQuotaRoute, err := cmd.Flags().GetInt("route-quota")
if err != nil {
return err
}
Expand Down Expand Up @@ -163,23 +163,23 @@ var updateOrganizationCmd = &cobra.Command{
if err != nil {
return err
}
organizationQuotaProject, err := cmd.Flags().GetUint("project-quota")
organizationQuotaProject, err := cmd.Flags().GetInt("project-quota")
if err != nil {
return err
}
organizationQuotaGroup, err := cmd.Flags().GetUint("group-quota")
organizationQuotaGroup, err := cmd.Flags().GetInt("group-quota")
if err != nil {
return err
}
organizationQuotaNotification, err := cmd.Flags().GetUint("notification-quota")
organizationQuotaNotification, err := cmd.Flags().GetInt("notification-quota")
if err != nil {
return err
}
organizationQuotaEnvironment, err := cmd.Flags().GetUint("environment-quota")
organizationQuotaEnvironment, err := cmd.Flags().GetInt("environment-quota")
if err != nil {
return err
}
organizationQuotaRoute, err := cmd.Flags().GetUint("route-quota")
organizationQuotaRoute, err := cmd.Flags().GetInt("route-quota")
if err != nil {
return err
}
Expand All @@ -196,11 +196,11 @@ var updateOrganizationCmd = &cobra.Command{
organizationInput := s.UpdateOrganizationPatchInput{
Description: nullStrCheck(organizationDescription),
FriendlyName: nullStrCheck(organizationFriendlyName),
QuotaProject: nullUintCheck(organizationQuotaProject),
QuotaGroup: nullUintCheck(organizationQuotaGroup),
QuotaNotification: nullUintCheck(organizationQuotaNotification),
QuotaEnvironment: nullUintCheck(organizationQuotaEnvironment),
QuotaRoute: nullUintCheck(organizationQuotaRoute),
QuotaProject: nullIntCheck(organizationQuotaProject),
QuotaGroup: nullIntCheck(organizationQuotaGroup),
QuotaNotification: nullIntCheck(organizationQuotaNotification),
QuotaEnvironment: nullIntCheck(organizationQuotaEnvironment),
QuotaRoute: nullIntCheck(organizationQuotaRoute),
}
result, err := l.UpdateOrganization(context.TODO(), organization.ID, organizationInput, lc)
handleError(err)
Expand Down Expand Up @@ -231,20 +231,20 @@ func init() {
addOrgCmd.Flags().StringP("name", "O", "", "Name of the organization")
addOrgCmd.Flags().String("friendly-name", "", "Friendly name of the organization")
addOrgCmd.Flags().String("description", "", "Description of the organization")
addOrgCmd.Flags().Uint("project-quota", 0, "Project quota for the organization")
addOrgCmd.Flags().Uint("group-quota", 0, "Group quota for the organization")
addOrgCmd.Flags().Uint("notification-quota", 0, "Notification quota for the organization")
addOrgCmd.Flags().Uint("environment-quota", 0, "Environment quota for the organization")
addOrgCmd.Flags().Uint("route-quota", 0, "Route quota for the organization")
addOrgCmd.Flags().Int("project-quota", 0, "Project quota for the organization")
addOrgCmd.Flags().Int("group-quota", 0, "Group quota for the organization")
addOrgCmd.Flags().Int("notification-quota", 0, "Notification quota for the organization")
addOrgCmd.Flags().Int("environment-quota", 0, "Environment quota for the organization")
addOrgCmd.Flags().Int("route-quota", 0, "Route quota for the organization")

updateOrganizationCmd.Flags().StringP("name", "O", "", "Name of the organization to update")
updateOrganizationCmd.Flags().String("friendly-name", "", "Friendly name of the organization")
updateOrganizationCmd.Flags().String("description", "", "Description of the organization")
updateOrganizationCmd.Flags().Uint("project-quota", 0, "Project quota for the organization")
updateOrganizationCmd.Flags().Uint("group-quota", 0, "Group quota for the organization")
updateOrganizationCmd.Flags().Uint("notification-quota", 0, "Notification quota for the organization")
updateOrganizationCmd.Flags().Uint("environment-quota", 0, "Environment quota for the organization")
updateOrganizationCmd.Flags().Uint("route-quota", 0, "Route quota for the organization")
updateOrganizationCmd.Flags().Int("project-quota", 0, "Project quota for the organization")
updateOrganizationCmd.Flags().Int("group-quota", 0, "Group quota for the organization")
updateOrganizationCmd.Flags().Int("notification-quota", 0, "Notification quota for the organization")
updateOrganizationCmd.Flags().Int("environment-quota", 0, "Environment quota for the organization")
updateOrganizationCmd.Flags().Int("route-quota", 0, "Route quota for the organization")

deleteOrgCmd.Flags().StringP("name", "O", "", "Name of the organization to delete")
}
7 changes: 7 additions & 0 deletions cmd/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ func nullUintCheck(i uint) *uint {
return &i
}

func nullIntCheck(i int) *int {
if i == 0 {
return nil
}
return &i
}

func requiredInputCheck(field string, value string) error {
if value == "" || value == "0" {
return fmt.Errorf(fmt.Sprintf("Missing argument: %s is not defined", field))
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/guregu/null v4.0.0+incompatible
// workaround for https://github.com/manifoldco/promptui/issues/98
github.com/nicksnyder/go-i18n v1.10.1 // indirect
github.com/uselagoon/machinery v0.0.12-0.20231023034503-73831e83e104
github.com/uselagoon/machinery v0.0.12-0.20231023051946-037b2d611755
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 // indirect
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
gopkg.in/alecthomas/kingpin.v3-unstable v3.0.0-20191105091915-95d230a53780 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ github.com/uselagoon/machinery v0.0.12-0.20231020044620-78ab64a18d9d h1:fEQ80pWi
github.com/uselagoon/machinery v0.0.12-0.20231020044620-78ab64a18d9d/go.mod h1:h/qeMWQR4Qqu33x+8AulNDeolEwvb/G+aIsn/jyUtwk=
github.com/uselagoon/machinery v0.0.12-0.20231023034503-73831e83e104 h1:4U+8Re8V0AY8jBuWAiGu7d07+LiKky9tDcfZBpgd/NU=
github.com/uselagoon/machinery v0.0.12-0.20231023034503-73831e83e104/go.mod h1:h/qeMWQR4Qqu33x+8AulNDeolEwvb/G+aIsn/jyUtwk=
github.com/uselagoon/machinery v0.0.12-0.20231023051946-037b2d611755 h1:wRzZdJmoItWrkwcdWxFI0yaHgt6cbm42xP66XrHVb8c=
github.com/uselagoon/machinery v0.0.12-0.20231023051946-037b2d611755/go.mod h1:h/qeMWQR4Qqu33x+8AulNDeolEwvb/G+aIsn/jyUtwk=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
Expand Down

0 comments on commit bbb125b

Please sign in to comment.