Skip to content

Add PlatformProperties to client.Action #528

@akshay-verma

Description

@akshay-verma

This needs two changes -

  1. Update the Action struct to add PlatformProperties map[string]string -
type Action struct {
	// Args are the command-line arguments to start the process. The first argument is the process
	// name, and the rest are its arguments.
	Args []string
	// EnvVars are the variables to add to the process's environment.
	EnvVars map[string]string
	// InputRoot and InputFiles contain the details of the input tree, in remote execution format.
	// They should normally be constructed through the PackageTree function.
	InputRoot  digest.Digest
	InputFiles map[digest.Digest][]byte
	// OutputFiles is a list of output files requested (full paths).
	OutputFiles []string
	// OutputDirs is a list of output directories requested (full paths).
	OutputDirs []string
	// Docker image is a docker:// URL to the docker image in which execution will take place.
	DockerImage string
	// Timeout is the maximum execution time for the action. Note that it's not an overall timeout on
	// the process, since there may be additional time for transferring files, waiting for a worker to
	// become available, or other overhead.
	//
	// If 0, the server's default timeout is used.
	Timeout time.Duration
	// DoNotCache, if true, indicates that the result of this action should never be cached. It
	// implies SkipCache.
	DoNotCache bool
	// SkipCache, if true, indicates that this action should be executed even if there is a copy of
	// its result in the action cache that could be used instead.
	SkipCache bool
+
+  // PlatformProperties are the properties to add to the command's Platform properties
+  PlatformProperties map[string]string
+
}
  1. Update PrepAction function to add this piece of code -
for name, val := range ac.PlatformProperties {
		reAc.Platform.Properties = append(cmd.Platform.Properties, &repb.Platform_Property{
			Name: name, Value: val,
		})
	}

Usage -

ac := client.Action{
	Args: []string{"..."},
	InputRoot: "...",
	DockerImage: "...",
	PlatformProperties: map[string]string{
		"prop1": "value1",
		"prop2": "value2"
	}
}

Does this change make sense? I think the DockerImage variable in Action struct could have been part of the generic platform properties to begin with.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions