Resolve declared file targets in Run
This commit is contained in:
@@ -106,8 +106,8 @@ func (executor *FileExecutor) existingReadTargetForAssignment(assignment protoco
|
||||
if err != nil {
|
||||
return "", "", false, err
|
||||
}
|
||||
targetKey := assignment.TargetKey
|
||||
if deploymentRoot {
|
||||
targetKey := fileTargetKeyForAssignment(assignment)
|
||||
if deploymentRoot && assignment.ExecutionInput.FileTargetKey == "" {
|
||||
targetKey = deploymentTargetKey(targetKey)
|
||||
filePath, err := existingDeploymentTarget(scope, targetKey)
|
||||
return scope, filePath, deploymentRoot, err
|
||||
@@ -245,8 +245,8 @@ func (executor *FileExecutor) read(ctx context.Context, scope string, deployment
|
||||
if err := ctx.Err(); err != nil {
|
||||
return lifecycleExecutionFailure("file_cancelled", "file read cancelled", false)
|
||||
}
|
||||
targetKey := assignment.TargetKey
|
||||
if deploymentRoot {
|
||||
targetKey := fileTargetKeyForAssignment(assignment)
|
||||
if deploymentRoot && assignment.ExecutionInput.FileTargetKey == "" {
|
||||
targetKey = deploymentTargetKey(targetKey)
|
||||
}
|
||||
var filePath string
|
||||
@@ -292,8 +292,8 @@ func (executor *FileExecutor) write(ctx context.Context, scope string, deploymen
|
||||
if err := ctx.Err(); err != nil {
|
||||
return lifecycleExecutionFailure("file_cancelled", "file write cancelled", false)
|
||||
}
|
||||
targetKey := assignment.TargetKey
|
||||
if deploymentRoot {
|
||||
targetKey := fileTargetKeyForAssignment(assignment)
|
||||
if deploymentRoot && assignment.ExecutionInput.FileTargetKey == "" {
|
||||
targetKey = deploymentTargetKey(targetKey)
|
||||
}
|
||||
var filePath string
|
||||
@@ -365,6 +365,13 @@ func (executor *FileExecutor) write(ctx context.Context, scope string, deploymen
|
||||
return LifecycleExecutionResult{State: lifecycleResultStateSucceeded, Progress: protocol.RunJobProgressReport{Percent: 100, Message: "file write completed"}, Message: "file write completed", ExecutionResult: protocol.RunJobExecutionResult{Kind: "file.write", Version: next.Version, Checksum: checksum, SizeBytes: int64(len(content)), Summary: "atomic compare-and-swap file write"}}
|
||||
}
|
||||
|
||||
func fileTargetKeyForAssignment(assignment protocol.RunJobAssignment) string {
|
||||
if targetKey := strings.TrimSpace(assignment.ExecutionInput.FileTargetKey); targetKey != "" {
|
||||
return targetKey
|
||||
}
|
||||
return assignment.TargetKey
|
||||
}
|
||||
|
||||
func deploymentTargetKey(value string) string {
|
||||
cleaned := path.Clean(strings.TrimPrefix(strings.ReplaceAll(strings.TrimSpace(value), "\\", "/"), "/"))
|
||||
if cleaned == "." || cleaned == "" {
|
||||
|
||||
Reference in New Issue
Block a user