Skip to content

Commit

Permalink
chore(clour run): Move container envs to separate func
Browse files Browse the repository at this point in the history
  • Loading branch information
mahad-akhter committed Nov 17, 2023
1 parent f08b50b commit ad7dbc1
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions internal/providers/gcp/cloudrun/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,17 +286,7 @@ func (r *Resource) GetContainerConfig(ctx context.Context, wl *Workload) *runpb.
resourceReq := r.GetResourceReqConfig(ctx)
containerPorts := r.GetContainerPortsConfig(ctx)

Envs := []*runpb.EnvVar{}

env := templateContainersConfig["env"].([]interface{})
for _, val := range env {
envVal := val.(map[string]interface{})
Envs = append(Envs, &runpb.EnvVar{
Name: fmt.Sprint(envVal["name"]),
Values: &runpb.EnvVar_Value{
Value: fmt.Sprint(envVal["value"])},
})
}
Envs := r.GetContainerEnvConfig(ctx)

volumeMountsName := templateContainersConfig["volume_mounts"].(map[string]interface{})["name"].(string)
volumeMountsPath := templateContainersConfig["volume_mounts"].(map[string]interface{})["mount_path"].(string)
Expand All @@ -318,6 +308,26 @@ func (r *Resource) GetContainerConfig(ctx context.Context, wl *Workload) *runpb.
return container
}

func (r *Resource) GetContainerEnvConfig(ctx context.Context) []*runpb.EnvVar {

templateConfig := r.Config["template"].(map[string]interface{})
templateContainersConfig := templateConfig["containers"].(map[string]interface{})

Envs := []*runpb.EnvVar{}

env := templateContainersConfig["env"].([]interface{})
for _, val := range env {
envVal := val.(map[string]interface{})
Envs = append(Envs, &runpb.EnvVar{
Name: fmt.Sprint(envVal["name"]),
Values: &runpb.EnvVar_Value{
Value: fmt.Sprint(envVal["value"])},
})
}

return Envs
}

func (r *Resource) GetContainerPortsConfig(ctx context.Context) []*runpb.ContainerPort {

templateConfig := r.Config["template"].(map[string]interface{})
Expand Down

0 comments on commit ad7dbc1

Please sign in to comment.