kcl-lang / kcl-go

KCL Go SDK
https://pkg.go.dev/kcl-lang.io/kcl-go@main
Apache License 2.0
52 stars 26 forks source link

[Enhancement] `kcl-lang.io/kcl-go` has too many third-party dependencies #359

Closed bozaro closed 3 months ago

bozaro commented 3 months ago

Enhancement

kcl-lang.io/kcl-go has too many third-party dependencies. This causes problems.

For example, the kcl-lang.io/kcl-go update also updates the github.com/prometheus/common module wich is incompatible with latest released k8s.io/component-base (github.com/prometheus/common requires https://github.com/kubernetes/kubernetes/commit/35ccdc8b35f1c4346071d4ff0efecdd7a6bcdecc commit).

It looks like the main number of strange dependencies is getting by kcl-lang.io/kpm package. Used only in this line: https://github.com/kcl-lang/kcl-go/blob/55f78337a18f851e95f4bb45e01d8f29ac61d977/pkg/tools/gen/genopenapi.go#L74

Module dependecy path example:

➜  kcl-go git:(main) go mod why -m github.com/prometheus/common github.com/aws/aws-sdk-go github.com/containerd/containerd github.com/docker/cli github.com/go-git/go-git/v5
# github.com/prometheus/common
kcl-lang.io/kcl-go/pkg/tools/gen
kcl-lang.io/kpm/pkg/api
kcl-lang.io/kpm/pkg/oci
oras.land/oras-go/pkg/auth/docker
oras.land/oras-go/pkg/auth/docker.test
github.com/distribution/distribution/v3/registry
github.com/docker/go-metrics
github.com/prometheus/client_golang/prometheus
github.com/prometheus/common/expfmt

# github.com/aws/aws-sdk-go
kcl-lang.io/kcl-go/pkg/tools/gen
kcl-lang.io/kpm/pkg/api
kcl-lang.io/kpm/pkg/client
kcl-lang.io/kpm/pkg/git
github.com/hashicorp/go-getter
github.com/aws/aws-sdk-go/aws

# github.com/containerd/containerd
kcl-lang.io/kcl-go/pkg/tools/gen
kcl-lang.io/kpm/pkg/api
kcl-lang.io/kpm/pkg/client
oras.land/oras-go/pkg/auth
github.com/containerd/containerd/remotes

# github.com/docker/cli
kcl-lang.io/kcl-go/pkg/tools/gen
kcl-lang.io/kpm/pkg/api
kcl-lang.io/kpm/pkg/oci
oras.land/oras-go/pkg/auth/docker
github.com/docker/cli/cli/config

# github.com/go-git/go-git/v5
kcl-lang.io/kcl-go/pkg/tools/gen
kcl-lang.io/kpm/pkg/api
kcl-lang.io/kpm/pkg/client
kcl-lang.io/kpm/pkg/git
github.com/go-git/go-git/v5

It may make sense to separate the KCL client runtime and the utilities to different go.mod files.

Peefy commented 3 months ago

This is indeed a problem, a very good suggestion. 👍 I will refactor it within this week. cc @zong-zhe