Skip to content

Commit

Permalink
Ignore casing on sandbox sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
jpreese committed Apr 21, 2020
1 parent 47c2a73 commit 822bad0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ One `RoleBinding` per name in the `owners` field. Bindings are added and removed

### ResourceQuota (sandbox-foo-resourcequota)

The `ResourceQuota` that is applied to the `Namespace` depends on the `size` of the `Sandbox` that was created.
The `ResourceQuota` that is applied to the `Namespace` depends on the `size` of the `Sandbox` that was created. Defaults to `small` if no size is given.

#### Small

Expand All @@ -193,10 +193,6 @@ The `ResourceQuota` that is applied to the `Namespace` depends on the `size` of
|ResourceRequestsStorage|40Gi|
|ResourcePersistentVolumeClaims|8|

```text
NOTE: If no size is given, small is the default.
```

## Managing Owners of a Sandbox

After the Sandbox has been created, you can add or remove owners that are associated to it.
Expand Down
17 changes: 9 additions & 8 deletions controller/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"log"
"os"
"strings"

operatorsv1alpha1 "github.com/plexsystems/sandbox-operator/apis/operators/v1alpha1"

Expand Down Expand Up @@ -250,7 +251,7 @@ func getRole(sandbox operatorsv1alpha1.Sandbox) rbacv1.Role {
Labels: getCommonLabels(),
},
Rules: []rbacv1.PolicyRule{
rbacv1.PolicyRule{
{
Verbs: []string{"*"},
APIGroups: []string{""},
Resources: []string{
Expand All @@ -266,7 +267,7 @@ func getRole(sandbox operatorsv1alpha1.Sandbox) rbacv1.Role {
"replicationcontrollers",
},
},
rbacv1.PolicyRule{
{
Verbs: []string{"*"},
APIGroups: []string{
"apps",
Expand All @@ -279,20 +280,20 @@ func getRole(sandbox operatorsv1alpha1.Sandbox) rbacv1.Role {
"statefulsets",
},
},
rbacv1.PolicyRule{
{
Verbs: []string{"*"},
APIGroups: []string{"autoscaling"},
Resources: []string{"horizontalpodautoscalers"},
},
rbacv1.PolicyRule{
{
Verbs: []string{"*"},
APIGroups: []string{"batch"},
Resources: []string{
"jobs",
"cronjobs",
},
},
rbacv1.PolicyRule{
{
Verbs: []string{
"create",
"list",
Expand All @@ -304,7 +305,7 @@ func getRole(sandbox operatorsv1alpha1.Sandbox) rbacv1.Role {
"rolebindings",
},
},
rbacv1.PolicyRule{
{
Verbs: []string{
"create",
"delete",
Expand Down Expand Up @@ -344,7 +345,7 @@ func getClusterRole(sandbox operatorsv1alpha1.Sandbox) rbacv1.ClusterRole {
Labels: getCommonLabels(),
},
Rules: []rbacv1.PolicyRule{
rbacv1.PolicyRule{
{
Verbs: []string{"*"},
APIGroups: []string{"operators.plex.dev"},
Resources: []string{"sandboxes"},
Expand Down Expand Up @@ -374,7 +375,7 @@ func getClusterRoleBinding(sandbox operatorsv1alpha1.Sandbox) rbacv1.ClusterRole

func getResourceQuota(sandbox operatorsv1alpha1.Sandbox) corev1.ResourceQuota {
var resourceQuotaSpec corev1.ResourceQuotaSpec
if sandbox.Spec.Size == "large" {
if strings.EqualFold(sandbox.Spec.Size, "large") {
resourceQuotaSpec = getLargeResourceQuotaSpec()
} else {
resourceQuotaSpec = getSmallResourceQuotaSpec()
Expand Down

0 comments on commit 822bad0

Please sign in to comment.