diff --git a/go.mod b/go.mod index 29d62f3ad..307dfe87b 100644 --- a/go.mod +++ b/go.mod @@ -44,9 +44,7 @@ require ( github.com/google/go-containerregistry v0.20.1 github.com/google/go-github/v50 v50.0.0 github.com/hashicorp/errwrap v1.1.0 - github.com/hashicorp/go-hclog v1.6.3 github.com/hashicorp/go-multierror v1.1.1 - github.com/hashicorp/go-plugin v1.6.0 github.com/hashicorp/go-version v1.7.0 github.com/hashicorp/hcl/v2 v2.16.1 github.com/hashicorp/vault/api v1.10.0 @@ -64,7 +62,7 @@ require ( github.com/pulumi/pulumi/sdk/v3 v3.68.0 github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 github.com/spf13/afero v1.6.0 - github.com/spf13/cobra v1.8.0 + github.com/spf13/cobra v1.8.1 github.com/stretchr/testify v1.9.0 github.com/swaggo/http-swagger v1.3.4 github.com/swaggo/swag v1.16.3 @@ -78,17 +76,19 @@ require ( gopkg.in/yaml.v3 v3.0.1 gorm.io/driver/mysql v1.5.4 gorm.io/gorm v1.25.7 - k8s.io/api v0.30.3 - k8s.io/apimachinery v0.30.3 - k8s.io/cli-runtime v0.30.3 - k8s.io/client-go v0.30.3 - k8s.io/component-base v0.30.3 - k8s.io/kubectl v0.30.3 - k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 + k8s.io/api v0.31.3 + k8s.io/apimachinery v0.31.3 + k8s.io/cli-runtime v0.31.3 + k8s.io/client-go v0.31.3 + k8s.io/component-base v0.31.3 + k8s.io/kubectl v0.31.3 + k8s.io/utils v0.0.0-20240821151609-f90d01438635 kcl-lang.io/kcl-go v0.10.0-alpha.3 kcl-lang.io/kcl-plugin v0.5.0 kcl-lang.io/kpm v0.9.5 kusionstack.io/kube-api v0.3.1 + kusionstack.io/kusion-api-go v0.13.0 + kusionstack.io/kusion-module-framework v0.2.3-beta.5 sigs.k8s.io/controller-runtime v0.15.1 ) @@ -102,8 +102,11 @@ require ( github.com/containers/storage v1.54.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect github.com/distribution/reference v0.6.0 // indirect + github.com/fxamacker/cbor/v2 v2.7.0 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/goccy/go-json v0.10.3 // indirect + github.com/hashicorp/go-hclog v1.6.3 // indirect + github.com/hashicorp/go-plugin v1.6.1 // indirect github.com/kubescape/go-git-url v0.0.30 // indirect github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect github.com/lestrrat-go/blackmagic v1.0.2 // indirect @@ -118,6 +121,8 @@ require ( github.com/segmentio/asm v1.2.0 // indirect github.com/stretchr/objx v0.5.2 // indirect github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect + github.com/x448/float16 v0.8.4 // indirect + gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect ) require ( @@ -183,7 +188,7 @@ require ( github.com/containerd/console v1.0.3 // indirect github.com/containerd/containerd v1.7.11 // indirect github.com/containerd/stargz-snapshotter/estargz v0.15.1 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect github.com/cyphar/filepath-securejoin v0.2.5 // indirect github.com/deckarep/golang-set v1.7.1 // indirect github.com/dimchansky/utfbom v1.1.1 // indirect @@ -203,7 +208,7 @@ require ( github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.5.0 // indirect github.com/go-jose/go-jose/v3 v3.0.3 // indirect - github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/jsonpointer v0.21.0 // indirect github.com/go-openapi/jsonreference v0.21.0 // indirect @@ -221,7 +226,7 @@ require ( github.com/google/gnostic-models v0.6.8 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect + github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af // indirect github.com/google/s2a-go v0.1.7 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/uuid v1.6.0 @@ -270,7 +275,7 @@ require ( github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/moby/locker v1.0.1 // indirect - github.com/moby/spdystream v0.2.0 // indirect + github.com/moby/spdystream v0.4.0 // indirect github.com/moby/term v0.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect @@ -286,10 +291,10 @@ require ( github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/powerman/rpc-codec v1.2.2 // indirect - github.com/prometheus/client_golang v1.19.0 // indirect - github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.51.1 // indirect - github.com/prometheus/procfs v0.12.0 // indirect + github.com/prometheus/client_golang v1.19.1 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.55.0 // indirect + github.com/prometheus/procfs v0.15.1 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect @@ -313,17 +318,17 @@ require ( github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect - go.opentelemetry.io/otel v1.24.0 // indirect - go.opentelemetry.io/otel/metric v1.24.0 // indirect - go.opentelemetry.io/otel/trace v1.24.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect + go.opentelemetry.io/otel v1.28.0 // indirect + go.opentelemetry.io/otel/metric v1.28.0 // indirect + go.opentelemetry.io/otel/trace v1.28.0 // indirect go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/arch v0.4.0 // indirect golang.org/x/crypto v0.25.0 golang.org/x/mod v0.19.0 // indirect golang.org/x/net v0.27.0 // indirect - golang.org/x/oauth2 v0.20.0 // indirect + golang.org/x/oauth2 v0.21.0 // indirect golang.org/x/sync v0.7.0 golang.org/x/sys v0.22.0 // indirect golang.org/x/term v0.22.0 // indirect @@ -334,20 +339,20 @@ require ( google.golang.org/api v0.169.0 // indirect google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed // indirect google.golang.org/grpc v1.65.0 - google.golang.org/protobuf v1.34.2 + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect - k8s.io/klog/v2 v2.120.1 + k8s.io/klog/v2 v2.130.1 k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect kcl-lang.io/lib v0.10.0-alpha.3 // indirect oras.land/oras-go v1.2.5 // indirect oras.land/oras-go/v2 v2.5.0 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 // indirect - sigs.k8s.io/kustomize/kyaml v0.14.3-0.20230601165947-6ce0bf390ce3 // indirect + sigs.k8s.io/kustomize/api v0.17.2 // indirect + sigs.k8s.io/kustomize/kyaml v0.17.1 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect + sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/go.sum b/go.sum index 84c7717c1..d0926a370 100644 --- a/go.sum +++ b/go.sum @@ -419,8 +419,8 @@ github.com/containers/ocicrypt v1.1.10 h1:r7UR6o8+lyhkEywetubUUgcKFjOWOaWz8cEBrC github.com/containers/ocicrypt v1.1.10/go.mod h1:YfzSSr06PTHQwSTUKqDSjish9BeW1E4HUmreluQcMd8= github.com/containers/storage v1.54.0 h1:xwYAlf6n9OnIlURQLLg3FYHbO74fQ/2W2N6EtQEUM4I= github.com/containers/storage v1.54.0/go.mod h1:PlMOoinRrBSnhYODLxt4EXl0nmJt+X0kjG0Xdt9fMTw= -github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM= -github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/cyphar/filepath-securejoin v0.2.5 h1:6iR5tXJ/e6tJZzzdMc1km3Sa7RRIVBKAK32O2s7AYfo= @@ -497,6 +497,8 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= +github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= @@ -531,8 +533,8 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -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/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= @@ -684,8 +686,8 @@ github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= +github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af h1:kmjWCqn2qkEml422C2Rrd27c3VGxi6a/6HNq8QmHRKM= +github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= @@ -723,7 +725,6 @@ github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gosuri/uilive v0.0.4 h1:hUEBpQDj8D8jXgtCdBu7sWsy5sbW/5GhuO8KBwJ2jyY= @@ -743,8 +744,8 @@ github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVH github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-plugin v1.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A= -github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI= +github.com/hashicorp/go-plugin v1.6.1 h1:P7MR2UP6gNKGPp+y7EZw2kOiq4IR9WiqLvp0XOsVdwI= +github.com/hashicorp/go-plugin v1.6.1/go.mod h1:XPHFku2tFo3o3QKFgSYo+cghcUhw1NA1hZyMK0PWAw0= github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU= github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk= github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= @@ -912,8 +913,8 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= -github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8= -github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= +github.com/moby/spdystream v0.4.0 h1:Vy79D6mHeJJjiPdFEL2yku1kl0chZpJfZcPpb16BRl8= +github.com/moby/spdystream v0.4.0/go.mod h1:xBAYlnt/ay+11ShkdFKNAG7LsyK/tmNBVvVOwrfMgdI= github.com/moby/sys/mountinfo v0.7.1 h1:/tTvQaSJRr2FshkhXiIpux6fQ2Zvc4j7tAhMTStAG2g= github.com/moby/sys/mountinfo v0.7.1/go.mod h1:IJb6JQeOklcdMU9F5xQ8ZALD+CUr5VlGpwtX+VE0rpI= github.com/moby/sys/user v0.1.0 h1:WmZ93f5Ux6het5iituh9x2zAG7NFY9Aqi49jjE1PaQg= @@ -992,22 +993,22 @@ github.com/powerman/rpc-codec v1.2.2/go.mod h1:3Qr/y/+u3CwcSww9tfJMRn/95lB2qUdUe github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g= -github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= -github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= +github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= +github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= -github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc= -github.com/prometheus/common v0.51.1 h1:eIjN50Bwglz6a/c3hAgSMcofL3nD+nFQkV6Dd4DsQCw= -github.com/prometheus/common v0.51.1/go.mod h1:lrWtQx+iDfn2mbH5GUzlH9TSHyfZpHkSiG1W7y3sF2Q= +github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= +github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= -github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= -github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= +github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/pterm/pterm v0.12.27/go.mod h1:PhQ89w4i95rhgE+xedAoqous6K9X+r6aSOI2eFF7DZI= github.com/pterm/pterm v0.12.29/go.mod h1:WI3qxgvoQFFGKGjGnJR849gU0TsEOvKn5Q8LlY1U7lg= github.com/pterm/pterm v0.12.30/go.mod h1:MOqLIyMOgmTDz9yorcYbcw+HsgoZo3BQfg2wtl3HEFE= @@ -1051,8 +1052,8 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9 github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= -github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= -github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= @@ -1104,6 +1105,8 @@ github.com/vbatts/tar-split v0.11.5 h1:3bHCTIheBm1qFTcgh9oPu+nNBtX+XJIupG/vacinC github.com/vbatts/tar-split v0.11.5/go.mod h1:yZbwRsSeGjusneWgA781EKej9HF8vme8okylkAeNKLk= github.com/virtuald/go-ordered-json v0.0.0-20170621173500-b18e6e673d74 h1:JwtAtbp7r/7QSyGz8mKUbYJBg2+6Cd7OjM8o/GNOcVo= github.com/virtuald/go-ordered-json v0.0.0-20170621173500-b18e6e673d74/go.mod h1:RmMWU37GKR2s6pgrIEB4ixgpVCt/cf7dnJv3fuH1J1c= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ= @@ -1137,16 +1140,16 @@ go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 h1:4Pp6oUg3+e/6M4C0A/3kJ2VYa++dsWVTtGgLVj5xtHg= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= -go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= -go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= -go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= -go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= -go.opentelemetry.io/otel/sdk v1.22.0 h1:6coWHw9xw7EfClIC/+O31R8IY3/+EiRFHevmHafB2Gw= -go.opentelemetry.io/otel/sdk v1.22.0/go.mod h1:iu7luyVGYovrRpe2fmj3CVKouQNdTOkxtLzPvPz1DOc= -go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= -go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 h1:4K4tsIXefpVJtvA/8srF4V4y0akAoPHkIslgAkjixJA= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0/go.mod h1:jjdQuTGVsXV4vSs+CJ2qYDeDPf9yIJV23qlIzBm73Vg= +go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= +go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= +go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= +go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= +go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= +go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= +go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= +go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.starlark.net v0.0.0-20230525235612-a134d8f9ddca h1:VdD38733bfYv5tUZwEIskMM93VanwNIi5bIKnDrJdEY= go.starlark.net v0.0.0-20230525235612-a134d8f9ddca/go.mod h1:jxU+3+j+71eXOW14274+SmmuW82qJzl6iZSeqEtTGds= @@ -1307,8 +1310,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= -golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= +golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= 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= @@ -1685,8 +1688,8 @@ google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUE google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo= google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 h1:7whR9kGa5LUwFtpLm2ArCEejtnxlGeLbAyjFY8sGNFw= google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 h1:Zy9XzmMEflZ/MAaA7vNcoebnRAld7FsPW1EeBB7V0m8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed h1:J6izYgfBXAI3xTKLgxzTmUltdYaLsuBxFCgDHWJ/eXg= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -1751,6 +1754,8 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4= +gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= @@ -1792,26 +1797,26 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.30.3 h1:ImHwK9DCsPA9uoU3rVh4QHAHHK5dTSv1nxJUapx8hoQ= -k8s.io/api v0.30.3/go.mod h1:GPc8jlzoe5JG3pb0KJCSLX5oAFIW3/qNJITlDj8BH04= +k8s.io/api v0.31.3 h1:umzm5o8lFbdN/hIXbrK9oRpOproJO62CV1zqxXrLgk8= +k8s.io/api v0.31.3/go.mod h1:UJrkIp9pnMOI9K2nlL6vwpxRzzEX5sWgn8kGQe92kCE= k8s.io/apiextensions-apiserver v0.27.2 h1:iwhyoeS4xj9Y7v8YExhUwbVuBhMr3Q4bd/laClBV6Bo= k8s.io/apiextensions-apiserver v0.27.2/go.mod h1:Oz9UdvGguL3ULgRdY9QMUzL2RZImotgxvGjdWRq6ZXQ= -k8s.io/apimachinery v0.30.3 h1:q1laaWCmrszyQuSQCfNB8cFgCuDAoPszKY4ucAjDwHc= -k8s.io/apimachinery v0.30.3/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= -k8s.io/cli-runtime v0.30.3 h1:aG69oRzJuP2Q4o8dm+f5WJIX4ZBEwrvdID0+MXyUY6k= -k8s.io/cli-runtime v0.30.3/go.mod h1:hwrrRdd9P84CXSKzhHxrOivAR9BRnkMt0OeP5mj7X30= -k8s.io/client-go v0.30.3 h1:bHrJu3xQZNXIi8/MoxYtZBBWQQXwy16zqJwloXXfD3k= -k8s.io/client-go v0.30.3/go.mod h1:8d4pf8vYu665/kUbsxWAQ/JDBNWqfFeZnvFiVdmx89U= -k8s.io/component-base v0.30.3 h1:Ci0UqKWf4oiwy8hr1+E3dsnliKnkMLZMVbWzeorlk7s= -k8s.io/component-base v0.30.3/go.mod h1:C1SshT3rGPCuNtBs14RmVD2xW0EhRSeLvBh7AGk1quA= -k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= -k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/apimachinery v0.31.3 h1:6l0WhcYgasZ/wk9ktLq5vLaoXJJr5ts6lkaQzgeYPq4= +k8s.io/apimachinery v0.31.3/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= +k8s.io/cli-runtime v0.31.3 h1:fEQD9Xokir78y7pVK/fCJN090/iYNrLHpFbGU4ul9TI= +k8s.io/cli-runtime v0.31.3/go.mod h1:Q2jkyTpl+f6AtodQvgDI8io3jrfr+Z0LyQBPJJ2Btq8= +k8s.io/client-go v0.31.3 h1:CAlZuM+PH2cm+86LOBemaJI/lQ5linJ6UFxKX/SoG+4= +k8s.io/client-go v0.31.3/go.mod h1:2CgjPUTpv3fE5dNygAr2NcM8nhHzXvxB8KL5gYc3kJs= +k8s.io/component-base v0.31.3 h1:DMCXXVx546Rfvhj+3cOm2EUxhS+EyztH423j+8sOwhQ= +k8s.io/component-base v0.31.3/go.mod h1:xME6BHfUOafRgT0rGVBGl7TuSg8Z9/deT7qq6w7qjIU= +k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= +k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag= k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= -k8s.io/kubectl v0.30.3 h1:YIBBvMdTW0xcDpmrOBzcpUVsn+zOgjMYIu7kAq+yqiI= -k8s.io/kubectl v0.30.3/go.mod h1:IcR0I9RN2+zzTRUa1BzZCm4oM0NLOawE6RzlDvd1Fpo= -k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A= -k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/kubectl v0.31.3 h1:3r111pCjPsvnR98oLLxDMwAeM6OPGmPty6gSKaLTQes= +k8s.io/kubectl v0.31.3/go.mod h1:lhMECDCbJN8He12qcKqs2QfmVo9Pue30geovBVpH5fs= +k8s.io/utils v0.0.0-20240821151609-f90d01438635 h1:2wThSvJoW/Ncn9TmQEYXRnevZXi2duqHWf5OX9S3zjI= +k8s.io/utils v0.0.0-20240821151609-f90d01438635/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= kcl-lang.io/kcl-go v0.10.0-alpha.3 h1:01grUuyy/XfBZDRoMqUesU6OdzVPk0WF9WDOvuY70ZI= kcl-lang.io/kcl-go v0.10.0-alpha.3/go.mod h1:kfHDBqsLNT+9T6VorS/EVbriZzix1rjIq0w6WCJ7GbA= kcl-lang.io/kcl-plugin v0.5.0 h1:eoh6y4l81rwA8yhJXU4hN7YmJeTUNB1nfYCP9OffSxc= @@ -1822,6 +1827,10 @@ kcl-lang.io/lib v0.10.0-alpha.3 h1:tZ7du+9/wv5ZHyPmPxljZQ33DdTYw++d9joH0LMC3q8= kcl-lang.io/lib v0.10.0-alpha.3/go.mod h1:tu+tzwGgHLzYZSIxUG/ntipStrxZd6OvutWYPTxS7cs= kusionstack.io/kube-api v0.3.1 h1:MqU41B0i2cofm2M5KQIkuTsWQ81p0Ueq93zbdUaOuCM= kusionstack.io/kube-api v0.3.1/go.mod h1:atpgBn0kdjGbYQrSt1H7jtfXybBmT0XL/GBuZQ8FVpU= +kusionstack.io/kusion-api-go v0.13.0 h1:fDrLkgpkBnG7DTSHmCEfO/aL+iv6FZCTZ4ucxaQSuwg= +kusionstack.io/kusion-api-go v0.13.0/go.mod h1:GlHukjtIyhDSG2hYFbSf+8udzWsCcIQFeLd59+d6L8c= +kusionstack.io/kusion-module-framework v0.2.3-beta.5 h1:CpF0DFXF8g9H11rfxxhBp3IGlTcpd3DJ8dK01WynZsY= +kusionstack.io/kusion-module-framework v0.2.3-beta.5/go.mod h1:wdUgPfcDMaoE4tBvzj1diEovJVTvWDry8AedM78gvwk= oras.land/oras-go v1.2.5 h1:XpYuAwAb0DfQsunIyMfeET92emK8km3W4yEzZvUbsTo= oras.land/oras-go v1.2.5/go.mod h1:PuAwRShRZCsZb7g8Ar3jKKQR/2A/qN+pkYxIOd/FAoo= oras.land/oras-go/v2 v2.5.0 h1:o8Me9kLY74Vp5uw07QXPiitjsw7qNXi8Twd+19Zf02c= @@ -1833,11 +1842,11 @@ sigs.k8s.io/controller-runtime v0.15.1 h1:9UvgKD4ZJGcj24vefUFgZFP3xej/3igL9BsOUT sigs.k8s.io/controller-runtime v0.15.1/go.mod h1:7ngYvp1MLT+9GeZ+6lH3LOlcHkp/+tzA/fmHa4iq9kk= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 h1:XX3Ajgzov2RKUdc5jW3t5jwY7Bo7dcRm+tFxT+NfgY0= -sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3/go.mod h1:9n16EZKMhXBNSiUC5kSdFQJkdH3zbxS/JoO619G1VAY= -sigs.k8s.io/kustomize/kyaml v0.14.3-0.20230601165947-6ce0bf390ce3 h1:W6cLQc5pnqM7vh3b7HvGNfXrJ/xL6BDMS0v1V/HHg5U= -sigs.k8s.io/kustomize/kyaml v0.14.3-0.20230601165947-6ce0bf390ce3/go.mod h1:JWP1Fj0VWGHyw3YUPjXSQnRnrwezrZSrApfX5S0nIag= +sigs.k8s.io/kustomize/api v0.17.2 h1:E7/Fjk7V5fboiuijoZHgs4aHuexi5Y2loXlVOAVAG5g= +sigs.k8s.io/kustomize/api v0.17.2/go.mod h1:UWTz9Ct+MvoeQsHcJ5e+vziRRkwimm3HytpZgIYqye0= +sigs.k8s.io/kustomize/kyaml v0.17.1 h1:TnxYQxFXzbmNG6gOINgGWQt09GghzgTP6mIurOgrLCQ= +sigs.k8s.io/kustomize/kyaml v0.17.1/go.mod h1:9V0mCjIEYjlXuCdYsSXvyoy2BTsLESH7TlGV81S282U= sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= -sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= +sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= +sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/pkg/engine/api/builders/appconfig_builder.go b/pkg/engine/api/builders/appconfig_builder.go index 9843913cd..ca96064aa 100644 --- a/pkg/engine/api/builders/appconfig_builder.go +++ b/pkg/engine/api/builders/appconfig_builder.go @@ -20,8 +20,8 @@ import ( "kcl-lang.io/kpm/pkg/api" v1 "kusionstack.io/kusion/pkg/apis/api.kusion.io/v1" - "kusionstack.io/kusion/pkg/modules" - "kusionstack.io/kusion/pkg/modules/generators" + "kusionstack.io/kusion/pkg/generators" + "kusionstack.io/kusion/pkg/generators/appconfiguration" ) type AppsConfigBuilder struct { @@ -34,19 +34,19 @@ func (acg *AppsConfigBuilder) Build(kclPackage *api.KclPackage, project *v1.Proj Resources: []v1.Resource{}, } - var gfs []modules.NewGeneratorFunc - err := modules.ForeachOrdered(acg.Apps, func(appName string, app v1.AppConfiguration) error { + var gfs []generators.NewSpecGeneratorFunc + err := generators.ForeachOrdered(acg.Apps, func(appName string, app v1.AppConfiguration) error { if kclPackage == nil { return fmt.Errorf("kcl package is nil when generating app configuration for %s", appName) } dependencies := kclPackage.GetDependenciesInModFile() - gfs = append(gfs, generators.NewAppConfigurationGeneratorFunc(project, stack, appName, &app, acg.Workspace, dependencies)) + gfs = append(gfs, appconfiguration.NewAppConfigurationGeneratorFunc(project, stack, appName, &app, acg.Workspace, dependencies)) return nil }) if err != nil { return nil, err } - if err = modules.CallGenerators(i, gfs...); err != nil { + if err = generators.CallGenerators(i, gfs...); err != nil { return nil, err } diff --git a/pkg/engine/api/builders/appconfig_builder_test.go b/pkg/engine/api/builders/appconfig_builder_test.go index 08eab6f53..bb5a342e2 100644 --- a/pkg/engine/api/builders/appconfig_builder_test.go +++ b/pkg/engine/api/builders/appconfig_builder_test.go @@ -24,7 +24,7 @@ import ( "kcl-lang.io/kpm/pkg/api" v1 "kusionstack.io/kusion/pkg/apis/api.kusion.io/v1" - "kusionstack.io/kusion/pkg/modules" + "kusionstack.io/kusion/pkg/generators" ) func TestBuild(t *testing.T) { @@ -37,7 +37,7 @@ func TestBuild(t *testing.T) { Workspace: buildMockWorkspace(), } - callMock := mockey.Mock(modules.CallGenerators).Return(nil).Build() + callMock := mockey.Mock(generators.CallGenerators).Return(nil).Build() defer func() { callMock.UnPatch() }() diff --git a/pkg/modules/generators/app_configurations_generator.go b/pkg/generators/appconfiguration/app_configurations_generator.go similarity index 95% rename from pkg/modules/generators/app_configurations_generator.go rename to pkg/generators/appconfiguration/app_configurations_generator.go index 5fb6a0965..a3a20cb2d 100644 --- a/pkg/modules/generators/app_configurations_generator.go +++ b/pkg/generators/appconfiguration/app_configurations_generator.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package generators +package appconfiguration import ( "context" @@ -32,14 +32,17 @@ import ( k8sjson "k8s.io/apimachinery/pkg/util/json" pkg "kcl-lang.io/kpm/pkg/package" + "kusionstack.io/kusion-module-framework/pkg/module" + "kusionstack.io/kusion-module-framework/pkg/module/proto" v1 "kusionstack.io/kusion/pkg/apis/api.kusion.io/v1" "kusionstack.io/kusion/pkg/engine/runtime/terraform/tfops" + "kusionstack.io/kusion/pkg/generators" + "kusionstack.io/kusion/pkg/generators/secret" "kusionstack.io/kusion/pkg/log" - "kusionstack.io/kusion/pkg/modules" - "kusionstack.io/kusion/pkg/modules/generators/secret" - "kusionstack.io/kusion/pkg/modules/proto" // import the secrets register pkg to register supported secret providers + ns "kusionstack.io/kusion/pkg/generators/namespace" + orderedres "kusionstack.io/kusion/pkg/generators/orderedresources" _ "kusionstack.io/kusion/pkg/secrets/providers/register" jsonutil "kusionstack.io/kusion/pkg/util/json" "kusionstack.io/kusion/pkg/workspace" @@ -71,7 +74,7 @@ func NewAppConfigurationGenerator( app *v1.AppConfiguration, ws *v1.Workspace, dependencies *pkg.Dependencies, -) (modules.Generator, error) { +) (generators.SpecGenerator, error) { if project == nil { return nil, fmt.Errorf("project must not be nil") } @@ -113,8 +116,8 @@ func NewAppConfigurationGeneratorFunc( app *v1.AppConfiguration, ws *v1.Workspace, kpmDependencies *pkg.Dependencies, -) modules.NewGeneratorFunc { - return func() (modules.Generator, error) { +) generators.NewSpecGeneratorFunc { + return func() (generators.SpecGenerator, error) { return NewAppConfigurationGenerator(project, stack, appName, app, ws, kpmDependencies) } } @@ -150,8 +153,8 @@ func (g *appConfigurationGenerator) Generate(spec *v1.Spec) error { // generate built-in resources namespace := g.getNamespaceName() - gfs := []modules.NewGeneratorFunc{ - NewNamespaceGeneratorFunc(namespace), + gfs := []generators.NewSpecGeneratorFunc{ + ns.NewNamespaceGeneratorFunc(namespace), } if g.app.Workload != nil { @@ -164,7 +167,7 @@ func (g *appConfigurationGenerator) Generate(spec *v1.Spec) error { })) } - if err = modules.CallGenerators(spec, gfs...); err != nil { + if err = generators.CallGenerators(spec, gfs...); err != nil { return err } @@ -196,7 +199,7 @@ func (g *appConfigurationGenerator) Generate(spec *v1.Spec) error { } // The OrderedResourcesGenerator should be executed after all resources are generated. - if err = modules.CallGenerators(spec, NewOrderedResourcesGeneratorFunc()); err != nil { + if err = generators.CallGenerators(spec, orderedres.NewOrderedResourcesGeneratorFunc()); err != nil { return err } @@ -432,7 +435,7 @@ type moduleConfig struct { } func (g *appConfigurationGenerator) callModules(projectModuleConfigs map[string]v1.GenericConfig) (workload *v1.Resource, resources []v1.Resource, patchers []v1.Patcher, err error) { - pluginMap := make(map[string]*modules.Plugin) + pluginMap := make(map[string]*module.Plugin) defer func() { if e := recover(); e != nil { switch x := e.(type) { @@ -521,13 +524,13 @@ func (g *appConfigurationGenerator) callModules(projectModuleConfigs map[string] } func (g *appConfigurationGenerator) invokeModule( - pluginMap map[string]*modules.Plugin, + pluginMap map[string]*module.Plugin, key string, config moduleConfig, ) (*proto.GeneratorResponse, error) { // init the plugin if pluginMap[key] == nil { - plugin, err := modules.NewPlugin(key, g.stack.Path) + plugin, err := module.NewPlugin(key, g.stack.Path) if err != nil { return nil, err } @@ -698,13 +701,13 @@ func (g *appConfigurationGenerator) getNamespaceName() string { func mergeExtensions(project *v1.Project, stack *v1.Stack) []*v1.Extension { var extensions []*v1.Extension extensionKindMap := make(map[string]struct{}) - if stack.Extensions != nil && len(stack.Extensions) != 0 { + if len(stack.Extensions) != 0 { for _, extension := range stack.Extensions { extensions = append(extensions, extension) extensionKindMap[string(extension.Kind)] = struct{}{} } } - if project.Extensions != nil && len(project.Extensions) != 0 { + if len(project.Extensions) != 0 { for _, extension := range project.Extensions { if _, exist := extensionKindMap[string(extension.Kind)]; !exist { extensions = append(extensions, extension) diff --git a/pkg/modules/generators/app_configurations_generator_test.go b/pkg/generators/appconfiguration/app_configurations_generator_test.go similarity index 94% rename from pkg/modules/generators/app_configurations_generator_test.go rename to pkg/generators/appconfiguration/app_configurations_generator_test.go index a32e473d3..29f9c6efe 100644 --- a/pkg/modules/generators/app_configurations_generator_test.go +++ b/pkg/generators/appconfiguration/app_configurations_generator_test.go @@ -1,4 +1,4 @@ -package generators +package appconfiguration import ( "context" @@ -18,9 +18,9 @@ import ( pkg "kcl-lang.io/kpm/pkg/package" orderedmap "github.com/elliotchance/orderedmap/v2" + "kusionstack.io/kusion-module-framework/pkg/module" + "kusionstack.io/kusion-module-framework/pkg/module/proto" v1 "kusionstack.io/kusion/pkg/apis/api.kusion.io/v1" - "kusionstack.io/kusion/pkg/modules" - "kusionstack.io/kusion/pkg/modules/proto" jsonutil "kusionstack.io/kusion/pkg/util/json" ) @@ -65,10 +65,10 @@ func (f *fakeModule) Generate(_ context.Context, _ *proto.GeneratorRequest) (*pr } func mockPlugin() (*mockey.Mocker, *mockey.Mocker) { - pluginMock := mockey.Mock(modules.NewPlugin).To(func(key string) (*modules.Plugin, error) { - return &modules.Plugin{Module: &fakeModule{}}, nil + pluginMock := mockey.Mock(module.NewPlugin).To(func(key string) (*module.Plugin, error) { + return &module.Plugin{Module: &fakeModule{}}, nil }).Build() - killMock := mockey.Mock((*modules.Plugin).KillPluginClient).Return(nil).Build() + killMock := mockey.Mock((*module.Plugin).KillPluginClient).Return(nil).Build() return pluginMock, killMock } @@ -433,10 +433,10 @@ func TestAppConfigurationGenerator_CallModules(t *testing.T) { t.Run("Successful module call", func(t *testing.T) { // Mock the plugin - pluginMock := mockey.Mock(modules.NewPlugin).To(func(key string) (*modules.Plugin, error) { - return &modules.Plugin{Module: &fakeModule{}}, nil + pluginMock := mockey.Mock(module.NewPlugin).To(func(key string) (*module.Plugin, error) { + return &module.Plugin{Module: &fakeModule{}}, nil }).Build() - killMock := mockey.Mock((*modules.Plugin).KillPluginClient).Return(nil).Build() + killMock := mockey.Mock((*module.Plugin).KillPluginClient).Return(nil).Build() defer func() { pluginMock.UnPatch() killMock.UnPatch() @@ -451,7 +451,7 @@ func TestAppConfigurationGenerator_CallModules(t *testing.T) { t.Run("Failed module call due to missing module in dependencies", func(t *testing.T) { // Mock the plugin - pluginMock := mockey.Mock(modules.NewPlugin).To(func(key string) (*modules.Plugin, error) { + pluginMock := mockey.Mock(module.NewPlugin).To(func(key string) (*module.Plugin, error) { return nil, fmt.Errorf("module not found") }).Build() defer func() { @@ -464,10 +464,10 @@ func TestAppConfigurationGenerator_CallModules(t *testing.T) { t.Run("Failed module call due to error in plugin", func(t *testing.T) { // Mock the plugin - pluginMock := mockey.Mock(modules.NewPlugin).To(func(key string) (*modules.Plugin, error) { - return &modules.Plugin{Module: &fakeModule{}}, nil + pluginMock := mockey.Mock(module.NewPlugin).To(func(key string) (*module.Plugin, error) { + return &module.Plugin{Module: &fakeModule{}}, nil }).Build() - killMock := mockey.Mock((*modules.Plugin).KillPluginClient).Return(fmt.Errorf("error in plugin")).Build() + killMock := mockey.Mock((*module.Plugin).KillPluginClient).Return(fmt.Errorf("error in plugin")).Build() defer func() { pluginMock.UnPatch() killMock.UnPatch() diff --git a/pkg/modules/generators/doc.go b/pkg/generators/doc.go similarity index 100% rename from pkg/modules/generators/doc.go rename to pkg/generators/doc.go diff --git a/pkg/generators/interfaces.go b/pkg/generators/interfaces.go new file mode 100644 index 000000000..decc664ac --- /dev/null +++ b/pkg/generators/interfaces.go @@ -0,0 +1,15 @@ +package generators + +import ( + v1 "kusionstack.io/kusion/pkg/apis/api.kusion.io/v1" +) + +// SpecGenerator is an interface for things that can generate Spec from input configurations. +// Note: it's for built-in generators to produce Spec, which is not the same as the general Module interface. +type SpecGenerator interface { + // Generate performs the intent generate operation. + Generate(intent *v1.Spec) error +} + +// NewSpecGeneratorFunc is a function that returns a SpecGenerator. +type NewSpecGeneratorFunc func() (SpecGenerator, error) diff --git a/pkg/generators/namespace/namespace_generator.go b/pkg/generators/namespace/namespace_generator.go new file mode 100644 index 000000000..b5e5d13b4 --- /dev/null +++ b/pkg/generators/namespace/namespace_generator.go @@ -0,0 +1,56 @@ +package namespace + +import ( + "context" + + "github.com/jinzhu/copier" + modgen "kusionstack.io/kusion-module-framework/pkg/module/generator" + v1 "kusionstack.io/kusion/pkg/apis/api.kusion.io/v1" + "kusionstack.io/kusion/pkg/generators" +) + +type namespaceGenerator struct { + namespace string +} + +func NewNamespaceGenerator(namespace string) (generators.SpecGenerator, error) { + return &namespaceGenerator{ + namespace: namespace, + }, nil +} + +func NewNamespaceGeneratorFunc(namespace string) generators.NewSpecGeneratorFunc { + return func() (generators.SpecGenerator, error) { + return NewNamespaceGenerator(namespace) + } +} + +func (g *namespaceGenerator) Generate(i *v1.Spec) error { + if i.Resources == nil { + i.Resources = make(v1.Resources, 0) + } + + // Generate Kubernetes Namespace resource. + ns, err := modgen.NamespaceResource(context.Background(), g.namespace) + if err != nil { + return err + } + + // Avoid generating duplicate namespaces with the same ID. + for _, res := range i.Resources { + if res.ID == ns.ID { + return nil + } + } + + // In Kusion, the type of `Resource` being passed around is internally defined, + // so here we are converting the `Resource` type in `kusionstack.io/kusion-api-go` into + // the internally defined type. + // Fixme: the types passed around in Kusion may also be unified to the types in `kusion-api-go`. + var res v1.Resource + copier.Copy(&res, ns) + + i.Resources = append(i.Resources, res) + + return nil +} diff --git a/pkg/modules/generators/namespace_generator_test.go b/pkg/generators/namespace/namespace_generator_test.go similarity index 98% rename from pkg/modules/generators/namespace_generator_test.go rename to pkg/generators/namespace/namespace_generator_test.go index cdbc7eda1..02e1f6fb2 100644 --- a/pkg/modules/generators/namespace_generator_test.go +++ b/pkg/generators/namespace/namespace_generator_test.go @@ -1,4 +1,4 @@ -package generators +package namespace import ( "testing" diff --git a/pkg/generators/orderedresources/ordered_resources_generator.go b/pkg/generators/orderedresources/ordered_resources_generator.go new file mode 100644 index 000000000..4b085cf58 --- /dev/null +++ b/pkg/generators/orderedresources/ordered_resources_generator.go @@ -0,0 +1,62 @@ +package orderedresources + +import ( + "context" + + "github.com/jinzhu/copier" + apiv1 "kusionstack.io/kusion-api-go/api.kusion.io/v1" + modgen "kusionstack.io/kusion-module-framework/pkg/module/generator" + v1 "kusionstack.io/kusion/pkg/apis/api.kusion.io/v1" + "kusionstack.io/kusion/pkg/generators" +) + +// orderedResourcesGenerator is a generator that inject the dependsOn of resources in a specified order. +type orderedResourcesGenerator struct { + orderedKinds []string +} + +// NewOrderedResourcesGenerator returns a new instance of orderedResourcesGenerator. +func NewOrderedResourcesGenerator(multipleOrderedKinds ...[]string) (generators.SpecGenerator, error) { + orderedKinds := modgen.DefaultOrderedKinds + if len(multipleOrderedKinds) > 0 && len(multipleOrderedKinds[0]) > 0 { + orderedKinds = multipleOrderedKinds[0] + } + return &orderedResourcesGenerator{ + orderedKinds: orderedKinds, + }, nil +} + +// NewOrderedResourcesGeneratorFunc returns a function that creates a new orderedResourcesGenerator. +func NewOrderedResourcesGeneratorFunc(multipleOrderedKinds ...[]string) generators.NewSpecGeneratorFunc { + return func() (generators.SpecGenerator, error) { + return NewOrderedResourcesGenerator(multipleOrderedKinds...) + } +} + +// Generate inject the dependsOn of resources in a specified order. +func (g *orderedResourcesGenerator) Generate(itt *v1.Spec) error { + if itt.Resources == nil { + itt.Resources = make(v1.Resources, 0) + } + + // In Kusion, the type of `Resources` being passed around is internally defined, + // so here we are converting the `Resources` type in `kusionstack.io/kusion-api-go` into + // the internally defined type. + // Fixme: the types passed around in Kusion may also be unified to the types in `kusion-api-go`. + var resources apiv1.Resources + copier.Copy(&resources, &itt.Resources) + + // Generate the ordered resources. + orderedResources, err := modgen.OrderedResources( + context.Background(), + resources, + g.orderedKinds, + ) + if err != nil { + return err + } + + copier.Copy(&itt.Resources, &orderedResources) + + return nil +} diff --git a/pkg/modules/generators/ordered_resources_generator_test.go b/pkg/generators/orderedresources/ordered_resources_generator_test.go similarity index 58% rename from pkg/modules/generators/ordered_resources_generator_test.go rename to pkg/generators/orderedresources/ordered_resources_generator_test.go index d642117d8..7c9867aa4 100644 --- a/pkg/modules/generators/ordered_resources_generator_test.go +++ b/pkg/generators/orderedresources/ordered_resources_generator_test.go @@ -1,4 +1,4 @@ -package generators +package orderedresources import ( "testing" @@ -17,10 +17,10 @@ var ( "namespace": "foo", "name": "bar", }, - "Spec": map[string]interface{}{ + "spec": map[string]interface{}{ "replica": 1, "template": map[string]interface{}{ - "Spec": map[string]interface{}{ + "spec": map[string]interface{}{ "containers": []map[string]interface{}{ { "image": "foo.bar.com:v1", @@ -103,77 +103,3 @@ func TestOrderedResourcesGenerator_Generate(t *testing.T) { assert.NoError(t, err) assert.Equal(t, expected, actual) } - -func TestResourceKind(t *testing.T) { - r := &resource{ - Type: runtime.Kubernetes, - Attributes: map[string]interface{}{ - "kind": "Deployment", - }, - } - - expected := "Deployment" - actual := r.kubernetesKind() - - assert.Equal(t, expected, actual) -} - -func TestInjectAllDependsOn(t *testing.T) { - spec := genOldSpec() - dependKinds := []string{"Namespace"} - - expected := []string{"v1:Namespace:foo"} - actual := resource([]v1.Resource(spec.Resources)[0]) - actual.injectDependsOn(dependKinds, spec.Resources) - - assert.Equal(t, expected, actual.DependsOn) -} - -func TestFindDependKinds(t *testing.T) { - r := &resource{ - Type: runtime.Kubernetes, - Attributes: map[string]interface{}{ - "kind": "Deployment", - }, - } - - expected := []string{ - "Namespace", - "ResourceQuota", - "StorageClass", - "CustomResourceDefinition", - "ServiceAccount", - "PodSecurityPolicy", - "Role", - "ClusterRole", - "RoleBinding", - "ClusterRoleBinding", - "ConfigMap", - "Secret", - "Endpoints", - "Service", - "LimitRange", - "PriorityClass", - "PersistentVolume", - "PersistentVolumeClaim", - } - actual := r.findDependKinds(defaultOrderedKinds) - - assert.Equal(t, expected, actual) -} - -func TestFindDependResources(t *testing.T) { - dependKind := "Namespace" - resources := genOldSpec().Resources - - expected := []*v1.Resource{ - { - ID: "v1:Namespace:foo", - Type: runtime.Kubernetes, - Attributes: fakeNamespace, - }, - } - actual := findDependResources(dependKind, resources) - - assert.Equal(t, expected, actual) -} diff --git a/pkg/modules/generators/secret/rand.go b/pkg/generators/secret/rand.go similarity index 100% rename from pkg/modules/generators/secret/rand.go rename to pkg/generators/secret/rand.go diff --git a/pkg/modules/generators/secret/rand_test.go b/pkg/generators/secret/rand_test.go similarity index 100% rename from pkg/modules/generators/secret/rand_test.go rename to pkg/generators/secret/rand_test.go diff --git a/pkg/modules/generators/secret/secret.go b/pkg/generators/secret/secret.go similarity index 93% rename from pkg/modules/generators/secret/secret.go rename to pkg/generators/secret/secret.go index ff476beb3..e1b336495 100644 --- a/pkg/modules/generators/secret/secret.go +++ b/pkg/generators/secret/secret.go @@ -9,9 +9,10 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "kusionstack.io/kusion-module-framework/pkg/module" v1 "kusionstack.io/kusion/pkg/apis/api.kusion.io/v1" + "kusionstack.io/kusion/pkg/generators" "kusionstack.io/kusion/pkg/log" - "kusionstack.io/kusion/pkg/modules" ) type secretGenerator struct { @@ -32,7 +33,7 @@ type GeneratorRequest struct { SecretStore *v1.SecretStore } -func NewSecretGenerator(request *GeneratorRequest) (modules.Generator, error) { +func NewSecretGenerator(request *GeneratorRequest) (generators.SpecGenerator, error) { if len(request.Project) == 0 { return nil, fmt.Errorf("project name must not be empty") } @@ -63,8 +64,8 @@ func NewSecretGenerator(request *GeneratorRequest) (modules.Generator, error) { }, nil } -func NewSecretGeneratorFunc(request *GeneratorRequest) modules.NewGeneratorFunc { - return func() (modules.Generator, error) { +func NewSecretGeneratorFunc(request *GeneratorRequest) generators.NewSpecGeneratorFunc { + return func() (generators.SpecGenerator, error) { return NewSecretGenerator(request) } } @@ -80,8 +81,8 @@ func (g *secretGenerator) Generate(spec *v1.Spec) error { return err } - resourceID := modules.KubernetesResourceID(secret.TypeMeta, secret.ObjectMeta) - err = modules.AppendToSpec( + resourceID := module.KubernetesResourceID(secret.TypeMeta, secret.ObjectMeta) + err = generators.AppendToSpec( v1.Kubernetes, resourceID, spec, diff --git a/pkg/modules/generators/secret/secret_test.go b/pkg/generators/secret/secret_test.go similarity index 100% rename from pkg/modules/generators/secret/secret_test.go rename to pkg/generators/secret/secret_test.go diff --git a/pkg/generators/util.go b/pkg/generators/util.go new file mode 100644 index 000000000..a173f8eec --- /dev/null +++ b/pkg/generators/util.go @@ -0,0 +1,85 @@ +package generators + +import ( + "errors" + "sort" + + "k8s.io/apimachinery/pkg/runtime" + + v1 "kusionstack.io/kusion/pkg/apis/api.kusion.io/v1" +) + +// CallGeneratorFuncs calls each NewSpecGeneratorFunc in the given slice +// and returns a slice of SpecGenerator instances. +func CallGeneratorFuncs(newGenerators ...NewSpecGeneratorFunc) ([]SpecGenerator, error) { + gs := make([]SpecGenerator, 0, len(newGenerators)) + for _, newGenerator := range newGenerators { + if g, err := newGenerator(); err != nil { + return nil, err + } else { + gs = append(gs, g) + } + } + return gs, nil +} + +// CallGenerators calls the Generate method of each SpecGenerator instance +// returned by the given NewSpecGeneratorFuncs. +func CallGenerators(i *v1.Spec, newGenerators ...NewSpecGeneratorFunc) error { + gs, err := CallGeneratorFuncs(newGenerators...) + if err != nil { + return err + } + for _, g := range gs { + if err := g.Generate(i); err != nil { + return err + } + } + return nil +} + +// ForeachOrdered executes the given function on each +// item in the map in order of their keys. +func ForeachOrdered[T any](m map[string]T, f func(key string, value T) error) error { + keys := make([]string, 0, len(m)) + for k := range m { + keys = append(keys, k) + } + + sort.Strings(keys) + + for _, k := range keys { + v := m[k] + if err := f(k, v); err != nil { + return err + } + } + + return nil +} + +// AppendToSpec adds a Kubernetes resource to the Spec resources slice. +func AppendToSpec(resourceType v1.Type, resourceID string, i *v1.Spec, resource any) error { + // this function is only used for Kubernetes resources + if resourceType != v1.Kubernetes { + return errors.New("AppendToSpec is only used for Kubernetes resources") + } + + gvk := resource.(runtime.Object).GetObjectKind().GroupVersionKind().String() + // fixme: this function converts int to int64 by default + unstructured, err := runtime.DefaultUnstructuredConverter.ToUnstructured(resource) + if err != nil { + return err + } + r := v1.Resource{ + ID: resourceID, + Type: resourceType, + Attributes: unstructured, + DependsOn: nil, + Extensions: map[string]any{ + v1.ResourceExtensionGVK: gvk, + }, + } + i.Resources = append(i.Resources, r) + return nil +} diff --git a/pkg/modules/util_test.go b/pkg/generators/util_test.go similarity index 59% rename from pkg/modules/util_test.go rename to pkg/generators/util_test.go index e783bb8ef..9032421a8 100644 --- a/pkg/modules/util_test.go +++ b/pkg/generators/util_test.go @@ -1,4 +1,4 @@ -package modules +package generators import ( "testing" @@ -22,18 +22,18 @@ func TestCallGenerators(t *testing.T) { i := &v1.Spec{} var ( - generator1 Generator = &mockGenerator{ + generator1 SpecGenerator = &mockGenerator{ GenerateFunc: func(Spec *v1.Spec) error { return nil }, } - generator2 Generator = &mockGenerator{ + generator2 SpecGenerator = &mockGenerator{ GenerateFunc: func(Spec *v1.Spec) error { return assert.AnError }, } - gf1 = func() (Generator, error) { return generator1, nil } - gf2 = func() (Generator, error) { return generator2, nil } + gf1 = func() (SpecGenerator, error) { return generator1, nil } + gf2 = func() (SpecGenerator, error) { return generator2, nil } ) err := CallGenerators(i, gf1, gf2) @@ -42,11 +42,11 @@ func TestCallGenerators(t *testing.T) { } func TestCallGeneratorFuncs(t *testing.T) { - generatorFunc1 := func() (Generator, error) { + generatorFunc1 := func() (SpecGenerator, error) { return &mockGenerator{}, nil } - generatorFunc2 := func() (Generator, error) { + generatorFunc2 := func() (SpecGenerator, error) { return nil, assert.AnError } @@ -76,50 +76,6 @@ func TestForeachOrdered(t *testing.T) { assert.Equal(t, "abc", result) } -func TestGenericPtr(t *testing.T) { - value := 42 - ptr := GenericPtr(value) - assert.Equal(t, &value, ptr) -} - -func TestMergeMaps(t *testing.T) { - map1 := map[string]string{ - "a": "1", - "b": "2", - } - - map2 := map[string]string{ - "c": "3", - "d": "4", - } - - merged := MergeMaps(map1, nil, map2) - - expected := map[string]string{ - "a": "1", - "b": "2", - "c": "3", - "d": "4", - } - - assert.Equal(t, expected, merged) -} - -func TestKubernetesResourceID(t *testing.T) { - typeMeta := metav1.TypeMeta{ - APIVersion: "apps/v1", - Kind: "Deployment", - } - - objectMeta := metav1.ObjectMeta{ - Namespace: "example", - Name: "my-deployment", - } - - id := KubernetesResourceID(typeMeta, objectMeta) - assert.Equal(t, "apps/v1:Deployment:example:my-deployment", id) -} - func TestAppendToSpec(t *testing.T) { i := &v1.Spec{} resource := &v1.Resource{ @@ -135,8 +91,6 @@ func TestAppendToSpec(t *testing.T) { "spec": make(map[string]interface{}), "status": make(map[string]interface{}), }, - DependsOn: nil, - Extensions: nil, } ns := &corev1.Namespace{ @@ -159,68 +113,6 @@ func TestAppendToSpec(t *testing.T) { assert.Equal(t, ns.GroupVersionKind().String(), i.Resources[0].Extensions[v1.ResourceExtensionGVK]) } -func TestUniqueAppName(t *testing.T) { - projectName := "my-project" - stackName := "my-stack" - appName := "my-app" - - expected := "my-project-my-stack-my-app" - result := UniqueAppName(projectName, stackName, appName) - - assert.Equal(t, expected, result) -} - -func TestUniqueAppLabels(t *testing.T) { - projectName := "my-project" - appName := "my-app" - - expected := map[string]string{ - "app.kubernetes.io/part-of": projectName, - "app.kubernetes.io/name": appName, - } - - result := UniqueAppLabels(projectName, appName) - - assert.Equal(t, expected, result) -} - -func TestPatchResource(t *testing.T) { - resources := map[string][]*v1.Resource{ - "/v1, Kind=Namespace": { - { - ID: "v1:Namespace:default", - Type: "Kubernetes", - Attributes: map[string]interface{}{ - "apiVersion": "v1", - "kind": "Namespace", - "metadata": map[string]interface{}{ - "name": "default", - }, - }, - Extensions: map[string]interface{}{ - "GVK": "/v1, Kind=Namespace", - }, - }, - }, - } - assert.NoError( - t, - PatchResource(resources, "/v1, Kind=Namespace", func(ns *corev1.Namespace) error { - ns.Labels = map[string]string{ - "foo": "bar", - } - return nil - }), - ) - assert.Equal( - t, - map[string]interface{}{ - "foo": "bar", - }, - resources["/v1, Kind=Namespace"][0].Attributes["metadata"].(map[string]interface{})["labels"].(map[string]interface{}), - ) -} - func TestAddKubeConfigIf(t *testing.T) { testcases := []struct { name string diff --git a/pkg/modules/generators/namespace_generator.go b/pkg/modules/generators/namespace_generator.go deleted file mode 100644 index ef24ec9c5..000000000 --- a/pkg/modules/generators/namespace_generator.go +++ /dev/null @@ -1,49 +0,0 @@ -package generators - -import ( - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - v1 "kusionstack.io/kusion/pkg/apis/api.kusion.io/v1" - "kusionstack.io/kusion/pkg/modules" -) - -type namespaceGenerator struct { - namespace string -} - -func NewNamespaceGenerator(namespace string) (modules.Generator, error) { - return &namespaceGenerator{ - namespace: namespace, - }, nil -} - -func NewNamespaceGeneratorFunc(namespace string) modules.NewGeneratorFunc { - return func() (modules.Generator, error) { - return NewNamespaceGenerator(namespace) - } -} - -func (g *namespaceGenerator) Generate(i *v1.Spec) error { - if i.Resources == nil { - i.Resources = make(v1.Resources, 0) - } - - ns := &corev1.Namespace{ - TypeMeta: metav1.TypeMeta{ - Kind: "Namespace", - APIVersion: corev1.SchemeGroupVersion.String(), - }, - ObjectMeta: metav1.ObjectMeta{Name: g.namespace}, - } - - // Avoid generating duplicate namespaces with the same ID. - id := modules.KubernetesResourceID(ns.TypeMeta, ns.ObjectMeta) - for _, res := range i.Resources { - if res.ID == id { - return nil - } - } - - return modules.AppendToSpec(v1.Kubernetes, id, i, ns) -} diff --git a/pkg/modules/generators/ordered_resources_generator.go b/pkg/modules/generators/ordered_resources_generator.go deleted file mode 100644 index 87758f3b6..000000000 --- a/pkg/modules/generators/ordered_resources_generator.go +++ /dev/null @@ -1,129 +0,0 @@ -package generators - -import ( - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - - v1 "kusionstack.io/kusion/pkg/apis/api.kusion.io/v1" - "kusionstack.io/kusion/pkg/engine/runtime" - "kusionstack.io/kusion/pkg/modules" -) - -// defaultOrderedKinds provides the default order of kubernetes resource kinds. -var defaultOrderedKinds = []string{ - "Namespace", - "ResourceQuota", - "StorageClass", - "CustomResourceDefinition", - "ServiceAccount", - "PodSecurityPolicy", - "Role", - "ClusterRole", - "RoleBinding", - "ClusterRoleBinding", - "ConfigMap", - "Secret", - "Endpoints", - "Service", - "LimitRange", - "PriorityClass", - "PersistentVolume", - "PersistentVolumeClaim", - "Deployment", - "StatefulSet", - "CronJob", - "PodDisruptionBudget", - "MutatingWebhookConfiguration", - "ValidatingWebhookConfiguration", -} - -// orderedResourcesGenerator is a generator that inject the dependsOn of resources in a specified order. -type orderedResourcesGenerator struct { - orderedKinds []string -} - -// NewOrderedResourcesGenerator returns a new instance of orderedResourcesGenerator. -func NewOrderedResourcesGenerator(multipleOrderedKinds ...[]string) (modules.Generator, error) { - orderedKinds := defaultOrderedKinds - if len(multipleOrderedKinds) > 0 && len(multipleOrderedKinds[0]) > 0 { - orderedKinds = multipleOrderedKinds[0] - } - return &orderedResourcesGenerator{ - orderedKinds: orderedKinds, - }, nil -} - -// NewOrderedResourcesGeneratorFunc returns a function that creates a new orderedResourcesGenerator. -func NewOrderedResourcesGeneratorFunc(multipleOrderedKinds ...[]string) modules.NewGeneratorFunc { - return func() (modules.Generator, error) { - return NewOrderedResourcesGenerator(multipleOrderedKinds...) - } -} - -// Generate inject the dependsOn of resources in a specified order. -func (g *orderedResourcesGenerator) Generate(itt *v1.Spec) error { - if itt.Resources == nil { - itt.Resources = make(v1.Resources, 0) - } - - for i := 0; i < len(itt.Resources); i++ { - // Continue if the resource is not a kubernetes resource. - if itt.Resources[i].Type != runtime.Kubernetes { - continue - } - - // Inject dependsOn of the resource. - r := (*resource)(&itt.Resources[i]) - r.injectDependsOn(g.orderedKinds, itt.Resources) - } - - return nil -} - -type resource v1.Resource - -// kubernetesKind returns the kubernetes kind of the given resource. -func (r resource) kubernetesKind() string { - u := &unstructured.Unstructured{} - u.SetUnstructuredContent(r.Attributes) - return u.GetKind() -} - -// injectDependsOn injects all dependsOn relationships for the given resource and dependent kinds. -func (r *resource) injectDependsOn(orderedKinds []string, rs []v1.Resource) { - kinds := r.findDependKinds(orderedKinds) - for _, kind := range kinds { - drs := findDependResources(kind, rs) - r.appendDependsOn(drs) - } -} - -// appendDependsOn injects dependsOn relationships for the given resource and dependent resources. -func (r *resource) appendDependsOn(dependResources []*v1.Resource) { - for _, dr := range dependResources { - r.DependsOn = append(r.DependsOn, dr.ID) - } -} - -// findDependKinds returns the dependent resource kinds for the specified kind. -func (r *resource) findDependKinds(orderedKinds []string) []string { - curKind := r.kubernetesKind() - dependKinds := make([]string, 0) - for _, previousKind := range orderedKinds { - if curKind == previousKind { - break - } - dependKinds = append(dependKinds, previousKind) - } - return dependKinds -} - -// findDependResources returns the dependent resources of the specified kind. -func findDependResources(dependKind string, rs []v1.Resource) []*v1.Resource { - var dependResources []*v1.Resource - for i := 0; i < len(rs); i++ { - if resource(rs[i]).kubernetesKind() == dependKind { - dependResources = append(dependResources, &rs[i]) - } - } - return dependResources -} diff --git a/pkg/modules/interfaces.go b/pkg/modules/interfaces.go deleted file mode 100644 index 0b2907d34..000000000 --- a/pkg/modules/interfaces.go +++ /dev/null @@ -1,72 +0,0 @@ -package modules - -import ( - "context" - - "github.com/hashicorp/go-plugin" - "github.com/pkg/errors" - "google.golang.org/grpc" - - v1 "kusionstack.io/kusion/pkg/apis/api.kusion.io/v1" - "kusionstack.io/kusion/pkg/modules/proto" -) - -const PluginKey = "module-default" - -// Generator is an interface for things that can generate Intent from input configurations. -// todo it's for built-in generators and we should consider to convert it to a general Module interface -type Generator interface { - // Generate performs the intent generate operation. - Generate(intent *v1.Spec) error -} - -// Module is the interface that we're exposing as a kusion module plugin. -type Module interface { - Generate(ctx context.Context, req *proto.GeneratorRequest) (*proto.GeneratorResponse, error) -} - -// NewGeneratorFunc is a function that returns a Generator. -type NewGeneratorFunc func() (Generator, error) - -type GRPCClient struct { - client proto.ModuleClient -} - -func (c *GRPCClient) Generate(ctx context.Context, req *proto.GeneratorRequest) (*proto.GeneratorResponse, error) { - return c.client.Generate(ctx, req) -} - -type GRPCServer struct { - // This is the real implementation - Impl Module - proto.UnimplementedModuleServer -} - -func (s *GRPCServer) Generate(ctx context.Context, req *proto.GeneratorRequest) (res *proto.GeneratorResponse, err error) { - defer func() { - if e := recover(); e != nil { - err = errors.WithStack(err) - res = &proto.GeneratorResponse{} - } - }() - res, err = s.Impl.Generate(ctx, req) - return -} - -type GRPCPlugin struct { - // GRPCPlugin must still implement the Plugin interface - plugin.Plugin - // Concrete implementation, written in Go. This is only used for plugins that are written in Go. - Impl Module -} - -// GRPCServer is going to be invoked by the go-plugin framework -func (p *GRPCPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error { - proto.RegisterModuleServer(s, &GRPCServer{Impl: p.Impl}) - return nil -} - -// GRPCClient is going to be invoked by the go-plugin framework -func (p *GRPCPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) { - return &GRPCClient{client: proto.NewModuleClient(c)}, nil -} diff --git a/pkg/modules/plugin.go b/pkg/modules/plugin.go deleted file mode 100644 index 8d3de9fc0..000000000 --- a/pkg/modules/plugin.go +++ /dev/null @@ -1,187 +0,0 @@ -package modules - -import ( - "fmt" - "os" - "os/exec" - "path/filepath" - "runtime" - "strings" - "sync" - - "github.com/hashicorp/go-hclog" - "github.com/hashicorp/go-plugin" - - "kusionstack.io/kusion/pkg/log" - "kusionstack.io/kusion/pkg/util/kfile" -) - -const ( - DefaultModulePathEnv = "KUSION_MODULE_PATH" - KusionModuleBinaryPrefix = "kusion-module-" - Dir = "modules" -) - -var mu sync.Mutex - -// HandshakeConfig is a common handshake that is shared by plugin and host. -var HandshakeConfig = plugin.HandshakeConfig{ - ProtocolVersion: 1, - MagicCookieKey: "MODULE_PLUGIN", - MagicCookieValue: "ON", -} - -// PluginMap is the map of plugins we can dispense. -var PluginMap = map[string]plugin.Plugin{ - PluginKey: &GRPCPlugin{}, -} - -type Plugin struct { - // key represents the module key, it consists of two parts: namespace/moduleName@version. e.g. "kusionstack/mysql@v0.1.0" - key string - client *plugin.Client - // Module represents the real module impl - Module Module - // dir represents the working directory of the plugin binary, which will be typically set as the stack path. - dir string - ModuleName string -} - -func NewPlugin(key, dir string) (*Plugin, error) { - if key == "" { - return nil, fmt.Errorf("module key can not be empty") - } - p := &Plugin{key: key, dir: dir} - err := p.initModule() - if err != nil { - return nil, err - } - return p, nil -} - -func (p *Plugin) initModule() error { - key := p.key - split := strings.Split(key, "@") - msg := "init module failed. Invalid plugin module key: %s. " + - "The correct format for a key should be as follows: org/moduleName@version. e.g. kusionstack/mysql@v0.1.0" - if len(split) != 2 { - return fmt.Errorf(msg, key) - } - prefix := strings.Split(split[0], "/") - if len(prefix) != 2 { - return fmt.Errorf(msg, key) - } - - // build the plugin client - pluginPath, err := buildPluginPath(prefix[0], prefix[1], split[1]) - if err != nil { - return err - } - pluginName := prefix[0] + "-" + prefix[1] - p.ModuleName = pluginName - client, err := NewPluginClient(pluginPath, pluginName, p.dir) - if err != nil { - return err - } - p.client = client - rpcClient, err := client.Client() - if err != nil { - return fmt.Errorf("init kusion module plugin: %s failed. %w", key, err) - } - - // dispense the plugin to get the real module - raw, err := rpcClient.Dispense(PluginKey) - if err != nil { - return err - } - p.Module = raw.(Module) - - return nil -} - -func buildPluginPath(namespace, resourceType, version string) (string, error) { - mu.Lock() - defer mu.Unlock() - - // validate the module path - prefixPath, err := PluginDir() - if err != nil { - return "", err - } - goOs := runtime.GOOS - goArch := runtime.GOARCH - name := resourceType + "_" + version - p := filepath.Join(prefixPath, namespace, resourceType, version, goOs, goArch, KusionModuleBinaryPrefix+name) - if runtime.GOOS == "windows" && !strings.HasSuffix(p, ".exe") { - p += ".exe" - } - _, err = os.Stat(p) - if err != nil { - if os.IsNotExist(err) { - return "", fmt.Errorf("module binary doesn't exist. %s", p) - } else { - return "", err - } - } - return p, nil -} - -func NewPluginClient(modulePluginPath, moduleName, workingDir string) (*plugin.Client, error) { - // create the plugin log file - var logFilePath string - dir, err := kfile.KusionDataFolder() - if err != nil { - return nil, err - } - logDir := filepath.Join(dir, log.Folder, Dir, moduleName) - if _, err := os.Stat(logDir); os.IsNotExist(err) { - if err := os.MkdirAll(logDir, os.ModePerm); err != nil { - return nil, fmt.Errorf("failed to create module log dir: %w", err) - } - } - logFilePath = filepath.Join(logDir, moduleName+".log") - logFile, err := os.OpenFile(logFilePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644) - if err != nil { - return nil, fmt.Errorf("failed to open module %s log file: %w", moduleName, err) - } - - // write log to a separate file - logger := hclog.New(&hclog.LoggerOptions{ - Name: moduleName, - Output: logFile, - Level: hclog.Debug, - }) - - cmd := exec.Command(modulePluginPath) - cmd.Dir = workingDir - - // We're a host! Start by launching the plugin process.Need to defer kill - client := plugin.NewClient(&plugin.ClientConfig{ - HandshakeConfig: HandshakeConfig, - Plugins: PluginMap, - Cmd: cmd, - AllowedProtocols: []plugin.Protocol{ - plugin.ProtocolGRPC, - }, - Logger: logger, - }) - return client, nil -} - -func (p *Plugin) KillPluginClient() error { - if p.client == nil { - return fmt.Errorf("plugin: %s client is nil", p.key) - } - p.client.Kill() - return nil -} - -func PluginDir() (string, error) { - if env, found := os.LookupEnv(DefaultModulePathEnv); found { - return env, nil - } else if dir, err := kfile.KusionDataFolder(); err == nil { - return filepath.Join(dir, Dir), nil - } else { - return "", err - } -} diff --git a/pkg/modules/proto/module.pb.go b/pkg/modules/proto/module.pb.go deleted file mode 100644 index b1cec4a17..000000000 --- a/pkg/modules/proto/module.pb.go +++ /dev/null @@ -1,301 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.34.2 -// protoc v3.21.12 -// source: module.proto - -package proto - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// GeneratorRequest represents a request to generate something based on the project details -type GeneratorRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Project represents the project name - Project string `protobuf:"bytes,1,opt,name=project,proto3" json:"project,omitempty"` - // Stack represents the stack name - Stack string `protobuf:"bytes,2,opt,name=stack,proto3" json:"stack,omitempty"` - // App represents the application name, which is typically the same as the namespace of Kubernetes resources - App string `protobuf:"bytes,3,opt,name=app,proto3" json:"app,omitempty"` - // Workload represents the v1.Workload defined in the AppConfiguration - Workload []byte `protobuf:"bytes,4,opt,name=workload,proto3" json:"workload,omitempty"` - // DevModuleConfig is the developer's inputs of this module - DevConfig []byte `protobuf:"bytes,5,opt,name=dev_config,json=devConfig,proto3" json:"dev_config,omitempty"` - // PlatformModuleConfig is the platform engineer's inputs of this module - PlatformConfig []byte `protobuf:"bytes,6,opt,name=platform_config,json=platformConfig,proto3" json:"platform_config,omitempty"` - // context contains workspace-level configurations, such as topologies, server endpoints, metadata, etc. - Context []byte `protobuf:"bytes,7,opt,name=context,proto3" json:"context,omitempty"` - // SecretStore represents a secure external location for storing secrets. - SecretStore []byte `protobuf:"bytes,8,opt,name=secret_store,json=secretStore,proto3" json:"secret_store,omitempty"` -} - -func (x *GeneratorRequest) Reset() { - *x = GeneratorRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_module_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GeneratorRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GeneratorRequest) ProtoMessage() {} - -func (x *GeneratorRequest) ProtoReflect() protoreflect.Message { - mi := &file_module_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GeneratorRequest.ProtoReflect.Descriptor instead. -func (*GeneratorRequest) Descriptor() ([]byte, []int) { - return file_module_proto_rawDescGZIP(), []int{0} -} - -func (x *GeneratorRequest) GetProject() string { - if x != nil { - return x.Project - } - return "" -} - -func (x *GeneratorRequest) GetStack() string { - if x != nil { - return x.Stack - } - return "" -} - -func (x *GeneratorRequest) GetApp() string { - if x != nil { - return x.App - } - return "" -} - -func (x *GeneratorRequest) GetWorkload() []byte { - if x != nil { - return x.Workload - } - return nil -} - -func (x *GeneratorRequest) GetDevConfig() []byte { - if x != nil { - return x.DevConfig - } - return nil -} - -func (x *GeneratorRequest) GetPlatformConfig() []byte { - if x != nil { - return x.PlatformConfig - } - return nil -} - -func (x *GeneratorRequest) GetContext() []byte { - if x != nil { - return x.Context - } - return nil -} - -func (x *GeneratorRequest) GetSecretStore() []byte { - if x != nil { - return x.SecretStore - } - return nil -} - -// GeneratorResponse represents the generate result of the generator. -type GeneratorResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Resources is a v1.Resource array, which represents the generated resources by this module. - Resources [][]byte `protobuf:"bytes,1,rep,name=resources,proto3" json:"resources,omitempty"` - // Patcher contains fields should be patched into the workload corresponding fields - Patcher []byte `protobuf:"bytes,2,opt,name=patcher,proto3" json:"patcher,omitempty"` -} - -func (x *GeneratorResponse) Reset() { - *x = GeneratorResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_module_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GeneratorResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GeneratorResponse) ProtoMessage() {} - -func (x *GeneratorResponse) ProtoReflect() protoreflect.Message { - mi := &file_module_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GeneratorResponse.ProtoReflect.Descriptor instead. -func (*GeneratorResponse) Descriptor() ([]byte, []int) { - return file_module_proto_rawDescGZIP(), []int{1} -} - -func (x *GeneratorResponse) GetResources() [][]byte { - if x != nil { - return x.Resources - } - return nil -} - -func (x *GeneratorResponse) GetPatcher() []byte { - if x != nil { - return x.Patcher - } - return nil -} - -var File_module_proto protoreflect.FileDescriptor - -var file_module_proto_rawDesc = []byte{ - 0x0a, 0x0c, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf5, - 0x01, 0x0a, 0x10, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x14, 0x0a, - 0x05, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x74, - 0x61, 0x63, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x70, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x61, 0x70, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x6c, 0x6f, 0x61, - 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x6c, 0x6f, 0x61, - 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x64, 0x65, 0x76, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x64, 0x65, 0x76, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x12, 0x27, 0x0a, 0x0f, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x5f, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x70, 0x6c, 0x61, 0x74, 0x66, - 0x6f, 0x72, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, - 0x74, 0x65, 0x78, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, - 0x65, 0x78, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x5f, 0x73, 0x74, - 0x6f, 0x72, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x73, 0x65, 0x63, 0x72, 0x65, - 0x74, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x22, 0x4b, 0x0a, 0x11, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, - 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x72, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x09, - 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x74, - 0x63, 0x68, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x74, 0x63, - 0x68, 0x65, 0x72, 0x32, 0x3b, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x31, 0x0a, - 0x08, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x12, 0x11, 0x2e, 0x47, 0x65, 0x6e, 0x65, - 0x72, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x47, - 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_module_proto_rawDescOnce sync.Once - file_module_proto_rawDescData = file_module_proto_rawDesc -) - -func file_module_proto_rawDescGZIP() []byte { - file_module_proto_rawDescOnce.Do(func() { - file_module_proto_rawDescData = protoimpl.X.CompressGZIP(file_module_proto_rawDescData) - }) - return file_module_proto_rawDescData -} - -var file_module_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_module_proto_goTypes = []any{ - (*GeneratorRequest)(nil), // 0: GeneratorRequest - (*GeneratorResponse)(nil), // 1: GeneratorResponse -} -var file_module_proto_depIdxs = []int32{ - 0, // 0: Module.Generate:input_type -> GeneratorRequest - 1, // 1: Module.Generate:output_type -> GeneratorResponse - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_module_proto_init() } -func file_module_proto_init() { - if File_module_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_module_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*GeneratorRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_module_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*GeneratorResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_module_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_module_proto_goTypes, - DependencyIndexes: file_module_proto_depIdxs, - MessageInfos: file_module_proto_msgTypes, - }.Build() - File_module_proto = out.File - file_module_proto_rawDesc = nil - file_module_proto_goTypes = nil - file_module_proto_depIdxs = nil -} diff --git a/pkg/modules/proto/module.proto b/pkg/modules/proto/module.proto deleted file mode 100644 index 6a85a57c2..000000000 --- a/pkg/modules/proto/module.proto +++ /dev/null @@ -1,34 +0,0 @@ -syntax = "proto3"; -option go_package = "../proto"; - -// GeneratorRequest represents a request to generate something based on the project details -message GeneratorRequest { - // Project represents the project name - string project = 1; - // Stack represents the stack name - string stack = 2; - // App represents the application name, which is typically the same as the namespace of Kubernetes resources - string app = 3; - // Workload represents the v1.Workload defined in the AppConfiguration - bytes workload = 4; - // DevModuleConfig is the developer's inputs of this module - bytes dev_config = 5; - // PlatformModuleConfig is the platform engineer's inputs of this module - bytes platform_config = 6; - // context contains workspace-level configurations, such as topologies, server endpoints, metadata, etc. - bytes context = 7; - // SecretStore represents a secure external location for storing secrets. - bytes secret_store = 8; -} - -// GeneratorResponse represents the generate result of the generator. -message GeneratorResponse { - // Resources is a v1.Resource array, which represents the generated resources by this module. - repeated bytes resources = 1; - // Patcher contains fields should be patched into the workload corresponding fields - bytes patcher = 2; -} - -service Module { - rpc Generate(GeneratorRequest) returns (GeneratorResponse); -} \ No newline at end of file diff --git a/pkg/modules/proto/module_grpc.pb.go b/pkg/modules/proto/module_grpc.pb.go deleted file mode 100644 index 370ffc828..000000000 --- a/pkg/modules/proto/module_grpc.pb.go +++ /dev/null @@ -1,121 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc v3.21.12 -// source: module.proto - -package proto - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - Module_Generate_FullMethodName = "/Module/Generate" -) - -// ModuleClient is the client API for Module service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type ModuleClient interface { - Generate(ctx context.Context, in *GeneratorRequest, opts ...grpc.CallOption) (*GeneratorResponse, error) -} - -type moduleClient struct { - cc grpc.ClientConnInterface -} - -func NewModuleClient(cc grpc.ClientConnInterface) ModuleClient { - return &moduleClient{cc} -} - -func (c *moduleClient) Generate(ctx context.Context, in *GeneratorRequest, opts ...grpc.CallOption) (*GeneratorResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GeneratorResponse) - err := c.cc.Invoke(ctx, Module_Generate_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ModuleServer is the server API for Module service. -// All implementations must embed UnimplementedModuleServer -// for forward compatibility. -type ModuleServer interface { - Generate(context.Context, *GeneratorRequest) (*GeneratorResponse, error) - mustEmbedUnimplementedModuleServer() -} - -// UnimplementedModuleServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedModuleServer struct{} - -func (UnimplementedModuleServer) Generate(context.Context, *GeneratorRequest) (*GeneratorResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Generate not implemented") -} -func (UnimplementedModuleServer) mustEmbedUnimplementedModuleServer() {} -func (UnimplementedModuleServer) testEmbeddedByValue() {} - -// UnsafeModuleServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to ModuleServer will -// result in compilation errors. -type UnsafeModuleServer interface { - mustEmbedUnimplementedModuleServer() -} - -func RegisterModuleServer(s grpc.ServiceRegistrar, srv ModuleServer) { - // If the following call pancis, it indicates UnimplementedModuleServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&Module_ServiceDesc, srv) -} - -func _Module_Generate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GeneratorRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ModuleServer).Generate(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Module_Generate_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ModuleServer).Generate(ctx, req.(*GeneratorRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// Module_ServiceDesc is the grpc.ServiceDesc for Module service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Module_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "Module", - HandlerType: (*ModuleServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Generate", - Handler: _Module_Generate_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "module.proto", -} diff --git a/pkg/modules/proto/scrip.sh b/pkg/modules/proto/scrip.sh deleted file mode 100755 index adb0137f4..000000000 --- a/pkg/modules/proto/scrip.sh +++ /dev/null @@ -1,3 +0,0 @@ -protoc --go_out=. --go_opt=paths=source_relative \ - --go-grpc_out=. --go-grpc_opt=paths=source_relative \ - module.proto \ No newline at end of file diff --git a/pkg/modules/util.go b/pkg/modules/util.go deleted file mode 100644 index 1c461b89c..000000000 --- a/pkg/modules/util.go +++ /dev/null @@ -1,174 +0,0 @@ -package modules - -import ( - "errors" - "sort" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - - v1 "kusionstack.io/kusion/pkg/apis/api.kusion.io/v1" -) - -// IgnoreModules todo@dayuan delete this condition after workload is changed into a module -var IgnoreModules = map[string]bool{ - "service": true, - "job": true, -} - -// CallGeneratorFuncs calls each NewGeneratorFunc in the given slice -// and returns a slice of Generator instances. -func CallGeneratorFuncs(newGenerators ...NewGeneratorFunc) ([]Generator, error) { - gs := make([]Generator, 0, len(newGenerators)) - for _, newGenerator := range newGenerators { - if g, err := newGenerator(); err != nil { - return nil, err - } else { - gs = append(gs, g) - } - } - return gs, nil -} - -// CallGenerators calls the Generate method of each Generator instance -// returned by the given NewGeneratorFuncs. -func CallGenerators(i *v1.Spec, newGenerators ...NewGeneratorFunc) error { - gs, err := CallGeneratorFuncs(newGenerators...) - if err != nil { - return err - } - for _, g := range gs { - if err := g.Generate(i); err != nil { - return err - } - } - return nil -} - -// ForeachOrdered executes the given function on each -// item in the map in order of their keys. -func ForeachOrdered[T any](m map[string]T, f func(key string, value T) error) error { - keys := make([]string, 0, len(m)) - for k := range m { - keys = append(keys, k) - } - - sort.Strings(keys) - - for _, k := range keys { - v := m[k] - if err := f(k, v); err != nil { - return err - } - } - - return nil -} - -// GenericPtr returns a pointer to the provided value. -func GenericPtr[T any](i T) *T { - return &i -} - -// MergeMaps merges multiple map[string]string into one -// map[string]string. -// If a map is nil, it skips it and moves on to the next one. For each -// non-nil map, it iterates over its key-value pairs and adds them to -// the merged map. Finally, it returns the merged map. -func MergeMaps(maps ...map[string]string) map[string]string { - merged := make(map[string]string) - - for _, m := range maps { - if len(m) == 0 { - continue - } - for k, v := range m { - merged[k] = v - } - } - - if len(merged) == 0 { - return nil - } - return merged -} - -// KubernetesResourceID returns the unique ID of a Kubernetes resource -// based on its type and metadata. -func KubernetesResourceID(typeMeta metav1.TypeMeta, objectMeta metav1.ObjectMeta) string { - // resource id example: apps/v1:Deployment:code-city:code-citydev - id := typeMeta.APIVersion + ":" + typeMeta.Kind + ":" - if objectMeta.Namespace != "" { - id += objectMeta.Namespace + ":" - } - id += objectMeta.Name - return id -} - -// KusionPathDependency returns the implicit resource dependency path based on -// the resource id and name with the "$kusion_path" prefix. -func KusionPathDependency(id, name string) string { - return "$kusion_path." + id + "." + name -} - -// AppendToSpec adds a Kubernetes resource to the Spec resources slice. -func AppendToSpec(resourceType v1.Type, resourceID string, i *v1.Spec, resource any) error { - // this function is only used for Kubernetes resources - if resourceType != v1.Kubernetes { - return errors.New("AppendToSpec is only used for Kubernetes resources") - } - - gvk := resource.(runtime.Object).GetObjectKind().GroupVersionKind().String() - // fixme: this function converts int to int64 by default - unstructured, err := runtime.DefaultUnstructuredConverter.ToUnstructured(resource) - if err != nil { - return err - } - r := v1.Resource{ - ID: resourceID, - Type: resourceType, - Attributes: unstructured, - DependsOn: nil, - Extensions: map[string]any{ - v1.ResourceExtensionGVK: gvk, - }, - } - i.Resources = append(i.Resources, r) - return nil -} - -// UniqueAppName returns a unique name for a workload based on its project and app name. -func UniqueAppName(projectName, stackName, appName string) string { - return projectName + "-" + stackName + "-" + appName -} - -// UniqueAppLabels returns a map of labels that identify an app based on its project and name. -func UniqueAppLabels(projectName, appName string) map[string]string { - return map[string]string{ - "app.kubernetes.io/part-of": projectName, - "app.kubernetes.io/name": appName, - } -} - -// PatchResource patches the resource with the given patch. -func PatchResource[T any](resources map[string][]*v1.Resource, gvk string, patchFunc func(*T) error) error { - var obj T - for _, r := range resources[gvk] { - // convert unstructured to typed object - if err := runtime.DefaultUnstructuredConverter.FromUnstructured(r.Attributes, &obj); err != nil { - return err - } - - if err := patchFunc(&obj); err != nil { - return err - } - - // convert typed object to unstructured - updated, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&obj) - if err != nil { - return err - } - r.Attributes = updated - } - return nil -} diff --git a/pkg/workspace/validation.go b/pkg/workspace/validation.go index b5fa2b750..313edcead 100644 --- a/pkg/workspace/validation.go +++ b/pkg/workspace/validation.go @@ -9,7 +9,6 @@ import ( utilerrors "k8s.io/apimachinery/pkg/util/errors" v1 "kusionstack.io/kusion/pkg/apis/api.kusion.io/v1" - "kusionstack.io/kusion/pkg/modules" ) var ( @@ -87,9 +86,6 @@ func ValidateModuleConfig(name string, config *v1.ModuleConfig) error { } func ValidateModuleMetadata(name string, config *v1.ModuleConfig) error { - if modules.IgnoreModules[name] { - return nil - } if config.Version == "" { return fmt.Errorf("empty version of module:%s in the workspacek config", name) } diff --git a/pkg/workspace/validation_test.go b/pkg/workspace/validation_test.go index 08b821a6b..71b717413 100644 --- a/pkg/workspace/validation_test.go +++ b/pkg/workspace/validation_test.go @@ -288,11 +288,6 @@ func TestValidateModuleMetadata(t *testing.T) { assert.NoError(t, err) }) - t.Run("IgnoreModule", func(t *testing.T) { - err := ValidateModuleMetadata("service", &v1.ModuleConfig{Version: "1.0.0", Path: "/path/to/module"}) - assert.NoError(t, err) - }) - t.Run("EmptyModuleVersion", func(t *testing.T) { err := ValidateModuleMetadata("testModule", &v1.ModuleConfig{Version: "", Path: "/path/to/module"}) assert.Error(t, err)