diff --git a/cmd/kcl/commands/mod_push.go b/cmd/kcl/commands/mod_push.go index a36d564..b6feb06 100644 --- a/cmd/kcl/commands/mod_push.go +++ b/cmd/kcl/commands/mod_push.go @@ -7,9 +7,9 @@ import ( "github.com/spf13/cobra" "kcl-lang.io/kpm/pkg/client" + "kcl-lang.io/kpm/pkg/downloader" "kcl-lang.io/kpm/pkg/errors" kpmoci "kcl-lang.io/kpm/pkg/oci" - "kcl-lang.io/kpm/pkg/opt" pkg "kcl-lang.io/kpm/pkg/package" "kcl-lang.io/kpm/pkg/reporter" "kcl-lang.io/kpm/pkg/utils" @@ -164,24 +164,21 @@ func pushPackage(ociUrl string, kclPkg *pkg.KclPkg, vendorMode bool, cli *client ) } } - - // 3. Generate the OCI options from oci url and the version of current kcl package. - ociOpts, err := opt.ParseOciOptionFromOciUrl(ociUrl, kclPkg.GetPkgTag()) - if err != (*reporter.KpmEvent)(nil) { - return reporter.NewErrorEvent( - reporter.UnsupportOciUrlScheme, - errors.InvalidOciUrl, - "only support url scheme 'oci://'.", - ) - } - ociOpts.Annotations, err = kclPkg.GenOciManifestFromPkg() + // 4. Push it. + ociSource := downloader.Source{} + err = ociSource.FromString(ociUrl) if err != nil { return err } - - reporter.ReportMsgTo(fmt.Sprintf("package '%s' will be pushed", kclPkg.GetPkgName()), cli.GetLogWriter()) - // 4. Push it. - err = cli.PushToOci(tarPath, ociOpts) + ociSource.ModSpec = &downloader.ModSpec{ + Name: kclPkg.GetPkgName(), + Version: kclPkg.GetPkgTag(), + } + err = cli.Push( + client.WithPushModPath(kclPkg.HomePath), + client.WithPushSource(ociSource), + client.WithPushVendorMode(vendorMode), + ) if err != (*reporter.KpmEvent)(nil) { return err } diff --git a/go.mod b/go.mod index 6592f83..d92e6e3 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( kcl-lang.io/kcl-go v0.10.8 kcl-lang.io/kcl-openapi v0.10.0 kcl-lang.io/kcl-plugin v0.6.0 - kcl-lang.io/kpm v0.11.0-alpha.1 + kcl-lang.io/kpm v0.11.0-alpha.2 ) require ( @@ -36,7 +36,7 @@ require ( github.com/dchest/siphash v1.2.3 // indirect github.com/distribution/reference v0.6.0 // indirect github.com/ebitengine/purego v0.7.1 // indirect - github.com/elliotchance/orderedmap/v2 v2.4.0 // indirect + github.com/elliotchance/orderedmap/v2 v2.5.0 // indirect github.com/emicklei/proto v1.13.2 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect diff --git a/go.sum b/go.sum index 26fe1c7..214fff8 100644 --- a/go.sum +++ b/go.sum @@ -378,8 +378,8 @@ github.com/ebitengine/purego v0.7.1/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2 github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU= github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= -github.com/elliotchance/orderedmap/v2 v2.4.0 h1:6tUmMwD9F998FNpwFxA5E6NQvSpk2PVw7RKsVq3+2Cw= -github.com/elliotchance/orderedmap/v2 v2.4.0/go.mod h1:85lZyVbpGaGvHvnKa7Qhx7zncAdBIBq6u56Hb1PRU5Q= +github.com/elliotchance/orderedmap/v2 v2.5.0 h1:WRPmWGChucaZ09eEd3UkU8XfVajv6ZZ6eg3+x0cLWPM= +github.com/elliotchance/orderedmap/v2 v2.5.0/go.mod h1:85lZyVbpGaGvHvnKa7Qhx7zncAdBIBq6u56Hb1PRU5Q= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/proto v1.13.2 h1:z/etSFO3uyXeuEsVPzfl56WNgzcvIr42aQazXaQmFZY= @@ -1697,8 +1697,8 @@ kcl-lang.io/kcl-openapi v0.10.0 h1:yetZMSnn/HHaMcfiLt1P2zhCF06O33jxkjtHrm08VR8= kcl-lang.io/kcl-openapi v0.10.0/go.mod h1:kGCf0AZygrZyB+xpmMtiC3FYoiV/1rCLXuAq2QtuLf8= kcl-lang.io/kcl-plugin v0.6.0 h1:rBdoqKDPdOtojeOHCFnXoB/I7ltFjV61r0KkfOcL5sE= kcl-lang.io/kcl-plugin v0.6.0/go.mod h1:LoIouleHYRKAvFcdW30yUlhsMYH2W9zD5Ji1XHfbht4= -kcl-lang.io/kpm v0.11.0-alpha.1 h1:WZDfCQDinyWionkLDYe56IEeCJpcCYTAwZJtIrtCyFg= -kcl-lang.io/kpm v0.11.0-alpha.1/go.mod h1:/G40SABMTuPEVaD1lp0nvPx4v1TIvxIuDwNCV6N9YSU= +kcl-lang.io/kpm v0.11.0-alpha.2 h1:EwWt9oedkB20E7ypnR8OOxxL1oNzdOrNhnDU7vsJ9no= +kcl-lang.io/kpm v0.11.0-alpha.2/go.mod h1:Z7df8c7NwWm8KNFGd6vmO0F6LArxtuN5a2eGVY95/1g= kcl-lang.io/lib v0.10.8 h1:/Mhko6fngIstvdx9dAS3H6N1utogkWfoARVj643l5nU= kcl-lang.io/lib v0.10.8/go.mod h1:0Dw/MQwRMjLDksxl4JerGBn/ueaxRyCCKBCCwQwJ1MI= oras.land/oras-go v1.2.6 h1:z8cmxQXBU8yZ4mkytWqXfo6tZcamPwjsuxYU81xJ8Lk= diff --git a/scripts/e2e/pull_pkg.sh b/scripts/e2e/pull_pkg.sh index 992cf5d..e5a2f6d 100755 --- a/scripts/e2e/pull_pkg.sh +++ b/scripts/e2e/pull_pkg.sh @@ -13,6 +13,11 @@ cd ./scripts/e2e/pkg_in_reg/ # Check if file exists + +if [ ! -d "./oci/ghcr.io/kcl-lang/k8s/1.27/k8s/1.27" ]; then + $current_dir/bin/kcl mod pull k8s:1.27 +fi + if [ ! -d "./oci/ghcr.io/kcl-lang/k8s/1.28/k8s/1.28" ]; then $current_dir/bin/kcl mod pull k8s:1.28 fi diff --git a/scripts/e2e/push_pkg.sh b/scripts/e2e/push_pkg.sh index c255b81..cd6e7ac 100755 --- a/scripts/e2e/push_pkg.sh +++ b/scripts/e2e/push_pkg.sh @@ -11,6 +11,11 @@ echo $current_dir $current_dir/bin/kcl registry login -u test -p 1234 localhost:5001 +cd ./scripts/e2e/pkg_in_reg/oci/ghcr.io/kcl-lang/k8s/1.27/k8s/1.27 +$current_dir/bin/kcl mod push + +cd "$current_dir" + cd ./scripts/e2e/pkg_in_reg/oci/ghcr.io/kcl-lang/k8s/1.28/k8s/1.28 $current_dir/bin/kcl mod push