-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: the package replace logic when using tag, branch or commit (#2299)
## Description Fix the package replace logic when using tag, branch or commit The current issue is the `package replace logic` fails when you add a tag, branch or commit in the replace value, like this example: `replace: - github.com/kurtosis-tech/ethereum-package: github.com/kurtosis-tech/ethereum-package@da55be84861e93ce777076e545abee35ff2d51ce` If we see the evaluation error `Evaluation error: An error occurred while loading the module 'github.com/kurtosis-tech/ethereum-package@da55be84861e93ce777076e545abee35ff2d51ce/src/package_io/input_parser.star' Caused by: '/input_parser.star' doesn't exist in the package 'kurtosis-tech/ethereum-package' at [github.com/kurtosis-tech/ethereum-package@da55be84861e93ce777076e545abee35ff2d51ce/main.star:1:29]: <toplevel> at [github.com/kurtosis-tech/awesome-kurtosis/chainlink-node/main.star:2:33]: <toplevel>` we understand it's trying to import the file from this path `github.com/kurtosis-tech/ethereum-package@da55be84861e93ce777076e545abee35ff2d51ce` and it doesn't exist because the folder, inside the APIC file system, is created without the hash, it's `github.com/kurtosis-tech/ethereum-package` This is happening because an absolute locator like this `github.com/kurtosis-tech/ethereum-package/src/package_io/input_parser.star` does not incorporate the concept of hash, branch or commit. The fix is incorporated the concept of `hash, branch or commit` in a new AbsoluteLocator object, so this way we can specify if the absolute locator is pointing to other place than the main branch. With this change we can accept the `github.com/kurtosis-tech/ethereum-package@da55be84861e93ce777076e545abee35ff2d51ce` replace value and an absolute locator string like this `github.com/kurtosis-tech/ethereum-package@da55be84861e93ce777076e545abee35ff2d51ce/src/package_io/input_parser.star` will be represented with an AbsoluteLocator object with locator `github.com/kurtosis-tech/ethereum-package/src/package_io/input_parser.star` and and tagBranchOrCommit `da55be84861e93ce777076e545abee35ff2d51ce` We already had support for retrieving packages from different tag, branch or commit but only for `packageId` values and not for `absolute locators` ## REMINDER: Tag Reviewers, so they get notified to review ## Is this change user facing? YES ## References (if applicable) Fix #2279
- Loading branch information
Showing
23 changed files
with
370 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
core/server/api_container/server/startosis_engine/startosis_packages/absolute_locator.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package startosis_packages | ||
|
||
import "fmt" | ||
|
||
const ( | ||
defaultMainBranch = "" | ||
) | ||
|
||
// PackageAbsoluteLocator represents the absolute locator for a file in a Kurtosis package | ||
type PackageAbsoluteLocator struct { | ||
// it is the file locator value | ||
locator string | ||
// indicates if the absolute locator correspond to a specific tag, branch or commit | ||
// the zero value (empty string) correspond to the main (or master) branch | ||
tagBranchOrCommit string | ||
} | ||
|
||
func NewPackageAbsoluteLocator(locator string, tagBranchOrCommit string) *PackageAbsoluteLocator { | ||
return &PackageAbsoluteLocator{locator: locator, tagBranchOrCommit: tagBranchOrCommit} | ||
} | ||
|
||
func (packageAbsoluteLocator *PackageAbsoluteLocator) GetLocator() string { | ||
return packageAbsoluteLocator.locator | ||
} | ||
|
||
func (packageAbsoluteLocator *PackageAbsoluteLocator) GetTagBranchOrCommit() string { | ||
return packageAbsoluteLocator.tagBranchOrCommit | ||
} | ||
|
||
func (packageAbsoluteLocator *PackageAbsoluteLocator) GetGitURL() string { | ||
if packageAbsoluteLocator.tagBranchOrCommit == defaultMainBranch { | ||
return packageAbsoluteLocator.locator | ||
} | ||
return fmt.Sprintf("%s@%s", packageAbsoluteLocator.locator, packageAbsoluteLocator.tagBranchOrCommit) | ||
} |
Oops, something went wrong.