Documentation ¶
Overview ¶
Package resources holds simple functions for synthesizing child resources from a Space.
Index ¶
- func AuditorRoleName(space *v1alpha1.Space) string
- func DeveloperRoleName(space *v1alpha1.Space) string
- func LimitRangeName(space *v1alpha1.Space) string
- func MakeAuditorRole(space *v1alpha1.Space) (*v1.Role, error)
- func MakeDeveloperRole(space *v1alpha1.Space) (*v1.Role, error)
- func MakeLimitRange(space *v1alpha1.Space) (*v1.LimitRange, error)
- func MakeNamespace(space *v1alpha1.Space) (*v1.Namespace, error)
- func MakeResourceQuota(space *v1alpha1.Space) (*v1.ResourceQuota, error)
- func NamespaceName(space *v1alpha1.Space) string
- func ResourceQuotaName(space *v1alpha1.Space) string
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuditorRoleName ¶
AuditorRoleName gets the name of the auditor role given the space.
Example ¶
space := &v1alpha1.Space{} space.Name = "my-space" fmt.Println(AuditorRoleName(space))
Output: space-auditor
func DeveloperRoleName ¶
DeveloperRoleName gets the name of the developer role given the space.
Example ¶
space := &v1alpha1.Space{} space.Name = "my-space" fmt.Println(DeveloperRoleName(space))
Output: space-developer
func LimitRangeName ¶
LimitRangeName gets the name of the limit range given the space.
func MakeAuditorRole ¶
MakeAuditorRole creates a Role for auditor access from a Space object.
func MakeDeveloperRole ¶
MakeDeveloperRole creates a Role for developer access from a Space object.
func MakeLimitRange ¶
func MakeLimitRange(space *v1alpha1.Space) (*v1.LimitRange, error)
MakeLimitRange creates a LimitRange from a Space object.
Example ¶
space := &v1alpha1.Space{} space.Name = "my-space" mem, _ := resource.ParseQuantity("1Gi") cpu, _ := resource.ParseQuantity("100m") defaultRequestLimit := v1.ResourceList{ v1.ResourceMemory: mem, v1.ResourceCPU: cpu, } limit := v1.LimitRangeItem{ Type: v1.LimitTypePod, DefaultRequest: defaultRequestLimit, } space.Spec.ResourceLimits.ResourceDefaults = []v1.LimitRangeItem{limit} limitRange, err := MakeLimitRange(space) if err != nil { panic(err) } fmt.Println("Name:", LimitRangeName(space)) fmt.Println("Managed by:", limitRange.Labels[managedByLabel]) fmt.Println("Limit type:", limitRange.Spec.Limits[0].Type) fmt.Println("Default memory request:", limitRange.Spec.Limits[0].DefaultRequest.Memory()) fmt.Println("Default cpu request:", limitRange.Spec.Limits[0].DefaultRequest.Cpu())
Output: Name: space-limit-range Managed by: kf Limit type: Pod Default memory request: 1Gi Default cpu request: 100m
func MakeNamespace ¶
MakeNamespace creates a Namespace from a Space object.
Example ¶
space := &v1alpha1.Space{} space.Name = "my-space" ns, err := MakeNamespace(space) if err != nil { panic(err) } fmt.Println("Name:", NamespaceName(space)) fmt.Println("Label Count:", len(ns.Labels)) fmt.Println("Managed By:", ns.Labels[managedByLabel]) fmt.Println("Istio Injection:", ns.Labels[istioInjectionLabel])
Output: Name: my-space Label Count: 2 Managed By: kf Istio Injection: enabled
func MakeResourceQuota ¶
func MakeResourceQuota(space *v1alpha1.Space) (*v1.ResourceQuota, error)
MakeResourceQuota creates a ResourceQuota from a Space object.
Example ¶
space := &v1alpha1.Space{} space.Name = "my-space" mem, _ := resource.ParseQuantity("20Gi") cpu, _ := resource.ParseQuantity("800m") space.Spec.ResourceLimits.SpaceQuota = v1.ResourceList{ v1.ResourceMemory: mem, v1.ResourceCPU: cpu, } quota, err := MakeResourceQuota(space) if err != nil { panic(err) } fmt.Println("Name:", ResourceQuotaName(space)) fmt.Println("Managed by:", quota.Labels[managedByLabel]) fmt.Println("Memory quota:", quota.Spec.Hard.Memory()) fmt.Println("CPU quota:", quota.Spec.Hard.Cpu())
Output: Name: space-quota Managed by: kf Memory quota: 20Gi CPU quota: 800m
func NamespaceName ¶
NamespaceName gets the name of a namespace given the space.
Example ¶
space := &v1alpha1.Space{} space.Name = "my-space" fmt.Println(NamespaceName(space))
Output: my-space
func ResourceQuotaName ¶
ResourceQuotaName gets the name of the resource quota given the space.
Types ¶
This section is empty.