Skip to content

Commit

Permalink
fix a bug where user cannot get build parameter from template (#3967)
Browse files Browse the repository at this point in the history
* fix a bug where user cannot get parameter for build when it is using a template

Signed-off-by: Min Min <[email protected]>

* bugfix

Signed-off-by: Min Min <[email protected]>

---------

Signed-off-by: Min Min <[email protected]>
  • Loading branch information
jamsman94 authored Jan 23, 2025
1 parent d89cdfa commit 3325cf0
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions pkg/microservice/aslan/core/build/service/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,20 @@ func OpenAPIGetBuildModule(name, serviceName, serviceModule, projectName string,
}
resp.Repos = append(resp.Repos, repo)
}

for _, kv := range svcBuild.Envs {
newKV := &commonmodels.ServiceKeyVal{
Key: kv.Key,
Value: kv.Value,
Type: kv.Type,
ChoiceOption: kv.ChoiceOption,
ChoiceValue: kv.ChoiceValue,
IsCredential: kv.IsCredential,
}

resp.Parameters = append(resp.Parameters, newKV)
}

break
}
}
Expand Down Expand Up @@ -428,15 +442,18 @@ func OpenAPIGetBuildModule(name, serviceName, serviceModule, projectName string,
CacheDir: build.CacheUserDir,
}

resp.Parameters = make([]*commonmodels.ServiceKeyVal, 0)
for _, kv := range build.PreBuild.Envs {
resp.Parameters = append(resp.Parameters, &commonmodels.ServiceKeyVal{
Key: kv.Key,
Value: kv.Value,
Type: kv.Type,
IsCredential: kv.IsCredential,
})
if len(resp.Parameters) == 0 {
resp.Parameters = make([]*commonmodels.ServiceKeyVal, 0)
for _, kv := range build.PreBuild.Envs {
resp.Parameters = append(resp.Parameters, &commonmodels.ServiceKeyVal{
Key: kv.Key,
Value: kv.Value,
Type: kv.Type,
IsCredential: kv.IsCredential,
})
}
}

resp.Outputs = build.Outputs

resp.PostBuild = build.PostBuild
Expand Down

0 comments on commit 3325cf0

Please sign in to comment.