From 6a1949364af2ac01ac1723608d49dbd1b607d190 Mon Sep 17 00:00:00 2001 From: zongz Date: Tue, 12 Nov 2024 20:37:06 +0800 Subject: [PATCH] fix: fix if case Signed-off-by: zongz --- pkg/package/package.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) 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, }, }