Skip to content

Commit

Permalink
fix: move push on API Push
Browse files Browse the repository at this point in the history
Signed-off-by: zongz <[email protected]>
  • Loading branch information
zong-zhe committed Dec 9, 2024
1 parent b734242 commit ab04451
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
29 changes: 13 additions & 16 deletions cmd/kcl/commands/mod_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
5 changes: 5 additions & 0 deletions scripts/e2e/pull_pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions scripts/e2e/push_pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ab04451

Please sign in to comment.