diff --git a/api/go.mod b/api/go.mod index b781b7867..0b8eeadb0 100644 --- a/api/go.mod +++ b/api/go.mod @@ -7,43 +7,72 @@ go 1.21 toolchain go1.22.2 +replace github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common => ../common + require ( + github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common v0.7.0 github.com/nutanix-cloud-native/prism-go-client v0.3.4 github.com/onsi/gomega v1.33.0 k8s.io/api v0.29.3 k8s.io/apiextensions-apiserver v0.29.3 k8s.io/apimachinery v0.29.3 - k8s.io/utils v0.0.0-20231127182322-b307cd553661 sigs.k8s.io/cluster-api v1.7.0 sigs.k8s.io/controller-runtime v0.17.3 ) require ( + github.com/beorn7/perks v1.0.1 // indirect github.com/blang/semver/v4 v4.0.0 // indirect - github.com/emicklei/go-restful/v3 v3.11.0 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/emicklei/go-restful/v3 v3.12.0 // indirect + github.com/evanphx/json-patch/v5 v5.9.0 // indirect + github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-logr/logr v1.4.1 // 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/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/gnostic-models v0.6.8 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/gofuzz v1.2.0 // indirect + github.com/google/uuid v1.4.0 // indirect + github.com/imdario/mergo v0.3.13 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/mailru/easyjson v0.7.7 // indirect + github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_model v0.5.0 // indirect + github.com/prometheus/common v0.45.0 // indirect + github.com/prometheus/procfs v0.12.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/valyala/fastjson v1.6.4 // indirect + golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/net v0.24.0 // indirect + golang.org/x/oauth2 v0.18.0 // indirect + golang.org/x/sys v0.19.0 // indirect + golang.org/x/term v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect + golang.org/x/time v0.5.0 // indirect + gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect + google.golang.org/appengine v1.6.8 // 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 gopkg.in/yaml.v3 v3.0.1 // indirect + k8s.io/client-go v0.29.3 // indirect + k8s.io/component-base v0.29.3 // indirect k8s.io/klog/v2 v2.120.1 // indirect k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect + k8s.io/utils v0.0.0-20231127182322-b307cd553661 // 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/api/go.sum b/api/go.sum index 81d5fd288..88c2af63f 100644 --- a/api/go.sum +++ b/api/go.sum @@ -62,12 +62,16 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkY github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/aws/aws-sdk-go v1.42.23/go.mod h1:gyRszuZ/icHmHAVE4gc/r+cfCmhA1AD+vqfWbgI+eHs= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/bnkamalesh/webgo/v4 v4.1.11/go.mod h1:taIAonQTzao8G5rnB22WgKmQuIOWHpQ0n/YLAidBXlM= github.com/bnkamalesh/webgo/v6 v6.2.2/go.mod h1:2Y+dEdTp1xC/ra+3PAVZV6hh4sCI+iPK7mcHt+t9bfM= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -94,8 +98,8 @@ github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3 github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= -github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.12.0 h1:y2DdzBAURM29NFF94q6RaY4vjIH1rtwDapwQtU84iWk= +github.com/emicklei/go-restful/v3 v3.12.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -104,10 +108,16 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/evanphx/json-patch v5.7.0+incompatible h1:vgGkfT/9f8zE6tvSCe74nfpAVDQ2tG6yudJd8LBksgI= +github.com/evanphx/json-patch v5.7.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg= +github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/getkin/kin-openapi v0.76.0/go.mod h1:660oXbgy5JFMKreazJaQTw7o+X00qeSyhcnluiMv+Xg= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= @@ -126,6 +136,8 @@ github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbV github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/zapr v1.2.3/go.mod h1:eIauM6P8qSvTw5o2ez6UEAfGjQKrxQTl5EoK+Qa2oG4= +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.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= @@ -150,6 +162,8 @@ github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg78 github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= +github.com/gobuffalo/flect v1.0.2 h1:eqjPGSo2WmjgY2XlpGwo2NXgL3RucAKo4k4qQMNA5sA= +github.com/gobuffalo/flect v1.0.2/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= github.com/goccy/go-json v0.9.4/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= @@ -158,6 +172,7 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= @@ -232,6 +247,8 @@ github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLe github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= +github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= @@ -245,6 +262,8 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= +github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= @@ -297,6 +316,8 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= +github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.2.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= @@ -309,6 +330,7 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= @@ -341,7 +363,15 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= +github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= +github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= +github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM= +github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= +github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= @@ -368,14 +398,16 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasthttp v1.35.0/go.mod h1:t/G+3rLek+CyY9bnIE+YlMRddxVAAGjhxndDB4i4C0I= +github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ= +github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= @@ -390,6 +422,7 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.keploy.io/server v0.1.8/go.mod h1:ZqhwTZOBb+dzx5t30Wt6eUGI6kO5QizvPg6coNPtbow= go.mongodb.org/mongo-driver v1.8.0/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY= go.mongodb.org/mongo-driver v1.8.1/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY= @@ -405,10 +438,16 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= +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/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +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.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= +go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= +go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -432,6 +471,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +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/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -457,6 +498,7 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -501,6 +543,7 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -515,6 +558,8 @@ golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= +golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -526,6 +571,7 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -583,11 +629,15 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= +golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -597,6 +647,7 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -604,6 +655,8 @@ golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -660,12 +713,15 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= +gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= @@ -694,6 +750,8 @@ google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -793,6 +851,7 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -812,6 +871,12 @@ k8s.io/apimachinery v0.24.3/go.mod h1:82Bi4sCzVBdpYjyI4jY6aHX+YCUchUIrZrXKedjd2U k8s.io/apimachinery v0.29.3 h1:2tbx+5L7RNvqJjn7RIuIKu9XTsIZ9Z5wX2G22XAa5EU= k8s.io/apimachinery v0.29.3/go.mod h1:hx/S4V2PNW4OMg3WizRrHutyB5la0iCUbZym+W0EQIU= k8s.io/client-go v0.24.2/go.mod h1:zg4Xaoo+umDsfCWr4fCnmLEtQXyCNXCvJuSsglNcV30= +k8s.io/client-go v0.29.3 h1:R/zaZbEAxqComZ9FHeQwOh3Y1ZUs7FaHKZdQtIc2WZg= +k8s.io/client-go v0.29.3/go.mod h1:tkDisCvgPfiRpxGnOORfkljmS+UrW+WtXAy2fTvXJB0= +k8s.io/cluster-bootstrap v0.29.3 h1:DIMDZSN8gbFMy9CS2mAS2Iqq/fIUG783WN/1lqi5TF8= +k8s.io/cluster-bootstrap v0.29.3/go.mod h1:aPAg1VtXx3uRrx5qU2jTzR7p1rf18zLXWS+pGhiqPto= +k8s.io/component-base v0.29.3 h1:Oq9/nddUxlnrCuuR2K/jp6aflVvc0uDvxMzAWxnGzAo= +k8s.io/component-base v0.29.3/go.mod h1:Yuj33XXjuOk2BAaHsIGHhCKZQAgYKhqIxIjIr2UXYio= k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= diff --git a/api/openapi/patterns/anchored.go b/api/openapi/patterns/anchored.go deleted file mode 100644 index 8f4a36dfe..000000000 --- a/api/openapi/patterns/anchored.go +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2023 D2iQ, Inc. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -package patterns - -func Anchored(pattern string) string { - return "^" + pattern + "$" -} - -func HTTPSURL() string { - return `^https://` -} diff --git a/api/openapi/patterns/distribution.go b/api/openapi/patterns/distribution.go deleted file mode 100644 index 5379a6921..000000000 --- a/api/openapi/patterns/distribution.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2023 D2iQ, Inc. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -package patterns - -const ( - // See: https://github.com/distribution/reference/blob/v0.5.0/regexp.go#L53 - NameSeparator = `(?:[._]|__|[-]+)` - - // See: https://github.com/distribution/reference/blob/v0.5.0/regexp.go#L123 - PathComponent = Alphanumeric + `(` + NameSeparator + Alphanumeric + `)*` - - // See: https://github.com/distribution/reference/blob/v0.5.0/regexp.go#L125-L130 - ImageRepository = `(` + HostAndOptionalPort + `/)?` + PathComponent + `(/` + PathComponent + `)*` - - // See: https://github.com/distribution/reference/blob/v0.5.0/regexp.go#L68 - ImageTag = `[\w][\w.-]{0,127}` - - // See: https://github.com/distribution/reference/blob/v0.5.0/regexp.go#L81 - ImageDigest = `[A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][0-9A-Fa-f]{32,}` - - // See: https://github.com/distribution/reference/blob/v0.5.0/regexp.go#L136C2-L136C14 - ImageReference = ImageRepository + `(:` + ImageTag + `)?` + `(@` + ImageDigest + `)?` -) diff --git a/api/openapi/patterns/dns1123.go b/api/openapi/patterns/dns1123.go deleted file mode 100644 index 3652ce90e..000000000 --- a/api/openapi/patterns/dns1123.go +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2023 D2iQ, Inc. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -package patterns - -const ( - // See: https://github.com/kubernetes/apimachinery/blob/v0.28.1/pkg/util/validation/validation.go#L178 - DNS1123Label = `[a-z0-9]([-a-z0-9]*[a-z0-9])?` - - // See: https://github.com/kubernetes/apimachinery/blob/v0.28.1/pkg/util/validation/validation.go#L205 - DNS1123Subdomain = DNS1123Label + `(\.` + DNS1123Label + `)*` -) diff --git a/api/openapi/patterns/generic.go b/api/openapi/patterns/generic.go deleted file mode 100644 index 62d9645ca..000000000 --- a/api/openapi/patterns/generic.go +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2023 D2iQ, Inc. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -package patterns - -const ( - // See: https://github.com/distribution/reference/blob/v0.5.0/regexp.go#L44C2-L44C28 - Alphanumeric = `[a-z0-9]+` -) diff --git a/api/openapi/patterns/net.go b/api/openapi/patterns/net.go deleted file mode 100644 index ac3013eb6..000000000 --- a/api/openapi/patterns/net.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2023 D2iQ, Inc. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -package patterns - -const ( - // See: https://github.com/distribution/reference/blob/v0.5.0/regexp.go#L91 - IPv6 = `\[(?:[a-fA-F0-9:]+)\]` - - Port = `:[0-9]+` - - // See https://github.com/distribution/reference/blob/v0.5.0/regexp.go#L65 - OptionalPort = `(` + Port + `)?` - - // See: https://github.com/distribution/reference/blob/v0.5.0/regexp.go#L106 - Host = `(?:` + DNS1123Subdomain + `|` + IPv6 + `)` - - // See: https://github.com/distribution/reference/blob/v0.5.0/regexp.go#L110 - HostAndOptionalPort = Host + OptionalPort -) diff --git a/api/v1alpha1/addon_types.go b/api/v1alpha1/addon_types.go index 6a74b5645..9395ff58e 100644 --- a/api/v1alpha1/addon_types.go +++ b/api/v1alpha1/addon_types.go @@ -6,10 +6,6 @@ package v1alpha1 import ( corev1 "k8s.io/api/core/v1" storagev1 "k8s.io/api/storage/v1" - "k8s.io/utils/ptr" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/variables" ) const ( @@ -40,111 +36,38 @@ type Addons struct { CSIProviders *CSI `json:"csi,omitempty"` } -func (Addons) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "Cluster configuration", - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "cni": CNI{}.VariableSchema().OpenAPIV3Schema, - "nfd": NFD{}.VariableSchema().OpenAPIV3Schema, - "clusterAutoscaler": ClusterAutoscaler{}.VariableSchema().OpenAPIV3Schema, - "csi": CSI{}.VariableSchema().OpenAPIV3Schema, - "ccm": CCM{}.VariableSchema().OpenAPIV3Schema, - }, - }, - } -} - type AddonStrategy string // CNI required for providing CNI configuration. type CNI struct { - // +optional - Provider string `json:"provider,omitempty"` - // +optional - Strategy AddonStrategy `json:"strategy,omitempty"` -} - -func (CNI) VariableSchema() clusterv1.VariableSchema { - supportedCNIProviders := []string{CNIProviderCalico, CNIProviderCilium} - - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "provider": { - Description: "CNI provider to deploy", - Type: "string", - Enum: variables.MustMarshalValuesToEnumJSON(supportedCNIProviders...), - }, - "strategy": { - Description: "Addon strategy used to deploy the CNI provider to the workload cluster", - Type: "string", - Enum: variables.MustMarshalValuesToEnumJSON( - AddonStrategyClusterResourceSet, - AddonStrategyHelmAddon, - ), - }, - }, - Required: []string{"provider", "strategy"}, - }, - } + // CNI provider to deploy. + // +kubebuilder:validation:Enum=Calico;Cilium + Provider string `json:"provider"` + // Addon strategy used to deploy the CNI provider to the workload cluster. + // +kubebuilder:validation:Enum=ClusterResourceSet;HelmAddon + Strategy AddonStrategy `json:"strategy"` } // NFD tells us to enable or disable the node feature discovery addon. type NFD struct { - // +optional - Strategy AddonStrategy `json:"strategy,omitempty"` -} - -func (NFD) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "strategy": { - Description: "Addon strategy used to deploy Node Feature Discovery (NFD) to the workload cluster", - Type: "string", - Enum: variables.MustMarshalValuesToEnumJSON( - AddonStrategyClusterResourceSet, - AddonStrategyHelmAddon, - ), - }, - }, - Required: []string{"strategy"}, - }, - } + // Addon strategy used to deploy Node Feature Discovery (NFD) to the workload cluster. + // +kubebuilder:validation:Enum=ClusterResourceSet;HelmAddon + Strategy AddonStrategy `json:"strategy"` } // ClusterAutoscaler tells us to enable or disable the cluster-autoscaler addon. type ClusterAutoscaler struct { - // +optional - Strategy AddonStrategy `json:"strategy,omitempty"` -} - -func (ClusterAutoscaler) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "strategy": { - Description: "Addon strategy used to deploy cluster-autoscaler to the management cluster," + - "targeting the workload cluster.", - Type: "string", - Enum: variables.MustMarshalValuesToEnumJSON( - AddonStrategyClusterResourceSet, - AddonStrategyHelmAddon, - ), - }, - }, - Required: []string{"strategy"}, - }, - } + // Addon strategy used to deploy cluster-autoscaler to the management cluster + // targeting the workload cluster. + // +kubebuilder:validation:Enum=ClusterResourceSet;HelmAddon + Strategy AddonStrategy `json:"strategy"` } type DefaultStorage struct { - ProviderName string `json:"providerName"` + // Name of the CSI Provider for the default storage class. + // +kubebuilder:validation:Enum=aws-ebs;nutanix + ProviderName string `json:"providerName"` + // Name of storage class config in any of the provider objects. StorageClassConfigName string `json:"storageClassConfigName"` } @@ -156,186 +79,49 @@ type CSI struct { } type CSIProvider struct { + // Name of the CSI Provider. + // +kubebuilder:validation:Enum=aws-ebs;nutanix Name string `json:"name"` // +optional StorageClassConfig []StorageClassConfig `json:"storageClassConfig,omitempty"` + // Addon strategy used to deploy the CSI provider to the workload cluster. + // +kubebuilder:validation:Enum=ClusterResourceSet;HelmAddon Strategy AddonStrategy `json:"strategy"` + // The reference to any secret used by the CSI Provider. // +optional Credentials *corev1.LocalObjectReference `json:"credentials,omitempty"` } type StorageClassConfig struct { + // Name of storage class config. Name string `json:"name"` + // Parameters passed into the storage class object. // +optional Parameters map[string]string `json:"parameters,omitempty"` + // +kubebuilder:validation:Enum=Delete;Retain;Recycle + // +kubebuilder:default=Delete // +optional ReclaimPolicy corev1.PersistentVolumeReclaimPolicy `json:"reclaimPolicy,omitempty"` + // +kubebuilder:validation:Enum=Immediate;WaitForFirstConsumer + // +kubebuilder:default=WaitForFirstConsumer // +optional VolumeBindingMode storagev1.VolumeBindingMode `json:"volumeBindingMode,omitempty"` + // If the storage class should allow volume expanding + // +kubebuilder:default=false // +optional AllowExpansion bool `json:"allowExpansion,omitempty"` } -func (StorageClassConfig) VariableSchema() clusterv1.VariableSchema { - supportedReclaimPolicies := []string{ - string(VolumeReclaimRecycle), - string(VolumeReclaimDelete), - string(VolumeReclaimRetain), - } - supportedBindingModes := []string{ - string(VolumeBindingImmediate), - string(VolumeBindingWaitForFirstConsumer), - } - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "object", - Required: []string{"name"}, - Properties: map[string]clusterv1.JSONSchemaProps{ - "name": { - Type: "string", - Description: "Name of storage class config.", - }, - "parameters": { - Type: "object", - Description: "Parameters passed into the storage class object.", - AdditionalProperties: &clusterv1.JSONSchemaProps{ - Type: "string", - }, - }, - "reclaimPolicy": { - Type: "string", - Enum: variables.MustMarshalValuesToEnumJSON(supportedReclaimPolicies...), - Default: variables.MustMarshal(VolumeReclaimDelete), - }, - "volumeBindingMode": { - Type: "string", - Enum: variables.MustMarshalValuesToEnumJSON(supportedBindingModes...), - Default: variables.MustMarshal(VolumeBindingWaitForFirstConsumer), - }, - "allowExpansion": { - Type: "boolean", - Default: variables.MustMarshal(false), - Description: "If the storage class should allow volume expanding", - }, - }, - }, - } -} - -func (CSIProvider) VariableSchema() clusterv1.VariableSchema { - supportedCSIProviders := []string{CSIProviderAWSEBS, CSIProviderNutanix} - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "object", - Required: []string{"name", "strategy"}, - Properties: map[string]clusterv1.JSONSchemaProps{ - "name": { - Description: "Name of the CSI Provider", - Type: "string", - Enum: variables.MustMarshalValuesToEnumJSON( - supportedCSIProviders...), - }, - "strategy": { - Description: "Addon strategy used to deploy the CSI provider to the workload cluster", - Type: "string", - Enum: variables.MustMarshalValuesToEnumJSON( - AddonStrategyClusterResourceSet, - AddonStrategyHelmAddon, - ), - }, - "credentials": { - Type: "object", - Description: "The reference to any secret used by the CSI Provider.", - Properties: map[string]clusterv1.JSONSchemaProps{ - "name": { - Type: "string", - }, - }, - }, - "storageClassConfig": { - Type: "array", - Items: ptr.To(StorageClassConfig{}.VariableSchema().OpenAPIV3Schema), - }, - }, - }, - } -} - -func (DefaultStorage) VariableSchema() clusterv1.VariableSchema { - supportedCSIProviders := []string{CSIProviderAWSEBS, CSIProviderNutanix} - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "object", - Description: "A tuple of provider name and storage class ", - Required: []string{"providerName", "storageClassConfigName"}, - Properties: map[string]clusterv1.JSONSchemaProps{ - "providerName": { - Type: "string", - Description: "Name of the CSI Provider for the default storage class", - Enum: variables.MustMarshalValuesToEnumJSON( - supportedCSIProviders..., - ), - }, - "storageClassConfigName": { - Type: "string", - Description: "Name of storage class config in any of the provider objects", - }, - }, - }, - } -} - -func (CSI) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "providers": { - Type: "array", - Items: ptr.To(CSIProvider{}.VariableSchema().OpenAPIV3Schema), - }, - "defaultStorage": DefaultStorage{}.VariableSchema().OpenAPIV3Schema, - }, - }, - } -} - // CCM tells us to enable or disable the cloud provider interface. type CCM struct { // A reference to the Secret for credential information for the target Prism Central instance // +optional Credentials *corev1.LocalObjectReference `json:"credentials,omitempty"` } - -func (CCM) VariableSchema() clusterv1.VariableSchema { - // TODO Validate credentials is set. - // This CCM is shared across all providers. - // Some of these providers may require credentials to be set, but we don't want to require it for all providers. - // The Nutanix CCM handler will fail in at runtime if credentials are not set. - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "credentials": { - Description: "A reference to the Secret for credential information" + - "for the target Prism Central instance", - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "name": { - Description: "The name of the Secret", - Type: "string", - }, - }, - Required: []string{"name"}, - }, - }, - }, - } -} diff --git a/api/v1alpha1/aws_clusterconfig_types.go b/api/v1alpha1/aws_clusterconfig_types.go index cfce84640..049469868 100644 --- a/api/v1alpha1/aws_clusterconfig_types.go +++ b/api/v1alpha1/aws_clusterconfig_types.go @@ -4,146 +4,49 @@ package v1alpha1 import ( - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - capav1 "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/external/sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2" - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/variables" ) type AWSSpec struct { // AWS region to create cluster in. // +optional Region *Region `json:"region,omitempty"` + // AWS network configuration. // +optional Network *AWSNetwork `json:"network,omitempty"` // +optional ControlPlaneLoadBalancer *AWSLoadBalancerSpec `json:"controlPlaneLoadBalancer,omitempty"` } -func (AWSSpec) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "AWS cluster configuration", - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "region": Region("").VariableSchema().OpenAPIV3Schema, - "network": AWSNetwork{}.VariableSchema().OpenAPIV3Schema, - "controlPlaneLoadBalancer": AWSLoadBalancerSpec{}.VariableSchema().OpenAPIV3Schema, - }, - }, - } -} - type Region string -func (Region) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "AWS region to create cluster in", - Type: "string", - }, - } -} - type AWSNetwork struct { // +optional VPC *VPC `json:"vpc,omitempty"` + // AWS Subnet configuration. // +optional Subnets Subnets `json:"subnets,omitempty"` } -func (AWSNetwork) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "AWS network configuration", - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "vpc": VPC{}.VariableSchema().OpenAPIV3Schema, - "subnets": Subnets{}.VariableSchema().OpenAPIV3Schema, - }, - }, - } -} - type VPC struct { - // ID is the vpc-id of the VPC this provider should use to create resources. - ID string `json:"id,omitempty"` -} - -func (VPC) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "AWS VPC configuration", - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "id": { - Description: "Existing VPC ID to use for the cluster", - Type: "string", - }, - }, - }, - } + // Existing VPC ID to use for the cluster. + ID string `json:"id"` } type Subnets []SubnetSpec -func (Subnets) VariableSchema() clusterv1.VariableSchema { - resourceSchema := SubnetSpec{}.VariableSchema().OpenAPIV3Schema - - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "AWS Subnet configurations", - Type: "array", - Items: &resourceSchema, - }, - } -} - // SubnetSpec configures an AWS Subnet. type SubnetSpec struct { - // ID defines a unique identifier to reference this resource. + // Existing Subnet ID to use for the cluster. ID string `json:"id"` } -func (SubnetSpec) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "An AWS Subnet configuration", - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "id": { - Description: "Existing Subnet ID to use for the cluster", - Type: "string", - }, - }, - }, - } -} - // AWSLoadBalancerSpec configures an AWS control-plane LoadBalancer. type AWSLoadBalancerSpec struct { - // Scheme sets the scheme of the load balancer (defaults to internet-facing) + // Scheme sets the scheme of the load balancer. // +kubebuilder:default=internet-facing // +kubebuilder:validation:Enum=internet-facing;internal // +optional Scheme *capav1.ELBScheme `json:"scheme,omitempty"` } - -func (AWSLoadBalancerSpec) VariableSchema() clusterv1.VariableSchema { - supportedScheme := []capav1.ELBScheme{capav1.ELBSchemeInternetFacing, capav1.ELBSchemeInternal} - - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "AWS control-plane LoadBalancer configuration", - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "scheme": { - Description: "Scheme sets the scheme of the load balancer (defaults to internet-facing)", - Type: "string", - Enum: variables.MustMarshalValuesToEnumJSON(supportedScheme...), - }, - }, - }, - } -} diff --git a/api/v1alpha1/aws_node_types.go b/api/v1alpha1/aws_node_types.go index 15b9967af..99e1e6987 100644 --- a/api/v1alpha1/aws_node_types.go +++ b/api/v1alpha1/aws_node_types.go @@ -3,29 +3,34 @@ package v1alpha1 -import ( - v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - "k8s.io/utils/ptr" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/variables" -) +type AWSControlPlaneNodeSpec struct { + // The IAM instance profile to use for the cluster Machines. + // +kubebuilder:default=control-plane.cluster-api-provider-aws.sigs.k8s.io + // +optional + IAMInstanceProfile string `json:"iamInstanceProfile,omitempty"` -const ( - AWSControlPlaneInstanceType InstanceType = "m5.xlarge" - AWSWorkerInstanceType InstanceType = "m5.2xlarge" + // +kubebuilder:default=m5.xlarge + // +optional + InstanceType string `json:"instanceType,omitempty"` - AWSControlPlaneInstanceProfile IAMInstanceProfile = "control-plane.cluster-api-provider-aws.sigs.k8s.io" - AWSWorkerInstanceProfile IAMInstanceProfile = "nodes.cluster-api-provider-aws.sigs.k8s.io" -) + AWSGenericNodeSpec `json:",inline"` +} -type AWSNodeSpec struct { +type AWSWorkerNodeSpec struct { + // The IAM instance profile to use for the cluster Machines. + // +kubebuilder:default=nodes.cluster-api-provider-aws.sigs.k8s.io // +optional - IAMInstanceProfile *IAMInstanceProfile `json:"iamInstanceProfile,omitempty"` + IAMInstanceProfile string `json:"iamInstanceProfile,omitempty"` + // The AWS instance type to use for the cluster Machines. + // +kubebuilder:default=m5.2xlarge // +optional - InstanceType *InstanceType `json:"instanceType,omitempty"` + InstanceType string `json:"instanceType,omitempty"` + AWSGenericNodeSpec `json:",inline"` +} + +type AWSGenericNodeSpec struct { // AMI or AMI Lookup arguments for machine image of a AWS machine. // If both AMI ID and AMI lookup arguments are provided then AMI ID takes precedence //+optional @@ -35,87 +40,16 @@ type AWSNodeSpec struct { AdditionalSecurityGroups AdditionalSecurityGroup `json:"additionalSecurityGroups,omitempty"` } -func NewAWSControlPlaneNodeSpec() *AWSNodeSpec { - return &AWSNodeSpec{ - InstanceType: ptr.To(AWSControlPlaneInstanceType), - IAMInstanceProfile: ptr.To(AWSControlPlaneInstanceProfile), - } -} - -func NewAWSWorkerNodeSpec() *AWSNodeSpec { - return &AWSNodeSpec{ - InstanceType: ptr.To(AWSWorkerInstanceType), - IAMInstanceProfile: ptr.To(AWSWorkerInstanceProfile), - } -} - type AdditionalSecurityGroup []SecurityGroup type SecurityGroup struct { // ID is the id of the security group // +optional - ID *string `json:"id,omitempty"` -} - -func (AdditionalSecurityGroup) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "array", - Items: &clusterv1.JSONSchemaProps{ - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "id": { - Type: "string", - Description: "Security group ID to add for the cluster Machines", - }, - }, - }, - }, - } -} - -func (a AWSNodeSpec) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "AWS Node configuration", - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "iamInstanceProfile": a.IAMInstanceProfile.VariableSchema().OpenAPIV3Schema, - "instanceType": a.InstanceType.VariableSchema().OpenAPIV3Schema, - "ami": AMISpec{}.VariableSchema().OpenAPIV3Schema, - "additionalSecurityGroups": AdditionalSecurityGroup{}.VariableSchema().OpenAPIV3Schema, - }, - Required: []string{"instanceType"}, - }, - } -} - -type IAMInstanceProfile string - -func (i IAMInstanceProfile) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "string", - Description: "The IAM instance profile to use for the cluster Machines", - Default: variables.MustMarshal(i), - }, - } -} - -type InstanceType string - -func (i InstanceType) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "string", - Description: "The AWS instance type to use for the cluster Machines", - Default: variables.MustMarshal(i), - }, - } + ID string `json:"id,omitempty"` } type AMISpec struct { - // ID is an explicit AMI to use. + // AMI ID is the reference to the AMI from which to create the machine instance. // +optional ID string `json:"id,omitempty"` @@ -124,58 +58,18 @@ type AMISpec struct { Lookup *AMILookup `json:"lookup,omitempty"` } -func (AMISpec) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "object", - Default: &v1.JSON{}, - Description: "AMI or AMI Lookup arguments for machine image of a AWS machine." + - "If both AMI ID and AMI lookup arguments are provided then AMI ID takes precedence", - Properties: map[string]clusterv1.JSONSchemaProps{ - "id": { - Type: "string", - Description: "AMI ID is the reference to the AMI from which to create the machine instance.", - }, - "lookup": AMILookup{}.VariableSchema().OpenAPIV3Schema, - }, - }, - } -} - type AMILookup struct { - // Format is the AMI naming format + // AMI naming format. Supports substitutions for {{.BaseOS}} and {{.K8sVersion}} with the + // base OS and kubernetes version. + // +kubebuilder:example=`capa-ami-{{.BaseOS}}-?{{.K8sVersion}}-*` // +optional Format string `json:"format,omitempty"` - // Org is the AWS Organization ID to use for image lookup + // The AWS Organization ID to use for image lookup. // +optional Org string `json:"org,omitempty"` - // BaseOS is the name of the base os for image lookup + // The name of the base os for image lookup // +optional BaseOS string `json:"baseOS,omitempty"` } - -func (AMILookup) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "object", - Default: &v1.JSON{}, - Properties: map[string]clusterv1.JSONSchemaProps{ - "format": { - Type: "string", - Description: "AMI naming format. Supports substitutions for {{.BaseOS}} and {{.K8sVersion}} with the" + - "base OS and kubernetes version. example: capa-ami-{{.BaseOS}}-?{{.K8sVersion}}-*", - }, - "org": { - Type: "string", - Description: "The AWS Organization ID to use for image lookup", - }, - "baseOS": { - Type: "string", - Description: "The name of the base os for image lookup", - }, - }, - }, - } -} diff --git a/api/v1alpha1/clusterconfig_types.go b/api/v1alpha1/clusterconfig_types.go index 3e238f2b2..caeb673af 100644 --- a/api/v1alpha1/clusterconfig_types.go +++ b/api/v1alpha1/clusterconfig_types.go @@ -4,16 +4,13 @@ package v1alpha1 import ( - "fmt" - "maps" - "strings" + _ "embed" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/ptr" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/openapi/patterns" + "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/variables" ) type StorageProvisioner string @@ -44,198 +41,181 @@ var ( "127.0.0.1", "0.0.0.0", } + + //go:embed crds/caren.nutanix.com_dockerclusterconfigs.yaml + dockerClusterConfigCRDDefinition []byte + //go:embed crds/caren.nutanix.com_awsclusterconfigs.yaml + awsClusterConfigCRDDefinition []byte + //go:embed crds/caren.nutanix.com_nutanixclusterconfigs.yaml + nutanixClusterConfigCRDDefinition []byte + + dockerClusterConfigVariableSchema = variables.MustSchemaFromCRDYAML( + dockerClusterConfigCRDDefinition, + ) + awsClusterConfigVariableSchema = variables.MustSchemaFromCRDYAML( + awsClusterConfigCRDDefinition, + ) + nutanixClusterConfigVariableSchema = variables.MustSchemaFromCRDYAML( + nutanixClusterConfigCRDDefinition, + ) ) // +kubebuilder:object:root=true -// ClusterConfig is the Schema for the clusterconfigs API. -type ClusterConfig struct { +// AWSClusterConfig is the Schema for the awsclusterconfigs API. +type AWSClusterConfig struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` // +optional - Spec ClusterConfigSpec `json:"spec,omitempty"` + Spec AWSClusterConfigSpec `json:"spec,omitempty"` +} + +func (s AWSClusterConfig) VariableSchema() clusterv1.VariableSchema { //nolint:gocritic,lll // Passed by value for no potential side-effect. + return awsClusterConfigVariableSchema } -// ClusterConfigSpec defines the desired state of ClusterConfig. -type ClusterConfigSpec struct { +// AWSClusterConfigSpec defines the desired state of ClusterConfig. +type AWSClusterConfigSpec struct { + // AWS cluster configuration. // +optional AWS *AWSSpec `json:"aws,omitempty"` - // +optional - Docker *DockerSpec `json:"docker,omitempty"` - // +optional - Nutanix *NutanixSpec `json:"nutanix,omitempty"` - GenericClusterConfig `json:",inline"` + GenericClusterConfigSpec `json:",inline"` + + // +optional + ControlPlane *AWSControlPlaneNodeConfigSpec `json:"controlPlane,omitempty"` + // Extra Subject Alternative Names for the API Server signing cert. + // +kubebuilder:validation:UniqueItems=true + // +kubebuilder:validation:items:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$` // +optional - ControlPlane *NodeConfigSpec `json:"controlPlane,omitempty"` + ExtraAPIServerCertSANs []string `json:"extraAPIServerCertSANs,omitempty"` } -func (s ClusterConfigSpec) VariableSchema() clusterv1.VariableSchema { //nolint:gocritic,lll // Passed by value for no potential side-effect. - clusterConfigProps := GenericClusterConfig{}.VariableSchema() - switch { - case s.AWS != nil: - maps.Copy( - clusterConfigProps.OpenAPIV3Schema.Properties, - map[string]clusterv1.JSONSchemaProps{ - AWSVariableName: s.AWS.VariableSchema().OpenAPIV3Schema, - "controlPlane": s.ControlPlane.VariableSchema().OpenAPIV3Schema, - }, - ) - case s.Docker != nil: - maps.Copy( - clusterConfigProps.OpenAPIV3Schema.Properties, - map[string]clusterv1.JSONSchemaProps{ - "docker": DockerSpec{}.VariableSchema().OpenAPIV3Schema, - "controlPlane": NodeConfigSpec{ - Docker: &DockerNodeSpec{}, - }.VariableSchema().OpenAPIV3Schema, - }, - ) - case s.Nutanix != nil: - maps.Copy( - clusterConfigProps.OpenAPIV3Schema.Properties, - map[string]clusterv1.JSONSchemaProps{ - NutanixVariableName: NutanixSpec{}.VariableSchema().OpenAPIV3Schema, - "controlPlane": NodeConfigSpec{ - Nutanix: &NutanixNodeSpec{}, - }.VariableSchema().OpenAPIV3Schema, - }, - ) - } +// +kubebuilder:object:root=true - return clusterConfigProps +// DockerClusterConfig is the Schema for the dockerclusterconfigs API. +type DockerClusterConfig struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec DockerClusterConfigSpec `json:"spec,omitempty"` } -func NewAWSClusterConfigSpec() *ClusterConfigSpec { - return &ClusterConfigSpec{ - AWS: &AWSSpec{}, - ControlPlane: &NodeConfigSpec{ - AWS: NewAWSControlPlaneNodeSpec(), - }, - } +func (s DockerClusterConfig) VariableSchema() clusterv1.VariableSchema { //nolint:gocritic,lll // Passed by value for no potential side-effect. + return dockerClusterConfigVariableSchema } -// GenericClusterConfig defines the generic cluster configdesired. -type GenericClusterConfig struct { +// DockerClusterConfigSpec defines the desired state of DockerClusterConfig. +type DockerClusterConfigSpec struct { // +optional - KubernetesImageRepository *KubernetesImageRepository `json:"kubernetesImageRepository,omitempty"` + Docker *DockerSpec `json:"docker,omitempty"` + + GenericClusterConfigSpec `json:",inline"` // +optional - Etcd *Etcd `json:"etcd,omitempty"` + ControlPlane *DockerNodeConfigSpec `json:"controlPlane,omitempty"` + + // Extra Subject Alternative Names for the API Server signing cert. + // For the Nutanix provider, the following default SANs will always be added: + // - localhost + // - 127.0.0.1 + // - 0.0.0.0 + // - host.docker.internal + // +kubebuilder:validation:UniqueItems=true + // +kubebuilder:validation:items:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$` + // +optional + ExtraAPIServerCertSANs []string `json:"extraAPIServerCertSANs,omitempty"` +} + +// +kubebuilder:object:root=true + +// NutanixClusterConfig is the Schema for the nutanixclusterconfigs API. +type NutanixClusterConfig struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` // +optional - Proxy *HTTPProxy `json:"proxy,omitempty"` + Spec NutanixClusterConfigSpec `json:"spec,omitempty"` +} +func (s NutanixClusterConfig) VariableSchema() clusterv1.VariableSchema { //nolint:gocritic,lll // Passed by value for no potential side-effect. + return nutanixClusterConfigVariableSchema +} + +// NutanixClusterConfigSpec defines the desired state of NutanixClusterConfig. +type NutanixClusterConfigSpec struct { // +optional - ExtraAPIServerCertSANs ExtraAPIServerCertSANs `json:"extraAPIServerCertSANs,omitempty"` + Nutanix *NutanixSpec `json:"nutanix,omitempty"` + GenericClusterConfigSpec `json:",inline"` + + // +optional + ControlPlane *NutanixNodeConfigSpec `json:"controlPlane,omitempty"` + + // Subject Alternative Names for the API Server signing cert. + // For the Nutanix provider, the following default SANs will always be added: + // - localhost + // - 127.0.0.1 + // - 0.0.0.0 + // +kubebuilder:validation:UniqueItems=true + // +kubebuilder:validation:items:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$` // +optional - ImageRegistries ImageRegistries `json:"imageRegistries,omitempty"` + ExtraAPIServerCertSANs []string `json:"extraAPIServerCertSANs,omitempty"` +} +// GenericClusterConfigSpec defines the desired state of GenericClusterConfig. +type GenericClusterConfigSpec struct { + // Sets the Kubernetes image repository used for the KubeadmControlPlane. + // +kubebuilder:validation:Pattern=`^((?:[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*|\[(?:[a-fA-F0-9:]+)\])(:[0-9]+)?/)?[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*(/[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*)*$` // +optional - GlobalImageRegistryMirror *GlobalImageRegistryMirror `json:"globalImageRegistryMirror,omitempty"` + KubernetesImageRepository *string `json:"kubernetesImageRepository,omitempty"` // +optional - Addons *Addons `json:"addons,omitempty"` + Etcd *Etcd `json:"etcd,omitempty"` // +optional - Users Users `json:"users,omitempty"` -} + Proxy *HTTPProxy `json:"proxy,omitempty"` -func (s GenericClusterConfig) VariableSchema() clusterv1.VariableSchema { //nolint:gocritic,lll // Passed by value for no potential side-effect. - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "Cluster configuration", - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "addons": Addons{}.VariableSchema().OpenAPIV3Schema, - "etcd": Etcd{}.VariableSchema().OpenAPIV3Schema, - "extraAPIServerCertSANs": ExtraAPIServerCertSANs{}.VariableSchema().OpenAPIV3Schema, - "proxy": HTTPProxy{}.VariableSchema().OpenAPIV3Schema, - "kubernetesImageRepository": KubernetesImageRepository( - "", - ).VariableSchema(). - OpenAPIV3Schema, - "imageRegistries": ImageRegistries{}.VariableSchema().OpenAPIV3Schema, - "globalImageRegistryMirror": GlobalImageRegistryMirror{}.VariableSchema().OpenAPIV3Schema, - "users": Users{}.VariableSchema().OpenAPIV3Schema, - }, - }, - } -} + // +optional + ImageRegistries []ImageRegistry `json:"imageRegistries,omitempty"` -// KubernetesImageRepository required for overriding Kubernetes image repository. -type KubernetesImageRepository string + // +optional + GlobalImageRegistryMirror *GlobalImageRegistryMirror `json:"globalImageRegistryMirror,omitempty"` -func (KubernetesImageRepository) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "Sets the Kubernetes image repository used for the KubeadmControlPlane.", - Type: "string", - Pattern: patterns.Anchored(patterns.ImageRepository), - }, - } -} + // +optional + Addons *Addons `json:"addons,omitempty"` -func (v KubernetesImageRepository) String() string { - return string(v) + // +optional + Users []User `json:"users,omitempty"` } type Image struct { // Repository is used to override the image repository to pull from. + // +kubebuilder:validation:Pattern=`^((?:[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*|\[(?:[a-fA-F0-9:]+)\])(:[0-9]+)?/)?[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*(/[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*)*$` // +optional Repository string `json:"repository,omitempty"` // Tag is used to override the default image tag. + // +kubebuilder:validation:Pattern=`^[\w][\w.-]{0,127}$` // +optional Tag string `json:"tag,omitempty"` } -func (Image) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "repository": { - Description: "Image repository to pull from.", - Type: "string", - Pattern: patterns.Anchored(patterns.ImageRepository), - }, - "tag": { - Description: "Image tag to use.", - Type: "string", - Pattern: patterns.Anchored(patterns.ImageTag), - }, - }, - }, - } -} - type Etcd struct { // Image required for overriding etcd image details. // +optional Image *Image `json:"image,omitempty"` } -func (Etcd) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "image": Image{}.VariableSchema().OpenAPIV3Schema, - }, - }, - } -} - // HTTPProxy required for providing proxy configuration. type HTTPProxy struct { - // HTTP proxy. + // HTTP proxy value. HTTP string `json:"http,omitempty"` - // HTTPS proxy. + // HTTPS proxy value. HTTPS string `json:"https,omitempty"` // AdditionalNo Proxy list that will be added to the automatically calculated @@ -245,56 +225,6 @@ type HTTPProxy struct { AdditionalNo []string `json:"additionalNo"` } -func (HTTPProxy) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "http": { - Description: "HTTP proxy value.", - Type: "string", - }, - "https": { - Description: "HTTPS proxy value.", - Type: "string", - }, - "additionalNo": { - Description: "Additional No Proxy list that will be added to the automatically calculated " + - "values required for cluster internal network. " + - "Default value: localhost,127.0.0.1,,,kubernetes," + - "kubernetes.default,.svc,.svc.", - Type: "array", - Items: &clusterv1.JSONSchemaProps{ - Type: "string", - }, - }, - }, - }, - } -} - -// ExtraAPIServerCertSANs required for providing API server cert SANs. -type ExtraAPIServerCertSANs []string - -func (ExtraAPIServerCertSANs) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: fmt.Sprintf( - //nolint:lll // its a user facing message - "Subject Alternative Names for the API Server signing cert. For Docker %s are injected automatically. For Nutanix %s are injected automatically.", - strings.Join(DefaultDockerCertSANs, ","), - strings.Join(DefaultNutanixCertSANs, ","), - ), - Type: "array", - UniqueItems: true, - Items: &clusterv1.JSONSchemaProps{ - Type: "string", - Pattern: patterns.Anchored(patterns.DNS1123Subdomain), - }, - }, - } -} - type RegistryCredentials struct { // A reference to the Secret containing the registry credentials and optional CA certificate // using the keys `username`, `password` and `ca.crt`. @@ -303,33 +233,11 @@ type RegistryCredentials struct { SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty"` } -func (RegistryCredentials) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "secretRef": { - Description: "A reference to the Secret containing the registry credentials and optional CA certificate. " + - "The Secret should have keys 'username', 'password' and optional 'ca.crt'. " + - "This credentials Secret is not required for some registries, e.g. ECR.", - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "name": { - Description: "The name of the Secret containing the registry credentials. This Secret must exist in " + - "the same namespace as the Cluster.", - Type: "string", - }, - }, - Required: []string{"name"}, - }, - }, - }, - } -} - // GlobalImageRegistryMirror sets default mirror configuration for all the image registries. type GlobalImageRegistryMirror struct { - // Registry URL. + // Registry mirror URL. + // +kubebuilder:validation:Format=`uri` + // +kubebuilder:validation:Pattern=`^https?://` URL string `json:"url"` // Credentials and CA certificate for the image registry mirror @@ -337,26 +245,10 @@ type GlobalImageRegistryMirror struct { Credentials *RegistryCredentials `json:"credentials,omitempty"` } -func (GlobalImageRegistryMirror) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "url": { - Description: "Registry mirror URL.", - Type: "string", - Format: "uri", - Pattern: "^https?://", - }, - "credentials": RegistryCredentials{}.VariableSchema().OpenAPIV3Schema, - }, - Required: []string{"url"}, - }, - } -} - type ImageRegistry struct { // Registry URL. + // +kubebuilder:validation:Format=`uri` + // +kubebuilder:validation:Pattern=`^https?://` URL string `json:"url"` // Credentials and CA certificate for the image registry @@ -364,48 +256,6 @@ type ImageRegistry struct { Credentials *RegistryCredentials `json:"credentials,omitempty"` } -func (ImageRegistry) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "url": { - Description: "Registry URL.", - Type: "string", - Format: "uri", - Pattern: "^https?://", - }, - "credentials": RegistryCredentials{}.VariableSchema().OpenAPIV3Schema, - }, - Required: []string{"url"}, - }, - } -} - -type ImageRegistries []ImageRegistry - -func (ImageRegistries) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "Configuration for image registries.", - Type: "array", - Items: ptr.To(ImageRegistry{}.VariableSchema().OpenAPIV3Schema), - }, - } -} - -type Users []User - -func (Users) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "Users to add to the machine", - Type: "array", - Items: ptr.To(User{}.VariableSchema().OpenAPIV3Schema), - }, - } -} - // User defines the input for a generated user in cloud-init. type User struct { // Name specifies the user name. @@ -431,46 +281,10 @@ type User struct { Sudo string `json:"sudo,omitempty"` } -func (User) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "object", - Required: []string{"name"}, - Properties: map[string]clusterv1.JSONSchemaProps{ - "name": { - Description: "The username", - Type: "string", - }, - "hashedPassword": { - Description: "The hashed password for the user. Must be in the format of some hash function supported by the OS.", - Type: "string", - // The crypt (5) man page lists regexes for supported hash - // functions. We could validate input against a set of - // regexes, but because the set may be different from the - // set supported by the chosen OS, we might return a false - // negative or positive. For this reason, we do not validate - // the input. - }, - "sshAuthorizedKeys": { - Description: "A list of SSH authorized keys for this user", - Type: "array", - Items: &clusterv1.JSONSchemaProps{ - // No description, because the one for the parent array is enough. - Type: "string", - }, - }, - "sudo": { - Description: "The sudo rule that applies to this user", - Type: "string", - // A sudo rule is defined using an EBNF grammar, and must be - // parsed to be validated. We have decided to not integrate - // a sudo rule parser, so we do not validate the input. - }, - }, - }, - } -} - func init() { - SchemeBuilder.Register(&ClusterConfig{}) + SchemeBuilder.Register( + &AWSClusterConfig{}, + &DockerClusterConfig{}, + &NutanixClusterConfig{}, + ) } diff --git a/api/v1alpha1/common_types.go b/api/v1alpha1/common_types.go index d1b0851d2..11d1321f8 100644 --- a/api/v1alpha1/common_types.go +++ b/api/v1alpha1/common_types.go @@ -3,13 +3,6 @@ package v1alpha1 -import ( - "k8s.io/utils/ptr" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/variables" -) - const ( APIServerPort = 6443 ) @@ -35,28 +28,13 @@ type ObjectMeta struct { Annotations map[string]string `json:"annotations,omitempty"` } -type ControlPlaneEndpointSpec clusterv1.APIEndpoint +type ControlPlaneEndpointSpec struct { + // The hostname on which the API server is serving. + // +kubebuilder:validation:MinLength=1 + Host string `json:"host"` -func (ControlPlaneEndpointSpec) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "Kubernetes control-plane endpoint configuration", - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "host": { - Description: "host ip/fqdn for control plane API Server", - Type: "string", - MinLength: ptr.To[int64](1), - }, - "port": { - Description: "port for control plane API Server", - Type: "integer", - Default: variables.MustMarshal(APIServerPort), - Minimum: ptr.To[int64](1), - Maximum: ptr.To[int64](65535), - }, - }, - Required: []string{"host", "port"}, - }, - } + // The port on which the API server is serving. + // +kubebuilder:validation:Minimum=1 + // +kubebuilder:validation:Maximum=65535 + Port int32 `json:"port"` } diff --git a/api/v1alpha1/crds/caren.nutanix.com_awsclusterconfigs.yaml b/api/v1alpha1/crds/caren.nutanix.com_awsclusterconfigs.yaml new file mode 100644 index 000000000..14ec91fc4 --- /dev/null +++ b/api/v1alpha1/crds/caren.nutanix.com_awsclusterconfigs.yaml @@ -0,0 +1,446 @@ +# Copyright 2023 D2iQ, Inc. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: (devel) + name: awsclusterconfigs.caren.nutanix.com +spec: + group: caren.nutanix.com + names: + kind: AWSClusterConfig + listKind: AWSClusterConfigList + plural: awsclusterconfigs + singular: awsclusterconfig + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: AWSClusterConfig is the Schema for the awsclusterconfigs API. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: AWSClusterConfigSpec defines the desired state of ClusterConfig. + properties: + addons: + properties: + ccm: + description: CCM tells us to enable or disable the cloud provider + interface. + properties: + credentials: + description: A reference to the Secret for credential information + for the target Prism Central instance + properties: + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? + type: string + type: object + x-kubernetes-map-type: atomic + type: object + clusterAutoscaler: + description: ClusterAutoscaler tells us to enable or disable the + cluster-autoscaler addon. + properties: + strategy: + description: |- + Addon strategy used to deploy cluster-autoscaler to the management cluster + targeting the workload cluster. + enum: + - ClusterResourceSet + - HelmAddon + type: string + required: + - strategy + type: object + cni: + description: CNI required for providing CNI configuration. + properties: + provider: + description: CNI provider to deploy. + enum: + - Calico + - Cilium + type: string + strategy: + description: Addon strategy used to deploy the CNI provider + to the workload cluster. + enum: + - ClusterResourceSet + - HelmAddon + type: string + required: + - provider + - strategy + type: object + csi: + properties: + defaultStorage: + properties: + providerName: + description: Name of the CSI Provider for the default + storage class. + enum: + - aws-ebs + - nutanix + type: string + storageClassConfigName: + description: Name of storage class config in any of the + provider objects. + type: string + required: + - providerName + - storageClassConfigName + type: object + providers: + items: + properties: + credentials: + description: The reference to any secret used by the + CSI Provider. + properties: + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? + type: string + type: object + x-kubernetes-map-type: atomic + name: + description: Name of the CSI Provider. + enum: + - aws-ebs + - nutanix + type: string + storageClassConfig: + items: + properties: + allowExpansion: + default: false + description: If the storage class should allow + volume expanding + type: boolean + name: + description: Name of storage class config. + type: string + parameters: + additionalProperties: + type: string + description: Parameters passed into the storage + class object. + type: object + reclaimPolicy: + default: Delete + description: PersistentVolumeReclaimPolicy describes + a policy for end-of-life maintenance of persistent + volumes. + enum: + - Delete + - Retain + - Recycle + type: string + volumeBindingMode: + default: WaitForFirstConsumer + description: VolumeBindingMode indicates how PersistentVolumeClaims + should be bound. + enum: + - Immediate + - WaitForFirstConsumer + type: string + required: + - name + type: object + type: array + strategy: + description: Addon strategy used to deploy the CSI provider + to the workload cluster. + enum: + - ClusterResourceSet + - HelmAddon + type: string + required: + - name + - strategy + type: object + type: array + type: object + nfd: + description: NFD tells us to enable or disable the node feature + discovery addon. + properties: + strategy: + description: Addon strategy used to deploy Node Feature Discovery + (NFD) to the workload cluster. + enum: + - ClusterResourceSet + - HelmAddon + type: string + required: + - strategy + type: object + type: object + aws: + description: AWS cluster configuration. + properties: + controlPlaneLoadBalancer: + description: AWSLoadBalancerSpec configures an AWS control-plane + LoadBalancer. + properties: + scheme: + default: internet-facing + description: Scheme sets the scheme of the load balancer. + enum: + - internet-facing + - internal + type: string + type: object + network: + description: AWS network configuration. + properties: + subnets: + description: AWS Subnet configuration. + items: + description: SubnetSpec configures an AWS Subnet. + properties: + id: + description: Existing Subnet ID to use for the cluster. + type: string + required: + - id + type: object + type: array + vpc: + properties: + id: + description: Existing VPC ID to use for the cluster. + type: string + required: + - id + type: object + type: object + region: + description: AWS region to create cluster in. + type: string + type: object + controlPlane: + description: |- + AWSControlPlaneConfigSpec defines the desired state of AWSNodeConfig. + Place any configuration that can be applied to individual Nodes here. + Otherwise, it should go into the ClusterConfigSpec. + properties: + aws: + properties: + additionalSecurityGroups: + items: + properties: + id: + description: ID is the id of the security group + type: string + type: object + type: array + ami: + description: |- + AMI or AMI Lookup arguments for machine image of a AWS machine. + If both AMI ID and AMI lookup arguments are provided then AMI ID takes precedence + properties: + id: + description: AMI ID is the reference to the AMI from which + to create the machine instance. + type: string + lookup: + description: Lookup is the lookup arguments for the AMI. + properties: + baseOS: + description: The name of the base os for image lookup + type: string + format: + description: |- + AMI naming format. Supports substitutions for {{.BaseOS}} and {{.K8sVersion}} with the + base OS and kubernetes version. + example: capa-ami-{{.BaseOS}}-?{{.K8sVersion}}-* + type: string + org: + description: The AWS Organization ID to use for image + lookup. + type: string + type: object + type: object + iamInstanceProfile: + default: control-plane.cluster-api-provider-aws.sigs.k8s.io + description: The IAM instance profile to use for the cluster + Machines. + type: string + instanceType: + default: m5.xlarge + type: string + type: object + type: object + etcd: + properties: + image: + description: Image required for overriding etcd image details. + properties: + repository: + description: Repository is used to override the image repository + to pull from. + pattern: ^((?:[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*|\[(?:[a-fA-F0-9:]+)\])(:[0-9]+)?/)?[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*(/[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*)*$ + type: string + tag: + description: Tag is used to override the default image tag. + pattern: ^[\w][\w.-]{0,127}$ + type: string + type: object + type: object + extraAPIServerCertSANs: + description: Extra Subject Alternative Names for the API Server signing + cert. + items: + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ + type: string + type: array + uniqueItems: true + globalImageRegistryMirror: + description: GlobalImageRegistryMirror sets default mirror configuration + for all the image registries. + properties: + credentials: + description: Credentials and CA certificate for the image registry + mirror + properties: + secretRef: + description: |- + A reference to the Secret containing the registry credentials and optional CA certificate + using the keys `username`, `password` and `ca.crt`. + This credentials Secret is not required for some registries, e.g. ECR. + properties: + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? + type: string + type: object + x-kubernetes-map-type: atomic + type: object + url: + description: Registry mirror URL. + format: uri + pattern: ^https?:// + type: string + required: + - url + type: object + imageRegistries: + items: + properties: + credentials: + description: Credentials and CA certificate for the image registry + properties: + secretRef: + description: |- + A reference to the Secret containing the registry credentials and optional CA certificate + using the keys `username`, `password` and `ca.crt`. + This credentials Secret is not required for some registries, e.g. ECR. + properties: + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? + type: string + type: object + x-kubernetes-map-type: atomic + type: object + url: + description: Registry URL. + format: uri + pattern: ^https?:// + type: string + required: + - url + type: object + type: array + kubernetesImageRepository: + description: Sets the Kubernetes image repository used for the KubeadmControlPlane. + pattern: ^((?:[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*|\[(?:[a-fA-F0-9:]+)\])(:[0-9]+)?/)?[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*(/[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*)*$ + type: string + proxy: + description: HTTPProxy required for providing proxy configuration. + properties: + additionalNo: + description: |- + AdditionalNo Proxy list that will be added to the automatically calculated + values that will apply no_proxy configuration for cluster internal network. + Default values: localhost,127.0.0.1,,,kubernetes + ,kubernetes.default,.svc,.svc. + items: + type: string + type: array + http: + description: HTTP proxy value. + type: string + https: + description: HTTPS proxy value. + type: string + required: + - additionalNo + type: object + users: + items: + description: User defines the input for a generated user in cloud-init. + properties: + hashedPassword: + description: |- + HashedPassword is a hashed password for the user, formatted as described + by the crypt(5) man page. See your distribution's documentation for + instructions to create a hashed password. + An empty string is not marshalled, because it is not a valid value. + type: string + name: + description: Name specifies the user name. + type: string + sshAuthorizedKeys: + description: |- + SSHAuthorizedKeys is a list of public SSH keys to write to the + machine. Use the corresponding private SSH keys to authenticate. See SSH + documentation for instructions to create a key pair. + items: + type: string + type: array + sudo: + description: |- + Sudo is a sudo user specification, formatted as described in the sudo + documentation. + An empty string is not marshalled, because it is not a valid value. + type: string + required: + - name + type: object + type: array + type: object + type: object + served: true + storage: true diff --git a/api/v1alpha1/crds/caren.nutanix.com_awsworkernodeconfigs.yaml b/api/v1alpha1/crds/caren.nutanix.com_awsworkernodeconfigs.yaml new file mode 100644 index 000000000..76512b4e7 --- /dev/null +++ b/api/v1alpha1/crds/caren.nutanix.com_awsworkernodeconfigs.yaml @@ -0,0 +1,96 @@ +# Copyright 2023 D2iQ, Inc. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: (devel) + name: awsworkernodeconfigs.caren.nutanix.com +spec: + group: caren.nutanix.com + names: + kind: AWSWorkerNodeConfig + listKind: AWSWorkerNodeConfigList + plural: awsworkernodeconfigs + singular: awsworkernodeconfig + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: AWSWorkerNodeConfig is the Schema for the awsnodeconfigs API. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: |- + AWSWorkerNodeConfigSpec defines the desired state of AWSNodeConfig. + Place any configuration that can be applied to individual Nodes here. + Otherwise, it should go into the ClusterConfigSpec. + properties: + aws: + properties: + additionalSecurityGroups: + items: + properties: + id: + description: ID is the id of the security group + type: string + type: object + type: array + ami: + description: |- + AMI or AMI Lookup arguments for machine image of a AWS machine. + If both AMI ID and AMI lookup arguments are provided then AMI ID takes precedence + properties: + id: + description: AMI ID is the reference to the AMI from which + to create the machine instance. + type: string + lookup: + description: Lookup is the lookup arguments for the AMI. + properties: + baseOS: + description: The name of the base os for image lookup + type: string + format: + description: |- + AMI naming format. Supports substitutions for {{.BaseOS}} and {{.K8sVersion}} with the + base OS and kubernetes version. + example: capa-ami-{{.BaseOS}}-?{{.K8sVersion}}-* + type: string + org: + description: The AWS Organization ID to use for image + lookup. + type: string + type: object + type: object + iamInstanceProfile: + default: nodes.cluster-api-provider-aws.sigs.k8s.io + description: The IAM instance profile to use for the cluster Machines. + type: string + instanceType: + default: m5.2xlarge + description: The AWS instance type to use for the cluster Machines. + type: string + type: object + type: object + type: object + served: true + storage: true diff --git a/api/v1alpha1/crds/caren.nutanix.com_dockerclusterconfigs.yaml b/api/v1alpha1/crds/caren.nutanix.com_dockerclusterconfigs.yaml new file mode 100644 index 000000000..0086d1894 --- /dev/null +++ b/api/v1alpha1/crds/caren.nutanix.com_dockerclusterconfigs.yaml @@ -0,0 +1,370 @@ +# Copyright 2023 D2iQ, Inc. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: (devel) + name: dockerclusterconfigs.caren.nutanix.com +spec: + group: caren.nutanix.com + names: + kind: DockerClusterConfig + listKind: DockerClusterConfigList + plural: dockerclusterconfigs + singular: dockerclusterconfig + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: DockerClusterConfig is the Schema for the dockerclusterconfigs + API. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: DockerClusterConfigSpec defines the desired state of DockerClusterConfig. + properties: + addons: + properties: + ccm: + description: CCM tells us to enable or disable the cloud provider + interface. + properties: + credentials: + description: A reference to the Secret for credential information + for the target Prism Central instance + properties: + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? + type: string + type: object + x-kubernetes-map-type: atomic + type: object + clusterAutoscaler: + description: ClusterAutoscaler tells us to enable or disable the + cluster-autoscaler addon. + properties: + strategy: + description: |- + Addon strategy used to deploy cluster-autoscaler to the management cluster + targeting the workload cluster. + enum: + - ClusterResourceSet + - HelmAddon + type: string + required: + - strategy + type: object + cni: + description: CNI required for providing CNI configuration. + properties: + provider: + description: CNI provider to deploy. + enum: + - Calico + - Cilium + type: string + strategy: + description: Addon strategy used to deploy the CNI provider + to the workload cluster. + enum: + - ClusterResourceSet + - HelmAddon + type: string + required: + - provider + - strategy + type: object + csi: + properties: + defaultStorage: + properties: + providerName: + description: Name of the CSI Provider for the default + storage class. + enum: + - aws-ebs + - nutanix + type: string + storageClassConfigName: + description: Name of storage class config in any of the + provider objects. + type: string + required: + - providerName + - storageClassConfigName + type: object + providers: + items: + properties: + credentials: + description: The reference to any secret used by the + CSI Provider. + properties: + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? + type: string + type: object + x-kubernetes-map-type: atomic + name: + description: Name of the CSI Provider. + enum: + - aws-ebs + - nutanix + type: string + storageClassConfig: + items: + properties: + allowExpansion: + default: false + description: If the storage class should allow + volume expanding + type: boolean + name: + description: Name of storage class config. + type: string + parameters: + additionalProperties: + type: string + description: Parameters passed into the storage + class object. + type: object + reclaimPolicy: + default: Delete + description: PersistentVolumeReclaimPolicy describes + a policy for end-of-life maintenance of persistent + volumes. + enum: + - Delete + - Retain + - Recycle + type: string + volumeBindingMode: + default: WaitForFirstConsumer + description: VolumeBindingMode indicates how PersistentVolumeClaims + should be bound. + enum: + - Immediate + - WaitForFirstConsumer + type: string + required: + - name + type: object + type: array + strategy: + description: Addon strategy used to deploy the CSI provider + to the workload cluster. + enum: + - ClusterResourceSet + - HelmAddon + type: string + required: + - name + - strategy + type: object + type: array + type: object + nfd: + description: NFD tells us to enable or disable the node feature + discovery addon. + properties: + strategy: + description: Addon strategy used to deploy Node Feature Discovery + (NFD) to the workload cluster. + enum: + - ClusterResourceSet + - HelmAddon + type: string + required: + - strategy + type: object + type: object + controlPlane: + description: DockerNodeConfigSpec defines the desired state of DockerNodeSpec. + properties: + docker: + properties: + customImage: + description: Custom OCI image for control plane and worker + Nodes. + pattern: ^((?:[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*|\[(?:[a-fA-F0-9:]+)\])(:[0-9]+)?/)?[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*(/[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*)*(:[\w][\w.-]{0,127})?(@[A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][0-9A-Fa-f]{32,})?$ + type: string + type: object + type: object + docker: + type: object + etcd: + properties: + image: + description: Image required for overriding etcd image details. + properties: + repository: + description: Repository is used to override the image repository + to pull from. + pattern: ^((?:[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*|\[(?:[a-fA-F0-9:]+)\])(:[0-9]+)?/)?[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*(/[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*)*$ + type: string + tag: + description: Tag is used to override the default image tag. + pattern: ^[\w][\w.-]{0,127}$ + type: string + type: object + type: object + extraAPIServerCertSANs: + description: |- + Extra Subject Alternative Names for the API Server signing cert. + For the Nutanix provider, the following default SANs will always be added: + - localhost + - 127.0.0.1 + - 0.0.0.0 + - host.docker.internal + items: + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ + type: string + type: array + uniqueItems: true + globalImageRegistryMirror: + description: GlobalImageRegistryMirror sets default mirror configuration + for all the image registries. + properties: + credentials: + description: Credentials and CA certificate for the image registry + mirror + properties: + secretRef: + description: |- + A reference to the Secret containing the registry credentials and optional CA certificate + using the keys `username`, `password` and `ca.crt`. + This credentials Secret is not required for some registries, e.g. ECR. + properties: + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? + type: string + type: object + x-kubernetes-map-type: atomic + type: object + url: + description: Registry mirror URL. + format: uri + pattern: ^https?:// + type: string + required: + - url + type: object + imageRegistries: + items: + properties: + credentials: + description: Credentials and CA certificate for the image registry + properties: + secretRef: + description: |- + A reference to the Secret containing the registry credentials and optional CA certificate + using the keys `username`, `password` and `ca.crt`. + This credentials Secret is not required for some registries, e.g. ECR. + properties: + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? + type: string + type: object + x-kubernetes-map-type: atomic + type: object + url: + description: Registry URL. + format: uri + pattern: ^https?:// + type: string + required: + - url + type: object + type: array + kubernetesImageRepository: + description: Sets the Kubernetes image repository used for the KubeadmControlPlane. + pattern: ^((?:[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*|\[(?:[a-fA-F0-9:]+)\])(:[0-9]+)?/)?[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*(/[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*)*$ + type: string + proxy: + description: HTTPProxy required for providing proxy configuration. + properties: + additionalNo: + description: |- + AdditionalNo Proxy list that will be added to the automatically calculated + values that will apply no_proxy configuration for cluster internal network. + Default values: localhost,127.0.0.1,,,kubernetes + ,kubernetes.default,.svc,.svc. + items: + type: string + type: array + http: + description: HTTP proxy value. + type: string + https: + description: HTTPS proxy value. + type: string + required: + - additionalNo + type: object + users: + items: + description: User defines the input for a generated user in cloud-init. + properties: + hashedPassword: + description: |- + HashedPassword is a hashed password for the user, formatted as described + by the crypt(5) man page. See your distribution's documentation for + instructions to create a hashed password. + An empty string is not marshalled, because it is not a valid value. + type: string + name: + description: Name specifies the user name. + type: string + sshAuthorizedKeys: + description: |- + SSHAuthorizedKeys is a list of public SSH keys to write to the + machine. Use the corresponding private SSH keys to authenticate. See SSH + documentation for instructions to create a key pair. + items: + type: string + type: array + sudo: + description: |- + Sudo is a sudo user specification, formatted as described in the sudo + documentation. + An empty string is not marshalled, because it is not a valid value. + type: string + required: + - name + type: object + type: array + type: object + type: object + served: true + storage: true diff --git a/api/v1alpha1/crds/caren.nutanix.com_dockernodeconfigs.yaml b/api/v1alpha1/crds/caren.nutanix.com_dockernodeconfigs.yaml new file mode 100644 index 000000000..c5189c1ee --- /dev/null +++ b/api/v1alpha1/crds/caren.nutanix.com_dockernodeconfigs.yaml @@ -0,0 +1,54 @@ +# Copyright 2023 D2iQ, Inc. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: (devel) + name: dockernodeconfigs.caren.nutanix.com +spec: + group: caren.nutanix.com + names: + kind: DockerNodeConfig + listKind: DockerNodeConfigList + plural: dockernodeconfigs + singular: dockernodeconfig + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: DockerNodeConfig is the Schema for the dockernodeconfigs API. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: DockerNodeConfigSpec defines the desired state of DockerNodeSpec. + properties: + docker: + properties: + customImage: + description: Custom OCI image for control plane and worker Nodes. + pattern: ^((?:[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*|\[(?:[a-fA-F0-9:]+)\])(:[0-9]+)?/)?[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*(/[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*)*(:[\w][\w.-]{0,127})?(@[A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][0-9A-Fa-f]{32,})?$ + type: string + type: object + type: object + type: object + served: true + storage: true diff --git a/api/v1alpha1/crds/caren.nutanix.com_clusterconfigs.yaml b/api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml similarity index 81% rename from api/v1alpha1/crds/caren.nutanix.com_clusterconfigs.yaml rename to api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml index 317feb268..1d7b4c9aa 100644 --- a/api/v1alpha1/crds/caren.nutanix.com_clusterconfigs.yaml +++ b/api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml @@ -6,20 +6,21 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: (devel) - name: clusterconfigs.caren.nutanix.com + name: nutanixclusterconfigs.caren.nutanix.com spec: group: caren.nutanix.com names: - kind: ClusterConfig - listKind: ClusterConfigList - plural: clusterconfigs - singular: clusterconfig + kind: NutanixClusterConfig + listKind: NutanixClusterConfigList + plural: nutanixclusterconfigs + singular: nutanixclusterconfig scope: Namespaced versions: - name: v1alpha1 schema: openAPIV3Schema: - description: ClusterConfig is the Schema for the clusterconfigs API. + description: NutanixClusterConfig is the Schema for the nutanixclusterconfigs + API. properties: apiVersion: description: |- @@ -39,7 +40,7 @@ spec: metadata: type: object spec: - description: ClusterConfigSpec defines the desired state of ClusterConfig. + description: NutanixClusterConfigSpec defines the desired state of NutanixClusterConfig. properties: addons: properties: @@ -65,23 +66,50 @@ spec: cluster-autoscaler addon. properties: strategy: + description: |- + Addon strategy used to deploy cluster-autoscaler to the management cluster + targeting the workload cluster. + enum: + - ClusterResourceSet + - HelmAddon type: string + required: + - strategy type: object cni: description: CNI required for providing CNI configuration. properties: provider: + description: CNI provider to deploy. + enum: + - Calico + - Cilium type: string strategy: + description: Addon strategy used to deploy the CNI provider + to the workload cluster. + enum: + - ClusterResourceSet + - HelmAddon type: string + required: + - provider + - strategy type: object csi: properties: defaultStorage: properties: providerName: + description: Name of the CSI Provider for the default + storage class. + enum: + - aws-ebs + - nutanix type: string storageClassConfigName: + description: Name of storage class config in any of the + provider objects. type: string required: - providerName @@ -91,9 +119,8 @@ spec: items: properties: credentials: - description: |- - LocalObjectReference contains enough information to let you locate the - referenced object inside the same namespace. + description: The reference to any secret used by the + CSI Provider. properties: name: description: |- @@ -104,32 +131,56 @@ spec: type: object x-kubernetes-map-type: atomic name: + description: Name of the CSI Provider. + enum: + - aws-ebs + - nutanix type: string storageClassConfig: items: properties: allowExpansion: + default: false + description: If the storage class should allow + volume expanding type: boolean name: + description: Name of storage class config. type: string parameters: additionalProperties: type: string + description: Parameters passed into the storage + class object. type: object reclaimPolicy: + default: Delete description: PersistentVolumeReclaimPolicy describes a policy for end-of-life maintenance of persistent volumes. + enum: + - Delete + - Retain + - Recycle type: string volumeBindingMode: + default: WaitForFirstConsumer description: VolumeBindingMode indicates how PersistentVolumeClaims should be bound. + enum: + - Immediate + - WaitForFirstConsumer type: string required: - name type: object type: array strategy: + description: Addon strategy used to deploy the CSI provider + to the workload cluster. + enum: + - ClusterResourceSet + - HelmAddon type: string required: - name @@ -142,100 +193,19 @@ spec: discovery addon. properties: strategy: - type: string - type: object - type: object - aws: - properties: - controlPlaneLoadBalancer: - description: AWSLoadBalancerSpec configures an AWS control-plane - LoadBalancer. - properties: - scheme: - default: internet-facing - description: Scheme sets the scheme of the load balancer (defaults - to internet-facing) + description: Addon strategy used to deploy Node Feature Discovery + (NFD) to the workload cluster. enum: - - internet-facing - - internal + - ClusterResourceSet + - HelmAddon type: string + required: + - strategy type: object - network: - properties: - subnets: - items: - description: SubnetSpec configures an AWS Subnet. - properties: - id: - description: ID defines a unique identifier to reference - this resource. - type: string - required: - - id - type: object - type: array - vpc: - properties: - id: - description: ID is the vpc-id of the VPC this provider - should use to create resources. - type: string - type: object - type: object - region: - description: AWS region to create cluster in. - type: string type: object controlPlane: - description: |- - NodeConfigSpec defines the desired state of NodeConfig. - Place any configuration that can be applied to individual Nodes here. - Otherwise, it should go into the ClusterConfigSpec. + description: NutanixNodeSpec defines the desired state of NutanixNodeSpec. properties: - aws: - properties: - additionalSecurityGroups: - items: - properties: - id: - description: ID is the id of the security group - type: string - type: object - type: array - ami: - description: |- - AMI or AMI Lookup arguments for machine image of a AWS machine. - If both AMI ID and AMI lookup arguments are provided then AMI ID takes precedence - properties: - id: - description: ID is an explicit AMI to use. - type: string - lookup: - description: Lookup is the lookup arguments for the AMI. - properties: - baseOS: - description: BaseOS is the name of the base os for - image lookup - type: string - format: - description: Format is the AMI naming format - type: string - org: - description: Org is the AWS Organization ID to use - for image lookup - type: string - type: object - type: object - iamInstanceProfile: - type: string - instanceType: - type: string - type: object - docker: - properties: - customImage: - type: string - type: object nutanix: properties: machineDetails: @@ -258,6 +228,9 @@ spec: bootType: description: Defines the boot type of the virtual machine. Only supports UEFI and Legacy + enum: + - legacy + - uefi type: string cluster: description: |- @@ -392,8 +365,6 @@ spec: - machineDetails type: object type: object - docker: - type: object etcd: properties: image: @@ -402,18 +373,26 @@ spec: repository: description: Repository is used to override the image repository to pull from. + pattern: ^((?:[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*|\[(?:[a-fA-F0-9:]+)\])(:[0-9]+)?/)?[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*(/[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*)*$ type: string tag: description: Tag is used to override the default image tag. + pattern: ^[\w][\w.-]{0,127}$ type: string type: object type: object extraAPIServerCertSANs: - description: ExtraAPIServerCertSANs required for providing API server - cert SANs. + description: |- + Subject Alternative Names for the API Server signing cert. + For the Nutanix provider, the following default SANs will always be added: + - localhost + - 127.0.0.1 + - 0.0.0.0 items: + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ type: string type: array + uniqueItems: true globalImageRegistryMirror: description: GlobalImageRegistryMirror sets default mirror configuration for all the image registries. @@ -438,7 +417,9 @@ spec: x-kubernetes-map-type: atomic type: object url: - description: Registry URL. + description: Registry mirror URL. + format: uri + pattern: ^https?:// type: string required: - url @@ -466,14 +447,16 @@ spec: type: object url: description: Registry URL. + format: uri + pattern: ^https?:// type: string required: - url type: object type: array kubernetesImageRepository: - description: KubernetesImageRepository required for overriding Kubernetes - image repository. + description: Sets the Kubernetes image repository used for the KubeadmControlPlane. + pattern: ^((?:[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*|\[(?:[a-fA-F0-9:]+)\])(:[0-9]+)?/)?[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*(/[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*)*$ type: string nutanix: description: NutanixSpec defines the desired state of NutanixCluster. @@ -485,10 +468,13 @@ spec: properties: host: description: The hostname on which the API server is serving. + minLength: 1 type: string port: description: The port on which the API server is serving. format: int32 + maximum: 65535 + minimum: 1 type: integer required: - host @@ -502,10 +488,11 @@ spec: A base64 PEM encoded x509 cert for the RootCA that was used to create the certificate for a Prism Central that uses certificates that were issued by a non-publicly trusted RootCA. The trust bundle is added to the cert pool used to authenticate the TLS connection to the Prism Central. + format: byte type: string credentials: description: A reference to the Secret for credential information - for the target Prism Central instance + for the target Prism Central instance. properties: name: description: |- @@ -520,7 +507,9 @@ spec: type: boolean url: description: The URL of Nutanix Prism Central, can be DNS - name or an IP address + name or an IP address. + format: uri + pattern: ^https:// type: string required: - credentials @@ -543,10 +532,10 @@ spec: type: string type: array http: - description: HTTP proxy. + description: HTTP proxy value. type: string https: - description: HTTPS proxy. + description: HTTPS proxy value. type: string required: - additionalNo diff --git a/api/v1alpha1/crds/caren.nutanix.com_nodeconfigs.yaml b/api/v1alpha1/crds/caren.nutanix.com_nutanixnodeconfigs.yaml similarity index 79% rename from api/v1alpha1/crds/caren.nutanix.com_nodeconfigs.yaml rename to api/v1alpha1/crds/caren.nutanix.com_nutanixnodeconfigs.yaml index 35eada48a..d06c890a8 100644 --- a/api/v1alpha1/crds/caren.nutanix.com_nodeconfigs.yaml +++ b/api/v1alpha1/crds/caren.nutanix.com_nutanixnodeconfigs.yaml @@ -6,20 +6,20 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: (devel) - name: nodeconfigs.caren.nutanix.com + name: nutanixnodeconfigs.caren.nutanix.com spec: group: caren.nutanix.com names: - kind: NodeConfig - listKind: NodeConfigList - plural: nodeconfigs - singular: nodeconfig + kind: NutanixNodeConfig + listKind: NutanixNodeConfigList + plural: nutanixnodeconfigs + singular: nutanixnodeconfig scope: Namespaced versions: - name: v1alpha1 schema: openAPIV3Schema: - description: NodeConfig is the Schema for the workerconfigs API. + description: NutanixNodeConfig is the Schema for the nutanixnodeconfigs API. properties: apiVersion: description: |- @@ -39,55 +39,8 @@ spec: metadata: type: object spec: - description: |- - NodeConfigSpec defines the desired state of NodeConfig. - Place any configuration that can be applied to individual Nodes here. - Otherwise, it should go into the ClusterConfigSpec. + description: NutanixNodeSpec defines the desired state of NutanixNodeSpec. properties: - aws: - properties: - additionalSecurityGroups: - items: - properties: - id: - description: ID is the id of the security group - type: string - type: object - type: array - ami: - description: |- - AMI or AMI Lookup arguments for machine image of a AWS machine. - If both AMI ID and AMI lookup arguments are provided then AMI ID takes precedence - properties: - id: - description: ID is an explicit AMI to use. - type: string - lookup: - description: Lookup is the lookup arguments for the AMI. - properties: - baseOS: - description: BaseOS is the name of the base os for image - lookup - type: string - format: - description: Format is the AMI naming format - type: string - org: - description: Org is the AWS Organization ID to use for - image lookup - type: string - type: object - type: object - iamInstanceProfile: - type: string - instanceType: - type: string - type: object - docker: - properties: - customImage: - type: string - type: object nutanix: properties: machineDetails: @@ -110,6 +63,9 @@ spec: bootType: description: Defines the boot type of the virtual machine. Only supports UEFI and Legacy + enum: + - legacy + - uefi type: string cluster: description: |- diff --git a/api/v1alpha1/docker_clusterconfig_types.go b/api/v1alpha1/docker_clusterconfig_types.go index 7fbcc8fd3..cc37284cb 100644 --- a/api/v1alpha1/docker_clusterconfig_types.go +++ b/api/v1alpha1/docker_clusterconfig_types.go @@ -3,18 +3,4 @@ package v1alpha1 -import ( - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" -) - type DockerSpec struct{} - -func (DockerSpec) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "Docker cluster configuration", - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{}, - }, - } -} diff --git a/api/v1alpha1/docker_node_types.go b/api/v1alpha1/docker_node_types.go index 268194eee..da8bf5ad3 100644 --- a/api/v1alpha1/docker_node_types.go +++ b/api/v1alpha1/docker_node_types.go @@ -3,37 +3,9 @@ package v1alpha1 -import ( - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/openapi/patterns" -) - type DockerNodeSpec struct { + // Custom OCI image for control plane and worker Nodes. + // +kubebuilder:validation:Pattern=`^((?:[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*|\[(?:[a-fA-F0-9:]+)\])(:[0-9]+)?/)?[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*(/[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*)*(:[\w][\w.-]{0,127})?(@[A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][0-9A-Fa-f]{32,})?$` // +optional - CustomImage *OCIImage `json:"customImage,omitempty"` -} - -func (DockerNodeSpec) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "Docker Node configuration", - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "customImage": OCIImage("").VariableSchema().OpenAPIV3Schema, - }, - }, - } -} - -type OCIImage string - -func (OCIImage) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "Custom OCI image for control plane and worker Nodes.", - Type: "string", - Pattern: patterns.Anchored(patterns.ImageReference), - }, - } + CustomImage *string `json:"customImage,omitempty"` } diff --git a/api/v1alpha1/node_types.go b/api/v1alpha1/node_types.go deleted file mode 100644 index 7455da6cf..000000000 --- a/api/v1alpha1/node_types.go +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2023 D2iQ, Inc. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -package v1alpha1 - -import ( - "maps" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" -) - -//+kubebuilder:object:root=true - -// NodeConfig is the Schema for the workerconfigs API. -type NodeConfig struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - //+optional - Spec NodeConfigSpec `json:"spec,omitempty"` -} - -// NodeConfigSpec defines the desired state of NodeConfig. -// Place any configuration that can be applied to individual Nodes here. -// Otherwise, it should go into the ClusterConfigSpec. -type NodeConfigSpec struct { - // +optional - AWS *AWSNodeSpec `json:"aws,omitempty"` - // +optional - Docker *DockerNodeSpec `json:"docker,omitempty"` - // +optional - Nutanix *NutanixNodeSpec `json:"nutanix,omitempty"` -} - -func (s NodeConfigSpec) VariableSchema() clusterv1.VariableSchema { - nodeConfigProps := GenericNodeConfig{}.VariableSchema() - - switch { - case s.AWS != nil: - maps.Copy( - nodeConfigProps.OpenAPIV3Schema.Properties, - map[string]clusterv1.JSONSchemaProps{ - AWSVariableName: s.AWS.VariableSchema().OpenAPIV3Schema, - }, - ) - case s.Docker != nil: - maps.Copy( - nodeConfigProps.OpenAPIV3Schema.Properties, - map[string]clusterv1.JSONSchemaProps{ - "docker": DockerNodeSpec{}.VariableSchema().OpenAPIV3Schema, - }, - ) - case s.Nutanix != nil: - maps.Copy( - nodeConfigProps.OpenAPIV3Schema.Properties, - map[string]clusterv1.JSONSchemaProps{ - "nutanix": NutanixNodeSpec{}.VariableSchema().OpenAPIV3Schema, - }, - ) - } - - return nodeConfigProps -} - -func NewAWSWorkerConfigSpec() *NodeConfigSpec { - return &NodeConfigSpec{ - AWS: NewAWSWorkerNodeSpec(), - } -} - -type GenericNodeConfig struct{} - -func (GenericNodeConfig) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "Node configuration", - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{}, - }, - } -} - -func init() { - SchemeBuilder.Register(&NodeConfig{}) -} diff --git a/api/v1alpha1/nodeconfig_types.go b/api/v1alpha1/nodeconfig_types.go new file mode 100644 index 000000000..4125ece69 --- /dev/null +++ b/api/v1alpha1/nodeconfig_types.go @@ -0,0 +1,107 @@ +// Copyright 2023 D2iQ, Inc. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +package v1alpha1 + +import ( + _ "embed" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + + "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/variables" +) + +var ( + //go:embed crds/caren.nutanix.com_dockernodeconfigs.yaml + dockerNodeConfigCRDDefinition []byte + //go:embed crds/caren.nutanix.com_awsworkernodeconfigs.yaml + awsNodeConfigCRDDefinition []byte + //go:embed crds/caren.nutanix.com_nutanixnodeconfigs.yaml + nutanixNodeConfigCRDDefinition []byte + + dockerNodeConfigVariableSchema = variables.MustSchemaFromCRDYAML( + dockerNodeConfigCRDDefinition, + ) + awsWorkerNodeConfigVariableSchema = variables.MustSchemaFromCRDYAML(awsNodeConfigCRDDefinition) + nutanixNodeConfigVariableSchema = variables.MustSchemaFromCRDYAML( + nutanixNodeConfigCRDDefinition, + ) +) + +// +kubebuilder:object:root=true + +// AWSWorkerNodeConfig is the Schema for the awsnodeconfigs API. +type AWSWorkerNodeConfig struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + //+optional + Spec AWSWorkerNodeConfigSpec `json:"spec,omitempty"` +} + +func (s AWSWorkerNodeConfig) VariableSchema() clusterv1.VariableSchema { //nolint:gocritic,lll // Passed by value for no potential side-effect. + return awsWorkerNodeConfigVariableSchema +} + +// AWSWorkerNodeConfigSpec defines the desired state of AWSNodeConfig. +// Place any configuration that can be applied to individual Nodes here. +// Otherwise, it should go into the ClusterConfigSpec. +type AWSWorkerNodeConfigSpec struct { + // +optional + AWS *AWSWorkerNodeSpec `json:"aws,omitempty"` +} + +// AWSControlPlaneConfigSpec defines the desired state of AWSNodeConfig. +// Place any configuration that can be applied to individual Nodes here. +// Otherwise, it should go into the ClusterConfigSpec. +type AWSControlPlaneNodeConfigSpec struct { + // +optional + AWS *AWSControlPlaneNodeSpec `json:"aws,omitempty"` +} + +// +kubebuilder:object:root=true + +// DockerNodeConfig is the Schema for the dockernodeconfigs API. +type DockerNodeConfig struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + //+optional + Spec DockerNodeConfigSpec `json:"spec,omitempty"` +} + +func (s DockerNodeConfig) VariableSchema() clusterv1.VariableSchema { //nolint:gocritic,lll // Passed by value for no potential side-effect. + return dockerNodeConfigVariableSchema +} + +// DockerNodeConfigSpec defines the desired state of DockerNodeSpec. +type DockerNodeConfigSpec struct { + // +optional + Docker *DockerNodeSpec `json:"docker,omitempty"` +} + +// +kubebuilder:object:root=true + +// NutanixNodeConfig is the Schema for the nutanixnodeconfigs API. +type NutanixNodeConfig struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + //+optional + Spec NutanixNodeConfigSpec `json:"spec,omitempty"` +} + +func (s NutanixNodeConfig) VariableSchema() clusterv1.VariableSchema { //nolint:gocritic,lll // Passed by value for no potential side-effect. + return nutanixNodeConfigVariableSchema +} + +// NutanixNodeSpec defines the desired state of NutanixNodeSpec. +type NutanixNodeConfigSpec struct { + // +optional + Nutanix *NutanixNodeSpec `json:"nutanix,omitempty"` +} + +func init() { + SchemeBuilder.Register(&AWSWorkerNodeConfig{}, &DockerNodeConfig{}, &NutanixNodeConfig{}) +} diff --git a/api/v1alpha1/nutanix_clusterconfig_types.go b/api/v1alpha1/nutanix_clusterconfig_types.go index 3b46d838d..3d7ff29c8 100644 --- a/api/v1alpha1/nutanix_clusterconfig_types.go +++ b/api/v1alpha1/nutanix_clusterconfig_types.go @@ -9,10 +9,6 @@ import ( "strconv" corev1 "k8s.io/api/core/v1" - "k8s.io/utils/ptr" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/openapi/patterns" ) const ( @@ -23,27 +19,16 @@ const ( type NutanixSpec struct { // ControlPlaneEndpoint represents the endpoint used to communicate with the control plane. // host can be either DNS name or ip address - ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"` + ControlPlaneEndpoint ControlPlaneEndpointSpec `json:"controlPlaneEndpoint"` // Nutanix Prism Central endpoint configuration. PrismCentralEndpoint NutanixPrismCentralEndpointSpec `json:"prismCentralEndpoint"` } -func (NutanixSpec) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "Nutanix cluster configuration", - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "controlPlaneEndpoint": ControlPlaneEndpointSpec{}.VariableSchema().OpenAPIV3Schema, - "prismCentralEndpoint": NutanixPrismCentralEndpointSpec{}.VariableSchema().OpenAPIV3Schema, - }, - }, - } -} - type NutanixPrismCentralEndpointSpec struct { - // The URL of Nutanix Prism Central, can be DNS name or an IP address + // The URL of Nutanix Prism Central, can be DNS name or an IP address. + // +kubebuilder:validation:Format=`uri` + // +kubebuilder:validation:Pattern=`^https://` URL string `json:"url"` // use insecure connection to Prism Central endpoint @@ -53,58 +38,15 @@ type NutanixPrismCentralEndpointSpec struct { // A base64 PEM encoded x509 cert for the RootCA that was used to create // the certificate for a Prism Central that uses certificates that were issued by a non-publicly trusted RootCA. // The trust bundle is added to the cert pool used to authenticate the TLS connection to the Prism Central. + // +kubebuilder:validation:Format=`byte` // +optional AdditionalTrustBundle *string `json:"additionalTrustBundle,omitempty"` - // A reference to the Secret for credential information for the target Prism Central instance - Credentials corev1.LocalObjectReference `json:"credentials"` -} - -func (NutanixPrismCentralEndpointSpec) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "Nutanix Prism Central endpoint configuration", - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "url": { - Description: "The URL of Nutanix Prism Central, can be DNS name or an IP address", - Type: "string", - MinLength: ptr.To[int64](1), - Format: "uri", - Pattern: patterns.HTTPSURL(), - }, - "insecure": { - Description: "Use insecure connection to Prism Central endpoint", - Type: "boolean", - }, - "additionalTrustBundle": { - Description: "A base64 PEM encoded x509 cert for the RootCA " + - "that was used to create the certificate for a Prism Central that uses certificates " + - "that were issued by a non-publicly trusted RootCA." + - "The trust bundle is added to the cert pool used to authenticate the TLS connection " + - "to the Prism Central.", - Type: "string", - Format: "byte", - }, - "credentials": { - Description: "A reference to the Secret for credential information" + - "for the target Prism Central instance", - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "name": { - Description: "The name of the Secret", - Type: "string", - }, - }, - Required: []string{"name"}, - }, - }, - Required: []string{"url", "credentials"}, - }, - } + // A reference to the Secret for credential information for the target Prism Central instance. + Credentials *corev1.LocalObjectReference `json:"credentials"` } -//nolint:gocritic // no need for named return values +//nolint:gocritic // No need for named return values func (s NutanixPrismCentralEndpointSpec) ParseURL() (string, int32, error) { var prismCentralURL *url.URL prismCentralURL, err := url.Parse(s.URL) diff --git a/api/v1alpha1/nutanix_node_types.go b/api/v1alpha1/nutanix_node_types.go index c028c280a..5b8ddbe6b 100644 --- a/api/v1alpha1/nutanix_node_types.go +++ b/api/v1alpha1/nutanix_node_types.go @@ -5,30 +5,14 @@ package v1alpha1 import ( "k8s.io/apimachinery/pkg/api/resource" - "k8s.io/utils/ptr" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" capxv1 "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/external/github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1" - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/variables" ) type NutanixNodeSpec struct { MachineDetails NutanixMachineDetails `json:"machineDetails"` } -func (NutanixNodeSpec) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "Nutanix Node configuration", - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "machineDetails": NutanixMachineDetails{}.VariableSchema().OpenAPIV3Schema, - }, - Required: []string{"machineDetails"}, - }, - } -} - type NutanixMachineDetails struct { // vcpusPerSocket is the number of vCPUs per socket of the VM VCPUsPerSocket int32 `json:"vcpusPerSocket"` @@ -69,150 +53,14 @@ type NutanixMachineDetails struct { Project *NutanixResourceIdentifier `json:"project,omitempty"` } -func (NutanixMachineDetails) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "Nutanix Machine configuration", - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "vcpusPerSocket": { - Description: "vcpusPerSocket is the number of vCPUs per socket of the VM", - Type: "integer", - }, - "vcpuSockets": { - Description: "vcpuSockets is the number of vCPU sockets of the VM", - Type: "integer", - }, - "memorySize": { - Description: "memorySize is the memory size (in Quantity format) of the VM eg. 4Gi", - Type: "string", - }, - "image": NutanixResourceIdentifier{}.VariableSchemaFromDescription( - //nolint:lll // Long description. - "image identifies the image uploaded to Prism Central (PC). The identifier (uuid or name) can be obtained from the console or API.", - ).OpenAPIV3Schema, - "cluster": NutanixResourceIdentifier{}.VariableSchemaFromDescription( - //nolint:lll // Long description. - "cluster identifies the Prism Element in which the machine will be created. The identifier (uuid or name) can be obtained from the console or API.", - ).OpenAPIV3Schema, - "subnets": { - Type: "array", - Description: "subnets is a list of network subnets to use for the machine", - Items: ptr.To(NutanixResourceIdentifier{}.VariableSchemaFromDescription( - //nolint:lll // Long description. - "subnet identifies the network subnet to use for the machine. The identifier (uuid or name) can be obtained from the console or API.", - ).OpenAPIV3Schema), - }, - "additionalCategories": { - Type: "array", - //nolint:lll // Description is long. - Description: "List of categories that need to be added to the machines. Categories must already exist in Prism Central. One category key can have more than one value.", - Items: ptr.To( - NutanixCategoryIdentifier{}.VariableSchema().OpenAPIV3Schema, - ), - }, - "bootType": NutanixBootType( - capxv1.NutanixBootTypeLegacy, - ).VariableSchema(). - OpenAPIV3Schema, - "systemDiskSize": { - Description: "systemDiskSize is size (in Quantity format) of the system disk of the VM eg. 20Gi", - Type: "string", - }, - "project": NutanixResourceIdentifier{}.VariableSchemaFromDescription( - //nolint:lll // Long description. - "add the virtual machines to the project defined in Prism Central. The project must already be present in the Prism Central.", - ).OpenAPIV3Schema, - }, - Required: []string{ - "vcpusPerSocket", - "vcpuSockets", - "memorySize", - "image", - "cluster", - "subnets", - "systemDiskSize", - }, - }, - } -} - // NutanixIdentifierType is an enumeration of different resource identifier types. type NutanixIdentifierType capxv1.NutanixIdentifierType -func (NutanixIdentifierType) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "string", - Description: "NutanixIdentifierType is an enumeration of different resource identifier types", - Enum: variables.MustMarshalValuesToEnumJSON( - capxv1.NutanixIdentifierUUID, - capxv1.NutanixIdentifierName, - ), - }, - } -} - // NutanixBootType is an enumeration of different boot types. +// +kubebuilder:validation:Required +// +kubebuilder:validation:Enum:=legacy;uefi type NutanixBootType capxv1.NutanixBootType -func (NutanixBootType) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Type: "string", - Description: "NutanixBootType is an enumeration of different boot types.", - Enum: variables.MustMarshalValuesToEnumJSON( - capxv1.NutanixBootTypeLegacy, - capxv1.NutanixBootTypeUEFI, - ), - }, - } -} - type NutanixResourceIdentifier capxv1.NutanixResourceIdentifier -func (NutanixResourceIdentifier) VariableSchemaFromDescription( - description string, -) clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "Nutanix Resource Identifier", - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "type": NutanixIdentifierType( - capxv1.NutanixIdentifierName, - ).VariableSchema(). - OpenAPIV3Schema, - "uuid": { - Type: "string", - Description: "uuid is the UUID of the resource in the PC.", - }, - "name": { - Type: "string", - Description: "name is the resource name in the PC.", - }, - }, - }, - } -} - type NutanixCategoryIdentifier capxv1.NutanixCategoryIdentifier - -func (NutanixCategoryIdentifier) VariableSchema() clusterv1.VariableSchema { - return clusterv1.VariableSchema{ - OpenAPIV3Schema: clusterv1.JSONSchemaProps{ - Description: "Nutanix Category Identifier", - Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ - "key": { - Type: "string", - Description: "key is the Key of category in PC.", - }, - "value": { - Type: "string", - Description: "value is the category value linked to the category key in PC.", - }, - }, - }, - } -} diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 01029e04d..d447db035 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -49,63 +49,101 @@ func (in *AMISpec) DeepCopy() *AMISpec { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AWSLoadBalancerSpec) DeepCopyInto(out *AWSLoadBalancerSpec) { +func (in *AWSClusterConfig) DeepCopyInto(out *AWSClusterConfig) { *out = *in - if in.Scheme != nil { - in, out := &in.Scheme, &out.Scheme - *out = new(v1beta2.ELBScheme) - **out = **in - } + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSLoadBalancerSpec. -func (in *AWSLoadBalancerSpec) DeepCopy() *AWSLoadBalancerSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSClusterConfig. +func (in *AWSClusterConfig) DeepCopy() *AWSClusterConfig { if in == nil { return nil } - out := new(AWSLoadBalancerSpec) + out := new(AWSClusterConfig) in.DeepCopyInto(out) return out } +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AWSClusterConfig) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AWSNetwork) DeepCopyInto(out *AWSNetwork) { +func (in *AWSClusterConfigSpec) DeepCopyInto(out *AWSClusterConfigSpec) { *out = *in - if in.VPC != nil { - in, out := &in.VPC, &out.VPC - *out = new(VPC) - **out = **in + if in.AWS != nil { + in, out := &in.AWS, &out.AWS + *out = new(AWSSpec) + (*in).DeepCopyInto(*out) } - if in.Subnets != nil { - in, out := &in.Subnets, &out.Subnets - *out = make(Subnets, len(*in)) + in.GenericClusterConfigSpec.DeepCopyInto(&out.GenericClusterConfigSpec) + if in.ControlPlane != nil { + in, out := &in.ControlPlane, &out.ControlPlane + *out = new(AWSControlPlaneNodeConfigSpec) + (*in).DeepCopyInto(*out) + } + if in.ExtraAPIServerCertSANs != nil { + in, out := &in.ExtraAPIServerCertSANs, &out.ExtraAPIServerCertSANs + *out = make([]string, len(*in)) copy(*out, *in) } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSNetwork. -func (in *AWSNetwork) DeepCopy() *AWSNetwork { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSClusterConfigSpec. +func (in *AWSClusterConfigSpec) DeepCopy() *AWSClusterConfigSpec { if in == nil { return nil } - out := new(AWSNetwork) + out := new(AWSClusterConfigSpec) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AWSNodeSpec) DeepCopyInto(out *AWSNodeSpec) { +func (in *AWSControlPlaneNodeConfigSpec) DeepCopyInto(out *AWSControlPlaneNodeConfigSpec) { *out = *in - if in.IAMInstanceProfile != nil { - in, out := &in.IAMInstanceProfile, &out.IAMInstanceProfile - *out = new(IAMInstanceProfile) - **out = **in + if in.AWS != nil { + in, out := &in.AWS, &out.AWS + *out = new(AWSControlPlaneNodeSpec) + (*in).DeepCopyInto(*out) } - if in.InstanceType != nil { - in, out := &in.InstanceType, &out.InstanceType - *out = new(InstanceType) - **out = **in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSControlPlaneNodeConfigSpec. +func (in *AWSControlPlaneNodeConfigSpec) DeepCopy() *AWSControlPlaneNodeConfigSpec { + if in == nil { + return nil } + out := new(AWSControlPlaneNodeConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AWSControlPlaneNodeSpec) DeepCopyInto(out *AWSControlPlaneNodeSpec) { + *out = *in + in.AWSGenericNodeSpec.DeepCopyInto(&out.AWSGenericNodeSpec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSControlPlaneNodeSpec. +func (in *AWSControlPlaneNodeSpec) DeepCopy() *AWSControlPlaneNodeSpec { + if in == nil { + return nil + } + out := new(AWSControlPlaneNodeSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AWSGenericNodeSpec) DeepCopyInto(out *AWSGenericNodeSpec) { + *out = *in if in.AMISpec != nil { in, out := &in.AMISpec, &out.AMISpec *out = new(AMISpec) @@ -114,18 +152,61 @@ func (in *AWSNodeSpec) DeepCopyInto(out *AWSNodeSpec) { if in.AdditionalSecurityGroups != nil { in, out := &in.AdditionalSecurityGroups, &out.AdditionalSecurityGroups *out = make(AdditionalSecurityGroup, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSGenericNodeSpec. +func (in *AWSGenericNodeSpec) DeepCopy() *AWSGenericNodeSpec { + if in == nil { + return nil + } + out := new(AWSGenericNodeSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AWSLoadBalancerSpec) DeepCopyInto(out *AWSLoadBalancerSpec) { + *out = *in + if in.Scheme != nil { + in, out := &in.Scheme, &out.Scheme + *out = new(v1beta2.ELBScheme) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSLoadBalancerSpec. +func (in *AWSLoadBalancerSpec) DeepCopy() *AWSLoadBalancerSpec { + if in == nil { + return nil + } + out := new(AWSLoadBalancerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AWSNetwork) DeepCopyInto(out *AWSNetwork) { + *out = *in + if in.VPC != nil { + in, out := &in.VPC, &out.VPC + *out = new(VPC) + **out = **in + } + if in.Subnets != nil { + in, out := &in.Subnets, &out.Subnets + *out = make(Subnets, len(*in)) + copy(*out, *in) } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSNodeSpec. -func (in *AWSNodeSpec) DeepCopy() *AWSNodeSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSNetwork. +func (in *AWSNetwork) DeepCopy() *AWSNetwork { if in == nil { return nil } - out := new(AWSNodeSpec) + out := new(AWSNetwork) in.DeepCopyInto(out) return out } @@ -160,14 +241,74 @@ func (in *AWSSpec) DeepCopy() *AWSSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AWSWorkerNodeConfig) DeepCopyInto(out *AWSWorkerNodeConfig) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSWorkerNodeConfig. +func (in *AWSWorkerNodeConfig) DeepCopy() *AWSWorkerNodeConfig { + if in == nil { + return nil + } + out := new(AWSWorkerNodeConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AWSWorkerNodeConfig) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AWSWorkerNodeConfigSpec) DeepCopyInto(out *AWSWorkerNodeConfigSpec) { + *out = *in + if in.AWS != nil { + in, out := &in.AWS, &out.AWS + *out = new(AWSWorkerNodeSpec) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSWorkerNodeConfigSpec. +func (in *AWSWorkerNodeConfigSpec) DeepCopy() *AWSWorkerNodeConfigSpec { + if in == nil { + return nil + } + out := new(AWSWorkerNodeConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AWSWorkerNodeSpec) DeepCopyInto(out *AWSWorkerNodeSpec) { + *out = *in + in.AWSGenericNodeSpec.DeepCopyInto(&out.AWSGenericNodeSpec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSWorkerNodeSpec. +func (in *AWSWorkerNodeSpec) DeepCopy() *AWSWorkerNodeSpec { + if in == nil { + return nil + } + out := new(AWSWorkerNodeSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in AdditionalSecurityGroup) DeepCopyInto(out *AdditionalSecurityGroup) { { in := &in *out = make(AdditionalSecurityGroup, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } + copy(*out, *in) } } @@ -326,25 +467,55 @@ func (in *ClusterAutoscaler) DeepCopy() *ClusterAutoscaler { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterConfig) DeepCopyInto(out *ClusterConfig) { +func (in *ControlPlaneEndpointSpec) DeepCopyInto(out *ControlPlaneEndpointSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ControlPlaneEndpointSpec. +func (in *ControlPlaneEndpointSpec) DeepCopy() *ControlPlaneEndpointSpec { + if in == nil { + return nil + } + out := new(ControlPlaneEndpointSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DefaultStorage) DeepCopyInto(out *DefaultStorage) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DefaultStorage. +func (in *DefaultStorage) DeepCopy() *DefaultStorage { + if in == nil { + return nil + } + out := new(DefaultStorage) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DockerClusterConfig) DeepCopyInto(out *DockerClusterConfig) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterConfig. -func (in *ClusterConfig) DeepCopy() *ClusterConfig { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DockerClusterConfig. +func (in *DockerClusterConfig) DeepCopy() *DockerClusterConfig { if in == nil { return nil } - out := new(ClusterConfig) + out := new(DockerClusterConfig) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ClusterConfig) DeepCopyObject() runtime.Object { +func (in *DockerClusterConfig) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -352,67 +523,78 @@ func (in *ClusterConfig) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterConfigSpec) DeepCopyInto(out *ClusterConfigSpec) { +func (in *DockerClusterConfigSpec) DeepCopyInto(out *DockerClusterConfigSpec) { *out = *in - if in.AWS != nil { - in, out := &in.AWS, &out.AWS - *out = new(AWSSpec) - (*in).DeepCopyInto(*out) - } if in.Docker != nil { in, out := &in.Docker, &out.Docker *out = new(DockerSpec) **out = **in } - if in.Nutanix != nil { - in, out := &in.Nutanix, &out.Nutanix - *out = new(NutanixSpec) - (*in).DeepCopyInto(*out) - } - in.GenericClusterConfig.DeepCopyInto(&out.GenericClusterConfig) + in.GenericClusterConfigSpec.DeepCopyInto(&out.GenericClusterConfigSpec) if in.ControlPlane != nil { in, out := &in.ControlPlane, &out.ControlPlane - *out = new(NodeConfigSpec) + *out = new(DockerNodeConfigSpec) (*in).DeepCopyInto(*out) } + if in.ExtraAPIServerCertSANs != nil { + in, out := &in.ExtraAPIServerCertSANs, &out.ExtraAPIServerCertSANs + *out = make([]string, len(*in)) + copy(*out, *in) + } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterConfigSpec. -func (in *ClusterConfigSpec) DeepCopy() *ClusterConfigSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DockerClusterConfigSpec. +func (in *DockerClusterConfigSpec) DeepCopy() *DockerClusterConfigSpec { if in == nil { return nil } - out := new(ClusterConfigSpec) + out := new(DockerClusterConfigSpec) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ControlPlaneEndpointSpec) DeepCopyInto(out *ControlPlaneEndpointSpec) { +func (in *DockerNodeConfig) DeepCopyInto(out *DockerNodeConfig) { *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ControlPlaneEndpointSpec. -func (in *ControlPlaneEndpointSpec) DeepCopy() *ControlPlaneEndpointSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DockerNodeConfig. +func (in *DockerNodeConfig) DeepCopy() *DockerNodeConfig { if in == nil { return nil } - out := new(ControlPlaneEndpointSpec) + out := new(DockerNodeConfig) in.DeepCopyInto(out) return out } +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *DockerNodeConfig) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DefaultStorage) DeepCopyInto(out *DefaultStorage) { +func (in *DockerNodeConfigSpec) DeepCopyInto(out *DockerNodeConfigSpec) { *out = *in + if in.Docker != nil { + in, out := &in.Docker, &out.Docker + *out = new(DockerNodeSpec) + (*in).DeepCopyInto(*out) + } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DefaultStorage. -func (in *DefaultStorage) DeepCopy() *DefaultStorage { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DockerNodeConfigSpec. +func (in *DockerNodeConfigSpec) DeepCopy() *DockerNodeConfigSpec { if in == nil { return nil } - out := new(DefaultStorage) + out := new(DockerNodeConfigSpec) in.DeepCopyInto(out) return out } @@ -422,7 +604,7 @@ func (in *DockerNodeSpec) DeepCopyInto(out *DockerNodeSpec) { *out = *in if in.CustomImage != nil { in, out := &in.CustomImage, &out.CustomImage - *out = new(OCIImage) + *out = new(string) **out = **in } } @@ -473,30 +655,11 @@ func (in *Etcd) DeepCopy() *Etcd { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in ExtraAPIServerCertSANs) DeepCopyInto(out *ExtraAPIServerCertSANs) { - { - in := &in - *out = make(ExtraAPIServerCertSANs, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtraAPIServerCertSANs. -func (in ExtraAPIServerCertSANs) DeepCopy() ExtraAPIServerCertSANs { - if in == nil { - return nil - } - out := new(ExtraAPIServerCertSANs) - in.DeepCopyInto(out) - return *out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GenericClusterConfig) DeepCopyInto(out *GenericClusterConfig) { +func (in *GenericClusterConfigSpec) DeepCopyInto(out *GenericClusterConfigSpec) { *out = *in if in.KubernetesImageRepository != nil { in, out := &in.KubernetesImageRepository, &out.KubernetesImageRepository - *out = new(KubernetesImageRepository) + *out = new(string) **out = **in } if in.Etcd != nil { @@ -509,14 +672,9 @@ func (in *GenericClusterConfig) DeepCopyInto(out *GenericClusterConfig) { *out = new(HTTPProxy) (*in).DeepCopyInto(*out) } - if in.ExtraAPIServerCertSANs != nil { - in, out := &in.ExtraAPIServerCertSANs, &out.ExtraAPIServerCertSANs - *out = make(ExtraAPIServerCertSANs, len(*in)) - copy(*out, *in) - } if in.ImageRegistries != nil { in, out := &in.ImageRegistries, &out.ImageRegistries - *out = make(ImageRegistries, len(*in)) + *out = make([]ImageRegistry, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -533,34 +691,19 @@ func (in *GenericClusterConfig) DeepCopyInto(out *GenericClusterConfig) { } if in.Users != nil { in, out := &in.Users, &out.Users - *out = make(Users, len(*in)) + *out = make([]User, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericClusterConfig. -func (in *GenericClusterConfig) DeepCopy() *GenericClusterConfig { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericClusterConfigSpec. +func (in *GenericClusterConfigSpec) DeepCopy() *GenericClusterConfigSpec { if in == nil { return nil } - out := new(GenericClusterConfig) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GenericNodeConfig) DeepCopyInto(out *GenericNodeConfig) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericNodeConfig. -func (in *GenericNodeConfig) DeepCopy() *GenericNodeConfig { - if in == nil { - return nil - } - out := new(GenericNodeConfig) + out := new(GenericClusterConfigSpec) in.DeepCopyInto(out) return out } @@ -620,27 +763,6 @@ func (in *Image) DeepCopy() *Image { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in ImageRegistries) DeepCopyInto(out *ImageRegistries) { - { - in := &in - *out = make(ImageRegistries, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageRegistries. -func (in ImageRegistries) DeepCopy() ImageRegistries { - if in == nil { - return nil - } - out := new(ImageRegistries) - in.DeepCopyInto(out) - return *out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ImageRegistry) DeepCopyInto(out *ImageRegistry) { *out = *in @@ -677,25 +799,40 @@ func (in *NFD) DeepCopy() *NFD { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NodeConfig) DeepCopyInto(out *NodeConfig) { +func (in *NutanixCategoryIdentifier) DeepCopyInto(out *NutanixCategoryIdentifier) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NutanixCategoryIdentifier. +func (in *NutanixCategoryIdentifier) DeepCopy() *NutanixCategoryIdentifier { + if in == nil { + return nil + } + out := new(NutanixCategoryIdentifier) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NutanixClusterConfig) DeepCopyInto(out *NutanixClusterConfig) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeConfig. -func (in *NodeConfig) DeepCopy() *NodeConfig { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NutanixClusterConfig. +func (in *NutanixClusterConfig) DeepCopy() *NutanixClusterConfig { if in == nil { return nil } - out := new(NodeConfig) + out := new(NutanixClusterConfig) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *NodeConfig) DeepCopyObject() runtime.Object { +func (in *NutanixClusterConfig) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -703,46 +840,32 @@ func (in *NodeConfig) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NodeConfigSpec) DeepCopyInto(out *NodeConfigSpec) { +func (in *NutanixClusterConfigSpec) DeepCopyInto(out *NutanixClusterConfigSpec) { *out = *in - if in.AWS != nil { - in, out := &in.AWS, &out.AWS - *out = new(AWSNodeSpec) - (*in).DeepCopyInto(*out) - } - if in.Docker != nil { - in, out := &in.Docker, &out.Docker - *out = new(DockerNodeSpec) - (*in).DeepCopyInto(*out) - } if in.Nutanix != nil { in, out := &in.Nutanix, &out.Nutanix - *out = new(NutanixNodeSpec) + *out = new(NutanixSpec) (*in).DeepCopyInto(*out) } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeConfigSpec. -func (in *NodeConfigSpec) DeepCopy() *NodeConfigSpec { - if in == nil { - return nil + in.GenericClusterConfigSpec.DeepCopyInto(&out.GenericClusterConfigSpec) + if in.ControlPlane != nil { + in, out := &in.ControlPlane, &out.ControlPlane + *out = new(NutanixNodeConfigSpec) + (*in).DeepCopyInto(*out) + } + if in.ExtraAPIServerCertSANs != nil { + in, out := &in.ExtraAPIServerCertSANs, &out.ExtraAPIServerCertSANs + *out = make([]string, len(*in)) + copy(*out, *in) } - out := new(NodeConfigSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NutanixCategoryIdentifier) DeepCopyInto(out *NutanixCategoryIdentifier) { - *out = *in } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NutanixCategoryIdentifier. -func (in *NutanixCategoryIdentifier) DeepCopy() *NutanixCategoryIdentifier { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NutanixClusterConfigSpec. +func (in *NutanixClusterConfigSpec) DeepCopy() *NutanixClusterConfigSpec { if in == nil { return nil } - out := new(NutanixCategoryIdentifier) + out := new(NutanixClusterConfigSpec) in.DeepCopyInto(out) return out } @@ -783,6 +906,52 @@ func (in *NutanixMachineDetails) DeepCopy() *NutanixMachineDetails { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NutanixNodeConfig) DeepCopyInto(out *NutanixNodeConfig) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NutanixNodeConfig. +func (in *NutanixNodeConfig) DeepCopy() *NutanixNodeConfig { + if in == nil { + return nil + } + out := new(NutanixNodeConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NutanixNodeConfig) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NutanixNodeConfigSpec) DeepCopyInto(out *NutanixNodeConfigSpec) { + *out = *in + if in.Nutanix != nil { + in, out := &in.Nutanix, &out.Nutanix + *out = new(NutanixNodeSpec) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NutanixNodeConfigSpec. +func (in *NutanixNodeConfigSpec) DeepCopy() *NutanixNodeConfigSpec { + if in == nil { + return nil + } + out := new(NutanixNodeConfigSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NutanixNodeSpec) DeepCopyInto(out *NutanixNodeSpec) { *out = *in @@ -807,7 +976,11 @@ func (in *NutanixPrismCentralEndpointSpec) DeepCopyInto(out *NutanixPrismCentral *out = new(string) **out = **in } - out.Credentials = in.Credentials + if in.Credentials != nil { + in, out := &in.Credentials, &out.Credentials + *out = new(v1.LocalObjectReference) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NutanixPrismCentralEndpointSpec. @@ -914,11 +1087,6 @@ func (in *RegistryCredentials) DeepCopy() *RegistryCredentials { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SecurityGroup) DeepCopyInto(out *SecurityGroup) { *out = *in - if in.ID != nil { - in, out := &in.ID, &out.ID - *out = new(string) - **out = **in - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecurityGroup. @@ -1007,27 +1175,6 @@ func (in *User) DeepCopy() *User { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in Users) DeepCopyInto(out *Users) { - { - in := &in - *out = make(Users, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Users. -func (in Users) DeepCopy() Users { - if in == nil { - return nil - } - out := new(Users) - in.DeepCopyInto(out) - return *out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VPC) DeepCopyInto(out *VPC) { *out = *in diff --git a/common/pkg/capi/clustertopology/variables/fromcrdyaml.go b/common/pkg/capi/clustertopology/variables/fromcrdyaml.go new file mode 100644 index 000000000..f04c50c13 --- /dev/null +++ b/common/pkg/capi/clustertopology/variables/fromcrdyaml.go @@ -0,0 +1,161 @@ +// Copyright 2024 D2iQ, Inc. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +package variables + +import ( + "fmt" + + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/utils/ptr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" +) + +func MustSchemaFromCRDYAML(yaml []byte) clusterv1.VariableSchema { + schema, err := SchemaFromCRDYAML(yaml) + if err != nil { + panic(err) + } + return schema +} + +func SchemaFromCRDYAML(yaml []byte) (clusterv1.VariableSchema, error) { + sch := runtime.NewScheme() + utilruntime.Must(apiextensionsv1.AddToScheme(sch)) + decode := serializer.NewCodecFactory(sch).UniversalDeserializer().Decode + obj, gKV, _ := decode(yaml, nil, nil) + if gKV.Kind != "CustomResourceDefinition" { + return clusterv1.VariableSchema{}, fmt.Errorf( + "expected CustomResourceDefinition, got %s", + gKV.Kind, + ) + } + crd := obj.(*apiextensionsv1.CustomResourceDefinition) + if len(crd.Spec.Versions) != 1 { + return clusterv1.VariableSchema{}, fmt.Errorf( + "expected exactly one version, got %d", + len(crd.Spec.Versions), + ) + } + if crd.Spec.Versions[0].Schema.OpenAPIV3Schema == nil { + return clusterv1.VariableSchema{}, fmt.Errorf("expected OpenAPIV3Schema, got nil") + } + + spec, ok := crd.Spec.Versions[0].Schema.OpenAPIV3Schema.Properties["spec"] + if !ok { + return clusterv1.VariableSchema{}, fmt.Errorf("missing spec") + } + + jsonSchemaProps, err := ConvertAPIExtensionsToJSONSchemaProps( + &spec, field.NewPath(""), + ) + if err != nil { + return clusterv1.VariableSchema{}, fmt.Errorf( + "failed to parse CRD into variables schema: %w", + err.ToAggregate(), + ) + } + + return clusterv1.VariableSchema{ + OpenAPIV3Schema: *jsonSchemaProps, + }, nil +} + +// ConvertAPIExtensionsToJSONSchemaProps converts a apiextensions.JSONSchemaProp to clusterv1.JSONSchemaProps. +func ConvertAPIExtensionsToJSONSchemaProps( + schema *apiextensionsv1.JSONSchemaProps, fldPath *field.Path, +) (*clusterv1.JSONSchemaProps, field.ErrorList) { + var allErrs field.ErrorList + + props := &clusterv1.JSONSchemaProps{ + Type: schema.Type, + Required: schema.Required, + MaxItems: schema.MaxItems, + MinItems: schema.MinItems, + UniqueItems: schema.UniqueItems, + Format: schema.Format, + MaxLength: schema.MaxLength, + MinLength: schema.MinLength, + Pattern: schema.Pattern, + ExclusiveMaximum: schema.ExclusiveMaximum, + ExclusiveMinimum: schema.ExclusiveMinimum, + XPreserveUnknownFields: ptr.Deref(schema.XPreserveUnknownFields, false), + Default: schema.Default, + Enum: schema.Enum, + Example: schema.Example, + } + + if schema.Maximum != nil { + props.Maximum = ptr.To(int64(*schema.Maximum)) + } + + if schema.Minimum != nil { + props.Minimum = ptr.To(int64(*schema.Minimum)) + } + + if schema.AdditionalProperties != nil && schema.AdditionalProperties.Schema != nil { + jsonSchemaProps, err := ConvertAPIExtensionsToJSONSchemaProps( + schema.AdditionalProperties.Schema, fldPath.Child("additionalProperties"), + ) + if err != nil { + allErrs = append( + allErrs, + field.Invalid( + fldPath.Child("additionalProperties"), + "", + fmt.Sprintf("failed to convert schema: %v", err), + ), + ) + } else { + props.AdditionalProperties = jsonSchemaProps + } + } + + if len(schema.Properties) > 0 { + props.Properties = make(map[string]clusterv1.JSONSchemaProps, len(schema.Properties)) + for propertyName := range schema.Properties { + p := schema.Properties[propertyName] + apiExtensionsSchema, err := ConvertAPIExtensionsToJSONSchemaProps( + &p, + fldPath.Child("properties").Key(propertyName), + ) + if err != nil { + allErrs = append( + allErrs, + field.Invalid( + fldPath.Child("properties").Key(propertyName), + "", + fmt.Sprintf("failed to convert schema: %v", err), + ), + ) + } else { + props.Properties[propertyName] = *apiExtensionsSchema + } + } + } + + if schema.Items != nil && schema.Items.Schema != nil { + jsonPropsSchema, err := ConvertAPIExtensionsToJSONSchemaProps( + schema.Items.Schema, + fldPath.Child("items"), + ) + if err != nil { + allErrs = append( + allErrs, + field.Invalid( + fldPath.Child("items"), + "", + fmt.Sprintf("failed to convert schema: %v", err), + ), + ) + } else { + props.Items = jsonPropsSchema + } + } + + return props, allErrs +} diff --git a/common/pkg/testutils/openapi/convert.go b/common/pkg/testutils/openapi/convert.go index 5eb248617..9e08c0e50 100644 --- a/common/pkg/testutils/openapi/convert.go +++ b/common/pkg/testutils/openapi/convert.go @@ -14,12 +14,12 @@ import ( clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ) -// ConvertToAPIExtensionsJSONSchemaProps converts a clusterv1.JSONSchemaProps to apiextensions.JSONSchemaProp. +// ConvertJSONSchemaPropsToAPIExtensions converts a clusterv1.JSONSchemaProps to apiextensions.JSONSchemaProp. // NOTE: This is used whenever we want to use one of the upstream libraries, as they use apiextensions.JSONSchemaProp. // NOTE: If new fields are added to clusterv1.JSONSchemaProps (e.g. to support complex types), the corresponding // schema validation must be added to validateRootSchema too. // See: https://github.com/kubernetes-sigs/cluster-api/blob/v1.5.1/internal/topology/variables/schema.go#L35 -func ConvertToAPIExtensionsJSONSchemaProps( +func ConvertJSONSchemaPropsToAPIExtensions( schema *clusterv1.JSONSchemaProps, fldPath *field.Path, ) (*apiextensions.JSONSchemaProps, field.ErrorList) { var allErrs field.ErrorList @@ -142,7 +142,7 @@ func ConvertToAPIExtensionsJSONSchemaProps( } if schema.AdditionalProperties != nil { - apiExtensionsSchema, err := ConvertToAPIExtensionsJSONSchemaProps( + apiExtensionsSchema, err := ConvertJSONSchemaPropsToAPIExtensions( schema.AdditionalProperties, fldPath.Child("additionalProperties"), ) if err != nil { @@ -168,7 +168,7 @@ func ConvertToAPIExtensionsJSONSchemaProps( props.Properties = map[string]apiextensions.JSONSchemaProps{} for propertyName := range schema.Properties { p := schema.Properties[propertyName] - apiExtensionsSchema, err := ConvertToAPIExtensionsJSONSchemaProps( + apiExtensionsSchema, err := ConvertJSONSchemaPropsToAPIExtensions( &p, fldPath.Child("properties").Key(propertyName), ) @@ -188,7 +188,7 @@ func ConvertToAPIExtensionsJSONSchemaProps( } if schema.Items != nil { - apiExtensionsSchema, err := ConvertToAPIExtensionsJSONSchemaProps( + apiExtensionsSchema, err := ConvertJSONSchemaPropsToAPIExtensions( schema.Items, fldPath.Child("items"), ) diff --git a/common/pkg/testutils/openapi/validate.go b/common/pkg/testutils/openapi/validate.go index bf776db6d..b42dbe8ee 100644 --- a/common/pkg/testutils/openapi/validate.go +++ b/common/pkg/testutils/openapi/validate.go @@ -38,7 +38,7 @@ func ValidateClusterVariable( } // Convert schema to Kubernetes APIExtensions Schema. - apiExtensionsSchema, allErrs := ConvertToAPIExtensionsJSONSchemaProps( + apiExtensionsSchema, allErrs := ConvertJSONSchemaPropsToAPIExtensions( &definition.Schema.OpenAPIV3Schema, field.NewPath("schema"), ) if len(allErrs) > 0 { diff --git a/go.mod b/go.mod index d0e79aec2..3621a941f 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/go-logr/logr v1.4.1 github.com/google/go-cmp v0.6.0 github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api v0.0.0-00010101000000-000000000000 - github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common v0.0.0-00010101000000-000000000000 + github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common v0.7.0 github.com/nutanix-cloud-native/prism-go-client v0.3.4 github.com/onsi/ginkgo/v2 v2.17.1 github.com/onsi/gomega v1.33.0 diff --git a/hack/flakes/flake.lock b/hack/flakes/flake.lock index 84a5ef8a3..8fd40d554 100644 --- a/hack/flakes/flake.lock +++ b/hack/flakes/flake.lock @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1710827359, - "narHash": "sha256-/KY8hffTh9SN/tTcDn/FrEiYwTXnU8NKnr4D7/stmmA=", + "lastModified": 1713805509, + "narHash": "sha256-YgSEan4CcrjivCNO5ZNzhg7/8ViLkZ4CB/GrGBVSudo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5710127d9693421e78cca4f74fac2db6d67162b1", + "rev": "1e1dc66fe68972a76679644a5577828b6a7e8be4", "type": "github" }, "original": { diff --git a/pkg/common/clusterconfig/types.go b/pkg/common/clusterconfig/types.go new file mode 100644 index 000000000..c82df26c6 --- /dev/null +++ b/pkg/common/clusterconfig/types.go @@ -0,0 +1,16 @@ +// Copyright 2024 D2iQ, Inc. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +package clusterconfig + +import carenv1 "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" + +type ClusterConfig struct { + AWS *carenv1.AWSSpec `json:"aws,omitempty"` + + Docker *carenv1.AWSSpec `json:"doker,omitempty"` + + Nutanix *carenv1.NutanixSpec `json:"nutanix,omitempty"` + + carenv1.GenericClusterConfigSpec `json:",inline"` +} diff --git a/pkg/handlers/aws/clusterconfig/variables.go b/pkg/handlers/aws/clusterconfig/variables.go index e80b72282..2b455d816 100644 --- a/pkg/handlers/aws/clusterconfig/variables.go +++ b/pkg/handlers/aws/clusterconfig/variables.go @@ -43,7 +43,7 @@ func (h *awsClusterConfigVariableHandler) DiscoverVariables( resp.Variables = append(resp.Variables, clusterv1.ClusterClassVariable{ Name: clusterconfig.MetaVariableName, Required: true, - Schema: v1alpha1.NewAWSClusterConfigSpec().VariableSchema(), + Schema: v1alpha1.AWSClusterConfig{}.VariableSchema(), }) resp.SetStatus(runtimehooksv1.ResponseStatusSuccess) } diff --git a/pkg/handlers/aws/mutation/ami/variables_test.go b/pkg/handlers/aws/mutation/ami/variables_test.go index 63eb78802..a95b9ed57 100644 --- a/pkg/handlers/aws/mutation/ami/variables_test.go +++ b/pkg/handlers/aws/mutation/ami/variables_test.go @@ -18,20 +18,22 @@ func TestVariableValidation(t *testing.T) { capitest.ValidateDiscoverVariables( t, clusterconfig.MetaVariableName, - ptr.To(v1alpha1.NewAWSClusterConfigSpec().VariableSchema()), + ptr.To(v1alpha1.AWSClusterConfig{}.VariableSchema()), true, awsclusterconfig.NewVariable, capitest.VariableTestDef{ Name: "AMI specification", - Vals: v1alpha1.ClusterConfigSpec{ - ControlPlane: &v1alpha1.NodeConfigSpec{ - AWS: &v1alpha1.AWSNodeSpec{ - AMISpec: &v1alpha1.AMISpec{ - ID: "ami-1234", - Lookup: &v1alpha1.AMILookup{ - Format: "capa-ami-{{.BaseOS}}-?{{.K8sVersion}}-*", - BaseOS: "rhel-8.4", - Org: "12345678", + Vals: v1alpha1.AWSClusterConfigSpec{ + ControlPlane: &v1alpha1.AWSControlPlaneNodeConfigSpec{ + AWS: &v1alpha1.AWSControlPlaneNodeSpec{ + AWSGenericNodeSpec: v1alpha1.AWSGenericNodeSpec{ + AMISpec: &v1alpha1.AMISpec{ + ID: "ami-1234", + Lookup: &v1alpha1.AMILookup{ + Format: "capa-ami-{{.BaseOS}}-?{{.K8sVersion}}-*", + BaseOS: "rhel-8.4", + Org: "12345678", + }, }, }, }, diff --git a/pkg/handlers/aws/mutation/controlplaneloadbalancer/variables_test.go b/pkg/handlers/aws/mutation/controlplaneloadbalancer/variables_test.go index 059f4f0ed..bf05693e1 100644 --- a/pkg/handlers/aws/mutation/controlplaneloadbalancer/variables_test.go +++ b/pkg/handlers/aws/mutation/controlplaneloadbalancer/variables_test.go @@ -19,12 +19,12 @@ func TestVariableValidation(t *testing.T) { capitest.ValidateDiscoverVariables( t, clusterconfig.MetaVariableName, - ptr.To(v1alpha1.NewAWSClusterConfigSpec().VariableSchema()), + ptr.To(v1alpha1.AWSClusterConfig{}.VariableSchema()), true, awsclusterconfig.NewVariable, capitest.VariableTestDef{ Name: "specified internet-facing scheme", - Vals: v1alpha1.ClusterConfigSpec{ + Vals: v1alpha1.AWSClusterConfigSpec{ AWS: &v1alpha1.AWSSpec{ ControlPlaneLoadBalancer: &v1alpha1.AWSLoadBalancerSpec{ Scheme: &capav1.ELBSchemeInternetFacing, @@ -34,7 +34,7 @@ func TestVariableValidation(t *testing.T) { }, capitest.VariableTestDef{ Name: "specified internal scheme", - Vals: v1alpha1.ClusterConfigSpec{ + Vals: v1alpha1.AWSClusterConfigSpec{ AWS: &v1alpha1.AWSSpec{ ControlPlaneLoadBalancer: &v1alpha1.AWSLoadBalancerSpec{ Scheme: &capav1.ELBSchemeInternal, @@ -44,7 +44,7 @@ func TestVariableValidation(t *testing.T) { }, capitest.VariableTestDef{ Name: "specified invalid scheme", - Vals: v1alpha1.ClusterConfigSpec{ + Vals: v1alpha1.AWSClusterConfigSpec{ AWS: &v1alpha1.AWSSpec{ ControlPlaneLoadBalancer: &v1alpha1.AWSLoadBalancerSpec{ Scheme: ptr.To(capav1.ELBScheme("invalid")), diff --git a/pkg/handlers/aws/mutation/iaminstanceprofile/inject_control_plane.go b/pkg/handlers/aws/mutation/iaminstanceprofile/inject_control_plane.go index 719c102ae..ce73b809e 100644 --- a/pkg/handlers/aws/mutation/iaminstanceprofile/inject_control_plane.go +++ b/pkg/handlers/aws/mutation/iaminstanceprofile/inject_control_plane.go @@ -62,7 +62,7 @@ func (h *awsIAMInstanceProfileControlPlanePatchHandler) Mutate( "holderRef", holderRef, ) - iamInstanceProfileVar, err := variables.Get[v1alpha1.IAMInstanceProfile]( + iamInstanceProfileVar, err := variables.Get[string]( vars, h.variableName, h.variableFieldPath..., @@ -99,7 +99,7 @@ func (h *awsIAMInstanceProfileControlPlanePatchHandler) Mutate( "patchedObjectName", client.ObjectKeyFromObject(obj), ).Info("setting IAM instance profile in control plane AWSMachineTemplate spec") - obj.Spec.Template.Spec.IAMInstanceProfile = string(iamInstanceProfileVar) + obj.Spec.Template.Spec.IAMInstanceProfile = iamInstanceProfileVar return nil }, diff --git a/pkg/handlers/aws/mutation/iaminstanceprofile/inject_worker.go b/pkg/handlers/aws/mutation/iaminstanceprofile/inject_worker.go index 38a1be5ce..8f165f0c9 100644 --- a/pkg/handlers/aws/mutation/iaminstanceprofile/inject_worker.go +++ b/pkg/handlers/aws/mutation/iaminstanceprofile/inject_worker.go @@ -56,7 +56,7 @@ func (h *awsIAMInstanceProfileWorkerPatchHandler) Mutate( "holderRef", holderRef, ) - iamInstanceProfileVar, err := variables.Get[v1alpha1.IAMInstanceProfile]( + iamInstanceProfileVar, err := variables.Get[string]( vars, h.variableName, h.variableFieldPath..., @@ -93,7 +93,7 @@ func (h *awsIAMInstanceProfileWorkerPatchHandler) Mutate( "patchedObjectName", client.ObjectKeyFromObject(obj), ).Info("setting IAM instance profile in worker AWSMachineTemplate spec") - obj.Spec.Template.Spec.IAMInstanceProfile = string(iamInstanceProfileVar) + obj.Spec.Template.Spec.IAMInstanceProfile = iamInstanceProfileVar return nil }, diff --git a/pkg/handlers/aws/mutation/iaminstanceprofile/variables_test.go b/pkg/handlers/aws/mutation/iaminstanceprofile/variables_test.go index f5aea0919..562280429 100644 --- a/pkg/handlers/aws/mutation/iaminstanceprofile/variables_test.go +++ b/pkg/handlers/aws/mutation/iaminstanceprofile/variables_test.go @@ -18,20 +18,22 @@ func TestVariableValidation(t *testing.T) { capitest.ValidateDiscoverVariables( t, clusterconfig.MetaVariableName, - ptr.To(v1alpha1.NewAWSClusterConfigSpec().VariableSchema()), + ptr.To(v1alpha1.AWSClusterConfig{}.VariableSchema()), true, awsclusterconfig.NewVariable, capitest.VariableTestDef{ Name: "AMI specification", - Vals: v1alpha1.ClusterConfigSpec{ - ControlPlane: &v1alpha1.NodeConfigSpec{ - AWS: &v1alpha1.AWSNodeSpec{ - AMISpec: &v1alpha1.AMISpec{ - ID: "ami-1234", - Lookup: &v1alpha1.AMILookup{ - Format: "capa-ami-{{.BaseOS}}-?{{.K8sVersion}}-*", - BaseOS: "rhel-8.4", - Org: "12345678", + Vals: v1alpha1.AWSClusterConfigSpec{ + ControlPlane: &v1alpha1.AWSControlPlaneNodeConfigSpec{ + AWS: &v1alpha1.AWSControlPlaneNodeSpec{ + AWSGenericNodeSpec: v1alpha1.AWSGenericNodeSpec{ + AMISpec: &v1alpha1.AMISpec{ + ID: "ami-1234", + Lookup: &v1alpha1.AMILookup{ + Format: "capa-ami-{{.BaseOS}}-?{{.K8sVersion}}-*", + BaseOS: "rhel-8.4", + Org: "12345678", + }, }, }, }, diff --git a/pkg/handlers/aws/mutation/instancetype/inject_control_plane.go b/pkg/handlers/aws/mutation/instancetype/inject_control_plane.go index ed4ebaaeb..10f330af3 100644 --- a/pkg/handlers/aws/mutation/instancetype/inject_control_plane.go +++ b/pkg/handlers/aws/mutation/instancetype/inject_control_plane.go @@ -62,7 +62,7 @@ func (h *awsInstanceTypeControlPlanePatchHandler) Mutate( "holderRef", holderRef, ) - instanceTypeVar, err := variables.Get[v1alpha1.InstanceType]( + instanceTypeVar, err := variables.Get[string]( vars, h.variableName, h.variableFieldPath..., @@ -99,7 +99,7 @@ func (h *awsInstanceTypeControlPlanePatchHandler) Mutate( "patchedObjectName", client.ObjectKeyFromObject(obj), ).Info("setting instance type in control plane AWSMachineTemplate spec") - obj.Spec.Template.Spec.InstanceType = string(instanceTypeVar) + obj.Spec.Template.Spec.InstanceType = instanceTypeVar return nil }, diff --git a/pkg/handlers/aws/mutation/instancetype/inject_worker.go b/pkg/handlers/aws/mutation/instancetype/inject_worker.go index 3deb4ce58..b439721da 100644 --- a/pkg/handlers/aws/mutation/instancetype/inject_worker.go +++ b/pkg/handlers/aws/mutation/instancetype/inject_worker.go @@ -56,7 +56,7 @@ func (h *awsInstanceTypeWorkerPatchHandler) Mutate( "holderRef", holderRef, ) - instanceTypeVar, err := variables.Get[v1alpha1.InstanceType]( + instanceTypeVar, err := variables.Get[string]( vars, h.variableName, h.variableFieldPath..., @@ -93,7 +93,7 @@ func (h *awsInstanceTypeWorkerPatchHandler) Mutate( "patchedObjectName", client.ObjectKeyFromObject(obj), ).Info("setting instance type in workers AWSMachineTemplate spec") - obj.Spec.Template.Spec.InstanceType = string(instanceTypeVar) + obj.Spec.Template.Spec.InstanceType = instanceTypeVar return nil }, diff --git a/pkg/handlers/aws/mutation/instancetype/variables_test.go b/pkg/handlers/aws/mutation/instancetype/variables_test.go index 040ca4384..0dcc81360 100644 --- a/pkg/handlers/aws/mutation/instancetype/variables_test.go +++ b/pkg/handlers/aws/mutation/instancetype/variables_test.go @@ -18,15 +18,15 @@ func TestVariableValidation(t *testing.T) { capitest.ValidateDiscoverVariables( t, clusterconfig.MetaVariableName, - ptr.To(v1alpha1.NewAWSClusterConfigSpec().VariableSchema()), + ptr.To(v1alpha1.AWSClusterConfig{}.VariableSchema()), true, awsclusterconfig.NewVariable, capitest.VariableTestDef{ Name: "specified instance type", - Vals: v1alpha1.ClusterConfigSpec{ - ControlPlane: &v1alpha1.NodeConfigSpec{ - AWS: &v1alpha1.AWSNodeSpec{ - InstanceType: ptr.To(v1alpha1.InstanceType("m5.small")), + Vals: v1alpha1.AWSClusterConfigSpec{ + ControlPlane: &v1alpha1.AWSControlPlaneNodeConfigSpec{ + AWS: &v1alpha1.AWSControlPlaneNodeSpec{ + InstanceType: "m5.small", }, }, }, diff --git a/pkg/handlers/aws/mutation/network/variables_test.go b/pkg/handlers/aws/mutation/network/variables_test.go index 2aa82b7a2..127045b48 100644 --- a/pkg/handlers/aws/mutation/network/variables_test.go +++ b/pkg/handlers/aws/mutation/network/variables_test.go @@ -18,12 +18,12 @@ func TestVariableValidation(t *testing.T) { capitest.ValidateDiscoverVariables( t, clusterconfig.MetaVariableName, - ptr.To(v1alpha1.NewAWSClusterConfigSpec().VariableSchema()), + ptr.To(v1alpha1.AWSClusterConfig{}.VariableSchema()), true, awsclusterconfig.NewVariable, capitest.VariableTestDef{ Name: "specified VPC ID", - Vals: v1alpha1.ClusterConfigSpec{ + Vals: v1alpha1.AWSClusterConfigSpec{ AWS: &v1alpha1.AWSSpec{ Network: &v1alpha1.AWSNetwork{ VPC: &v1alpha1.VPC{ @@ -35,7 +35,7 @@ func TestVariableValidation(t *testing.T) { }, capitest.VariableTestDef{ Name: "specified subnet IDs", - Vals: v1alpha1.ClusterConfigSpec{ + Vals: v1alpha1.AWSClusterConfigSpec{ AWS: &v1alpha1.AWSSpec{ Network: &v1alpha1.AWSNetwork{ Subnets: v1alpha1.Subnets{ @@ -49,7 +49,7 @@ func TestVariableValidation(t *testing.T) { }, capitest.VariableTestDef{ Name: "specified both VPC ID and subnet IDs", - Vals: v1alpha1.ClusterConfigSpec{ + Vals: v1alpha1.AWSClusterConfigSpec{ AWS: &v1alpha1.AWSSpec{ Network: &v1alpha1.AWSNetwork{ VPC: &v1alpha1.VPC{ diff --git a/pkg/handlers/aws/mutation/region/variables_test.go b/pkg/handlers/aws/mutation/region/variables_test.go index 295fb3f12..112108231 100644 --- a/pkg/handlers/aws/mutation/region/variables_test.go +++ b/pkg/handlers/aws/mutation/region/variables_test.go @@ -18,12 +18,12 @@ func TestVariableValidation(t *testing.T) { capitest.ValidateDiscoverVariables( t, clusterconfig.MetaVariableName, - ptr.To(v1alpha1.NewAWSClusterConfigSpec().VariableSchema()), + ptr.To(v1alpha1.AWSClusterConfig{}.VariableSchema()), true, awsclusterconfig.NewVariable, capitest.VariableTestDef{ Name: "specified region", - Vals: v1alpha1.ClusterConfigSpec{ + Vals: v1alpha1.AWSClusterConfigSpec{ AWS: &v1alpha1.AWSSpec{ Region: ptr.To(v1alpha1.Region("a-specified-region")), }, diff --git a/pkg/handlers/aws/mutation/securitygroups/inject.go b/pkg/handlers/aws/mutation/securitygroups/inject.go index 7853285b5..b76ba61ac 100644 --- a/pkg/handlers/aws/mutation/securitygroups/inject.go +++ b/pkg/handlers/aws/mutation/securitygroups/inject.go @@ -8,6 +8,7 @@ import ( apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/utils/ptr" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1" ctrl "sigs.k8s.io/controller-runtime" @@ -79,7 +80,7 @@ func (h *awsSecurityGroupSpecPatchHandler) Mutate( resourceRefs := make([]capav1.AWSResourceReference, 0, len(additionalSecGroupVar)) for _, secGroup := range additionalSecGroupVar { resourceRefs = append(resourceRefs, capav1.AWSResourceReference{ - ID: secGroup.ID, + ID: ptr.To(secGroup.ID), }) } return patches.MutateIfApplicable( diff --git a/pkg/handlers/aws/mutation/securitygroups/inject_control_plane_test.go b/pkg/handlers/aws/mutation/securitygroups/inject_control_plane_test.go index ef157d137..cd54f405e 100644 --- a/pkg/handlers/aws/mutation/securitygroups/inject_control_plane_test.go +++ b/pkg/handlers/aws/mutation/securitygroups/inject_control_plane_test.go @@ -6,7 +6,6 @@ package securitygroups import ( . "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" - "k8s.io/utils/ptr" runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" @@ -36,9 +35,9 @@ var _ = Describe("Generate SecurityGroup patches for ControlPlane", func() { capitest.VariableWithValue( clusterconfig.MetaVariableName, v1alpha1.AdditionalSecurityGroup{ - {ID: ptr.To("sg-1")}, - {ID: ptr.To("sg-2")}, - {ID: ptr.To("sg-3")}, + {ID: "sg-1"}, + {ID: "sg-2"}, + {ID: "sg-3"}, }, clusterconfig.MetaControlPlaneConfigName, v1alpha1.AWSVariableName, diff --git a/pkg/handlers/aws/mutation/securitygroups/inject_worker_test.go b/pkg/handlers/aws/mutation/securitygroups/inject_worker_test.go index 1755e94b8..701fc8e70 100644 --- a/pkg/handlers/aws/mutation/securitygroups/inject_worker_test.go +++ b/pkg/handlers/aws/mutation/securitygroups/inject_worker_test.go @@ -7,7 +7,6 @@ import ( . "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - "k8s.io/utils/ptr" runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" @@ -33,9 +32,9 @@ var _ = Describe("Generate AWS SecurityGroups patches for Worker", func() { capitest.VariableWithValue( workerconfig.MetaVariableName, v1alpha1.AdditionalSecurityGroup{ - {ID: ptr.To("sg-1")}, - {ID: ptr.To("sg-2")}, - {ID: ptr.To("sg-3")}, + {ID: "sg-1"}, + {ID: "sg-2"}, + {ID: "sg-3"}, }, v1alpha1.AWSVariableName, VariableName, diff --git a/pkg/handlers/aws/mutation/securitygroups/variables_test.go b/pkg/handlers/aws/mutation/securitygroups/variables_test.go index 27e634de3..661c46d65 100644 --- a/pkg/handlers/aws/mutation/securitygroups/variables_test.go +++ b/pkg/handlers/aws/mutation/securitygroups/variables_test.go @@ -18,20 +18,22 @@ func TestVariableValidation(t *testing.T) { capitest.ValidateDiscoverVariables( t, clusterconfig.MetaVariableName, - ptr.To(v1alpha1.NewAWSClusterConfigSpec().VariableSchema()), + ptr.To(v1alpha1.AWSClusterConfig{}.VariableSchema()), true, awsclusterconfig.NewVariable, capitest.VariableTestDef{ Name: "Additional Security Group Specification", - Vals: v1alpha1.ClusterConfigSpec{ - ControlPlane: &v1alpha1.NodeConfigSpec{ - AWS: &v1alpha1.AWSNodeSpec{ - AdditionalSecurityGroups: v1alpha1.AdditionalSecurityGroup{ - { - ID: ptr.To("sg-1234"), - }, - { - ID: ptr.To("sg-0420"), + Vals: v1alpha1.AWSClusterConfigSpec{ + ControlPlane: &v1alpha1.AWSControlPlaneNodeConfigSpec{ + AWS: &v1alpha1.AWSControlPlaneNodeSpec{ + AWSGenericNodeSpec: v1alpha1.AWSGenericNodeSpec{ + AdditionalSecurityGroups: v1alpha1.AdditionalSecurityGroup{ + { + ID: "sg-1234", + }, + { + ID: "sg-0420", + }, }, }, }, diff --git a/pkg/handlers/aws/workerconfig/variables.go b/pkg/handlers/aws/workerconfig/variables.go index 3b0975211..7e451e90f 100644 --- a/pkg/handlers/aws/workerconfig/variables.go +++ b/pkg/handlers/aws/workerconfig/variables.go @@ -43,7 +43,7 @@ func (h *awsWorkerConfigVariableHandler) DiscoverVariables( resp.Variables = append(resp.Variables, clusterv1.ClusterClassVariable{ Name: workerconfig.MetaVariableName, Required: false, - Schema: v1alpha1.NewAWSWorkerConfigSpec().VariableSchema(), + Schema: v1alpha1.AWSWorkerNodeConfig{}.VariableSchema(), }) resp.SetStatus(runtimehooksv1.ResponseStatusSuccess) } diff --git a/pkg/handlers/aws/workerconfig/variables_test.go b/pkg/handlers/aws/workerconfig/variables_test.go index 8bd661665..6e59abfb6 100644 --- a/pkg/handlers/aws/workerconfig/variables_test.go +++ b/pkg/handlers/aws/workerconfig/variables_test.go @@ -17,23 +17,23 @@ func TestVariableValidation(t *testing.T) { capitest.ValidateDiscoverVariables( t, workerconfig.MetaVariableName, - ptr.To(v1alpha1.NewAWSWorkerConfigSpec().VariableSchema()), + ptr.To(v1alpha1.AWSWorkerNodeConfig{}.VariableSchema()), false, NewVariable, capitest.VariableTestDef{ Name: "specified IAM instance profile", - Vals: v1alpha1.NodeConfigSpec{ - AWS: &v1alpha1.AWSNodeSpec{ - IAMInstanceProfile: ptr.To( - v1alpha1.IAMInstanceProfile("nodes.cluster-api-provider-aws.sigs.k8s.io"), - ), + Vals: v1alpha1.AWSWorkerNodeConfigSpec{ + AWS: &v1alpha1.AWSWorkerNodeSpec{ + IAMInstanceProfile: "nodes.cluster-api-provider-aws.sigs.k8s.io", }, }, }, capitest.VariableTestDef{ Name: "specified instance type", - Vals: v1alpha1.NodeConfigSpec{ - AWS: &v1alpha1.AWSNodeSpec{InstanceType: ptr.To(v1alpha1.InstanceType("m5.small"))}, + Vals: v1alpha1.AWSWorkerNodeConfigSpec{ + AWS: &v1alpha1.AWSWorkerNodeSpec{ + InstanceType: "m5.small", + }, }, }, ) diff --git a/pkg/handlers/docker/clusterconfig/variables.go b/pkg/handlers/docker/clusterconfig/variables.go index 27d9b1dea..6fccf3679 100644 --- a/pkg/handlers/docker/clusterconfig/variables.go +++ b/pkg/handlers/docker/clusterconfig/variables.go @@ -46,7 +46,7 @@ func (h *dockerClusterConfigVariableHandler) DiscoverVariables( resp.Variables = append(resp.Variables, clusterv1.ClusterClassVariable{ Name: clusterconfig.MetaVariableName, Required: true, - Schema: v1alpha1.ClusterConfigSpec{Docker: &v1alpha1.DockerSpec{}}.VariableSchema(), + Schema: v1alpha1.DockerClusterConfig{}.VariableSchema(), }) resp.SetStatus(runtimehooksv1.ResponseStatusSuccess) } diff --git a/pkg/handlers/docker/mutation/customimage/inject_control_plane.go b/pkg/handlers/docker/mutation/customimage/inject_control_plane.go index 2470eab6f..72f233f77 100644 --- a/pkg/handlers/docker/mutation/customimage/inject_control_plane.go +++ b/pkg/handlers/docker/mutation/customimage/inject_control_plane.go @@ -13,7 +13,6 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers/mutation" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/patches" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/patches/selectors" @@ -65,7 +64,7 @@ func (h *customImageControlPlanePatchHandler) Mutate( "holderRef", holderRef, ) - customImageVar, err := variables.Get[v1alpha1.OCIImage]( + customImageVar, err := variables.Get[string]( vars, h.variableName, h.variableFieldPath..., @@ -108,9 +107,7 @@ func (h *customImageControlPlanePatchHandler) Mutate( return err } - customImageVar = v1alpha1.OCIImage( - defaultKinDImageRepository + ":" + kubernetesVersion, - ) + customImageVar = defaultKinDImageRepository + ":" + kubernetesVersion } log.WithValues( @@ -119,7 +116,7 @@ func (h *customImageControlPlanePatchHandler) Mutate( "customImage", customImageVar, ).Info("setting customImage in control plane DockerMachineTemplate spec") - obj.Spec.Template.Spec.CustomImage = string(customImageVar) + obj.Spec.Template.Spec.CustomImage = customImageVar return nil }, diff --git a/pkg/handlers/docker/mutation/customimage/inject_worker.go b/pkg/handlers/docker/mutation/customimage/inject_worker.go index 9a5626e9a..98708b244 100644 --- a/pkg/handlers/docker/mutation/customimage/inject_worker.go +++ b/pkg/handlers/docker/mutation/customimage/inject_worker.go @@ -13,7 +13,6 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers/mutation" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/patches" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/patches/selectors" @@ -57,7 +56,7 @@ func (h *customImageWorkerPatchHandler) Mutate( "holderRef", holderRef, ) - customImageVar, err := variables.Get[v1alpha1.OCIImage]( + customImageVar, err := variables.Get[string]( vars, h.variableName, h.variableFieldPath..., @@ -100,9 +99,7 @@ func (h *customImageWorkerPatchHandler) Mutate( return err } - customImageVar = v1alpha1.OCIImage( - defaultKinDImageRepository + ":" + kubernetesVersion, - ) + customImageVar = defaultKinDImageRepository + ":" + kubernetesVersion } log.WithValues( @@ -111,7 +108,7 @@ func (h *customImageWorkerPatchHandler) Mutate( "customImage", customImageVar, ).Info("setting customImage in workers DockerMachineTemplate spec") - obj.Spec.Template.Spec.CustomImage = string(customImageVar) + obj.Spec.Template.Spec.CustomImage = customImageVar return nil }, diff --git a/pkg/handlers/docker/mutation/customimage/variables_test.go b/pkg/handlers/docker/mutation/customimage/variables_test.go index 9840b41ac..0362aa6f4 100644 --- a/pkg/handlers/docker/mutation/customimage/variables_test.go +++ b/pkg/handlers/docker/mutation/customimage/variables_test.go @@ -18,25 +18,25 @@ func TestVariableValidation(t *testing.T) { capitest.ValidateDiscoverVariables( t, clusterconfig.MetaVariableName, - ptr.To(v1alpha1.ClusterConfigSpec{Docker: &v1alpha1.DockerSpec{}}.VariableSchema()), + ptr.To(v1alpha1.DockerClusterConfig{}.VariableSchema()), true, dockerclusterconfig.NewVariable, capitest.VariableTestDef{ Name: "valid", - Vals: v1alpha1.ClusterConfigSpec{ - ControlPlane: &v1alpha1.NodeConfigSpec{ + Vals: v1alpha1.DockerClusterConfigSpec{ + ControlPlane: &v1alpha1.DockerNodeConfigSpec{ Docker: &v1alpha1.DockerNodeSpec{ - CustomImage: ptr.To(v1alpha1.OCIImage("docker.io/some/image:v2.3.4")), + CustomImage: ptr.To("docker.io/some/image:v2.3.4"), }, }, }, }, capitest.VariableTestDef{ Name: "invalid", - Vals: v1alpha1.ClusterConfigSpec{ - ControlPlane: &v1alpha1.NodeConfigSpec{ + Vals: v1alpha1.DockerClusterConfigSpec{ + ControlPlane: &v1alpha1.DockerNodeConfigSpec{ Docker: &v1alpha1.DockerNodeSpec{ - CustomImage: ptr.To(v1alpha1.OCIImage("this.is.not.valid?")), + CustomImage: ptr.To("this.is.not.valid?"), }, }, }, diff --git a/pkg/handlers/docker/workerconfig/variables.go b/pkg/handlers/docker/workerconfig/variables.go index c9f3e8457..fe3e2ef0d 100644 --- a/pkg/handlers/docker/workerconfig/variables.go +++ b/pkg/handlers/docker/workerconfig/variables.go @@ -46,7 +46,7 @@ func (h *dockerWorkerConfigVariableHandler) DiscoverVariables( resp.Variables = append(resp.Variables, clusterv1.ClusterClassVariable{ Name: workerconfig.MetaVariableName, Required: false, - Schema: v1alpha1.NodeConfigSpec{Docker: &v1alpha1.DockerNodeSpec{}}.VariableSchema(), + Schema: v1alpha1.DockerNodeConfig{}.VariableSchema(), }) resp.SetStatus(runtimehooksv1.ResponseStatusSuccess) } diff --git a/pkg/handlers/docker/workerconfig/variables_test.go b/pkg/handlers/docker/workerconfig/variables_test.go index 09a334706..7a67b9395 100644 --- a/pkg/handlers/docker/workerconfig/variables_test.go +++ b/pkg/handlers/docker/workerconfig/variables_test.go @@ -17,7 +17,7 @@ func TestVariableValidation(t *testing.T) { capitest.ValidateDiscoverVariables( t, workerconfig.MetaVariableName, - ptr.To(v1alpha1.NodeConfigSpec{Docker: &v1alpha1.DockerNodeSpec{}}.VariableSchema()), + ptr.To(v1alpha1.DockerNodeConfig{}.VariableSchema()), false, NewVariable, ) diff --git a/pkg/handlers/generic/clusterconfig/variables.go b/pkg/handlers/generic/clusterconfig/variables.go index f6cbce559..3803bc1c0 100644 --- a/pkg/handlers/generic/clusterconfig/variables.go +++ b/pkg/handlers/generic/clusterconfig/variables.go @@ -3,22 +3,6 @@ package clusterconfig -import ( - "context" - - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1" - - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" - commonhandlers "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers" - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers/mutation" -) - -var ( - _ commonhandlers.Named = &clusterConfigVariableHandler{} - _ mutation.DiscoverVariables = &clusterConfigVariableHandler{} -) - const ( // MetaVariableName is the meta cluster config patch variable name. MetaVariableName = "clusterConfig" @@ -29,26 +13,3 @@ const ( // HandlerNameVariable is the name of the variable handler. HandlerNameVariable = "ClusterConfigVars" ) - -func NewVariable() *clusterConfigVariableHandler { - return &clusterConfigVariableHandler{} -} - -type clusterConfigVariableHandler struct{} - -func (h *clusterConfigVariableHandler) Name() string { - return HandlerNameVariable -} - -func (h *clusterConfigVariableHandler) DiscoverVariables( - ctx context.Context, - _ *runtimehooksv1.DiscoverVariablesRequest, - resp *runtimehooksv1.DiscoverVariablesResponse, -) { - resp.Variables = append(resp.Variables, clusterv1.ClusterClassVariable{ - Name: MetaVariableName, - Required: false, - Schema: v1alpha1.GenericClusterConfig{}.VariableSchema(), - }) - resp.SetStatus(runtimehooksv1.ResponseStatusSuccess) -} diff --git a/pkg/handlers/generic/clusterconfig/variables_test.go b/pkg/handlers/generic/clusterconfig/variables_test.go deleted file mode 100644 index 70a691453..000000000 --- a/pkg/handlers/generic/clusterconfig/variables_test.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2023 D2iQ, Inc. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -package clusterconfig - -import ( - "testing" - - "k8s.io/utils/ptr" - - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest" -) - -func TestVariableValidation(t *testing.T) { - capitest.ValidateDiscoverVariables( - t, - MetaVariableName, - ptr.To(v1alpha1.GenericClusterConfig{}.VariableSchema()), - false, - NewVariable, - capitest.VariableTestDef{ - Name: "valid config", - Vals: v1alpha1.GenericClusterConfig{ - Proxy: &v1alpha1.HTTPProxy{ - HTTP: "http://a.b.c.example.com", - HTTPS: "https://a.b.c.example.com", - AdditionalNo: []string{"d.e.f.example.com"}, - }, - ExtraAPIServerCertSANs: v1alpha1.ExtraAPIServerCertSANs{"a.b.c.example.com"}, - }, - }, - ) -} diff --git a/pkg/handlers/generic/lifecycle/ccm/aws/handler.go b/pkg/handlers/generic/lifecycle/ccm/aws/handler.go index f67f36148..45543edce 100644 --- a/pkg/handlers/generic/lifecycle/ccm/aws/handler.go +++ b/pkg/handlers/generic/lifecycle/ccm/aws/handler.go @@ -15,8 +15,8 @@ import ( clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ctrlclient "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/k8s/client" + commonclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/common/clusterconfig" lifecycleutils "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/lifecycle/utils" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/options" ) @@ -57,7 +57,7 @@ func New( func (a *AWSCCM) Apply( ctx context.Context, cluster *clusterv1.Cluster, - _ *v1alpha1.ClusterConfigSpec, + _ *commonclusterconfig.ClusterConfig, log logr.Logger, ) error { log.Info("Creating AWS CCM ConfigMap for Cluster") diff --git a/pkg/handlers/generic/lifecycle/ccm/handler.go b/pkg/handlers/generic/lifecycle/ccm/handler.go index ef240ee8f..1403e319a 100644 --- a/pkg/handlers/generic/lifecycle/ccm/handler.go +++ b/pkg/handlers/generic/lifecycle/ccm/handler.go @@ -18,6 +18,7 @@ import ( commonhandlers "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers/lifecycle" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/variables" + commonclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/common/clusterconfig" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/clusterconfig" ) @@ -29,7 +30,7 @@ type CCMProvider interface { Apply( context.Context, *clusterv1.Cluster, - *v1alpha1.ClusterConfigSpec, + *commonclusterconfig.ClusterConfig, logr.Logger, ) error } @@ -95,7 +96,7 @@ func (c *CCMHandler) AfterControlPlaneInitialized( return } - clusterConfigVar, err := variables.Get[v1alpha1.ClusterConfigSpec]( + clusterConfigVar, err := variables.Get[commonclusterconfig.ClusterConfig]( varMap, clusterconfig.MetaVariableName, ) diff --git a/pkg/handlers/generic/lifecycle/ccm/nutanix/handler.go b/pkg/handlers/generic/lifecycle/ccm/nutanix/handler.go index 610468fc5..9e0d90345 100644 --- a/pkg/handlers/generic/lifecycle/ccm/nutanix/handler.go +++ b/pkg/handlers/generic/lifecycle/ccm/nutanix/handler.go @@ -18,8 +18,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" caaphv1 "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/external/sigs.k8s.io/cluster-api-addon-provider-helm/api/v1alpha1" - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/k8s/client" + commonclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/common/clusterconfig" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/lifecycle/config" lifecycleutils "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/lifecycle/utils" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/options" @@ -72,7 +72,7 @@ func New( func (p *provider) Apply( ctx context.Context, cluster *clusterv1.Cluster, - clusterConfig *v1alpha1.ClusterConfigSpec, + clusterConfig *commonclusterconfig.ClusterConfig, log logr.Logger, ) error { // No need to check for nil values in the struct, this function will only be called if CCM is not nil @@ -164,7 +164,7 @@ func (p *provider) Apply( return nil } -func templateValues(clusterConfig *v1alpha1.ClusterConfigSpec, text string) (string, error) { +func templateValues(clusterConfig *commonclusterconfig.ClusterConfig, text string) (string, error) { helmValuesTemplate, err := template.New("").Parse(text) if err != nil { return "", fmt.Errorf("failed to parse Helm values template: %w", err) diff --git a/pkg/handlers/generic/lifecycle/ccm/nutanix/handler_test.go b/pkg/handlers/generic/lifecycle/ccm/nutanix/handler_test.go index 2a9d71322..933b66184 100644 --- a/pkg/handlers/generic/lifecycle/ccm/nutanix/handler_test.go +++ b/pkg/handlers/generic/lifecycle/ccm/nutanix/handler_test.go @@ -13,6 +13,7 @@ import ( "k8s.io/utils/ptr" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" + commonclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/common/clusterconfig" ) const ( @@ -60,14 +61,15 @@ func Test_templateValues(t *testing.T) { tests := []struct { name string - clusterConfig *v1alpha1.ClusterConfigSpec - in string - expected string + clusterConfig *commonclusterconfig.ClusterConfig + + in string + expected string }{ { name: "With AdditionalTrustBundle set", - clusterConfig: &v1alpha1.ClusterConfigSpec{ - GenericClusterConfig: v1alpha1.GenericClusterConfig{ + clusterConfig: &commonclusterconfig.ClusterConfig{ + GenericClusterConfigSpec: v1alpha1.GenericClusterConfigSpec{ Addons: &v1alpha1.Addons{ CCM: &v1alpha1.CCM{ Credentials: &corev1.LocalObjectReference{ @@ -91,8 +93,8 @@ func Test_templateValues(t *testing.T) { }, { name: "Without an AdditionalTrustBundle set", - clusterConfig: &v1alpha1.ClusterConfigSpec{ - GenericClusterConfig: v1alpha1.GenericClusterConfig{ + clusterConfig: &commonclusterconfig.ClusterConfig{ + GenericClusterConfigSpec: v1alpha1.GenericClusterConfigSpec{ Addons: &v1alpha1.Addons{ CCM: &v1alpha1.CCM{ Credentials: &corev1.LocalObjectReference{ diff --git a/pkg/handlers/generic/lifecycle/clusterautoscaler/variables_test.go b/pkg/handlers/generic/lifecycle/clusterautoscaler/variables_test.go index 81ad72479..fa0050b48 100644 --- a/pkg/handlers/generic/lifecycle/clusterautoscaler/variables_test.go +++ b/pkg/handlers/generic/lifecycle/clusterautoscaler/variables_test.go @@ -10,19 +10,22 @@ import ( "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest" + awsclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws/clusterconfig" + dockerclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/docker/clusterconfig" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/clusterconfig" + nutanixclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/nutanix/clusterconfig" ) -func TestVariableValidation(t *testing.T) { +func TestVariableValidation_AWS(t *testing.T) { capitest.ValidateDiscoverVariables( t, clusterconfig.MetaVariableName, - ptr.To(v1alpha1.GenericClusterConfig{}.VariableSchema()), - false, - clusterconfig.NewVariable, + ptr.To(v1alpha1.AWSClusterConfig{}.VariableSchema()), + true, + awsclusterconfig.NewVariable, capitest.VariableTestDef{ Name: "ClusterResourceSet strategy", - Vals: v1alpha1.GenericClusterConfig{ + Vals: v1alpha1.GenericClusterConfigSpec{ Addons: &v1alpha1.Addons{ ClusterAutoscaler: &v1alpha1.ClusterAutoscaler{ Strategy: v1alpha1.AddonStrategyClusterResourceSet, @@ -32,7 +35,7 @@ func TestVariableValidation(t *testing.T) { }, capitest.VariableTestDef{ Name: "HelmAddon strategy", - Vals: v1alpha1.GenericClusterConfig{ + Vals: v1alpha1.GenericClusterConfigSpec{ Addons: &v1alpha1.Addons{ ClusterAutoscaler: &v1alpha1.ClusterAutoscaler{ Strategy: v1alpha1.AddonStrategyHelmAddon, @@ -42,7 +45,89 @@ func TestVariableValidation(t *testing.T) { }, capitest.VariableTestDef{ Name: "invalid strategy", - Vals: v1alpha1.GenericClusterConfig{ + Vals: v1alpha1.GenericClusterConfigSpec{ + Addons: &v1alpha1.Addons{ + ClusterAutoscaler: &v1alpha1.ClusterAutoscaler{ + Strategy: "invalid-strategy", + }, + }, + }, + ExpectError: true, + }, + ) +} + +func TestVariableValidation_Nutanix(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.NutanixClusterConfig{}.VariableSchema()), + true, + nutanixclusterconfig.NewVariable, + capitest.VariableTestDef{ + Name: "ClusterResourceSet strategy", + Vals: v1alpha1.GenericClusterConfigSpec{ + Addons: &v1alpha1.Addons{ + ClusterAutoscaler: &v1alpha1.ClusterAutoscaler{ + Strategy: v1alpha1.AddonStrategyClusterResourceSet, + }, + }, + }, + }, + capitest.VariableTestDef{ + Name: "HelmAddon strategy", + Vals: v1alpha1.GenericClusterConfigSpec{ + Addons: &v1alpha1.Addons{ + ClusterAutoscaler: &v1alpha1.ClusterAutoscaler{ + Strategy: v1alpha1.AddonStrategyHelmAddon, + }, + }, + }, + }, + capitest.VariableTestDef{ + Name: "invalid strategy", + Vals: v1alpha1.GenericClusterConfigSpec{ + Addons: &v1alpha1.Addons{ + ClusterAutoscaler: &v1alpha1.ClusterAutoscaler{ + Strategy: "invalid-strategy", + }, + }, + }, + ExpectError: true, + }, + ) +} + +func TestVariableValidation_Docker(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.DockerClusterConfig{}.VariableSchema()), + true, + dockerclusterconfig.NewVariable, + capitest.VariableTestDef{ + Name: "ClusterResourceSet strategy", + Vals: v1alpha1.GenericClusterConfigSpec{ + Addons: &v1alpha1.Addons{ + ClusterAutoscaler: &v1alpha1.ClusterAutoscaler{ + Strategy: v1alpha1.AddonStrategyClusterResourceSet, + }, + }, + }, + }, + capitest.VariableTestDef{ + Name: "HelmAddon strategy", + Vals: v1alpha1.GenericClusterConfigSpec{ + Addons: &v1alpha1.Addons{ + ClusterAutoscaler: &v1alpha1.ClusterAutoscaler{ + Strategy: v1alpha1.AddonStrategyHelmAddon, + }, + }, + }, + }, + capitest.VariableTestDef{ + Name: "invalid strategy", + Vals: v1alpha1.GenericClusterConfigSpec{ Addons: &v1alpha1.Addons{ ClusterAutoscaler: &v1alpha1.ClusterAutoscaler{ Strategy: "invalid-strategy", diff --git a/pkg/handlers/generic/lifecycle/cni/variables_test.go b/pkg/handlers/generic/lifecycle/cni/variables_test.go index 0023a9b17..d68314cea 100644 --- a/pkg/handlers/generic/lifecycle/cni/variables_test.go +++ b/pkg/handlers/generic/lifecycle/cni/variables_test.go @@ -10,61 +10,85 @@ import ( "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest" + awsclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws/clusterconfig" + dockerclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/docker/clusterconfig" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/clusterconfig" + nutanixclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/nutanix/clusterconfig" ) -func TestVariableValidation(t *testing.T) { - capitest.ValidateDiscoverVariables( - t, - clusterconfig.MetaVariableName, - ptr.To(v1alpha1.GenericClusterConfig{}.VariableSchema()), - false, - clusterconfig.NewVariable, - capitest.VariableTestDef{ - Name: "set with valid provider using ClusterResourceSet strategy", - Vals: v1alpha1.GenericClusterConfig{ - Addons: &v1alpha1.Addons{ - CNI: &v1alpha1.CNI{ - Provider: v1alpha1.CNIProviderCalico, - Strategy: v1alpha1.AddonStrategyClusterResourceSet, - }, - }, +var testDefs = []capitest.VariableTestDef{{ + Name: "set with valid provider using ClusterResourceSet strategy", + Vals: v1alpha1.GenericClusterConfigSpec{ + Addons: &v1alpha1.Addons{ + CNI: &v1alpha1.CNI{ + Provider: v1alpha1.CNIProviderCalico, + Strategy: v1alpha1.AddonStrategyClusterResourceSet, }, }, - capitest.VariableTestDef{ - Name: "set with valid provider using HelmAddon strategy", - Vals: v1alpha1.GenericClusterConfig{ - Addons: &v1alpha1.Addons{ - CNI: &v1alpha1.CNI{ - Provider: v1alpha1.CNIProviderCalico, - Strategy: v1alpha1.AddonStrategyHelmAddon, - }, - }, + }, +}, { + Name: "set with valid provider using HelmAddon strategy", + Vals: v1alpha1.GenericClusterConfigSpec{ + Addons: &v1alpha1.Addons{ + CNI: &v1alpha1.CNI{ + Provider: v1alpha1.CNIProviderCalico, + Strategy: v1alpha1.AddonStrategyHelmAddon, }, }, - capitest.VariableTestDef{ - Name: "set with invalid provider", - Vals: v1alpha1.GenericClusterConfig{ - Addons: &v1alpha1.Addons{ - CNI: &v1alpha1.CNI{ - Provider: "invalid-provider", - Strategy: v1alpha1.AddonStrategyClusterResourceSet, - }, - }, + }, +}, { + Name: "set with invalid provider", + Vals: v1alpha1.GenericClusterConfigSpec{ + Addons: &v1alpha1.Addons{ + CNI: &v1alpha1.CNI{ + Provider: "invalid-provider", + Strategy: v1alpha1.AddonStrategyClusterResourceSet, }, - ExpectError: true, }, - capitest.VariableTestDef{ - Name: "set with invalid strategy", - Vals: v1alpha1.GenericClusterConfig{ - Addons: &v1alpha1.Addons{ - CNI: &v1alpha1.CNI{ - Provider: v1alpha1.CNIProviderCalico, - Strategy: "invalid-strategy", - }, - }, + }, + ExpectError: true, +}, { + Name: "set with invalid strategy", + Vals: v1alpha1.GenericClusterConfigSpec{ + Addons: &v1alpha1.Addons{ + CNI: &v1alpha1.CNI{ + Provider: v1alpha1.CNIProviderCalico, + Strategy: "invalid-strategy", }, - ExpectError: true, }, + }, + ExpectError: true, +}} + +func TestVariableValidation_AWS(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.AWSClusterConfig{}.VariableSchema()), + true, + awsclusterconfig.NewVariable, + testDefs..., + ) +} + +func TestVariableValidation_Docker(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.DockerClusterConfig{}.VariableSchema()), + true, + dockerclusterconfig.NewVariable, + testDefs..., + ) +} + +func TestVariableValidation_Nutanix(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.NutanixClusterConfig{}.VariableSchema()), + true, + nutanixclusterconfig.NewVariable, + testDefs..., ) } diff --git a/pkg/handlers/generic/lifecycle/nfd/variables_test.go b/pkg/handlers/generic/lifecycle/nfd/variables_test.go index 110a57bbf..984645ab7 100644 --- a/pkg/handlers/generic/lifecycle/nfd/variables_test.go +++ b/pkg/handlers/generic/lifecycle/nfd/variables_test.go @@ -10,46 +10,71 @@ import ( "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest" + awsclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws/clusterconfig" + dockerclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/docker/clusterconfig" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/clusterconfig" + nutanixclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/nutanix/clusterconfig" ) -func TestVariableValidation(t *testing.T) { - capitest.ValidateDiscoverVariables( - t, - clusterconfig.MetaVariableName, - ptr.To(v1alpha1.GenericClusterConfig{}.VariableSchema()), - false, - clusterconfig.NewVariable, - capitest.VariableTestDef{ - Name: "ClusterResourceSet strategy", - Vals: v1alpha1.GenericClusterConfig{ - Addons: &v1alpha1.Addons{ - NFD: &v1alpha1.NFD{ - Strategy: v1alpha1.AddonStrategyClusterResourceSet, - }, - }, +var testDefs = []capitest.VariableTestDef{{ + Name: "ClusterResourceSet strategy", + Vals: v1alpha1.GenericClusterConfigSpec{ + Addons: &v1alpha1.Addons{ + NFD: &v1alpha1.NFD{ + Strategy: v1alpha1.AddonStrategyClusterResourceSet, }, }, - capitest.VariableTestDef{ - Name: "HelmAddon strategy", - Vals: v1alpha1.GenericClusterConfig{ - Addons: &v1alpha1.Addons{ - NFD: &v1alpha1.NFD{ - Strategy: v1alpha1.AddonStrategyHelmAddon, - }, - }, + }, +}, { + Name: "HelmAddon strategy", + Vals: v1alpha1.GenericClusterConfigSpec{ + Addons: &v1alpha1.Addons{ + NFD: &v1alpha1.NFD{ + Strategy: v1alpha1.AddonStrategyHelmAddon, }, }, - capitest.VariableTestDef{ - Name: "invalid strategy", - Vals: v1alpha1.GenericClusterConfig{ - Addons: &v1alpha1.Addons{ - NFD: &v1alpha1.NFD{ - Strategy: "invalid-strategy", - }, - }, + }, +}, { + Name: "invalid strategy", + Vals: v1alpha1.GenericClusterConfigSpec{ + Addons: &v1alpha1.Addons{ + NFD: &v1alpha1.NFD{ + Strategy: "invalid-strategy", }, - ExpectError: true, }, + }, + ExpectError: true, +}} + +func TestVariableValidation_AWS(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.AWSClusterConfig{}.VariableSchema()), + true, + awsclusterconfig.NewVariable, + testDefs..., + ) +} + +func TestVariableValidation_Docker(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.DockerClusterConfig{}.VariableSchema()), + true, + dockerclusterconfig.NewVariable, + testDefs..., + ) +} + +func TestVariableValidation_Nutanix(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.NutanixClusterConfig{}.VariableSchema()), + true, + nutanixclusterconfig.NewVariable, + testDefs..., ) } diff --git a/pkg/handlers/generic/mutation/etcd/variables_test.go b/pkg/handlers/generic/mutation/etcd/variables_test.go index f2488140a..6ab2f75e8 100644 --- a/pkg/handlers/generic/mutation/etcd/variables_test.go +++ b/pkg/handlers/generic/mutation/etcd/variables_test.go @@ -10,54 +10,78 @@ import ( "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest" + awsclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws/clusterconfig" + dockerclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/docker/clusterconfig" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/clusterconfig" + nutanixclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/nutanix/clusterconfig" ) -func TestVariableValidation(t *testing.T) { - capitest.ValidateDiscoverVariables( - t, - clusterconfig.MetaVariableName, - ptr.To(v1alpha1.GenericClusterConfig{}.VariableSchema()), - false, - clusterconfig.NewVariable, - capitest.VariableTestDef{ - Name: "unset", - Vals: v1alpha1.GenericClusterConfig{ - Etcd: &v1alpha1.Etcd{}, +var testDefs = []capitest.VariableTestDef{{ + Name: "unset", + Vals: v1alpha1.GenericClusterConfigSpec{ + Etcd: &v1alpha1.Etcd{}, + }, +}, { + Name: "set with valid image values", + Vals: v1alpha1.GenericClusterConfigSpec{ + Etcd: &v1alpha1.Etcd{ + Image: &v1alpha1.Image{ + Repository: "my-registry.io/my-org/my-repo", + Tag: "v3.5.99_custom.0", }, }, - capitest.VariableTestDef{ - Name: "set with valid image values", - Vals: v1alpha1.GenericClusterConfig{ - Etcd: &v1alpha1.Etcd{ - Image: &v1alpha1.Image{ - Repository: "my-registry.io/my-org/my-repo", - Tag: "v3.5.99_custom.0", - }, - }, + }, +}, { + Name: "set with invalid image repository", + Vals: v1alpha1.GenericClusterConfigSpec{ + Etcd: &v1alpha1.Etcd{ + Image: &v1alpha1.Image{ + Repository: "https://this.should.not.have.a.scheme", }, }, - capitest.VariableTestDef{ - Name: "set with invalid image repository", - Vals: v1alpha1.GenericClusterConfig{ - Etcd: &v1alpha1.Etcd{ - Image: &v1alpha1.Image{ - Repository: "https://this.should.not.have.a.scheme", - }, - }, + }, + ExpectError: true, +}, { + Name: "set with invalid image tag", + Vals: v1alpha1.GenericClusterConfigSpec{ + Etcd: &v1alpha1.Etcd{ + Image: &v1alpha1.Image{ + Tag: "this:is:not:a:valid:tag", }, - ExpectError: true, - }, - capitest.VariableTestDef{ - Name: "set with invalid image tag", - Vals: v1alpha1.GenericClusterConfig{ - Etcd: &v1alpha1.Etcd{ - Image: &v1alpha1.Image{ - Tag: "this:is:not:a:valid:tag", - }, - }, - }, - ExpectError: true, }, + }, + ExpectError: true, +}} + +func TestVariableValidation_AWS(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.AWSClusterConfig{}.VariableSchema()), + true, + awsclusterconfig.NewVariable, + testDefs..., + ) +} + +func TestVariableValidation_Docker(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.DockerClusterConfig{}.VariableSchema()), + true, + dockerclusterconfig.NewVariable, + testDefs..., + ) +} + +func TestVariableValidation_Nutanix(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.NutanixClusterConfig{}.VariableSchema()), + true, + nutanixclusterconfig.NewVariable, + testDefs..., ) } diff --git a/pkg/handlers/generic/mutation/extraapiservercertsans/inject.go b/pkg/handlers/generic/mutation/extraapiservercertsans/inject.go index 9e9c4f0fa..09f912839 100644 --- a/pkg/handlers/generic/mutation/extraapiservercertsans/inject.go +++ b/pkg/handlers/generic/mutation/extraapiservercertsans/inject.go @@ -60,7 +60,7 @@ func (h *extraAPIServerCertSANsPatchHandler) Mutate( log := ctrl.LoggerFrom(ctx).WithValues( "holderRef", holderRef, ) - extraAPIServerCertSANsVar, err := variables.Get[v1alpha1.ExtraAPIServerCertSANs]( + extraAPIServerCertSANsVar, err := variables.Get[[]string]( vars, h.variableName, h.variableFieldPath..., diff --git a/pkg/handlers/generic/mutation/extraapiservercertsans/inject_test.go b/pkg/handlers/generic/mutation/extraapiservercertsans/inject_test.go index 19a4d447e..a9d68407b 100644 --- a/pkg/handlers/generic/mutation/extraapiservercertsans/inject_test.go +++ b/pkg/handlers/generic/mutation/extraapiservercertsans/inject_test.go @@ -51,13 +51,11 @@ var _ = Describe("Generate Extra API server certificate patches", func() { Vars: []runtimehooksv1.Variable{ capitest.VariableWithValue( clusterconfig.MetaVariableName, - v1alpha1.ClusterConfigSpec{ - GenericClusterConfig: v1alpha1.GenericClusterConfig{ - ExtraAPIServerCertSANs: v1alpha1.ExtraAPIServerCertSANs{ - "a.b.c.example.com", - "a.b.c.example.com", - "d.e.f.example.com", - }, + v1alpha1.AWSClusterConfigSpec{ + ExtraAPIServerCertSANs: []string{ + "a.b.c.example.com", + "a.b.c.example.com", + "d.e.f.example.com", }, AWS: &v1alpha1.AWSSpec{}, }, @@ -92,11 +90,9 @@ var _ = Describe("Generate Extra API server certificate patches", func() { Vars: []runtimehooksv1.Variable{ capitest.VariableWithValue( clusterconfig.MetaVariableName, - v1alpha1.ClusterConfigSpec{ - GenericClusterConfig: v1alpha1.GenericClusterConfig{ - ExtraAPIServerCertSANs: v1alpha1.ExtraAPIServerCertSANs{ - "a.b.c.example.com", - }, + v1alpha1.DockerClusterConfigSpec{ + ExtraAPIServerCertSANs: []string{ + "a.b.c.example.com", }, }, ), @@ -136,11 +132,9 @@ var _ = Describe("Generate Extra API server certificate patches", func() { Vars: []runtimehooksv1.Variable{ capitest.VariableWithValue( clusterconfig.MetaVariableName, - v1alpha1.ClusterConfigSpec{ - GenericClusterConfig: v1alpha1.GenericClusterConfig{ - ExtraAPIServerCertSANs: v1alpha1.ExtraAPIServerCertSANs{ - "a.b.c.example.com", - }, + v1alpha1.NutanixClusterConfigSpec{ + ExtraAPIServerCertSANs: []string{ + "a.b.c.example.com", }, }, ), diff --git a/pkg/handlers/generic/mutation/extraapiservercertsans/variables_test.go b/pkg/handlers/generic/mutation/extraapiservercertsans/variables_test.go index f6925b313..a4701fedd 100644 --- a/pkg/handlers/generic/mutation/extraapiservercertsans/variables_test.go +++ b/pkg/handlers/generic/mutation/extraapiservercertsans/variables_test.go @@ -10,38 +10,101 @@ import ( "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest" + awsclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws/clusterconfig" + dockerclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/docker/clusterconfig" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/clusterconfig" + nutanixclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/nutanix/clusterconfig" ) -func TestVariableValidation(t *testing.T) { +func TestVariableValidation_AWS(t *testing.T) { capitest.ValidateDiscoverVariables( t, clusterconfig.MetaVariableName, - ptr.To(v1alpha1.GenericClusterConfig{}.VariableSchema()), - false, - clusterconfig.NewVariable, - capitest.VariableTestDef{ + ptr.To(v1alpha1.AWSClusterConfig{}.VariableSchema()), + true, + awsclusterconfig.NewVariable, + []capitest.VariableTestDef{{ Name: "single valid SAN", - Vals: v1alpha1.GenericClusterConfig{ - ExtraAPIServerCertSANs: v1alpha1.ExtraAPIServerCertSANs{"a.b.c.example.com"}, + Vals: v1alpha1.AWSClusterConfigSpec{ + ExtraAPIServerCertSANs: []string{"a.b.c.example.com"}, }, - }, - capitest.VariableTestDef{ + }, { Name: "single invalid SAN", - Vals: v1alpha1.GenericClusterConfig{ - ExtraAPIServerCertSANs: v1alpha1.ExtraAPIServerCertSANs{"invalid:san"}, + Vals: v1alpha1.AWSClusterConfigSpec{ + ExtraAPIServerCertSANs: []string{"invalid:san"}, }, ExpectError: true, - }, - capitest.VariableTestDef{ + }, { Name: "duplicate valid SANs", - Vals: v1alpha1.GenericClusterConfig{ - ExtraAPIServerCertSANs: v1alpha1.ExtraAPIServerCertSANs{ + Vals: v1alpha1.AWSClusterConfigSpec{ + ExtraAPIServerCertSANs: []string{ "a.b.c.example.com", "a.b.c.example.com", }, }, ExpectError: true, - }, + }}..., + ) +} + +func TestVariableValidation_Docker(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.DockerClusterConfig{}.VariableSchema()), + true, + dockerclusterconfig.NewVariable, + []capitest.VariableTestDef{{ + Name: "single valid SAN", + Vals: v1alpha1.DockerClusterConfigSpec{ + ExtraAPIServerCertSANs: []string{"a.b.c.example.com"}, + }, + }, { + Name: "single invalid SAN", + Vals: v1alpha1.DockerClusterConfigSpec{ + ExtraAPIServerCertSANs: []string{"invalid:san"}, + }, + ExpectError: true, + }, { + Name: "duplicate valid SANs", + Vals: v1alpha1.DockerClusterConfigSpec{ + ExtraAPIServerCertSANs: []string{ + "a.b.c.example.com", + "a.b.c.example.com", + }, + }, + ExpectError: true, + }}..., + ) +} + +func TestVariableValidation_Nutanix(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.NutanixClusterConfig{}.VariableSchema()), + true, + nutanixclusterconfig.NewVariable, + []capitest.VariableTestDef{{ + Name: "single valid SAN", + Vals: v1alpha1.NutanixClusterConfigSpec{ + ExtraAPIServerCertSANs: []string{"a.b.c.example.com"}, + }, + }, { + Name: "single invalid SAN", + Vals: v1alpha1.NutanixClusterConfigSpec{ + ExtraAPIServerCertSANs: []string{"invalid:san"}, + }, + ExpectError: true, + }, { + Name: "duplicate valid SANs", + Vals: v1alpha1.NutanixClusterConfigSpec{ + ExtraAPIServerCertSANs: []string{ + "a.b.c.example.com", + "a.b.c.example.com", + }, + }, + ExpectError: true, + }}..., ) } diff --git a/pkg/handlers/generic/mutation/httpproxy/variables_test.go b/pkg/handlers/generic/mutation/httpproxy/variables_test.go index ebeec8a9b..46bef2cc0 100644 --- a/pkg/handlers/generic/mutation/httpproxy/variables_test.go +++ b/pkg/handlers/generic/mutation/httpproxy/variables_test.go @@ -10,26 +10,52 @@ import ( "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest" + awsclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws/clusterconfig" + dockerclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/docker/clusterconfig" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/clusterconfig" + nutanixclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/nutanix/clusterconfig" ) -func TestVariableValidation(t *testing.T) { +var testDefs = []capitest.VariableTestDef{{ + Name: "valid proxy config", + Vals: v1alpha1.GenericClusterConfigSpec{ + Proxy: &v1alpha1.HTTPProxy{ + HTTP: "http://a.b.c.example.com", + HTTPS: "https://a.b.c.example.com", + AdditionalNo: []string{"d.e.f.example.com"}, + }, + }, +}} + +func TestVariableValidation_AWS(t *testing.T) { capitest.ValidateDiscoverVariables( t, clusterconfig.MetaVariableName, - ptr.To(v1alpha1.GenericClusterConfig{}.VariableSchema()), - false, - clusterconfig.NewVariable, - // HTTPProxy - capitest.VariableTestDef{ - Name: "valid proxy config", - Vals: v1alpha1.GenericClusterConfig{ - Proxy: &v1alpha1.HTTPProxy{ - HTTP: "http://a.b.c.example.com", - HTTPS: "https://a.b.c.example.com", - AdditionalNo: []string{"d.e.f.example.com"}, - }, - }, - }, + ptr.To(v1alpha1.AWSClusterConfig{}.VariableSchema()), + true, + awsclusterconfig.NewVariable, + testDefs..., + ) +} + +func TestVariableValidation_Docker(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.DockerClusterConfig{}.VariableSchema()), + true, + dockerclusterconfig.NewVariable, + testDefs..., + ) +} + +func TestVariableValidation_Nutanix(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.NutanixClusterConfig{}.VariableSchema()), + true, + nutanixclusterconfig.NewVariable, + testDefs..., ) } diff --git a/pkg/handlers/generic/mutation/imageregistries/credentials/inject.go b/pkg/handlers/generic/mutation/imageregistries/credentials/inject.go index a314bb99d..5ef9832a7 100644 --- a/pkg/handlers/generic/mutation/imageregistries/credentials/inject.go +++ b/pkg/handlers/generic/mutation/imageregistries/credentials/inject.go @@ -75,7 +75,7 @@ func (h *imageRegistriesPatchHandler) Mutate( "holderRef", holderRef, ) - imageRegistries, imageRegistriesErr := variables.Get[v1alpha1.ImageRegistries]( + imageRegistries, imageRegistriesErr := variables.Get[[]v1alpha1.ImageRegistry]( vars, h.variableName, h.variableFieldPath..., diff --git a/pkg/handlers/generic/mutation/imageregistries/credentials/inject_test.go b/pkg/handlers/generic/mutation/imageregistries/credentials/inject_test.go index 91bdf9971..38cb57081 100644 --- a/pkg/handlers/generic/mutation/imageregistries/credentials/inject_test.go +++ b/pkg/handlers/generic/mutation/imageregistries/credentials/inject_test.go @@ -148,11 +148,9 @@ var _ = Describe("Generate Image registry patches", func() { Vars: []runtimehooksv1.Variable{ capitest.VariableWithValue( clusterconfig.MetaVariableName, - v1alpha1.ImageRegistries{ - v1alpha1.ImageRegistry{ - URL: "https://123456789.dkr.ecr.us-east-1.amazonaws.com", - }, - }, + []v1alpha1.ImageRegistry{{ + URL: "https://123456789.dkr.ecr.us-east-1.amazonaws.com", + }}, imageregistries.VariableName, ), }, @@ -203,16 +201,14 @@ var _ = Describe("Generate Image registry patches", func() { Vars: []runtimehooksv1.Variable{ capitest.VariableWithValue( clusterconfig.MetaVariableName, - v1alpha1.ImageRegistries{ - v1alpha1.ImageRegistry{ - URL: "https://registry.example.com", - Credentials: &v1alpha1.RegistryCredentials{ - SecretRef: &corev1.LocalObjectReference{ - Name: validSecretName, - }, + []v1alpha1.ImageRegistry{{ + URL: "https://registry.example.com", + Credentials: &v1alpha1.RegistryCredentials{ + SecretRef: &corev1.LocalObjectReference{ + Name: validSecretName, }, }, - }, + }}, imageregistries.VariableName, ), }, @@ -269,11 +265,9 @@ var _ = Describe("Generate Image registry patches", func() { Vars: []runtimehooksv1.Variable{ capitest.VariableWithValue( clusterconfig.MetaVariableName, - v1alpha1.ImageRegistries{ - v1alpha1.ImageRegistry{ - URL: "https://123456789.dkr.ecr.us-east-1.amazonaws.com", - }, - }, + []v1alpha1.ImageRegistry{{ + URL: "https://123456789.dkr.ecr.us-east-1.amazonaws.com", + }}, imageregistries.VariableName, ), capitest.VariableWithValue( @@ -324,16 +318,14 @@ var _ = Describe("Generate Image registry patches", func() { Vars: []runtimehooksv1.Variable{ capitest.VariableWithValue( clusterconfig.MetaVariableName, - v1alpha1.ImageRegistries{ - v1alpha1.ImageRegistry{ - URL: "https://registry.example.com", - Credentials: &v1alpha1.RegistryCredentials{ - SecretRef: &corev1.LocalObjectReference{ - Name: validSecretName, - }, + []v1alpha1.ImageRegistry{{ + URL: "https://registry.example.com", + Credentials: &v1alpha1.RegistryCredentials{ + SecretRef: &corev1.LocalObjectReference{ + Name: validSecretName, }, }, - }, + }}, imageregistries.VariableName, ), capitest.VariableWithValue( @@ -387,11 +379,9 @@ var _ = Describe("Generate Image registry patches", func() { Vars: []runtimehooksv1.Variable{ capitest.VariableWithValue( clusterconfig.MetaVariableName, - v1alpha1.ImageRegistries{ - v1alpha1.ImageRegistry{ - URL: "https://registry.example.com", - }, - }, + []v1alpha1.ImageRegistry{{ + URL: "https://registry.example.com", + }}, imageregistries.VariableName, ), }, diff --git a/pkg/handlers/generic/mutation/imageregistries/credentials/variables_test.go b/pkg/handlers/generic/mutation/imageregistries/credentials/variables_test.go index 89e0b7b57..0b520e661 100644 --- a/pkg/handlers/generic/mutation/imageregistries/credentials/variables_test.go +++ b/pkg/handlers/generic/mutation/imageregistries/credentials/variables_test.go @@ -11,75 +11,100 @@ import ( "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest" + awsclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws/clusterconfig" + dockerclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/docker/clusterconfig" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/clusterconfig" + nutanixclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/nutanix/clusterconfig" ) -func TestVariableValidation(t *testing.T) { - capitest.ValidateDiscoverVariables( - t, - clusterconfig.MetaVariableName, - ptr.To(v1alpha1.GenericClusterConfig{}.VariableSchema()), - false, - clusterconfig.NewVariable, - capitest.VariableTestDef{ - Name: "without a credentials secret", - Vals: v1alpha1.GenericClusterConfig{ - ImageRegistries: []v1alpha1.ImageRegistry{ - { - URL: "http://a.b.c.example.com", - }, +var testDefs = []capitest.VariableTestDef{ + { + Name: "without a credentials secret", + Vals: v1alpha1.GenericClusterConfigSpec{ + ImageRegistries: []v1alpha1.ImageRegistry{ + { + URL: "http://a.b.c.example.com", }, }, }, - capitest.VariableTestDef{ - Name: "with a credentials secret", - Vals: v1alpha1.GenericClusterConfig{ - ImageRegistries: []v1alpha1.ImageRegistry{ - { - URL: "https://a.b.c.example.com/a/b/c", - Credentials: &v1alpha1.RegistryCredentials{ - SecretRef: &corev1.LocalObjectReference{ - Name: "a.b.c.example.com-creds", - }, + }, { + Name: "with a credentials secret", + Vals: v1alpha1.GenericClusterConfigSpec{ + ImageRegistries: []v1alpha1.ImageRegistry{ + { + URL: "https://a.b.c.example.com/a/b/c", + Credentials: &v1alpha1.RegistryCredentials{ + SecretRef: &corev1.LocalObjectReference{ + Name: "a.b.c.example.com-creds", }, }, }, }, }, - capitest.VariableTestDef{ - Name: "support for multiple image registries", - Vals: v1alpha1.GenericClusterConfig{ - ImageRegistries: []v1alpha1.ImageRegistry{ - { - URL: "http://first-image-registry.example.com", - }, - { - URL: "http://second-image-registry.example.com", - }, + }, { + Name: "support for multiple image registries", + Vals: v1alpha1.GenericClusterConfigSpec{ + ImageRegistries: []v1alpha1.ImageRegistry{ + { + URL: "http://first-image-registry.example.com", + }, + { + URL: "http://second-image-registry.example.com", }, }, }, - capitest.VariableTestDef{ - Name: "invalid registry URL", - Vals: v1alpha1.GenericClusterConfig{ - ImageRegistries: []v1alpha1.ImageRegistry{ - { - URL: "unsupportedformat://a.b.c.example.com", - }, + }, { + Name: "invalid registry URL", + Vals: v1alpha1.GenericClusterConfigSpec{ + ImageRegistries: []v1alpha1.ImageRegistry{ + { + URL: "unsupportedformat://a.b.c.example.com", }, }, - ExpectError: true, }, - capitest.VariableTestDef{ - Name: "registry URL without format", - Vals: v1alpha1.GenericClusterConfig{ - ImageRegistries: []v1alpha1.ImageRegistry{ - { - URL: "a.b.c.example.com/a/b/c", - }, + ExpectError: true, + }, { + Name: "registry URL without format", + Vals: v1alpha1.GenericClusterConfigSpec{ + ImageRegistries: []v1alpha1.ImageRegistry{ + { + URL: "a.b.c.example.com/a/b/c", }, }, - ExpectError: true, }, + ExpectError: true, + }, +} + +func TestVariableValidation_AWS(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.AWSClusterConfig{}.VariableSchema()), + true, + awsclusterconfig.NewVariable, + testDefs..., + ) +} + +func TestVariableValidation_Docker(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.DockerClusterConfig{}.VariableSchema()), + true, + dockerclusterconfig.NewVariable, + testDefs..., + ) +} + +func TestVariableValidation_Nutanix(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.NutanixClusterConfig{}.VariableSchema()), + true, + nutanixclusterconfig.NewVariable, + testDefs..., ) } diff --git a/pkg/handlers/generic/mutation/kubernetesimagerepository/inject.go b/pkg/handlers/generic/mutation/kubernetesimagerepository/inject.go index a7d08e8af..3baceeff5 100644 --- a/pkg/handlers/generic/mutation/kubernetesimagerepository/inject.go +++ b/pkg/handlers/generic/mutation/kubernetesimagerepository/inject.go @@ -14,7 +14,6 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers/mutation" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/patches" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/patches/selectors" @@ -58,7 +57,7 @@ func (h *imageRepositoryPatchHandler) Mutate( "holderRef", holderRef, ) - imageRepositoryVar, err := variables.Get[v1alpha1.KubernetesImageRepository]( + imageRepositoryVar, err := variables.Get[string]( vars, h.variableName, h.variableFieldPath..., @@ -91,7 +90,7 @@ func (h *imageRepositoryPatchHandler) Mutate( if obj.Spec.Template.Spec.KubeadmConfigSpec.ClusterConfiguration == nil { obj.Spec.Template.Spec.KubeadmConfigSpec.ClusterConfiguration = &bootstrapv1.ClusterConfiguration{} } - obj.Spec.Template.Spec.KubeadmConfigSpec.ClusterConfiguration.ImageRepository = imageRepositoryVar.String() + obj.Spec.Template.Spec.KubeadmConfigSpec.ClusterConfiguration.ImageRepository = imageRepositoryVar return nil }, diff --git a/pkg/handlers/generic/mutation/kubernetesimagerepository/inject_test.go b/pkg/handlers/generic/mutation/kubernetesimagerepository/inject_test.go index 7c19e02ba..d31908868 100644 --- a/pkg/handlers/generic/mutation/kubernetesimagerepository/inject_test.go +++ b/pkg/handlers/generic/mutation/kubernetesimagerepository/inject_test.go @@ -10,7 +10,6 @@ import ( "github.com/onsi/gomega" runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1" - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers/mutation" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest/request" @@ -37,7 +36,7 @@ var _ = Describe("Generate Kubernetes Image Repository patches", func() { Vars: []runtimehooksv1.Variable{ capitest.VariableWithValue( clusterconfig.MetaVariableName, - v1alpha1.KubernetesImageRepository("my-registry.io/my-org/my-repo"), + "my-registry.io/my-org/my-repo", VariableName, ), }, diff --git a/pkg/handlers/generic/mutation/kubernetesimagerepository/variables_test.go b/pkg/handlers/generic/mutation/kubernetesimagerepository/variables_test.go index 80fc94768..690d32a87 100644 --- a/pkg/handlers/generic/mutation/kubernetesimagerepository/variables_test.go +++ b/pkg/handlers/generic/mutation/kubernetesimagerepository/variables_test.go @@ -10,24 +10,50 @@ import ( "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest" + awsclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws/clusterconfig" + dockerclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/docker/clusterconfig" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/clusterconfig" + nutanixclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/nutanix/clusterconfig" ) -func TestVariableValidation(t *testing.T) { +var testDefs = []capitest.VariableTestDef{{ + Name: "set", + Vals: v1alpha1.GenericClusterConfigSpec{ + KubernetesImageRepository: ptr.To( + "my-registry.io/my-org/my-repo", + ), + }, +}} + +func TestVariableValidation_AWS(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.AWSClusterConfig{}.VariableSchema()), + true, + awsclusterconfig.NewVariable, + testDefs..., + ) +} + +func TestVariableValidation_Docker(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.DockerClusterConfig{}.VariableSchema()), + true, + dockerclusterconfig.NewVariable, + testDefs..., + ) +} + +func TestVariableValidation_Nutanix(t *testing.T) { capitest.ValidateDiscoverVariables( t, clusterconfig.MetaVariableName, - ptr.To(v1alpha1.GenericClusterConfig{}.VariableSchema()), - false, - clusterconfig.NewVariable, - // KubernetesImageRepository - capitest.VariableTestDef{ - Name: "set", - Vals: v1alpha1.GenericClusterConfig{ - KubernetesImageRepository: ptr.To( - v1alpha1.KubernetesImageRepository("my-registry.io/my-org/my-repo"), - ), - }, - }, + ptr.To(v1alpha1.NutanixClusterConfig{}.VariableSchema()), + true, + nutanixclusterconfig.NewVariable, + testDefs..., ) } diff --git a/pkg/handlers/generic/mutation/mirrors/variables_test.go b/pkg/handlers/generic/mutation/mirrors/variables_test.go index 0e735a544..dbd3e14f6 100644 --- a/pkg/handlers/generic/mutation/mirrors/variables_test.go +++ b/pkg/handlers/generic/mutation/mirrors/variables_test.go @@ -11,54 +11,78 @@ import ( "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest" + awsclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws/clusterconfig" + dockerclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/docker/clusterconfig" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/clusterconfig" + nutanixclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/nutanix/clusterconfig" ) -func TestVariableValidation(t *testing.T) { - capitest.ValidateDiscoverVariables( - t, - clusterconfig.MetaVariableName, - ptr.To(v1alpha1.GenericClusterConfig{}.VariableSchema()), - false, - clusterconfig.NewVariable, - capitest.VariableTestDef{ - Name: "without a credentials secret", - Vals: v1alpha1.GenericClusterConfig{ - GlobalImageRegistryMirror: &v1alpha1.GlobalImageRegistryMirror{ - URL: "http://a.b.c.example.com", - }, - }, +var testDefs = []capitest.VariableTestDef{{ + Name: "without a credentials secret", + Vals: v1alpha1.GenericClusterConfigSpec{ + GlobalImageRegistryMirror: &v1alpha1.GlobalImageRegistryMirror{ + URL: "http://a.b.c.example.com", }, - capitest.VariableTestDef{ - Name: "with a credentials CA secret", - Vals: v1alpha1.GenericClusterConfig{ - GlobalImageRegistryMirror: &v1alpha1.GlobalImageRegistryMirror{ - URL: "http://a.b.c.example.com", - Credentials: &v1alpha1.RegistryCredentials{ - SecretRef: &corev1.LocalObjectReference{ - Name: "a.b.c.example.com-ca-cert-creds", - }, - }, + }, +}, { + Name: "with a credentials CA secret", + Vals: v1alpha1.GenericClusterConfigSpec{ + GlobalImageRegistryMirror: &v1alpha1.GlobalImageRegistryMirror{ + URL: "http://a.b.c.example.com", + Credentials: &v1alpha1.RegistryCredentials{ + SecretRef: &corev1.LocalObjectReference{ + Name: "a.b.c.example.com-ca-cert-creds", }, }, }, - capitest.VariableTestDef{ - Name: "invalid mirror registry URL", - Vals: v1alpha1.GenericClusterConfig{ - GlobalImageRegistryMirror: &v1alpha1.GlobalImageRegistryMirror{ - URL: "unsupportedformat://a.b.c.example.com", - }, - }, - ExpectError: true, + }, +}, { + Name: "invalid mirror registry URL", + Vals: v1alpha1.GenericClusterConfigSpec{ + GlobalImageRegistryMirror: &v1alpha1.GlobalImageRegistryMirror{ + URL: "unsupportedformat://a.b.c.example.com", }, - capitest.VariableTestDef{ - Name: "mirror URL without format", - Vals: v1alpha1.GenericClusterConfig{ - GlobalImageRegistryMirror: &v1alpha1.GlobalImageRegistryMirror{ - URL: "a.b.c.example.com/a/b/c", - }, - }, - ExpectError: true, + }, + ExpectError: true, +}, { + Name: "mirror URL without format", + Vals: v1alpha1.GenericClusterConfigSpec{ + GlobalImageRegistryMirror: &v1alpha1.GlobalImageRegistryMirror{ + URL: "a.b.c.example.com/a/b/c", }, + }, + ExpectError: true, +}} + +func TestVariableValidation_AWS(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.AWSClusterConfig{}.VariableSchema()), + true, + awsclusterconfig.NewVariable, + testDefs..., + ) +} + +func TestVariableValidation_Docker(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.DockerClusterConfig{}.VariableSchema()), + true, + dockerclusterconfig.NewVariable, + testDefs..., + ) +} + +func TestVariableValidation_Nutanix(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.NutanixClusterConfig{}.VariableSchema()), + true, + nutanixclusterconfig.NewVariable, + testDefs..., ) } diff --git a/pkg/handlers/generic/mutation/users/inject.go b/pkg/handlers/generic/mutation/users/inject.go index 4891efee4..7ac2129cb 100644 --- a/pkg/handlers/generic/mutation/users/inject.go +++ b/pkg/handlers/generic/mutation/users/inject.go @@ -59,7 +59,7 @@ func (h *usersPatchHandler) Mutate( ) error { log := ctrl.LoggerFrom(ctx, "holderRef", holderRef) - usersVariable, err := variables.Get[v1alpha1.Users]( + usersVariable, err := variables.Get[[]v1alpha1.User]( vars, h.variableName, h.variableFieldPath..., diff --git a/pkg/handlers/generic/mutation/users/variables_test.go b/pkg/handlers/generic/mutation/users/variables_test.go index c7f4ba5bc..83a6b9bda 100644 --- a/pkg/handlers/generic/mutation/users/variables_test.go +++ b/pkg/handlers/generic/mutation/users/variables_test.go @@ -10,34 +10,61 @@ import ( "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest" + awsclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws/clusterconfig" + dockerclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/docker/clusterconfig" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/clusterconfig" + nutanixclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/nutanix/clusterconfig" ) -func TestVariableValidation(t *testing.T) { - capitest.ValidateDiscoverVariables( - t, - clusterconfig.MetaVariableName, - ptr.To(v1alpha1.GenericClusterConfig{}.VariableSchema()), - false, - clusterconfig.NewVariable, - capitest.VariableTestDef{ - Name: "valid users", - Vals: v1alpha1.GenericClusterConfig{ - Users: []v1alpha1.User{ - { - Name: "complete", - HashedPassword: "password", - SSHAuthorizedKeys: []string{ - "key1", - "key2", - }, - Sudo: "ALL=(ALL) NOPASSWD:ALL", - }, - { - Name: "onlyname", - }, +var testDefs = []capitest.VariableTestDef{{ + Name: "valid users", + Vals: v1alpha1.GenericClusterConfigSpec{ + Users: []v1alpha1.User{ + { + Name: "complete", + HashedPassword: "password", + SSHAuthorizedKeys: []string{ + "key1", + "key2", }, + Sudo: "ALL=(ALL) NOPASSWD:ALL", + }, + { + Name: "onlyname", }, }, + }, +}} + +func TestVariableValidation_AWS(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.AWSClusterConfig{}.VariableSchema()), + true, + awsclusterconfig.NewVariable, + testDefs..., + ) +} + +func TestVariableValidation_Docker(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.DockerClusterConfig{}.VariableSchema()), + true, + dockerclusterconfig.NewVariable, + testDefs..., + ) +} + +func TestVariableValidation_Nutanix(t *testing.T) { + capitest.ValidateDiscoverVariables( + t, + clusterconfig.MetaVariableName, + ptr.To(v1alpha1.NutanixClusterConfig{}.VariableSchema()), + true, + nutanixclusterconfig.NewVariable, + testDefs..., ) } diff --git a/pkg/handlers/generic/workerconfig/variables.go b/pkg/handlers/generic/workerconfig/variables.go index 0638d48fd..be2a68d21 100644 --- a/pkg/handlers/generic/workerconfig/variables.go +++ b/pkg/handlers/generic/workerconfig/variables.go @@ -3,49 +3,7 @@ package workerconfig -import ( - "context" - - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1" - - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" - commonhandlers "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers" - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers/mutation" -) - -var ( - _ commonhandlers.Named = &workerConfigsVariableHandler{} - _ mutation.DiscoverVariables = &workerConfigsVariableHandler{} -) - const ( // MetaVariableName is the meta worker config patch variable name. MetaVariableName = "workerConfig" - - // HandlerNameVariable is the name of the variable handler. - HandlerNameVariable = "WorkerConfigVars" ) - -func NewVariable() *workerConfigsVariableHandler { - return &workerConfigsVariableHandler{} -} - -type workerConfigsVariableHandler struct{} - -func (h *workerConfigsVariableHandler) Name() string { - return HandlerNameVariable -} - -func (h *workerConfigsVariableHandler) DiscoverVariables( - ctx context.Context, - _ *runtimehooksv1.DiscoverVariablesRequest, - resp *runtimehooksv1.DiscoverVariablesResponse, -) { - resp.Variables = append(resp.Variables, clusterv1.ClusterClassVariable{ - Name: MetaVariableName, - Required: false, - Schema: v1alpha1.GenericNodeConfig{}.VariableSchema(), - }) - resp.SetStatus(runtimehooksv1.ResponseStatusSuccess) -} diff --git a/pkg/handlers/generic/workerconfig/variables_test.go b/pkg/handlers/generic/workerconfig/variables_test.go deleted file mode 100644 index 8cfc42cf6..000000000 --- a/pkg/handlers/generic/workerconfig/variables_test.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2023 D2iQ, Inc. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -package workerconfig - -import ( - "testing" - - "k8s.io/utils/ptr" - - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" - "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest" -) - -func TestVariableValidation(t *testing.T) { - capitest.ValidateDiscoverVariables( - t, - MetaVariableName, - ptr.To(v1alpha1.GenericNodeConfig{}.VariableSchema()), - false, - NewVariable, - ) -} diff --git a/pkg/handlers/nutanix/clusterconfig/variables.go b/pkg/handlers/nutanix/clusterconfig/variables.go index a15818846..6a12b8734 100644 --- a/pkg/handlers/nutanix/clusterconfig/variables.go +++ b/pkg/handlers/nutanix/clusterconfig/variables.go @@ -46,7 +46,7 @@ func (h *nutanixClusterConfigVariableHandler) DiscoverVariables( resp.Variables = append(resp.Variables, clusterv1.ClusterClassVariable{ Name: clusterconfig.MetaVariableName, Required: true, - Schema: v1alpha1.ClusterConfigSpec{Nutanix: &v1alpha1.NutanixSpec{}}.VariableSchema(), + Schema: v1alpha1.NutanixClusterConfig{}.VariableSchema(), }) resp.SetStatus(runtimehooksv1.ResponseStatusSuccess) } diff --git a/pkg/handlers/nutanix/mutation/controlplaneendpoint/inject_test.go b/pkg/handlers/nutanix/mutation/controlplaneendpoint/inject_test.go index 15356cc81..30c61ceb8 100644 --- a/pkg/handlers/nutanix/mutation/controlplaneendpoint/inject_test.go +++ b/pkg/handlers/nutanix/mutation/controlplaneendpoint/inject_test.go @@ -8,9 +8,9 @@ import ( . "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1" + "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers/mutation" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest/request" @@ -38,7 +38,7 @@ var _ = Describe("Generate Nutanix ControlPlane endpoint patches", func() { Vars: []runtimehooksv1.Variable{ capitest.VariableWithValue( clusterconfig.MetaVariableName, - clusterv1.APIEndpoint{ + v1alpha1.ControlPlaneEndpointSpec{ Host: "10.20.100.10", Port: 6443, }, diff --git a/pkg/handlers/nutanix/mutation/controlplaneendpoint/variables_test.go b/pkg/handlers/nutanix/mutation/controlplaneendpoint/variables_test.go index 172ded87a..92fa0c8df 100644 --- a/pkg/handlers/nutanix/mutation/controlplaneendpoint/variables_test.go +++ b/pkg/handlers/nutanix/mutation/controlplaneendpoint/variables_test.go @@ -9,7 +9,6 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/utils/ptr" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest" @@ -26,21 +25,21 @@ func TestVariableValidation(t *testing.T) { capitest.ValidateDiscoverVariables( t, clusterconfig.MetaVariableName, - ptr.To(v1alpha1.ClusterConfigSpec{Nutanix: &v1alpha1.NutanixSpec{}}.VariableSchema()), + ptr.To(v1alpha1.NutanixClusterConfig{}.VariableSchema()), true, nutanixclusterconfig.NewVariable, capitest.VariableTestDef{ Name: "valid host and port", - Vals: v1alpha1.ClusterConfigSpec{ + Vals: v1alpha1.NutanixClusterConfigSpec{ Nutanix: &v1alpha1.NutanixSpec{ - ControlPlaneEndpoint: clusterv1.APIEndpoint{ + ControlPlaneEndpoint: v1alpha1.ControlPlaneEndpointSpec{ Host: "10.20.100.10", Port: 6443, }, // PrismCentralEndpoint is a required field and must always be set PrismCentralEndpoint: v1alpha1.NutanixPrismCentralEndpointSpec{ URL: testPrismCentralURL, - Credentials: corev1.LocalObjectReference{ + Credentials: &corev1.LocalObjectReference{ Name: "credentials", }, }, @@ -49,16 +48,16 @@ func TestVariableValidation(t *testing.T) { }, capitest.VariableTestDef{ Name: "empty host", - Vals: v1alpha1.ClusterConfigSpec{ + Vals: v1alpha1.NutanixClusterConfigSpec{ Nutanix: &v1alpha1.NutanixSpec{ - ControlPlaneEndpoint: clusterv1.APIEndpoint{ + ControlPlaneEndpoint: v1alpha1.ControlPlaneEndpointSpec{ Host: "", Port: 6443, }, // PrismCentralEndpoint is a required field and must always be set PrismCentralEndpoint: v1alpha1.NutanixPrismCentralEndpointSpec{ URL: testPrismCentralURL, - Credentials: corev1.LocalObjectReference{ + Credentials: &corev1.LocalObjectReference{ Name: "credentials", }, }, @@ -68,16 +67,16 @@ func TestVariableValidation(t *testing.T) { }, capitest.VariableTestDef{ Name: "port set to 0", - Vals: v1alpha1.ClusterConfigSpec{ + Vals: v1alpha1.NutanixClusterConfigSpec{ Nutanix: &v1alpha1.NutanixSpec{ - ControlPlaneEndpoint: clusterv1.APIEndpoint{ + ControlPlaneEndpoint: v1alpha1.ControlPlaneEndpointSpec{ Host: "10.20.100.10", Port: 0, }, // PrismCentralEndpoint is a required field and must always be set PrismCentralEndpoint: v1alpha1.NutanixPrismCentralEndpointSpec{ URL: testPrismCentralURL, - Credentials: corev1.LocalObjectReference{ + Credentials: &corev1.LocalObjectReference{ Name: "credentials", }, }, diff --git a/pkg/handlers/nutanix/mutation/machinedetails/variables_test.go b/pkg/handlers/nutanix/mutation/machinedetails/variables_test.go index e11a9eb22..397c6659d 100644 --- a/pkg/handlers/nutanix/mutation/machinedetails/variables_test.go +++ b/pkg/handlers/nutanix/mutation/machinedetails/variables_test.go @@ -60,7 +60,7 @@ func TestVariableValidation(t *testing.T) { capitest.ValidateDiscoverVariables( t, clusterconfig.MetaVariableName, - ptr.To(v1alpha1.ClusterConfigSpec{Nutanix: &v1alpha1.NutanixSpec{}}.VariableSchema()), + ptr.To(v1alpha1.NutanixClusterConfig{}.VariableSchema()), true, nutanixclusterconfig.NewVariable, capitest.VariableTestDef{ @@ -98,9 +98,9 @@ func TestVariableValidation(t *testing.T) { ) } -func minimumClusterConfigSpec() v1alpha1.ClusterConfigSpec { - return v1alpha1.ClusterConfigSpec{ - ControlPlane: &v1alpha1.NodeConfigSpec{ +func minimumClusterConfigSpec() v1alpha1.NutanixClusterConfigSpec { + return v1alpha1.NutanixClusterConfigSpec{ + ControlPlane: &v1alpha1.NutanixNodeConfigSpec{ Nutanix: &v1alpha1.NutanixNodeSpec{ MachineDetails: v1alpha1.NutanixMachineDetails{ BootType: v1alpha1.NutanixBootType(capxv1.NutanixBootTypeLegacy), diff --git a/pkg/handlers/nutanix/mutation/prismcentralendpoint/inject_test.go b/pkg/handlers/nutanix/mutation/prismcentralendpoint/inject_test.go index d270994d3..3b0f00ea0 100644 --- a/pkg/handlers/nutanix/mutation/prismcentralendpoint/inject_test.go +++ b/pkg/handlers/nutanix/mutation/prismcentralendpoint/inject_test.go @@ -47,7 +47,7 @@ var _ = Describe("Generate Nutanix Prism Central Endpoint patches", func() { v1alpha1.NutanixPrismCentralEndpointSpec{ URL: "https://prism-central.nutanix.com:9441", Insecure: true, - Credentials: corev1.LocalObjectReference{ + Credentials: &corev1.LocalObjectReference{ Name: "credentials", }, }, @@ -81,7 +81,7 @@ var _ = Describe("Generate Nutanix Prism Central Endpoint patches", func() { v1alpha1.NutanixPrismCentralEndpointSpec{ URL: "https://prism-central.nutanix.com", Insecure: true, - Credentials: corev1.LocalObjectReference{ + Credentials: &corev1.LocalObjectReference{ Name: "credentials", }, }, @@ -118,7 +118,7 @@ var _ = Describe("Generate Nutanix Prism Central Endpoint patches", func() { v1alpha1.NutanixPrismCentralEndpointSpec{ URL: "https://prism-central.nutanix.com:9441", Insecure: true, - Credentials: corev1.LocalObjectReference{ + Credentials: &corev1.LocalObjectReference{ Name: "credentials", }, AdditionalTrustBundle: ptr.To(testCertBundle), diff --git a/pkg/handlers/nutanix/mutation/prismcentralendpoint/variables_test.go b/pkg/handlers/nutanix/mutation/prismcentralendpoint/variables_test.go index bf10166f6..3590c624f 100644 --- a/pkg/handlers/nutanix/mutation/prismcentralendpoint/variables_test.go +++ b/pkg/handlers/nutanix/mutation/prismcentralendpoint/variables_test.go @@ -9,7 +9,6 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/utils/ptr" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest" @@ -21,12 +20,12 @@ func TestVariableValidation(t *testing.T) { capitest.ValidateDiscoverVariables( t, clusterconfig.MetaVariableName, - ptr.To(v1alpha1.ClusterConfigSpec{Nutanix: &v1alpha1.NutanixSpec{}}.VariableSchema()), + ptr.To(v1alpha1.NutanixClusterConfig{}.VariableSchema()), true, nutanixclusterconfig.NewVariable, capitest.VariableTestDef{ Name: "valid PC URL", - Vals: v1alpha1.ClusterConfigSpec{ + Vals: v1alpha1.NutanixClusterConfigSpec{ Nutanix: &v1alpha1.NutanixSpec{ PrismCentralEndpoint: v1alpha1.NutanixPrismCentralEndpointSpec{ URL: fmt.Sprintf( @@ -34,12 +33,12 @@ func TestVariableValidation(t *testing.T) { v1alpha1.DefaultPrismCentralPort, ), Insecure: false, - Credentials: corev1.LocalObjectReference{ + Credentials: &corev1.LocalObjectReference{ Name: "credentials", }, }, // ControlPlaneEndpoint is a required field and must always be set - ControlPlaneEndpoint: clusterv1.APIEndpoint{ + ControlPlaneEndpoint: v1alpha1.ControlPlaneEndpointSpec{ Host: "10.20.100.10", Port: 6443, }, @@ -48,7 +47,7 @@ func TestVariableValidation(t *testing.T) { }, capitest.VariableTestDef{ Name: "valid PC URL as an IP", - Vals: v1alpha1.ClusterConfigSpec{ + Vals: v1alpha1.NutanixClusterConfigSpec{ Nutanix: &v1alpha1.NutanixSpec{ PrismCentralEndpoint: v1alpha1.NutanixPrismCentralEndpointSpec{ URL: fmt.Sprintf( @@ -56,12 +55,12 @@ func TestVariableValidation(t *testing.T) { v1alpha1.DefaultPrismCentralPort, ), Insecure: false, - Credentials: corev1.LocalObjectReference{ + Credentials: &corev1.LocalObjectReference{ Name: "credentials", }, }, // ControlPlaneEndpoint is a required field and must always be set - ControlPlaneEndpoint: clusterv1.APIEndpoint{ + ControlPlaneEndpoint: v1alpha1.ControlPlaneEndpointSpec{ Host: "10.20.100.10", Port: 6443, }, @@ -70,17 +69,17 @@ func TestVariableValidation(t *testing.T) { }, capitest.VariableTestDef{ Name: "valid PC URL without a port", - Vals: v1alpha1.ClusterConfigSpec{ + Vals: v1alpha1.NutanixClusterConfigSpec{ Nutanix: &v1alpha1.NutanixSpec{ PrismCentralEndpoint: v1alpha1.NutanixPrismCentralEndpointSpec{ URL: "https://prism-central.nutanix.com", Insecure: false, - Credentials: corev1.LocalObjectReference{ + Credentials: &corev1.LocalObjectReference{ Name: "credentials", }, }, // ControlPlaneEndpoint is a required field and must always be set - ControlPlaneEndpoint: clusterv1.APIEndpoint{ + ControlPlaneEndpoint: v1alpha1.ControlPlaneEndpointSpec{ Host: "10.20.100.10", Port: 6443, }, @@ -89,16 +88,16 @@ func TestVariableValidation(t *testing.T) { }, capitest.VariableTestDef{ Name: "empty PC URL", - Vals: v1alpha1.ClusterConfigSpec{ + Vals: v1alpha1.NutanixClusterConfigSpec{ Nutanix: &v1alpha1.NutanixSpec{ PrismCentralEndpoint: v1alpha1.NutanixPrismCentralEndpointSpec{ Insecure: false, - Credentials: corev1.LocalObjectReference{ + Credentials: &corev1.LocalObjectReference{ Name: "credentials", }, }, // ControlPlaneEndpoint is a required field and must always be set - ControlPlaneEndpoint: clusterv1.APIEndpoint{ + ControlPlaneEndpoint: v1alpha1.ControlPlaneEndpointSpec{ Host: "10.20.100.10", Port: 6443, }, @@ -108,17 +107,17 @@ func TestVariableValidation(t *testing.T) { }, capitest.VariableTestDef{ Name: "http is not a valid PC URL", - Vals: v1alpha1.ClusterConfigSpec{ + Vals: v1alpha1.NutanixClusterConfigSpec{ Nutanix: &v1alpha1.NutanixSpec{ PrismCentralEndpoint: v1alpha1.NutanixPrismCentralEndpointSpec{ URL: "http://prism-central.nutanix.com", Insecure: false, - Credentials: corev1.LocalObjectReference{ + Credentials: &corev1.LocalObjectReference{ Name: "credentials", }, }, // ControlPlaneEndpoint is a required field and must always be set - ControlPlaneEndpoint: clusterv1.APIEndpoint{ + ControlPlaneEndpoint: v1alpha1.ControlPlaneEndpointSpec{ Host: "10.20.100.10", Port: 6443, }, @@ -128,17 +127,17 @@ func TestVariableValidation(t *testing.T) { }, capitest.VariableTestDef{ Name: "not a valid PC URL", - Vals: v1alpha1.ClusterConfigSpec{ + Vals: v1alpha1.NutanixClusterConfigSpec{ Nutanix: &v1alpha1.NutanixSpec{ PrismCentralEndpoint: v1alpha1.NutanixPrismCentralEndpointSpec{ URL: "not-a-valid-url", Insecure: false, - Credentials: corev1.LocalObjectReference{ + Credentials: &corev1.LocalObjectReference{ Name: "credentials", }, }, // ControlPlaneEndpoint is a required field and must always be set - ControlPlaneEndpoint: clusterv1.APIEndpoint{ + ControlPlaneEndpoint: v1alpha1.ControlPlaneEndpointSpec{ Host: "10.20.100.10", Port: 6443, }, @@ -148,7 +147,7 @@ func TestVariableValidation(t *testing.T) { }, capitest.VariableTestDef{ Name: "nil PC credentials", - Vals: v1alpha1.ClusterConfigSpec{ + Vals: v1alpha1.NutanixClusterConfigSpec{ Nutanix: &v1alpha1.NutanixSpec{ PrismCentralEndpoint: v1alpha1.NutanixPrismCentralEndpointSpec{ URL: fmt.Sprintf( @@ -158,7 +157,7 @@ func TestVariableValidation(t *testing.T) { Insecure: false, }, // ControlPlaneEndpoint is a required field and must always be set - ControlPlaneEndpoint: clusterv1.APIEndpoint{ + ControlPlaneEndpoint: v1alpha1.ControlPlaneEndpointSpec{ Host: "10.20.100.10", Port: 6443, }, diff --git a/pkg/handlers/nutanix/workerconfig/variables.go b/pkg/handlers/nutanix/workerconfig/variables.go index 14d56bd6f..bf8101c2e 100644 --- a/pkg/handlers/nutanix/workerconfig/variables.go +++ b/pkg/handlers/nutanix/workerconfig/variables.go @@ -46,7 +46,7 @@ func (h *nutanixWorkerConfigVariableHandler) DiscoverVariables( resp.Variables = append(resp.Variables, clusterv1.ClusterClassVariable{ Name: workerconfig.MetaVariableName, Required: false, - Schema: v1alpha1.NodeConfigSpec{Nutanix: &v1alpha1.NutanixNodeSpec{}}.VariableSchema(), + Schema: v1alpha1.NutanixNodeConfig{}.VariableSchema(), }) resp.SetStatus(runtimehooksv1.ResponseStatusSuccess) } diff --git a/pkg/handlers/nutanix/workerconfig/variables_test.go b/pkg/handlers/nutanix/workerconfig/variables_test.go index 87a6e4105..b300ee2f9 100644 --- a/pkg/handlers/nutanix/workerconfig/variables_test.go +++ b/pkg/handlers/nutanix/workerconfig/variables_test.go @@ -17,7 +17,7 @@ func TestVariableValidation(t *testing.T) { capitest.ValidateDiscoverVariables( t, workerconfig.MetaVariableName, - ptr.To(v1alpha1.NodeConfigSpec{Nutanix: &v1alpha1.NutanixNodeSpec{}}.VariableSchema()), + ptr.To(v1alpha1.NutanixNodeConfig{}.VariableSchema()), false, NewVariable, )