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: enable setting git token per package run #2355

Merged
merged 9 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ To submit code for review, follow these steps:

1. Make sure your changes are building and passing all tests locally, project following [README's guidance](./README.md#build-instructions)
2. Make sure your code is in accordance with our [Style Guide](https://github.com/kurtosis-tech/style-guide)
3. Open a PR whose title obeys the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) convention and fill out the information provided in the Pull Request template.
3. Open a PR whose title obeys the conventional commits convention and fill out the information provided in the Pull Request template.
4. After all CI checks pass, tag `@kurtosis-tech/engineers` for review
1,110 changes: 562 additions & 548 deletions api/golang/core/kurtosis_core_rpc_api_bindings/api_container_service.pb.go

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func NewRunStarlarkPackageArgs(
cloudUserId string,
imageDownloadMode kurtosis_core_rpc_api_bindings.ImageDownloadMode,
nonBlockingMode bool,
githubAuthToken string,
) *kurtosis_core_rpc_api_bindings.RunStarlarkPackageArgs {
parallelismCopy := new(int32)
*parallelismCopy = parallelism
Expand All @@ -90,6 +91,8 @@ func NewRunStarlarkPackageArgs(
imageDownloadModeCopy := new(kurtosis_core_rpc_api_bindings.ImageDownloadMode)
*imageDownloadModeCopy = imageDownloadMode
clonePackage := false
githubAuthTokenCopy := new(string)
*githubAuthTokenCopy = githubAuthToken
return &kurtosis_core_rpc_api_bindings.RunStarlarkPackageArgs{
PackageId: packageId,
ClonePackage: &clonePackage,
Expand All @@ -104,6 +107,7 @@ func NewRunStarlarkPackageArgs(
CloudUserId: cloudUserIdCopy,
ImageDownloadMode: imageDownloadModeCopy,
NonBlockingMode: &nonBlockingMode,
GithubAuthToken: githubAuthTokenCopy,
}
}

Expand All @@ -119,6 +123,7 @@ func NewRunStarlarkRemotePackageArgs(
cloudUserId string,
imageDownloadMode kurtosis_core_rpc_api_bindings.ImageDownloadMode,
nonBlockingMode bool,
githubAuthToken string,
) *kurtosis_core_rpc_api_bindings.RunStarlarkPackageArgs {
parallelismCopy := new(int32)
*parallelismCopy = parallelism
Expand All @@ -129,6 +134,8 @@ func NewRunStarlarkRemotePackageArgs(
imageDownloadModeCopy := new(kurtosis_core_rpc_api_bindings.ImageDownloadMode)
*imageDownloadModeCopy = imageDownloadMode
clonePackage := true
githubAuthTokenCopy := new(string)
*githubAuthTokenCopy = githubAuthToken
return &kurtosis_core_rpc_api_bindings.RunStarlarkPackageArgs{
PackageId: packageId,
ClonePackage: &clonePackage,
Expand All @@ -143,6 +150,7 @@ func NewRunStarlarkRemotePackageArgs(
CloudUserId: cloudUserIdCopy,
ImageDownloadMode: imageDownloadModeCopy,
NonBlockingMode: &nonBlockingMode,
GithubAuthToken: githubAuthTokenCopy,
}
}

Expand Down
9 changes: 6 additions & 3 deletions api/golang/core/lib/enclaves/enclave_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ func (enclaveCtx *EnclaveContext) RunStarlarkPackage(
runConfig.CloudInstanceId,
runConfig.CloudUserId,
runConfig.ImageDownload,
runConfig.NonBlockingMode)
runConfig.NonBlockingMode,
runConfig.GitHubAuthToken)
if err != nil {
return nil, nil, stacktrace.Propagate(err, "Error preparing package '%s' for execution", packageRootPath)
}
Expand Down Expand Up @@ -308,7 +309,7 @@ func (enclaveCtx *EnclaveContext) RunStarlarkRemotePackage(
}()

starlarkResponseLineChan := make(chan *kurtosis_core_rpc_api_bindings.StarlarkRunResponseLine)
executeStartosisScriptArgs := binding_constructors.NewRunStarlarkRemotePackageArgs(packageId, runConfig.RelativePathToMainFile, runConfig.MainFunctionName, serializedParams, runConfig.DryRun, runConfig.Parallelism, runConfig.ExperimentalFeatureFlags, runConfig.CloudInstanceId, runConfig.CloudUserId, runConfig.ImageDownload, runConfig.NonBlockingMode)
executeStartosisScriptArgs := binding_constructors.NewRunStarlarkRemotePackageArgs(packageId, runConfig.RelativePathToMainFile, runConfig.MainFunctionName, serializedParams, runConfig.DryRun, runConfig.Parallelism, runConfig.ExperimentalFeatureFlags, runConfig.CloudInstanceId, runConfig.CloudUserId, runConfig.ImageDownload, runConfig.NonBlockingMode, runConfig.GitHubAuthToken)

stream, err := enclaveCtx.client.RunStarlarkPackage(ctxWithCancel, executeStartosisScriptArgs)
if err != nil {
Expand Down Expand Up @@ -617,6 +618,7 @@ func (enclaveCtx *EnclaveContext) assembleRunStartosisPackageArg(
cloudUserId string,
imageDownloadMode kurtosis_core_rpc_api_bindings.ImageDownloadMode,
nonBlockingMode bool,
githubAuthToken string,
) (*kurtosis_core_rpc_api_bindings.RunStarlarkPackageArgs, error) {

return binding_constructors.NewRunStarlarkPackageArgs(
Expand All @@ -630,7 +632,8 @@ func (enclaveCtx *EnclaveContext) assembleRunStartosisPackageArg(
cloudInstanceId,
cloudUserId,
imageDownloadMode,
nonBlockingMode), nil
nonBlockingMode,
githubAuthToken), nil
}

func (enclaveCtx *EnclaveContext) uploadStarlarkPackage(packageId string, packageRootPath string) error {
Expand Down
13 changes: 12 additions & 1 deletion api/golang/core/lib/starlark_run_config/starlark_run_config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package starlark_run_config

import "github.com/kurtosis-tech/kurtosis/api/golang/core/kurtosis_core_rpc_api_bindings"
import (
"github.com/kurtosis-tech/kurtosis/api/golang/core/kurtosis_core_rpc_api_bindings"
)

const (
defaultRelativePathToMainFile = ""
Expand All @@ -12,6 +14,7 @@ const (
defaultCloudUserId = ""
defaultImageDownload = kurtosis_core_rpc_api_bindings.ImageDownloadMode_missing
defaultNonBlockingMode = false
defaultGitHubAuthToken = ""
)

var defaultExperimentalFeatureFlags = []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag(nil)
Expand All @@ -27,6 +30,7 @@ type StarlarkRunConfig struct {
CloudUserId string
ImageDownload kurtosis_core_rpc_api_bindings.ImageDownloadMode
NonBlockingMode bool
GitHubAuthToken string
}

type starlarkRunConfigOption func(*StarlarkRunConfig)
Expand All @@ -43,6 +47,7 @@ func NewRunStarlarkConfig(opts ...starlarkRunConfigOption) *StarlarkRunConfig {
CloudUserId: defaultCloudUserId,
ImageDownload: defaultImageDownload,
NonBlockingMode: defaultNonBlockingMode,
GitHubAuthToken: defaultGitHubAuthToken,
}

for _, opt := range opts {
Expand Down Expand Up @@ -113,3 +118,9 @@ func WithNonBlockingMode(nonBlockingMode bool) starlarkRunConfigOption {
config.NonBlockingMode = nonBlockingMode
}
}

func WithGitHubAuthToken(githubAuthToken string) starlarkRunConfigOption {
return func(config *StarlarkRunConfig) {
config.GitHubAuthToken = githubAuthToken
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions api/golang/http_rest/api_types/api_types.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading