Skip to content

Commit

Permalink
Merge pull request #137 from Peefy/chore-bump-kcl-go-and-kpm-to-0.10.…
Browse files Browse the repository at this point in the history
…0-beta.2

chore: bump kcl-go and kpm to v0.10.0-beta.2
  • Loading branch information
Peefy authored Aug 22, 2024
2 parents 5d2c8b7 + faed4b4 commit 82bf482
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 92 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# Reference from:
# https://github.com/c-bata/go-prompt/blob/master/.github/workflows/test.yml
name: CI
on: [push, pull_request]
on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
Test:
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/example-e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ on:
- main
jobs:
ubuntu:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ ubuntu-20.04, ubuntu-22.04, ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
Expand All @@ -28,7 +31,7 @@ jobs:
macos:
strategy:
matrix:
os: [macos-12, macos-13, macos-latest]
os: [ macos-12, macos-13, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand Down
145 changes: 77 additions & 68 deletions cmd/kcl/commands/mod_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
const (
modAddDesc = `This command adds new dependency
`
modAddExample = ` # Add the module dependency named "k8s"
modAddExample = ` # Add the module dependency named "k8s" from the default OCI registry
kcl mod add k8s
# Add the module dependency named "k8s" with the version "1.28"
# Add the module dependency named "k8s" with the version "1.28" from the default OCI registry
kcl mod add k8s:1.28
# Add the module dependency from the GitHub by git url
Expand All @@ -33,10 +33,13 @@ const (
# Add the module dependency from the local file system by file url
kcl mod add /path/to/another_module
# Add the module dependency from the GitHub by flag
# Add the module dependency from the GitHub by the tag flag
kcl mod add --git https://github.com/kcl-lang/konfig --tag v0.4.0
# Add the module dependency from the OCI Registry by flag
# Add the sub module dependency named "helloworld" from the Git repo by the tag flag
kcl mod add helloworld --git https://github.com/kcl-lang/modules --tag v0.1.0
# Add the module dependency from the OCI registry named "" by the tag flag
kcl mod add --oci https://ghcr.io/kcl-lang/helloworld --tag 0.1.0`
)

Expand All @@ -58,6 +61,7 @@ func NewModAddCmd(cli *client.KpmClient) *cobra.Command {
cmd.Flags().StringVar(&tag, "tag", "", "git or oci repository tag")
cmd.Flags().StringVar(&commit, "commit", "", "git repository commit")
cmd.Flags().StringVar(&branch, "branch", "", "git repository branch")
cmd.Flags().StringVar(&path, "path", "", "filesystem path to local dependency to add")
cmd.Flags().StringVar(&rename, "rename", "", "rename the dependency")
cmd.Flags().BoolVar(&noSumCheck, "no_sum_check", false, "do not check the checksum of the package and update kcl.mod.lock")

Expand Down Expand Up @@ -133,73 +137,80 @@ func ModAdd(cli *client.KpmClient, args []string) error {
// parseAddOptions will parse the user cli inputs.
func parseAddOptions(cli *client.KpmClient, localPath string, args []string) (*opt.AddOptions, error) {
// parse the CLI command with the following style
// kcl mod add <package>
// kcl mod add <package>:<version>
// kcl mod add /path/to/xxx
// kcl mod add https://xxx/xxx --tag 0.0.1
// kcl mod add oci://xxx/xxx --tag 0.0.1
//
// kcl mod add --git https://xxx/xxx --tag 0.0.1
// kcl mod add <sub_package> --git https://xxx/xxx --tag 0.0.1
// kcl mod add --oci https://xxx/xxx --tag 0.0.1
// kcl mod add <sub_package> --oci https://xxx/xxx --tag 0.0.1
// kcl mod add --path /path/to/xxx
if len(args) == 0 {
if len(git) != 0 {
gitUrl, err := url.Parse(git)
if err != nil {
return nil, err
}
gitOpt := opt.NewGitOptionsFromUrl(gitUrl)
if gitOpt == nil {
return nil, fmt.Errorf("invalid git url '%s'", git)
}

gitOpt.Tag = tag
gitOpt.Commit = commit
gitOpt.Branch = branch

return &opt.AddOptions{
LocalPath: localPath,
RegistryOpts: opt.RegistryOptions{Git: gitOpt},
NoSumCheck: noSumCheck,
NewPkgName: rename,
}, nil
} else if len(oci) != 0 {
ociUrl, err := url.Parse(oci)
if err != nil {
return nil, err
}
ociOpt := opt.NewOciOptionsFromUrl(ociUrl)
if ociOpt == nil {
return nil, fmt.Errorf("invalid oci url '%s'", oci)
}
ociOpt.Tag = tag

return &opt.AddOptions{
LocalPath: localPath,
RegistryOpts: opt.RegistryOptions{Oci: ociOpt},
NoSumCheck: noSumCheck,
NewPkgName: rename,
}, nil
} else if len(path) != 0 {
pathUrl, err := url.Parse(path)
if err != nil {
return nil, err
}

pathOpt, err := opt.NewLocalOptionsFromUrl(pathUrl)
if err != (*reporter.KpmEvent)(nil) {
return nil, err
}

return &opt.AddOptions{
LocalPath: localPath,
RegistryOpts: opt.RegistryOptions{Local: pathOpt},
NoSumCheck: noSumCheck,
NewPkgName: rename,
}, nil
// kcl mod add <sub_package> --path /path/to/xxx
if len(git) != 0 {
gitUrl, err := url.Parse(git)
if err != nil {
return nil, err
}
gitOpts := opt.NewGitOptionsFromUrl(gitUrl)
if gitOpts == nil {
return nil, fmt.Errorf("invalid git url '%s'", git)
}
gitOpts.Tag = tag
gitOpts.Commit = commit
gitOpts.Branch = branch
// Git sub package.
if len(args) > 0 {
gitOpts.Package = args[len(args)-1]
}
return &opt.AddOptions{
LocalPath: localPath,
RegistryOpts: opt.RegistryOptions{Git: gitOpts},
NoSumCheck: noSumCheck,
NewPkgName: rename,
}, nil
} else if len(oci) != 0 {
ociUrl, err := url.Parse(oci)
if err != nil {
return nil, err
}
ociOpts := opt.NewOciOptionsFromUrl(ociUrl)
if ociOpts == nil {
return nil, fmt.Errorf("invalid oci url '%s'", oci)
}
ociOpts.Tag = tag
// OCI sub package
if len(args) > 0 {
ociOpts.Package = args[len(args)-1]
}
return &opt.AddOptions{
LocalPath: localPath,
RegistryOpts: opt.RegistryOptions{Oci: ociOpts},
NoSumCheck: noSumCheck,
NewPkgName: rename,
}, nil
} else if len(path) != 0 {
pathUrl, err := url.Parse(path)
if err != nil {
return nil, err
}
pathOpts, err := opt.NewLocalOptionsFromUrl(pathUrl)
if err != (*reporter.KpmEvent)(nil) {
return nil, err
}
// Local path sub package
if len(args) > 0 {
pathOpts.Package = args[len(args)-1]
}
return &opt.AddOptions{
LocalPath: localPath,
RegistryOpts: opt.RegistryOptions{Local: pathOpts},
NoSumCheck: noSumCheck,
NewPkgName: rename,
}, nil
} else {
// parse the CLI command with the following style
// kcl mod add k8s
// kcl mod add k8s:0.0.1
// kcl mod add /path/to/xxx
// kcl mod add https://xxx/xxx --tag 0.0.1
// kcl mod add oci://xxx/xxx --tag 0.0.1

localPkg, err := parseLocalPathOptions(args)
pkgSource := argsGet(args, 0)
if err != (*reporter.KpmEvent)(nil) {
Expand Down Expand Up @@ -232,8 +243,6 @@ func parseAddOptions(cli *client.KpmClient, localPath string, args []string) (*o
}, nil
}
}

return nil, fmt.Errorf("invalid add options")
}

// parseLocalPathOptions will parse the local path information from user cli inputs.
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ require (
github.com/onsi/ginkgo/v2 v2.20.0
github.com/onsi/gomega v1.34.1
github.com/spf13/cobra v1.8.1
kcl-lang.io/kcl-go v0.10.0-beta.1
kcl-lang.io/kcl-go v0.10.0-beta.2
kcl-lang.io/kcl-openapi v0.8.0
kcl-lang.io/kcl-plugin v0.6.0
kcl-lang.io/kpm v0.10.0-alpha.3
kcl-lang.io/kpm v0.10.0-beta.2
)

require (
Expand All @@ -27,12 +27,12 @@ require (
github.com/containerd/errdefs v0.1.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/platforms v0.2.1 // indirect
github.com/containers/image/v5 v5.32.0 // indirect
github.com/containers/image/v5 v5.32.1 // indirect
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 // indirect
github.com/containers/ocicrypt v1.2.0 // indirect
github.com/containers/storage v1.55.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/elliotchance/orderedmap/v2 v2.2.0 // indirect
github.com/elliotchance/orderedmap/v2 v2.4.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
Expand All @@ -42,7 +42,7 @@ require (
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.2 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-getter v1.7.5 // indirect
github.com/hashicorp/go-getter v1.7.6 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/kubescape/go-git-url v0.0.30 // indirect
Expand All @@ -62,13 +62,13 @@ require (
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/time v0.5.0 // indirect
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
kcl-lang.io/lib v0.10.0-beta.1 // indirect
kcl-lang.io/lib v0.10.0-beta.2 // indirect
)

require (
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A=
github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw=
github.com/containers/image/v5 v5.32.0 h1:yjbweazPfr8xOzQ2hkkYm1A2V0jN96/kES6Gwyxj7hQ=
github.com/containers/image/v5 v5.32.0/go.mod h1:x5e0RDfGaY6bnQ13gJ2LqbfHvzssfB/y5a8HduGFxJc=
github.com/containers/image/v5 v5.32.1 h1:fVa7GxRC4BCPGsfSRs4JY12WyeY26SUYQ0NuANaCFrI=
github.com/containers/image/v5 v5.32.1/go.mod h1:v1l73VeMugfj/QtKI+jhYbwnwFCFnNGckvbST3rQ5Hk=
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 h1:Qzk5C6cYglewc+UyGf6lc8Mj2UaPTHy/iF2De0/77CA=
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01/go.mod h1:9rfv8iPl1ZP7aqh9YA68wnZv2NUDbXdcdPHVz0pFbPY=
github.com/containers/ocicrypt v1.2.0 h1:X14EgRK3xNFvJEfI5O4Qn4T3E25ANudSOZz/sirVuPM=
Expand Down Expand Up @@ -368,8 +368,8 @@ github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25Kn
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.2.0 h1:7/2iwO98kYT4XkOjA9mBEIwvi4KpGB4cyHeOFOnj4Vk=
github.com/elliotchance/orderedmap/v2 v2.2.0/go.mod h1:85lZyVbpGaGvHvnKa7Qhx7zncAdBIBq6u56Hb1PRU5Q=
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/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=
Expand Down Expand Up @@ -620,8 +620,8 @@ github.com/hashicorp/errwrap v1.0.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.5 h1:dT58k9hQ/vbxNMwoI5+xFYAJuv6152UNvdHokfI5wE4=
github.com/hashicorp/go-getter v1.7.5/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744=
github.com/hashicorp/go-getter v1.7.6 h1:5jHuM+aH373XNtXl9TNTUH5Qd69Trve11tHIrB+6yj4=
github.com/hashicorp/go-getter v1.7.6/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744=
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
Expand Down Expand Up @@ -1177,8 +1177,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.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs=
golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA=
golang.org/x/oauth2 v0.22.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=
Expand Down Expand Up @@ -1690,16 +1690,16 @@ k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk=
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
kcl-lang.io/kcl-go v0.10.0-beta.1 h1:SfP5yrsOjZ8TQweAqsF+R9giplmlxpwF+4nTY3HuD1c=
kcl-lang.io/kcl-go v0.10.0-beta.1/go.mod h1:CnvptPctRZPh9+rFdhlmlA3N1vF1xIb/RghbeeYo0Eo=
kcl-lang.io/kcl-go v0.10.0-beta.2 h1:MFARFYmDwjMhx1MZtJffMHrgPvHpEvyZivCPd6RrfFI=
kcl-lang.io/kcl-go v0.10.0-beta.2/go.mod h1:I8UMn+qt/yTxwzvz85ku9mil7xwHoOjTpMYgK+9IcAg=
kcl-lang.io/kcl-openapi v0.8.0 h1:/OAyn9nHW5Mvj6F2vL3KnRrEWJHf22T6rorfNEnwfXU=
kcl-lang.io/kcl-openapi v0.8.0/go.mod h1:ifq8MrgYQVIkJZctPYWgOxlR0+RSpSYgvEPW1/zMdEU=
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.10.0-alpha.3 h1:1lFC63/CEOFFEhyyAw6QVLTubru6c/HHC2H/axqiZVg=
kcl-lang.io/kpm v0.10.0-alpha.3/go.mod h1:gRRD/168OYKCSpjpEV7WiDEvhlwX5Xkvxr2cSjZ30UI=
kcl-lang.io/lib v0.10.0-beta.1 h1:VVMaYdzYXG2nnedzPeDYxwob0D1J2sbJH7zmKE4iXT4=
kcl-lang.io/lib v0.10.0-beta.1/go.mod h1:tu+tzwGgHLzYZSIxUG/ntipStrxZd6OvutWYPTxS7cs=
kcl-lang.io/kpm v0.10.0-beta.2 h1:qON9unqEmEwkcvIH1q67GnwuJr9u6eZhvVkRWtL7JC0=
kcl-lang.io/kpm v0.10.0-beta.2/go.mod h1:O2/0yBM7AaPE6JkKf9K7dF1wsj++ws7VQS6VtxnZsbk=
kcl-lang.io/lib v0.10.0-beta.2 h1:2C6flNt762+uH2GDzxxEVlG09NmWMOCedjoti0Kp4RQ=
kcl-lang.io/lib v0.10.0-beta.2/go.mod h1:tu+tzwGgHLzYZSIxUG/ntipStrxZd6OvutWYPTxS7cs=
oras.land/oras-go v1.2.6 h1:z8cmxQXBU8yZ4mkytWqXfo6tZcamPwjsuxYU81xJ8Lk=
oras.land/oras-go v1.2.6/go.mod h1:OVPc1PegSEe/K8YiLfosrlqlqTN9PUyFvOw5Y9gwrT8=
oras.land/oras-go/v2 v2.5.0 h1:o8Me9kLY74Vp5uw07QXPiitjsw7qNXi8Twd+19Zf02c=
Expand Down

0 comments on commit 82bf482

Please sign in to comment.