1
0
Fork 0
mirror of https://github.com/drone/drone-cli.git synced 2024-04-26 11:55:09 +02:00

(fix): add labels for tooling to query containers (#218)

* (fix): add labels for tooling to query containers
This commit is contained in:
Kamesh Sampath 2022-08-01 16:32:11 +05:30 committed by GitHub
parent a0d5adcf28
commit dcb1602f90
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,6 +19,7 @@ import (
"github.com/drone/envsubst"
"github.com/drone/runner-go/environ"
"github.com/drone/runner-go/environ/provider"
"github.com/drone/runner-go/labels"
"github.com/drone/runner-go/logger"
"github.com/drone/runner-go/manifest"
"github.com/drone/runner-go/pipeline"
@ -227,7 +228,15 @@ func exec(cliContext *cli.Context) error {
// disabled in favor of mounting the source code
// from the current working directory.
if !commy.Clone {
comp.Mount, _ = os.Getwd()
pwd, _ := os.Getwd()
comp.Mount = pwd
//Add the new labels that helps looking up the step containers
//by names
if comp.Labels == nil {
comp.Labels = make(map[string]string)
}
comp.Labels["io.drone.desktop.pipeline.dir"] = pwd
}
args := runtime.CompilerArgs{
@ -241,6 +250,15 @@ func exec(cliContext *cli.Context) error {
}
spec := comp.Compile(nocontext, args).(*engine.Spec)
//As the Compiler does not add labels for Steps adding few here
for i, step := range spec.Steps {
step.Labels = labels.Combine(step.Labels,
map[string]string{
"io.drone.step.name": step.Name,
"io.drone.step.number": fmt.Sprint(i),
})
}
// include only steps that are in the include list,
// if the list in non-empty.
if len(commy.Include) > 0 {
@ -294,6 +312,7 @@ func exec(cliContext *cli.Context) error {
if step.RunPolicy == runtime.RunNever {
continue
}
commy.Stage.Steps = append(commy.Stage.Steps, &drone.Step{
StageID: commy.Stage.ID,
Number: len(commy.Stage.Steps) + 1,