diff --git a/go.mod b/go.mod index 382d7f59..d0f50580 100644 --- a/go.mod +++ b/go.mod @@ -35,20 +35,20 @@ require ( github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-logr/zapr v1.3.0 // indirect - github.com/go-openapi/jsonpointer v0.20.2 // indirect - github.com/go-openapi/jsonreference v0.20.4 // indirect - github.com/go-openapi/swag v0.22.7 // indirect + github.com/go-openapi/jsonpointer v0.19.6 // indirect + github.com/go-openapi/jsonreference v0.20.2 // indirect + github.com/go-openapi/swag v0.22.3 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/gobuffalo/flect v1.0.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect - github.com/google/cel-go v0.18.2 // indirect + github.com/google/cel-go v0.17.7 // indirect github.com/google/gnostic-models v0.6.8 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect - github.com/imdario/mergo v0.3.16 // indirect + github.com/imdario/mergo v0.3.13 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -64,7 +64,7 @@ require ( github.com/prometheus/common v0.45.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/spf13/cobra v1.8.0 // indirect - github.com/stoewer/go-strcase v1.3.0 // indirect + github.com/stoewer/go-strcase v1.2.0 // indirect github.com/stretchr/objx v0.5.2 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.0 // indirect go.opentelemetry.io/otel v1.20.0 // indirect @@ -76,8 +76,7 @@ require ( go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - go4.org/netipx v0.0.0-20230303233057-f1b76eb4bb35 // indirect - golang.org/x/exp v0.0.0-20231226003508-02704c960a9b // indirect + golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/net v0.25.0 // indirect golang.org/x/oauth2 v0.18.0 // indirect golang.org/x/sync v0.7.0 // indirect @@ -88,9 +87,9 @@ require ( golang.org/x/tools v0.21.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect - google.golang.org/grpc v1.60.1 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect + google.golang.org/grpc v1.59.0 // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect @@ -98,10 +97,9 @@ require ( k8s.io/apiextensions-apiserver v0.29.3 // indirect k8s.io/apiserver v0.29.3 // indirect k8s.io/component-base v0.29.3 // indirect - k8s.io/kube-openapi v0.0.0-20240103160333-bb40bc074d37 // indirect + k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.28.0 // indirect - sigs.k8s.io/cluster-api-ipam-provider-in-cluster v0.1.0 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect sigs.k8s.io/yaml v1.4.0 // indirect diff --git a/go.sum b/go.sum index 821c28bb..23ebbb4d 100644 --- a/go.sum +++ b/go.sum @@ -58,16 +58,10 @@ github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= -github.com/go-openapi/jsonpointer v0.20.2 h1:mQc3nmndL8ZBzStEo3JYF8wzmeWffDH4VbXz58sAx6Q= -github.com/go-openapi/jsonpointer v0.20.2/go.mod h1:bHen+N0u1KEO3YlmqOjTT9Adn1RfD91Ar825/PuiRVs= github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= -github.com/go-openapi/jsonreference v0.20.4 h1:bKlDxQxQJgwpUSgOENiMPzCTBVuc7vTdXSSgNeAhojU= -github.com/go-openapi/jsonreference v0.20.4/go.mod h1:5pZJyJP2MnYCpoeoMAql78cCHauHj0V9Lhc506VOpw4= github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= -github.com/go-openapi/swag v0.22.7 h1:JWrc1uc/P9cSomxfnsFSVWoE1FW6bNbrVPmpQYpCcR8= -github.com/go-openapi/swag v0.22.7/go.mod h1:Gl91UqO+btAM0plGGxHqJcQZ1ZTy6jbmridBTsDy8A0= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/gobuffalo/flect v1.0.2 h1:eqjPGSo2WmjgY2XlpGwo2NXgL3RucAKo4k4qQMNA5sA= @@ -88,8 +82,6 @@ github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= github.com/google/cel-go v0.17.7 h1:6ebJFzu1xO2n7TLtN+UBqShGBhlD85bhvglh5DpcfqQ= github.com/google/cel-go v0.17.7/go.mod h1:HXZKzB0LXqer5lHHgfWAnlYwJaQBDKMjxjulNQzhwhY= -github.com/google/cel-go v0.18.2 h1:L0B6sNBSVmt0OyECi8v6VOS74KOc9W/tLiWKfZABvf4= -github.com/google/cel-go v0.18.2/go.mod h1:kWcIzTsPX0zmQ+H3TirHstLLf9ep5QTsZBN9u4dOYLg= github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -117,8 +109,6 @@ github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4 github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= -github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= -github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/ionos-cloud/sdk-go/v6 v6.1.11 h1:J/uRN4UWO3wCyGOeDdMKv8LWRzKu6UIkLEaes38Kzh8= @@ -192,7 +182,6 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= -github.com/stoewer/go-strcase v1.3.0/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= @@ -252,9 +241,6 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= -go4.org v0.0.0-20201209231011-d4a079459e60 h1:iqAGo78tVOJXELHQFRjR6TMwItrvXH4hrGJ32I/NFF8= -go4.org/netipx v0.0.0-20230303233057-f1b76eb4bb35 h1:nJAwRlGWZZDOD+6wni9KVUNHMpHko/OnRwsrCYeAzPo= -go4.org/netipx v0.0.0-20230303233057-f1b76eb4bb35/go.mod h1:TQvodOM+hJTioNQJilmLXu08JNb8i+ccq418+KWu1/Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -263,8 +249,6 @@ golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= -golang.org/x/exp v0.0.0-20231226003508-02704c960a9b h1:kLiC65FbiHWFAOu+lxwNPujcsl8VYyTYYEZnsOO1WK4= -golang.org/x/exp v0.0.0-20231226003508-02704c960a9b/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -322,16 +306,12 @@ google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAs google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 h1:wpZ8pe2x1Q3f2KyT5f8oP/fa9rHAKgFPr/HZdNuS+PQ= google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:J7XzRzVy1+IPwWHZUzoD0IccYZIrXILAQpc+Qy9CMhY= -google.golang.org/genproto v0.0.0-20231212172506-995d672761c0 h1:YJ5pD9rF8o9Qtta0Cmy9rdBwkSjrTCT6XTiUQVOtIos= google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 h1:JpwMPBpFN3uKhdaekDpiNlImDdkUAyiJ6ez/uxGaUSo= google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:0xJLfVdJqpAPl8tDg1ujOCGzx6LFLttXT5NhllGOXY4= -google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917/go.mod h1:CmlNWB9lSezaYELKS5Ym1r44VrrbPUa7JTvw+6MbpJ0= google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f h1:ultW7fxlIvee4HYrtnaRPon9HpEgFk5zYpmfMgtKB5I= google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f/go.mod h1:L9KNLi232K1/xB6f7AlSX692koaRnKaWSR0stBki0Yc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917/go.mod h1:xtjpI3tXFPP051KaWnhvxkiubL/6dJ18vLVf7q2pTOU= google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= -google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= @@ -369,16 +349,12 @@ k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780= k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA= -k8s.io/kube-openapi v0.0.0-20240103160333-bb40bc074d37 h1:sUW8i241H8NYn3v4QIwNYpPbiyNnlunqtKFt48hxc7g= -k8s.io/kube-openapi v0.0.0-20240103160333-bb40bc074d37/go.mod h1:sIV51WBTkZrlGOJMCDZDA1IaPBUDTulPpD4y7oe038k= k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ= k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.28.0 h1:TgtAeesdhpm2SGwkQasmbeqDo8th5wOBA5h/AjTKA4I= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.28.0/go.mod h1:VHVDI/KrK4fjnV61bE2g3sA7tiETLn8sooImelsCx3Y= sigs.k8s.io/cluster-api v1.7.2 h1:bRE8zoao7ajuLC0HijqfZVcubKQCPlZ04HMgcA53FGE= sigs.k8s.io/cluster-api v1.7.2/go.mod h1:V9ZhKLvQtsDODwjXOKgbitjyCmC71yMBwDcMyNNIov0= -sigs.k8s.io/cluster-api-ipam-provider-in-cluster v0.1.0 h1:k93V8X7ihC9CJff4AP7csyRIMO28cqp0pRMkvcChpis= -sigs.k8s.io/cluster-api-ipam-provider-in-cluster v0.1.0/go.mod h1:C+C1Xos6z9H9ymJSJsjI2qfqo/EnsugS7WHCYh3O+Nc= sigs.k8s.io/controller-runtime v0.17.3 h1:65QmN7r3FWgTxDMz9fvGnO1kbf2nu+acg9p2R9oYYYk= sigs.k8s.io/controller-runtime v0.17.3/go.mod h1:N0jpP5Lo7lMTF9aL56Z/B2oWBJjey6StQM0jRbKQXtY= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= diff --git a/internal/service/ipam/ipam_test.go b/internal/service/ipam/ipam_test.go index a7a16d7e..f28cfc4b 100644 --- a/internal/service/ipam/ipam_test.go +++ b/internal/service/ipam/ipam_test.go @@ -31,7 +31,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" - ipamprovider "sigs.k8s.io/cluster-api-ipam-provider-in-cluster/api/v1alpha2" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ipamv1 "sigs.k8s.io/cluster-api/exp/ipam/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" @@ -134,7 +133,6 @@ func (s *IpamTestSuite) SetupTest() { scheme := runtime.NewScheme() s.NoError(clusterv1.AddToScheme(scheme), "failed to extend scheme with Cluster API types") s.NoError(ipamv1.AddToScheme(scheme), "failed to extend scheme with Cluster API ipam types") - s.NoError(ipamprovider.AddToScheme(scheme), "failed to extend scheme with Cluster API ipam provider types") s.NoError(infrav1.AddToScheme(scheme), "failed to extend scheme with IonosCloud types") s.NoError(clientgoscheme.AddToScheme(scheme)) @@ -182,26 +180,10 @@ func (s *IpamTestSuite) TestReconcileIPAddressesDontCreateClaim() { s.Empty(list.Items) } -func (s *IpamTestSuite) TestReconcileIPAddressesPrimaryIpamv4InvalidPool() { - pool := defaultInClusterIPv4Pool() - - s.machineScope.IonosMachine.Spec.IPv4PoolRef = typedLocalRef(pool) - requeue, err := s.ipamHelper.ReconcileIPAddresses(s.ctx, s.machineScope) - s.True(requeue) - s.NoError(err) - - // Invalid PoolRefs provided. Reconciler creates claim anyway. - claim := defaultPrimaryIPv4Claim() - err = s.k8sClient.Get(s.ctx, client.ObjectKeyFromObject(claim), claim) - s.NoError(err) -} - func (s *IpamTestSuite) TestReconcileIPAddressesPrimaryIpv4CreateClaim() { - pool := defaultInClusterIPv4Pool() - err := s.k8sClient.Create(s.ctx, pool) - s.NoError(err) + poolRef := defaultInClusterIPv4PoolRef() - s.machineScope.IonosMachine.Spec.IPv4PoolRef = typedLocalRef(pool) + s.machineScope.IonosMachine.Spec.IPv4PoolRef = poolRef requeue, err := s.ipamHelper.ReconcileIPAddresses(s.ctx, s.machineScope) // IPAddressClaim was created, so we need to wait for the IPAddress to be created externally. s.True(requeue) @@ -213,11 +195,9 @@ func (s *IpamTestSuite) TestReconcileIPAddressesPrimaryIpv4CreateClaim() { } func (s *IpamTestSuite) TestReconcileIPAddressesPrimaryIpv6CreateClaim() { - pool := defaultInClusterIPv6Pool() - err := s.k8sClient.Create(s.ctx, pool) - s.NoError(err) + poolRef := defaultInClusterIPv6PoolRef() - s.machineScope.IonosMachine.Spec.IPv6PoolRef = typedLocalRef(pool) + s.machineScope.IonosMachine.Spec.IPv6PoolRef = poolRef requeue, err := s.ipamHelper.ReconcileIPAddresses(s.ctx, s.machineScope) // IPAddressClaim was created, so we need to wait for the IPAddress to be created externally. s.True(requeue) @@ -229,20 +209,18 @@ func (s *IpamTestSuite) TestReconcileIPAddressesPrimaryIpv6CreateClaim() { } func (s *IpamTestSuite) TestReconcileIPAddressesPrimaryIpv4GetIPFromClaim() { - pool := defaultInClusterIPv4Pool() - err := s.k8sClient.Create(s.ctx, pool) - s.NoError(err) + poolRef := defaultInClusterIPv4PoolRef() claim := defaultPrimaryIPv4Claim() claim.Status.AddressRef.Name = "nic-test-machine-ipv4-10-0-0-2" - err = s.k8sClient.Create(s.ctx, claim) + err := s.k8sClient.Create(s.ctx, claim) s.NoError(err) - ip := defaultIPv4Address(claim, pool) + ip := defaultIPv4Address(claim, poolRef) err = s.k8sClient.Create(s.ctx, ip) s.NoError(err) - s.machineScope.IonosMachine.Spec.IPv4PoolRef = typedLocalRef(pool) + s.machineScope.IonosMachine.Spec.IPv4PoolRef = poolRef requeue, err := s.ipamHelper.ReconcileIPAddresses(s.ctx, s.machineScope) s.False(requeue) s.NoError(err) @@ -250,20 +228,18 @@ func (s *IpamTestSuite) TestReconcileIPAddressesPrimaryIpv4GetIPFromClaim() { } func (s *IpamTestSuite) TestReconcileIPAddressesPrimaryIpv6GetIPFromClaim() { - pool := defaultInClusterIPv6Pool() - err := s.k8sClient.Create(s.ctx, pool) - s.NoError(err) + poolRef := defaultInClusterIPv6PoolRef() claim := defaultPrimaryIPv6Claim() claim.Status.AddressRef.Name = "nic-test-machine-ipv6-2001-db8--" - err = s.k8sClient.Create(s.ctx, claim) + err := s.k8sClient.Create(s.ctx, claim) s.NoError(err) - ip := defaultIPv6Address(claim, pool) + ip := defaultIPv6Address(claim, poolRef) err = s.k8sClient.Create(s.ctx, ip) s.NoError(err) - s.machineScope.IonosMachine.Spec.IPv6PoolRef = typedLocalRef(pool) + s.machineScope.IonosMachine.Spec.IPv6PoolRef = poolRef requeue, err := s.ipamHelper.ReconcileIPAddresses(s.ctx, s.machineScope) s.False(requeue) s.NoError(err) @@ -271,11 +247,9 @@ func (s *IpamTestSuite) TestReconcileIPAddressesPrimaryIpv6GetIPFromClaim() { } func (s *IpamTestSuite) TestReconcileIPAddressesAdditionalIpv4CreateClaim() { - pool := defaultInClusterIPv4Pool() - err := s.k8sClient.Create(s.ctx, pool) - s.NoError(err) + poolRef := defaultInClusterIPv4PoolRef() - s.machineScope.IonosMachine.Spec.AdditionalNetworks = defaultAdditionalNetworksIpv4(pool) + s.machineScope.IonosMachine.Spec.AdditionalNetworks = defaultAdditionalNetworksIpv4(poolRef) requeue, err := s.ipamHelper.ReconcileIPAddresses(s.ctx, s.machineScope) // IPAddressClaim was created, so we need to wait for the IPAddress to be created externally. s.True(requeue) @@ -287,11 +261,9 @@ func (s *IpamTestSuite) TestReconcileIPAddressesAdditionalIpv4CreateClaim() { } func (s *IpamTestSuite) TestReconcileIPAddressesAdditionalIpv6CreateClaim() { - pool := defaultInClusterIPv6Pool() - err := s.k8sClient.Create(s.ctx, pool) - s.NoError(err) + poolRef := defaultInClusterIPv6PoolRef() - s.machineScope.IonosMachine.Spec.AdditionalNetworks = defaultAdditionalNetworksIpv6(pool) + s.machineScope.IonosMachine.Spec.AdditionalNetworks = defaultAdditionalNetworksIpv6(poolRef) requeue, err := s.ipamHelper.ReconcileIPAddresses(s.ctx, s.machineScope) // IPAddressClaim was created, so we need to wait for the IPAddress to be created externally. s.True(requeue) @@ -303,53 +275,41 @@ func (s *IpamTestSuite) TestReconcileIPAddressesAdditionalIpv6CreateClaim() { } func (s *IpamTestSuite) TestReconcileIPAddressesAdditionalIpv6GetIPFromClaim() { - pool := defaultInClusterIPv6Pool() - err := s.k8sClient.Create(s.ctx, pool) - s.NoError(err) + poolRef := defaultInClusterIPv6PoolRef() claim := defaultAdditionalIPv6Claim() claim.Status.AddressRef.Name = "nic-test-machine-ipv6-2001-db8--" - err = s.k8sClient.Create(s.ctx, claim) + err := s.k8sClient.Create(s.ctx, claim) s.NoError(err) - ip := defaultIPv6Address(claim, pool) + ip := defaultIPv6Address(claim, poolRef) err = s.k8sClient.Create(s.ctx, ip) s.NoError(err) - s.machineScope.IonosMachine.Spec.AdditionalNetworks = defaultAdditionalNetworksIpv6(pool) + s.machineScope.IonosMachine.Spec.AdditionalNetworks = defaultAdditionalNetworksIpv6(poolRef) requeue, err := s.ipamHelper.ReconcileIPAddresses(s.ctx, s.machineScope) s.False(requeue) s.NoError(err) s.Equal("2001:db8::", s.machineScope.IonosMachine.Status.MachineNetworkInfo.NICInfo[1].IPv6Addresses[0]) } -func defaultInClusterIPv6Pool() *ipamprovider.InClusterIPPool { - return &ipamprovider.InClusterIPPool{ - TypeMeta: metav1.TypeMeta{}, - ObjectMeta: metav1.ObjectMeta{ - Name: "incluster-ipv6-pool", - }, - Spec: ipamprovider.InClusterIPPoolSpec{ - Addresses: []string{"2001:db8::/42"}, - Prefix: 42, - }, +func defaultInClusterIPv4PoolRef() *corev1.TypedLocalObjectReference { + return &corev1.TypedLocalObjectReference{ + APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + Kind: "InClusterIPPool", + Name: "incluster-ipv4-pool", } } -func defaultInClusterIPv4Pool() *ipamprovider.InClusterIPPool { - return &ipamprovider.InClusterIPPool{ - TypeMeta: metav1.TypeMeta{}, - ObjectMeta: metav1.ObjectMeta{ - Name: "incluster-ipv4-pool", - }, - Spec: ipamprovider.InClusterIPPoolSpec{ - Addresses: []string{"10.0.0.0/16"}, - Prefix: 16, - }, +func defaultInClusterIPv6PoolRef() *corev1.TypedLocalObjectReference { + return &corev1.TypedLocalObjectReference{ + APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + Kind: "InClusterIPPool", + Name: "incluster-ipv6-pool", } } -func defaultIPv4Address(claim *ipamv1.IPAddressClaim, pool *ipamprovider.InClusterIPPool) *ipamv1.IPAddress { +func defaultIPv4Address(claim *ipamv1.IPAddressClaim, poolRef *corev1.TypedLocalObjectReference) *ipamv1.IPAddress { return &ipamv1.IPAddress{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ @@ -358,14 +318,14 @@ func defaultIPv4Address(claim *ipamv1.IPAddressClaim, pool *ipamprovider.InClust }, Spec: ipamv1.IPAddressSpec{ ClaimRef: *localRef(claim), - PoolRef: *typedLocalRef(pool), + PoolRef: *poolRef, Address: "10.0.0.2", Prefix: 16, }, } } -func defaultIPv6Address(claim *ipamv1.IPAddressClaim, pool *ipamprovider.InClusterIPPool) *ipamv1.IPAddress { +func defaultIPv6Address(claim *ipamv1.IPAddressClaim, poolRef *corev1.TypedLocalObjectReference) *ipamv1.IPAddress { return &ipamv1.IPAddress{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ @@ -374,7 +334,7 @@ func defaultIPv6Address(claim *ipamv1.IPAddressClaim, pool *ipamprovider.InClust }, Spec: ipamv1.IPAddressSpec{ ClaimRef: *localRef(claim), - PoolRef: *typedLocalRef(pool), + PoolRef: *poolRef, Address: "2001:db8::", Prefix: 42, }, @@ -408,20 +368,20 @@ func defaultAdditionalIPv6Claim() *ipamv1.IPAddressClaim { } } -func defaultAdditionalNetworksIpv6(pool *ipamprovider.InClusterIPPool) []infrav1.Network { +func defaultAdditionalNetworksIpv6(poolRef *corev1.TypedLocalObjectReference) []infrav1.Network { return []infrav1.Network{{ NetworkID: 1, IPAMConfig: infrav1.IPAMConfig{ - IPv6PoolRef: typedLocalRef(pool), + IPv6PoolRef: poolRef, }, }} } -func defaultAdditionalNetworksIpv4(pool *ipamprovider.InClusterIPPool) []infrav1.Network { +func defaultAdditionalNetworksIpv4(poolRef *corev1.TypedLocalObjectReference) []infrav1.Network { return []infrav1.Network{{ NetworkID: 1, IPAMConfig: infrav1.IPAMConfig{ - IPv4PoolRef: typedLocalRef(pool), + IPv4PoolRef: poolRef, }, }} }