diff --git a/pkg/package/package.go b/pkg/package/package.go index c7f10913..87a8d949 100644 --- a/pkg/package/package.go +++ b/pkg/package/package.go @@ -74,11 +74,8 @@ func LoadKclPkgWithOpts(options ...LoadOption) (*KclPkg, error) { } pkgPath := opts.Path - var loadSettings *settings.Settings if opts.Settings == nil { - loadSettings = settings.GetSettings() - } else { - loadSettings = opts.Settings + opts.Settings = settings.GetSettings() } modFile := new(ModFile) @@ -120,7 +117,7 @@ func LoadKclPkgWithOpts(options ...LoadOption) (*KclPkg, error) { return nil, fmt.Errorf("could not load 'kcl.mod' in '%s'\n%w", pkgPath, err) } // 2. Fill the default oci registry, the default oci registry is in the settings. - err = fillDepsInfoWithSettings(&modFile.Dependencies, loadSettings) + err = fillDepsInfoWithSettings(&modFile.Dependencies, opts.Settings) if err != nil { return nil, fmt.Errorf("could not load 'kcl.mod' in '%s'\n%w", pkgPath, err) } @@ -142,8 +139,8 @@ func LoadKclPkgWithOpts(options ...LoadOption) (*KclPkg, error) { Version: lockDep.Version, }, Oci: &downloader.Oci{ - Reg: loadSettings.DefaultOciRegistry(), - Repo: utils.JoinPath(loadSettings.DefaultOciRepo(), lockDep.Name), + Reg: opts.Settings.DefaultOciRegistry(), + Repo: utils.JoinPath(opts.Settings.DefaultOciRepo(), lockDep.Name), Tag: lockDep.Version, }, }