From c1afe82ea58f8bbb576ffad40f64109cd1065ad8 Mon Sep 17 00:00:00 2001 From: Dayuan Date: Sun, 28 Apr 2024 16:43:28 +0800 Subject: [PATCH] feat: parse module name and version from the kcl.mod in `mod push` --- go.mod | 139 +++++++++++++++++++--------------------- go.sum | 20 +++--- pkg/cmd/mod/mod_push.go | 46 ++++++++----- 3 files changed, 106 insertions(+), 99 deletions(-) diff --git a/go.mod b/go.mod index 6c5e4968..c9b18389 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( github.com/go-chi/render v1.0.3 github.com/go-git/go-git/v5 v5.11.0 github.com/go-sql-driver/mysql v1.7.0 - github.com/go-test/deep v1.0.3 + github.com/go-test/deep v1.0.8 github.com/goccy/go-yaml v1.11.3 github.com/gonvenience/bunt v1.1.1 github.com/gonvenience/neat v1.3.0 @@ -79,83 +79,20 @@ require ( k8s.io/utils v0.0.0-20230726121419-3b25d923346b kcl-lang.io/kcl-go v0.8.2 kcl-lang.io/kcl-plugin v0.5.0 - kcl-lang.io/kpm v0.8.3-0.20240321122901-fd054837ea5c + kcl-lang.io/kpm v0.8.6-0.20240428063742-f3e75d94c905 kusionstack.io/kube-api v0.1.1 sigs.k8s.io/controller-runtime v0.15.1 ) require ( + atomicgo.dev/cursor v0.2.0 // indirect + atomicgo.dev/keyboard v0.2.9 // indirect + atomicgo.dev/schedule v0.1.0 // indirect cloud.google.com/go v0.112.0 // indirect cloud.google.com/go/compute v1.23.3 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect cloud.google.com/go/iam v1.1.5 // indirect cloud.google.com/go/storage v1.36.0 // indirect - github.com/KyleBanks/depth v1.2.1 // indirect - github.com/Microsoft/hcsshim v0.11.0 // indirect - github.com/ajg/form v1.5.1 // indirect - github.com/alibabacloud-go/darabonba-array v0.1.0 // indirect - github.com/alibabacloud-go/darabonba-encode-util v0.0.2 // indirect - github.com/alibabacloud-go/darabonba-map v0.0.2 // indirect - github.com/alibabacloud-go/darabonba-string v1.0.2 // indirect - github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 // indirect - github.com/alibabacloud-go/openapi-util v0.1.0 // indirect - github.com/alibabacloud-go/tea v1.2.1 // indirect - github.com/alibabacloud-go/tea-utils v1.3.1 // indirect - github.com/alibabacloud-go/tea-utils/v2 v2.0.3 // indirect - github.com/aliyun/alibaba-cloud-sdk-go v1.61.1800 // indirect - github.com/aliyun/alibabacloud-dkms-gcs-go-sdk v0.5.1 // indirect - github.com/aliyun/alibabacloud-dkms-transfer-go-sdk v0.1.8 // indirect - github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect - github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect - github.com/cyphar/filepath-securejoin v0.2.4 // indirect - github.com/deckarep/golang-set v1.7.1 // indirect - github.com/dominikbraun/graph v0.23.0 // indirect - github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/go-errors/errors v1.4.2 // indirect - github.com/go-openapi/spec v0.21.0 // indirect - github.com/google/btree v1.0.1 // indirect - github.com/google/gnostic-models v0.6.8 // indirect - github.com/google/s2a-go v0.1.7 // indirect - github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect - github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect - github.com/googleapis/gax-go/v2 v2.12.0 // indirect - github.com/gorilla/websocket v1.5.0 // indirect - github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect - github.com/hashicorp/go-getter v1.7.3 // indirect - github.com/hashicorp/go-safetemp v1.0.0 // indirect - github.com/hashicorp/yamux v0.1.1 // indirect - github.com/jinzhu/inflection v1.0.0 // indirect - github.com/jinzhu/now v1.1.5 // indirect - github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect - github.com/mitchellh/go-testing-interface v1.14.1 // indirect - github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect - github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect - github.com/oklog/run v1.0.0 // indirect - github.com/orcaman/concurrent-map v0.0.0-20210501183033-44dafcb38ecc // indirect - github.com/peterbourgon/diskv v2.0.1+incompatible // indirect - github.com/swaggo/files v1.0.1 // indirect - github.com/tjfoc/gmsm v1.4.1 // indirect - github.com/ulikunitz/xz v0.5.10 // indirect - github.com/vbatts/tar-split v0.11.3 // indirect - github.com/xlab/treeprint v1.2.0 // indirect - go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect - go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect - google.golang.org/api v0.155.0 // indirect - google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 // indirect - gopkg.in/ini.v1 v1.66.2 // indirect - kcl-lang.io/lib v0.8.2 // indirect - oras.land/oras-go v1.2.4 // 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 -) - -require ( - atomicgo.dev/cursor v0.2.0 // indirect - atomicgo.dev/keyboard v0.2.9 // indirect - atomicgo.dev/schedule v0.1.0 // indirect dario.cat/mergo v1.0.0 // indirect github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect @@ -168,10 +105,25 @@ require ( github.com/Azure/go-autorest/logger v0.2.1 // indirect github.com/Azure/go-autorest/tracing v0.6.0 // indirect github.com/BurntSushi/toml v1.3.2 // indirect + github.com/KyleBanks/depth v1.2.1 // indirect github.com/MakeNowJust/heredoc v1.0.0 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/Microsoft/hcsshim v0.11.0 // indirect github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect github.com/agext/levenshtein v1.2.1 // indirect + github.com/ajg/form v1.5.1 // indirect + github.com/alibabacloud-go/darabonba-array v0.1.0 // indirect + github.com/alibabacloud-go/darabonba-encode-util v0.0.2 // indirect + github.com/alibabacloud-go/darabonba-map v0.0.2 // indirect + github.com/alibabacloud-go/darabonba-string v1.0.2 // indirect + github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 // indirect + github.com/alibabacloud-go/openapi-util v0.1.0 // indirect + github.com/alibabacloud-go/tea v1.2.1 // indirect + github.com/alibabacloud-go/tea-utils v1.3.1 // indirect + github.com/alibabacloud-go/tea-utils/v2 v2.0.3 // indirect + github.com/aliyun/alibaba-cloud-sdk-go v1.61.1800 // indirect + github.com/aliyun/alibabacloud-dkms-gcs-go-sdk v0.5.1 // indirect + github.com/aliyun/alibabacloud-dkms-transfer-go-sdk v0.1.8 // indirect github.com/aliyun/aliyun-secretsmanager-client-go v1.1.4 github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.16.6 // indirect @@ -187,6 +139,7 @@ require ( github.com/aws/smithy-go v1.17.0 // indirect github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect github.com/beorn7/perks v1.0.1 // indirect + github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/cenkalti/backoff/v3 v3.0.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/chai2010/jsonv v1.1.3 // indirect @@ -194,7 +147,10 @@ require ( github.com/cloudflare/circl v1.3.7 // indirect github.com/containerd/console v1.0.3 // indirect github.com/containerd/containerd v1.7.6 // indirect + github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect + github.com/cyphar/filepath-securejoin v0.2.4 // indirect + github.com/deckarep/golang-set v1.7.1 // indirect github.com/dimchansky/utfbom v1.1.1 // indirect github.com/docker/cli v24.0.6+incompatible // indirect github.com/docker/distribution v2.8.2+incompatible // indirect @@ -203,9 +159,12 @@ require ( github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-metrics v0.0.1 // indirect github.com/docker/go-units v0.5.0 // indirect + github.com/dominikbraun/graph v0.23.0 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/fatih/color v1.13.0 // indirect + github.com/felixge/httpsnoop v1.0.4 // indirect + github.com/go-errors/errors v1.4.2 // indirect 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.0 // indirect @@ -213,6 +172,7 @@ require ( 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 + github.com/go-openapi/spec v0.21.0 // indirect github.com/go-openapi/swag v0.23.0 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/gofrs/flock v0.8.1 // indirect @@ -223,25 +183,38 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.4 // indirect + github.com/google/btree v1.0.1 // indirect + 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-20211214055906-6f57359322fd // 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 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect + github.com/googleapis/gax-go/v2 v2.12.0 // indirect github.com/gookit/color v1.5.4 // indirect github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect github.com/gorilla/mux v1.8.1 // indirect + github.com/gorilla/websocket v1.5.0 // indirect github.com/gosuri/uilive v0.0.4 // indirect + github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect + github.com/hashicorp/go-getter v1.7.4 // indirect github.com/hashicorp/go-retryablehttp v0.6.6 // indirect github.com/hashicorp/go-rootcerts v1.0.2 // indirect + github.com/hashicorp/go-safetemp v1.0.0 // indirect github.com/hashicorp/go-secure-stdlib/parseutil v0.1.6 // indirect github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect github.com/hashicorp/go-sockaddr v1.0.2 // indirect github.com/hashicorp/hc-install v0.6.2 github.com/hashicorp/hcl v1.0.0 // indirect + github.com/hashicorp/yamux v0.1.1 // indirect github.com/imdario/mergo v0.3.16 github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.5 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -250,6 +223,7 @@ require ( github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/klauspost/compress v1.16.7 // indirect github.com/kylelemons/godebug v1.1.0 // indirect + github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect github.com/lithammer/fuzzysearch v1.1.8 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-ciede2000 v0.0.0-20170301095244-782e8c62fec3 // indirect @@ -259,6 +233,7 @@ require ( github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-ps v1.0.0 + github.com/mitchellh/go-testing-interface v1.14.1 // indirect 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 @@ -266,11 +241,16 @@ require ( 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 + github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect github.com/morikuni/aec v1.0.0 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect + github.com/oklog/run v1.0.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/opencontainers/image-spec v1.1.0-rc5 // indirect + github.com/opencontainers/image-spec v1.1.0 // indirect + github.com/orcaman/concurrent-map v0.0.0-20210501183033-44dafcb38ecc // indirect github.com/otiai10/copy v1.12.0 // indirect + github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/powerman/rpc-codec v1.2.2 // indirect @@ -279,7 +259,7 @@ require ( github.com/prometheus/common v0.44.0 // indirect github.com/prometheus/procfs v0.11.1 // indirect github.com/rivo/uniseg v0.4.4 // indirect - github.com/rogpeppe/go-internal v1.11.0 // indirect + github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/ryanuber/go-glob v1.0.0 // indirect github.com/satori/go.uuid v1.2.0 // indirect @@ -288,15 +268,24 @@ require ( github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect github.com/smartystreets/goconvey v1.6.4 // indirect github.com/spf13/pflag v1.0.5 + github.com/swaggo/files v1.0.1 // indirect github.com/thoas/go-funk v0.9.3 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect + github.com/tjfoc/gmsm v1.4.1 // indirect + github.com/ulikunitz/xz v0.5.10 // indirect + github.com/vbatts/tar-split v0.11.3 // indirect github.com/virtuald/go-ordered-json v0.0.0-20170621173500-b18e6e673d74 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect + github.com/xlab/treeprint v1.2.0 // indirect 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.46.1 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/trace v1.21.0 // indirect + go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect go.uber.org/multierr v1.10.0 // indirect golang.org/x/arch v0.1.0 // indirect golang.org/x/crypto v0.21.0 @@ -310,18 +299,24 @@ require ( golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.19.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect + google.golang.org/api v0.155.0 // indirect google.golang.org/appengine v1.6.8 // indirect + google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect google.golang.org/grpc v1.62.0 google.golang.org/protobuf v1.33.0 gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/ini.v1 v1.66.2 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect k8s.io/klog/v2 v2.120.1 k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect + kcl-lang.io/lib v0.8.2 // indirect + oras.land/oras-go v1.2.4 // indirect oras.land/oras-go/v2 v2.3.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/structured-merge-diff/v4 v4.4.1 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) - -replace kcl-lang.io/kpm => github.com/KusionStack/kpm v0.8.4 diff --git a/go.sum b/go.sum index 883f1830..651a4b08 100644 --- a/go.sum +++ b/go.sum @@ -234,8 +234,6 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU= github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= -github.com/KusionStack/kpm v0.8.4 h1:6CfgJ4jIeLkbHyELct/dBu/tmlhuvhv8QcP8mJ4/bE8= -github.com/KusionStack/kpm v0.8.4/go.mod h1:3atE1tEbsSPaAuKslkADH1HTDi7SMWlDWllmuk2XsBA= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= @@ -533,8 +531,8 @@ github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9 github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= -github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= -github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM= +github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/goccy/go-yaml v1.11.3 h1:B3W9IdWbvrUu2OYQGwvU1nZtvMQJPBKgBUuweJjLj6I= github.com/goccy/go-yaml v1.11.3/go.mod h1:wKnAMd44+9JAAnGQpWVEgBzGt3YuTaQ4uXoHvE4m7WU= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= @@ -709,8 +707,8 @@ github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-getter v1.7.3 h1:bN2+Fw9XPFvOCjB0UOevFIMICZ7G2XSQHzfvLUyOM5E= -github.com/hashicorp/go-getter v1.7.3/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= +github.com/hashicorp/go-getter v1.7.4 h1:3yQjWuxICvSpYwqSayAdKRFcvBl1y/vogCxczWSmix0= +github.com/hashicorp/go-getter v1.7.4/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v0.16.2 h1:K4ev2ib4LdQETX5cSZBG0DVLk1jwGqSPXBjdah3veNs= github.com/hashicorp/go-hclog v0.16.2/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= @@ -909,8 +907,8 @@ github.com/onsi/gomega v1.31.0 h1:54UJxxj6cPInHS3a35wm6BK/F9nHYueZ1NVujHDrnXE= github.com/onsi/gomega v1.31.0/go.mod h1:DW9aCi7U6Yi40wNVAvT6kzFnEVEI5n3DloYBiKiT6zk= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI= -github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= +github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= +github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= github.com/orcaman/concurrent-map v0.0.0-20210501183033-44dafcb38ecc h1:Ak86L+yDSOzKFa7WM5bf5itSOo1e3Xh8bm5YCMUXIjQ= github.com/orcaman/concurrent-map v0.0.0-20210501183033-44dafcb38ecc/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI= github.com/otiai10/copy v1.12.0 h1:cLMgSQnXBs1eehF0Wy/FAGsgDTDmAqFR7rQylBb1nDY= @@ -968,8 +966,8 @@ github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= @@ -1754,6 +1752,8 @@ kcl-lang.io/kcl-go v0.8.2 h1:XbF7NJ2dHXREmZx/dJSvEdMdaOM9NA8ePZj3LdcEZ34= kcl-lang.io/kcl-go v0.8.2/go.mod h1:KLPIalP4jr19KUqnXWbe2sVNEMEH7EhnsXH+ihnTUQw= kcl-lang.io/kcl-plugin v0.5.0 h1:eoh6y4l81rwA8yhJXU4hN7YmJeTUNB1nfYCP9OffSxc= kcl-lang.io/kcl-plugin v0.5.0/go.mod h1:QnZ5OLcyBw5nOnHpChRHtvBq8wvjwiHu/ZZ8j1dfz48= +kcl-lang.io/kpm v0.8.6-0.20240428063742-f3e75d94c905 h1:c3QhaGQG/c6jbX7n1ZRQBe+UbeobTqvsl3ffJ0A0+RM= +kcl-lang.io/kpm v0.8.6-0.20240428063742-f3e75d94c905/go.mod h1:ws42LNStszL2UJ/fA6Zmof+XTAPbrJRTOlThDqB5jsA= kcl-lang.io/lib v0.8.2 h1:G8Fm+eHSMpVOSNJhd5T41XgoKZjysHRU290q6Xotepk= kcl-lang.io/lib v0.8.2/go.mod h1:ubsalGXxJaa5II/EsHmsI/tL2EluYHIcW+BwzQPt+uY= kusionstack.io/kube-api v0.1.1 h1:ieoZhaUfK78hsyQ7GsU6ZuxBAcVU+ZuKs7vedGkO8sI= diff --git a/pkg/cmd/mod/mod_push.go b/pkg/cmd/mod/mod_push.go index c15951ff..a8e31f3e 100644 --- a/pkg/cmd/mod/mod_push.go +++ b/pkg/cmd/mod/mod_push.go @@ -4,6 +4,7 @@ import ( "context" "encoding/base64" "fmt" + "net/url" "os" "os/exec" "path/filepath" @@ -15,6 +16,7 @@ import ( v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/spf13/cobra" "k8s.io/cli-runtime/pkg/genericiooptions" + "kcl-lang.io/kpm/pkg/api" cmdutil "kusionstack.io/kusion/pkg/cmd/util" "kusionstack.io/kusion/pkg/oci" @@ -34,24 +36,24 @@ var ( pushExample = i18n.T(` # Push a module of current OS arch to an OCI Registry using a token - kusion mod push /path/to/my-module oci://ghcr.io/org/my-module --version=1.0.0 --creds + kusion mod push /path/to/my-module oci://ghcr.io/org --creds # Push a module of specific OS arch to an OCI Registry using a token - kusion mod push /path/to/my-module oci://ghcr.io/org/my-module --os-arch==darwin/arm64 --version=1.0.0 --creds + kusion mod push /path/to/my-module oci://ghcr.io/org --os-arch==darwin/arm64 --creds # Push a module to an OCI Registry using a credentials in : format. - kusion mod push /path/to/my-module oci://ghcr.io/org/my-module --version=1.0.0 --creds : + kusion mod push /path/to/my-module oci://ghcr.io/org --creds : # Push a release candidate without marking it as the latest stable - kusion mod push /path/to/my-module oci://ghcr.io/org/my-module --version=1.0.0-rc.1 --latest=false + kusion mod push /path/to/my-module oci://ghcr.io/org --latest=false # Push a module with custom OCI annotations - kusion mod push /path/to/my-module oci://ghcr.io/org/my-module --version=1.0.0 \ + kusion mod push /path/to/my-module oci://ghcr.io/org \ --annotation='org.opencontainers.image.documentation=https://app.org/docs' # Push and sign a module with Cosign (the cosign binary must be present in PATH) export COSIGN_PASSWORD=password - kusion mod push /path/to/my-module oci://ghcr.io/org/my-module --version=1.0.0 \ + kusion mod push /path/to/my-module oci://ghcr.io/org \ --sign=cosign --cosign-key=/path/to/cosign.key`) ) @@ -64,7 +66,6 @@ const LatestVersion = "latest" // // This structure reduces the transformation to wiring and makes the logic itself easy to unit test. type PushModFlags struct { - Version string Latest bool OSArch string Annotations []string @@ -83,6 +84,7 @@ type PushModOptions struct { OCIUrl string Latest bool OSArch string + Name string Version string Sign string CosignKey string @@ -129,7 +131,6 @@ func NewCmdPush(ioStreams genericiooptions.IOStreams) *cobra.Command { // AddFlags registers flags for a cli. func (flags *PushModFlags) AddFlags(cmd *cobra.Command) { - cmd.Flags().StringVarP(&flags.Version, "version", "v", "", "The version of the module e.g. '1.0.0' or '1.0.0-rc.1'.") cmd.Flags().StringVar(&flags.OSArch, "os-arch", "", "The os arch of the module e.g. 'darwin/arm64', 'linux/amd64'.") cmd.Flags().BoolVar(&flags.Latest, "latest", true, "Tags the current version as the latest stable module version.") cmd.Flags().StringVar(&flags.Credentials, "creds", flags.Credentials, @@ -148,11 +149,22 @@ func (flags *PushModFlags) ToOptions(args []string, ioStreams genericiooptions.I } // version - version := flags.Version - if _, err := semver.StrictNewVersion(version); err != nil { + kclPkg, err := api.GetKclPackage(args[0]) + if err != nil { + return nil, err + } + version := kclPkg.GetVersion() + if _, err = semver.StrictNewVersion(version); err != nil { return nil, fmt.Errorf("version is not in semver format: %w", err) } + name := kclPkg.GetPkgName() + if name == "" { + return nil, fmt.Errorf("module name is empty") + } + + ociURL := strings.TrimRight(args[1], "/") + "/" + name + // If creds in format, creds must be base64 encoded if len(flags.Credentials) != 0 && !strings.Contains(flags.Credentials, ":") { flags.Credentials = base64.StdEncoding.EncodeToString([]byte(flags.Credentials)) @@ -205,12 +217,13 @@ func (flags *PushModFlags) ToOptions(args []string, ioStreams genericiooptions.I opt := &PushModOptions{ ModulePath: args[0], - OCIUrl: args[1], + OCIUrl: ociURL, Latest: flags.Latest, Sign: flags.Sign, CosignKey: flags.CosignKey, Client: client, Metadata: meta, + Name: name, Version: version, IOStreams: ioStreams, } @@ -224,7 +237,10 @@ func (o *PushModOptions) Validate() error { return fmt.Errorf("no module found at path %s", o.ModulePath) } - // TODO: add oci url validation + _, err := url.Parse(o.OCIUrl) + if err != nil { + return fmt.Errorf("illegal oci url:%s, %w", o.OCIUrl, err) + } return nil } @@ -322,10 +338,6 @@ func (o *PushModOptions) buildModule() (string, error) { pOS := o.Metadata.Platform.OS pArch := o.Metadata.Platform.Architecture - // OCIUrl example: oci://ghcr.io/org/my-module - split := strings.Split(o.OCIUrl, "/") - name := split[len(split)-1] - if matches, err := filepath.Glob(goFileSearchPattern); err != nil || len(matches) == 0 { return "", fmt.Errorf("no go source code files found for 'go build' matching %s", goFileSearchPattern) } @@ -335,7 +347,7 @@ func (o *PushModOptions) buildModule() (string, error) { return "", fmt.Errorf("unable to find executable 'go' binary: %w", err) } - output := filepath.Join(targetDir, "_dist", pOS, pArch, "kusion-module-"+name+"_"+o.Version) + output := filepath.Join(targetDir, "_dist", pOS, pArch, "kusion-module-"+o.Name+"_"+o.Version) if strings.Contains(o.OSArch, "windows") { output += ".exe" }