Skip to content

Commit

Permalink
Merge pull request kcl-lang#327 from officialasishkumar/fix-322
Browse files Browse the repository at this point in the history
feat: prohibit packaging and uploading when there are local dependencies
  • Loading branch information
Peefy committed May 21, 2024
2 parents 3a66dfe + 16833c6 commit 0b0b423
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/cmd/cmd_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ func pushCurrentPackage(ociUrl string, vendorMode bool, kpmcli *client.KpmClient
return err
}

if kclPkg.ModFile.Dependencies.CheckForLocalDeps() {
reporter.ReportEventToStdout(reporter.NewEvent(reporter.FailedPush, "local dependencies exist, cannot be packaged into tar and pushed."))
return nil
}

// 2. push the package
return pushPackage(ociUrl, kclPkg, vendorMode, kpmcli)
}
Expand All @@ -122,6 +127,11 @@ func pushTarPackage(ociUrl, localTarPath string, vendorMode bool, kpmcli *client
return err
}

if kclPkg.ModFile.Dependencies.CheckForLocalDeps() {
reporter.ReportEventToStdout(reporter.NewEvent(reporter.FailedPush, "local dependencies exist, cannot be pushed."))
return nil
}

// 2. push the package
return pushPackage(ociUrl, kclPkg, vendorMode, kpmcli)
}
Expand Down
9 changes: 9 additions & 0 deletions pkg/package/modfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ func (deps *Dependencies) ToDepMetadata() (*Dependencies, error) {
return &depMetadata, nil
}

func (deps *Dependencies) CheckForLocalDeps() bool {
for _, dep := range deps.Deps {
if dep.IsFromLocal() {
return true
}
}
return false
}

type Dependency struct {
Name string `json:"name" toml:"name,omitempty"`
FullName string `json:"-" toml:"full_name,omitempty"`
Expand Down

0 comments on commit 0b0b423

Please sign in to comment.