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

Updated spec for deploymentConfig #212

Merged
merged 1 commit into from
Aug 12, 2022
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
6 changes: 2 additions & 4 deletions api/computes_components.partials.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ DeploymentConfig:
imageLoc:
type: string
agentKVs:
type: array
items:
$ref: '#/components/schemas/AgentKV'
$ref: '#/components/schemas/AgentKVs'
required:
- jobId
- imageLoc
Expand All @@ -88,7 +86,7 @@ DeploymentConfig:
########################################
# Config for agents in the deployment
########################################
AgentKV:
AgentKVs:
description: Config for agents in the deployment
type: object
additionalProperties:
Expand Down
13 changes: 2 additions & 11 deletions cmd/deployer/app/resource_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,8 @@ func (r *resourceHandler) deployResources(deploymentConfig openapi.DeploymentCon
}
}

for _, agentKV := range deploymentConfig.AgentKVs {
// the agentKV is a map but with just one key (taskId) and one value (taskKey)
// TODO fix the api spec to have a map with multiple key:value pairs
taskIds := make([]string, len(agentKV))
i := 0
for k := range agentKV {
taskIds[i] = k
i++
}
taskId := taskIds[0]
taskKey := agentKV[taskIds[0]]
for taskId := range deploymentConfig.AgentKVs {
taskKey := deploymentConfig.AgentKVs[taskId]

context := map[string]string{
"imageLoc": deploymentConfig.ImageLoc,
Expand Down
6 changes: 2 additions & 4 deletions pkg/openapi/controller/api_computes_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,9 @@ func (s *ComputesApiService) GetDeploymentConfig(ctx context.Context, computeId
deploymentConfig.JobId = jobId
deploymentConfig.ImageLoc = imageLoc

agentKVs := []map[string]string{}
agentKVs := map[string]string{}
for _, task := range jobTasks {
agent := make(map[string]string)
agent[task.TaskId] = task.Key
agentKVs = append(agentKVs, agent)
agentKVs[task.TaskId] = task.Key
}
deploymentConfig.AgentKVs = agentKVs

Expand Down
3 changes: 2 additions & 1 deletion pkg/openapi/model_deployment_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ type DeploymentConfig struct {

ImageLoc string `json:"imageLoc"`

AgentKVs []map[string]string `json:"agentKVs"`
// Config for agents in the deployment
AgentKVs map[string]string `json:"agentKVs"`
}

// AssertDeploymentConfigRequired checks if the required fields are not zero-ed
Expand Down