Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: impl dependency list flag #2543

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

feat: impl dependency list flag #2543

wants to merge 15 commits into from

Conversation

tedim52
Copy link
Contributor

@tedim52 tedim52 commented Aug 30, 2024

Description

kurtosis run github.com/kurtosis-tech/... --dependencies returns a yaml with a list of images and packages the run will need to depend on.

Adding --pull will pull all the dependencies locally. The kurtosis.yml will be updated to use local versions of packages and Docker images are pulled onto the machine locally

Is this change user facing?

YES

@tedim52 tedim52 changed the title Tedi/dependencylist feat: impl dependency list flag Aug 30, 2024
Copy link
Collaborator

@mieubrisse mieubrisse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't sure what level of detail you wanted on this so just did the full shebang

func (enclaveCtx *EnclaveContext) GetStarlarkPackagePlanYaml(ctx context.Context, packageId string, serializedParams string, dependenciesOnly bool) (*kurtosis_core_rpc_api_bindings.PlanYaml, error) {
serializedParams, err := maybeParseYaml(serializedParams)
if err != nil {
return nil, stacktrace.Propagate(err, "An error occurred when parsing YAML args for package '%v'", serializedParams)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be s/serializedParams/packageId/?

DependenciesOnly: &dependenciesOnly,
})
if err != nil {
return nil, stacktrace.Propagate(err, "An error occurred while getting the starlark package plan yaml run.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the "....run" at the end of the sentence perhaps a copy-paste that wasn't deleted? (my understanding is this returns the actual YAML; feel free to ignore this comment if not useful)

DependenciesOnly: &dependenciesOnly,
})
if err != nil {
return nil, stacktrace.Propagate(err, "An error occurred while getting the last starlark script plan yaml run.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question

@@ -55,6 +60,11 @@ const (
dryRunFlagKey = "dry-run"
defaultDryRun = "false"

dependenciesFlagKey = "dependencies"
defaultDependencies = "false"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion to make this dependenciesFlagDefault, both to pattern match other varnames and not suggest that this variable is in fact containing a list of default dependencies

dependenciesFlagKey = "dependencies"
defaultDependencies = "false"
pullDependenciesFlagKey = "pull"
defaultPullDependencies = "false"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same idea here

@@ -386,6 +391,16 @@ func (interpreter *StartosisInterpreter) buildBindings(
return &predeclared, nil
}

const (
moduleIdSeperator = "/"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought: wouldn't this constant already be declared somewhere in the Startosis engine? Should we use that instead, so we don't have two constants doing the same thing?

)

func getModulePrefix(moduleId string) string {
return strings.Join(strings.SplitN(moduleId, moduleIdSeperator, numModuleIdSeparators)[:prefixNum], moduleIdSeperator)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand of SplitN, isn't numModuleIdSeparators always just prefixNum + 1 (so we don't need to maintain the extra const)?

@@ -115,7 +115,7 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestAddServiceWithFilesArtifa
require.Nil(suite.T(), interpretationError)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this file be renamed to startosis_interpreter_plan_yaml_generator_test to match the name of PlanYaml -> PlanYamlGenerator?

@@ -813,6 +833,9 @@ tasks:
command:
- echo {{ kurtosis.4.code }} {{ kurtosis.4.output }}
image: badouralix/curl-jq
images:
- badouralix/curl-jq
- postgres:latest
`
require.Equal(suite.T(), expectedYaml, planYaml)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a test case here where the dependenciesOnly flag is true? (assuming that, per the comment above, we maintain the dependenciesOnly flag on the PlanYamlGenerator and it's not the responsibility of the CLI or user to pull out the info they want)

prefixNum = 3
)

func getModulePrefix(moduleId string) string {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing this, it'd have been helpful to have a comment giving an example of getModulePrefix is supposed to return so that I know how to model its output in the above code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants