Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ require (
github.com/ghodss/yaml v1.0.0
github.com/hashicorp/go-version v1.6.0
github.com/hashicorp/terraform-plugin-sdk v1.17.2
github.com/rancher/norman v0.7.1
github.com/rancher/rancher v0.0.0-20251022154639-6291f0239b7f
github.com/rancher/norman v0.8.0
github.com/rancher/rancher v0.0.0-20251114145111-1ede64712337
github.com/rancher/rancher/pkg/apis v0.0.0
github.com/rancher/rancher/pkg/client v0.0.0
github.com/stretchr/testify v1.11.1
Expand Down Expand Up @@ -122,13 +122,13 @@ require (
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.66.1 // indirect
github.com/prometheus/procfs v0.17.0 // indirect
github.com/rancher/aks-operator v1.13.0-rc.1 // indirect
github.com/rancher/ali-operator v0.0.3-0.20251001142421-ca64da576db5 // indirect
github.com/rancher/apiserver v0.7.6 // indirect
github.com/rancher/aks-operator v1.13.0-rc.4 // indirect
github.com/rancher/ali-operator v1.13.0-rc.2 // indirect
github.com/rancher/apiserver v0.8.0 // indirect
github.com/rancher/channelserver v0.7.0 // indirect
github.com/rancher/eks-operator v1.13.0-rc.1 // indirect
github.com/rancher/fleet/pkg/apis v0.14.0-beta.1 // indirect
github.com/rancher/gke-operator v1.13.0-rc.1 // indirect
github.com/rancher/eks-operator v1.13.0-rc.4 // indirect
github.com/rancher/fleet/pkg/apis v0.14.0-rc.1 // indirect
github.com/rancher/gke-operator v1.13.0-rc.3 // indirect
github.com/rancher/lasso v0.2.5 // indirect
github.com/rancher/rke v1.8.0-rc.4 // indirect
github.com/rancher/wrangler/v3 v3.3.1 // indirect
Expand Down Expand Up @@ -188,8 +188,8 @@ replace (
github.com/crewjam/saml => github.com/crewjam/saml v0.4.5
github.com/docker/distribution => github.com/docker/distribution v2.8.1+incompatible
github.com/docker/docker => github.com/docker/docker v20.10.17+incompatible
github.com/rancher/rancher/pkg/apis => github.com/rancher/rancher/pkg/apis v0.0.0-20251023101703-73e6898b0472
github.com/rancher/rancher/pkg/client => github.com/rancher/rancher/pkg/client v0.0.0-20251023101703-73e6898b0472
github.com/rancher/rancher/pkg/apis => github.com/rancher/rancher/pkg/apis v0.0.0-20251114145111-1ede64712337
github.com/rancher/rancher/pkg/client => github.com/rancher/rancher/pkg/client v0.0.0-20251114145111-1ede64712337
github.com/spf13/afero => github.com/spf13/afero v1.2.2
go.qase.io/client => github.com/rancher/qase-go/client v0.0.0-20231114201952-65195ec001fa
helm.sh/helm/v3 => github.com/rancher/helm/v3 v3.9.0-rancher1
Expand Down
46 changes: 22 additions & 24 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8m
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/onsi/ginkgo/v2 v2.26.0 h1:1J4Wut1IlYZNEAWIV3ALrT9NfiaGW2cDCJQSFQMs/gE=
github.com/onsi/ginkgo/v2 v2.26.0/go.mod h1:qhEywmzWTBUY88kfO0BRvX4py7scov9yR+Az2oavUzw=
github.com/onsi/ginkgo/v2 v2.27.2 h1:LzwLj0b89qtIy6SSASkzlNvX6WktqurSHwkk2ipF/Ns=
github.com/onsi/ginkgo/v2 v2.27.2/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo=
github.com/onsi/gomega v1.38.2 h1:eZCjf2xjZAqe+LeWvKb5weQ+NcPwX84kqJ0cZNxok2A=
github.com/onsi/gomega v1.38.2/go.mod h1:W2MJcYxRGV63b418Ai34Ud0hEdTVXq9NW9+Sx6uXf3k=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
Expand All @@ -674,30 +674,30 @@ github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9Z
github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA=
github.com/prometheus/procfs v0.17.0 h1:FuLQ+05u4ZI+SS/w9+BWEM2TXiHKsUQ9TADiRH7DuK0=
github.com/prometheus/procfs v0.17.0/go.mod h1:oPQLaDAMRbA+u8H5Pbfq+dl3VDAvHxMUOVhe0wYB2zw=
github.com/rancher/aks-operator v1.13.0-rc.1 h1:Vy83SjeSm9q7kI18+nkSOR0hyeydDj398KGTo3XEuS4=
github.com/rancher/aks-operator v1.13.0-rc.1/go.mod h1:xu0BJ01Ynzs4wLMDf2V5eaazEf1/kndX0AeqqsTFVfQ=
github.com/rancher/ali-operator v0.0.3-0.20251001142421-ca64da576db5 h1:phyZ6BUqR/XnZNAHfSpYyGxclxu/ZTLGCc3wpcTjcmM=
github.com/rancher/ali-operator v0.0.3-0.20251001142421-ca64da576db5/go.mod h1:aJNM8GVaKCO1jH70Ds4qH8lE5tZlzOxWFbyOFOBHu5k=
github.com/rancher/apiserver v0.7.6 h1:bLS+pxNfGv5Zq5exxMUZr9z5X8kXOOY27RGmVv2k2rM=
github.com/rancher/apiserver v0.7.6/go.mod h1:Wb+Z8ktNyIuqt9hw30geFBQFJQucWTqgu6trxxMtcyM=
github.com/rancher/aks-operator v1.13.0-rc.4 h1:tc7p2gZmRg4c6VBwWTQJYwmh1hlN68kftjoBIdGCnqw=
github.com/rancher/aks-operator v1.13.0-rc.4/go.mod h1:1ZjZB6zGHK+NGchN9KLplq+xPxRRi+q6Uzet5bjFwxo=
github.com/rancher/ali-operator v1.13.0-rc.2 h1:a0biHGez+Np9XybJVh3yKN4RGPdaCzfM6D6cAXJac6o=
github.com/rancher/ali-operator v1.13.0-rc.2/go.mod h1:s5HznpxsN9LsgtX6u5UoW9dZNKnDLuXcwzQRAEoDcog=
github.com/rancher/apiserver v0.8.0 h1:yCXsCa67X/Y///NKJ/pq6pv6wmt3hq/OIzBaIna2grY=
github.com/rancher/apiserver v0.8.0/go.mod h1:Wb+Z8ktNyIuqt9hw30geFBQFJQucWTqgu6trxxMtcyM=
github.com/rancher/channelserver v0.7.0 h1:ZN5o8aD4mD31uhjEEW2e9yQXa3eOb+4Cp6DcWm7W/Lc=
github.com/rancher/channelserver v0.7.0/go.mod h1:Mwd7hlMSu9X4FnZKj+0mA5ak8nTyJZtZsVX33G62Gzc=
github.com/rancher/eks-operator v1.13.0-rc.1 h1:IbimIq+TuC88RQ3KF1Ez882XFP2nDnihbeqVPXLvuLk=
github.com/rancher/eks-operator v1.13.0-rc.1/go.mod h1:tj6ioCe9v5J1HM0ZXR3/K5InoEjOfjCvSHMuXMj2x4M=
github.com/rancher/fleet/pkg/apis v0.14.0-beta.1 h1:UoWkP6tiVx6xbOU6lG0EQXf3caEyBAYd5c88FFBULSg=
github.com/rancher/fleet/pkg/apis v0.14.0-beta.1/go.mod h1:oc+QHbx4P9guY34dr6UbzCOgt17Q9eSZhlyOs7xSinY=
github.com/rancher/gke-operator v1.13.0-rc.1 h1:VViWerZyc9iMmWTxK5FapRmMnBp8cq3CgqjbM+bvyaQ=
github.com/rancher/gke-operator v1.13.0-rc.1/go.mod h1:xW0iUqGMqUTPLzC4i+UKeydh9N9zYdM0BqC+7wiDfec=
github.com/rancher/eks-operator v1.13.0-rc.4 h1:XowN8+m3QZTIBOBLzar4frtz0xtREb9kcX6KXhF4eas=
github.com/rancher/eks-operator v1.13.0-rc.4/go.mod h1:SbaKX2ttFWCxGOYkrKYeWH/6E4oToq2rRTcrMa2Mmdk=
github.com/rancher/fleet/pkg/apis v0.14.0-rc.1 h1:ZsDc25j4/iuKJ8DhxaOSnHdqOskRRe7QxJAdD9HBn28=
github.com/rancher/fleet/pkg/apis v0.14.0-rc.1/go.mod h1:oc+QHbx4P9guY34dr6UbzCOgt17Q9eSZhlyOs7xSinY=
github.com/rancher/gke-operator v1.13.0-rc.3 h1:a6U+7+XIbJPH2CE7/vFUx6RpThNbFl7fqIqkEBb6zmA=
github.com/rancher/gke-operator v1.13.0-rc.3/go.mod h1:TroxpmqMh63Hf4H5bC+2GYcgOCQp9kIUDfyKdNAMo6Q=
github.com/rancher/lasso v0.2.5 h1:K++lWDDdfeN98Ixc1kCfUq0/q6tLjoHN++Np6QntXw0=
github.com/rancher/lasso v0.2.5/go.mod h1:71rWfv+KkdSmSxZ9Ly5QYhxAu0nEUcaq9N2ByjcHqAM=
github.com/rancher/norman v0.7.1 h1:OfmYfN4YeJ4qosXTAbOTPgCrb5GE8W6wFWnDxWcuKCo=
github.com/rancher/norman v0.7.1/go.mod h1:vZ5qL+eKodJ7zOMQYdl6jwMrSFrqTKpA+KYSFEKew2M=
github.com/rancher/rancher v0.0.0-20251022154639-6291f0239b7f h1:TIVU0VhKFD4vRJV4Koae9QiDtvRoLpBQluKpMpN9Iiw=
github.com/rancher/rancher v0.0.0-20251022154639-6291f0239b7f/go.mod h1:jzUABuDzxEfOoepEMld0JiCypVY+GBAmRFjSSu/fd1g=
github.com/rancher/rancher/pkg/apis v0.0.0-20251023101703-73e6898b0472 h1:8iE2Bd0x5OkVq8jQCB0DvTYNEaBvhtLE50O2E7S5Tqs=
github.com/rancher/rancher/pkg/apis v0.0.0-20251023101703-73e6898b0472/go.mod h1:H+KsnFeYVNUyLBAl1kqyKTM8KjuV1TNWDrZ2HT9ou/4=
github.com/rancher/rancher/pkg/client v0.0.0-20251023101703-73e6898b0472 h1:Mubagflz1JmYvVMQMHcDdloB+qbpUoP25KjBamr/eIs=
github.com/rancher/rancher/pkg/client v0.0.0-20251023101703-73e6898b0472/go.mod h1:kN5U1qD97yp9EUzm6LeoPENApyZsMzQdYES1GTJJbJw=
github.com/rancher/norman v0.8.0 h1://ZSe+B53cMgPNAbR7QBhzvIfWBxR4KaPWTKqG+g+O4=
github.com/rancher/norman v0.8.0/go.mod h1:vZ5qL+eKodJ7zOMQYdl6jwMrSFrqTKpA+KYSFEKew2M=
github.com/rancher/rancher v0.0.0-20251114145111-1ede64712337 h1:SXNtZt3WafJ2DelaciHxDVTFrg4oHMyi1yMT829NfII=
github.com/rancher/rancher v0.0.0-20251114145111-1ede64712337/go.mod h1:EswnwrltsbNm8g4WnD7Fp2MPKB0J/oymzumlCFT+GMo=
github.com/rancher/rancher/pkg/apis v0.0.0-20251114145111-1ede64712337 h1:9tkMyb1Yk1uFZXsxtdJIVc4NnnwPTwrR/bFF0OgRf4k=
github.com/rancher/rancher/pkg/apis v0.0.0-20251114145111-1ede64712337/go.mod h1:xyYMxIycb9QpdxZjUxf95Cc4E27rfma8Z77U5ysRx3A=
github.com/rancher/rancher/pkg/client v0.0.0-20251114145111-1ede64712337 h1:z6mq7GXPIt9kP3y9ZQUA+3SxpCcbZOidqQamv+T1OX0=
github.com/rancher/rancher/pkg/client v0.0.0-20251114145111-1ede64712337/go.mod h1:omk+GIbTxtBDoFQ8Dspb/Ne78QKTB7/jCSZeg/4rfbI=
github.com/rancher/rke v1.8.0-rc.4 h1:jowVyaF3LsJonC7vNsAwWf3MONHAtEFUD/j3UzNSE5U=
github.com/rancher/rke v1.8.0-rc.4/go.mod h1:x9N1abruzDFMwTpqq2cnaDYpKCptlNoW8VraNWB6Pc4=
github.com/rancher/wrangler/v3 v3.3.1 h1:YFqRfhxjuLNudUrvWrn+64wUPZ8pnn2KWbTsha75JLg=
Expand Down Expand Up @@ -808,8 +808,6 @@ go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689Cbtr
go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE=
go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
Expand Down
21 changes: 21 additions & 0 deletions rancher2/schema_project.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package rancher2

import (
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand All @@ -17,6 +19,25 @@ func projectResourceQuotaLimitFields() map[string]*schema.Schema {
Type: schema.TypeString,
Optional: true,
},
"extended": {
Type: schema.TypeMap,
Optional: true,
ValidateFunc: func(val any, key string) (warns []string, errs []error) {
// Ensure that `extended`s value is a `map[string]string`.
vmap, ok := val.(map[string]any)
if !ok || len(vmap) == 0 {
return
}
for k, v := range vmap {
_, ok := v.(string)
if ok {
continue
}
errs = append(errs, fmt.Errorf("'%s.%s' must have a string value", key, k))
}
return
},
},
"limits_cpu": {
Type: schema.TypeString,
Optional: true,
Expand Down
65 changes: 41 additions & 24 deletions rancher2/structure_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (

// Flatteners

func flattenProjectContainerResourceLimit(in *managementClient.ContainerResourceLimit) []interface{} {
obj := make(map[string]interface{})
func flattenProjectContainerResourceLimit(in *managementClient.ContainerResourceLimit) []any {
obj := make(map[string]any)
if in == nil {
return []interface{}{}
return []any{}
}

if len(in.LimitsCPU) > 0 {
Expand All @@ -26,19 +26,23 @@ func flattenProjectContainerResourceLimit(in *managementClient.ContainerResource
obj["requests_memory"] = in.RequestsMemory
}

return []interface{}{obj}
return []any{obj}
}

func flattenProjectResourceQuotaLimit(in *managementClient.ResourceQuotaLimit) []interface{} {
obj := make(map[string]interface{})
func flattenProjectResourceQuotaLimit(in *managementClient.ResourceQuotaLimit) []any {
obj := make(map[string]any)
if in == nil {
return []interface{}{}
return []any{}
}

if len(in.ConfigMaps) > 0 {
obj["config_maps"] = in.ConfigMaps
}

if len(in.Extended) > 0 {
obj["extended"] = in.Extended
}

if len(in.LimitsCPU) > 0 {
obj["limits_cpu"] = in.LimitsCPU
}
Expand Down Expand Up @@ -87,13 +91,13 @@ func flattenProjectResourceQuotaLimit(in *managementClient.ResourceQuotaLimit) [
obj["services_node_ports"] = in.ServicesNodePorts
}

return []interface{}{obj}
return []any{obj}
}

func flattenProjectResourceQuota(pQuota *managementClient.ProjectResourceQuota, nsQuota *managementClient.NamespaceResourceQuota) []interface{} {
obj := make(map[string]interface{})
func flattenProjectResourceQuota(pQuota *managementClient.ProjectResourceQuota, nsQuota *managementClient.NamespaceResourceQuota) []any {
obj := make(map[string]any)
if pQuota == nil || nsQuota == nil {
return []interface{}{}
return []any{}
}

if pQuota.Limit != nil {
Expand All @@ -106,7 +110,7 @@ func flattenProjectResourceQuota(pQuota *managementClient.ProjectResourceQuota,
obj["namespace_default_limit"] = limit
}

return []interface{}{obj}
return []any{obj}
}

func flattenProject(d *schema.ResourceData, in *managementClient.Project) error {
Expand Down Expand Up @@ -151,12 +155,12 @@ func flattenProject(d *schema.ResourceData, in *managementClient.Project) error

// Expanders

func expandProjectContainerResourceLimit(p []interface{}) *managementClient.ContainerResourceLimit {
func expandProjectContainerResourceLimit(p []any) *managementClient.ContainerResourceLimit {
obj := &managementClient.ContainerResourceLimit{}
if len(p) == 0 || p[0] == nil {
return nil
}
in := p[0].(map[string]interface{})
in := p[0].(map[string]any)

if v, ok := in["limits_cpu"].(string); ok && len(v) > 0 {
obj.LimitsCPU = v
Expand All @@ -174,18 +178,31 @@ func expandProjectContainerResourceLimit(p []interface{}) *managementClient.Cont
return obj
}

func expandProjectResourceQuotaLimit(p []interface{}) *managementClient.ResourceQuotaLimit {
func mapAnyToString(in map[string]any) map[string]string {
out := map[string]string{}
for k, v := range in {
out[k] = v.(string)
}

return out
}

func expandProjectResourceQuotaLimit(p []any) *managementClient.ResourceQuotaLimit {
obj := &managementClient.ResourceQuotaLimit{}

if len(p) == 0 || p[0] == nil {
return nil
}
in := p[0].(map[string]interface{})
in := p[0].(map[string]any)

if v, ok := in["config_maps"].(string); ok && len(v) > 0 {
obj.ConfigMaps = v
}

if v, ok := in["extended"].(map[string]any); ok && len(v) > 0 {
obj.Extended = mapAnyToString(v)
}

if v, ok := in["limits_cpu"].(string); ok && len(v) > 0 {
obj.LimitsCPU = v
}
Expand Down Expand Up @@ -237,21 +254,21 @@ func expandProjectResourceQuotaLimit(p []interface{}) *managementClient.Resource
return obj
}

func expandProjectResourceQuota(p []interface{}) (*managementClient.ProjectResourceQuota, *managementClient.NamespaceResourceQuota) {
func expandProjectResourceQuota(p []any) (*managementClient.ProjectResourceQuota, *managementClient.NamespaceResourceQuota) {
pQuota := &managementClient.ProjectResourceQuota{}
nsQuota := &managementClient.NamespaceResourceQuota{}

if len(p) == 0 || p[0] == nil {
return nil, nil
}
in := p[0].(map[string]interface{})
in := p[0].(map[string]any)

if v, ok := in["project_limit"].([]interface{}); ok && len(v) > 0 {
if v, ok := in["project_limit"].([]any); ok && len(v) > 0 {
pLimit := expandProjectResourceQuotaLimit(v)
pQuota.Limit = pLimit
}

if v, ok := in["namespace_default_limit"].([]interface{}); ok && len(v) > 0 {
if v, ok := in["namespace_default_limit"].([]any); ok && len(v) > 0 {
nsLimit := expandProjectResourceQuotaLimit(v)
nsQuota.Limit = nsLimit
}
Expand All @@ -273,22 +290,22 @@ func expandProject(in *schema.ResourceData) *managementClient.Project {
obj.Name = in.Get("name").(string)
obj.Description = in.Get("description").(string)

if v, ok := in.Get("container_resource_limit").([]interface{}); ok && len(v) > 0 {
if v, ok := in.Get("container_resource_limit").([]any); ok && len(v) > 0 {
containerLimit := expandProjectContainerResourceLimit(v)
obj.ContainerDefaultResourceLimit = containerLimit
}

if v, ok := in.Get("resource_quota").([]interface{}); ok && len(v) > 0 {
if v, ok := in.Get("resource_quota").([]any); ok && len(v) > 0 {
resourceQuota, nsResourceQuota := expandProjectResourceQuota(v)
obj.ResourceQuota = resourceQuota
obj.NamespaceDefaultResourceQuota = nsResourceQuota
}

if v, ok := in.Get("annotations").(map[string]interface{}); ok && len(v) > 0 {
if v, ok := in.Get("annotations").(map[string]any); ok && len(v) > 0 {
obj.Annotations = toMapString(v)
}

if v, ok := in.Get("labels").(map[string]interface{}); ok && len(v) > 0 {
if v, ok := in.Get("labels").(map[string]any); ok && len(v) > 0 {
obj.Labels = toMapString(v)
}

Expand Down
6 changes: 6 additions & 0 deletions rancher2/structure_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ func init() {
Services: "services",
ServicesLoadBalancers: "lb",
ServicesNodePorts: "np",
Extended: map[string]string{
"count/gpu": "anumber",
},
}
testProjectResourceQuotaLimitInterface = []interface{}{
map[string]interface{}{
Expand All @@ -68,6 +71,9 @@ func init() {
"services": "services",
"services_load_balancers": "lb",
"services_node_ports": "np",
"extended": map[string]string{
"count/gpu": "anumber",
},
},
}
testProjectResourceQuotaLimitNamespaceConf = &managementClient.ResourceQuotaLimit{
Expand Down
Loading