mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-10-22 07:42:23 +00:00
Move constrain to only have a single command in backend to run to dedicated backends (#1032)
at the moment we compile a script that we can pipe in as single command this is because of the constrains the docker backend gives us. so we move it into the docker backend and eventually get rid of it altogether
This commit is contained in:
@@ -1,3 +1,17 @@
|
||||
// Copyright 2022 Woodpecker Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package docker
|
||||
|
||||
import (
|
||||
@@ -8,6 +22,7 @@ import (
|
||||
|
||||
"github.com/docker/docker/api/types/container"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/pipeline/backend/common"
|
||||
"github.com/woodpecker-ci/woodpecker/pipeline/backend/types"
|
||||
)
|
||||
|
||||
@@ -20,15 +35,19 @@ func toConfig(step *types.Step) *container.Config {
|
||||
AttachStdout: true,
|
||||
AttachStderr: true,
|
||||
}
|
||||
|
||||
if len(step.Commands) != 0 {
|
||||
env, entry, cmd := common.GenerateContainerConf(step.Commands)
|
||||
for k, v := range env {
|
||||
step.Environment[k] = v
|
||||
}
|
||||
config.Entrypoint = entry
|
||||
config.Cmd = cmd
|
||||
}
|
||||
|
||||
if len(step.Environment) != 0 {
|
||||
config.Env = toEnv(step.Environment)
|
||||
}
|
||||
if len(step.Command) != 0 {
|
||||
config.Cmd = step.Command
|
||||
}
|
||||
if len(step.Entrypoint) != 0 {
|
||||
config.Entrypoint = step.Entrypoint
|
||||
}
|
||||
if len(step.Volumes) != 0 {
|
||||
config.Volumes = toVol(step.Volumes)
|
||||
}
|
||||
|
@@ -1,3 +1,17 @@
|
||||
// Copyright 2022 Woodpecker Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package docker
|
||||
|
||||
import (
|
||||
|
@@ -1,3 +1,17 @@
|
||||
// Copyright 2022 Woodpecker Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package docker
|
||||
|
||||
import (
|
||||
|
@@ -1,42 +0,0 @@
|
||||
package docker
|
||||
|
||||
// import (
|
||||
|
||||
// )
|
||||
//
|
||||
// // Pool manages a pool of Docker clients.
|
||||
// type Pool struct {
|
||||
// queue chan (backend.Engine)
|
||||
// }
|
||||
//
|
||||
// // NewPool returns a Pool.
|
||||
// func NewPool(engines ...backend.Engine) *Pool {
|
||||
// return &Pool{
|
||||
// queue: make(chan backend.Engine, len(engines)),
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Reserve requests the next available Docker client in the pool.
|
||||
// func (p *Pool) Reserve(c context.Context) backend.Engine {
|
||||
// select {
|
||||
// case <-c.Done():
|
||||
// case docker := <-p.queue:
|
||||
// return docker
|
||||
// }
|
||||
// return nil
|
||||
// }
|
||||
//
|
||||
// // Release releases the Docker client back to the pool.
|
||||
// func (p *Pool) Release(docker backend.Engine) {
|
||||
// p.queue <- docker
|
||||
// }
|
||||
|
||||
// pool := docker.Pool(
|
||||
// docker.FromEnvironmentMust(),
|
||||
// docker.FromEnvironmentMust(),
|
||||
// docker.FromEnvironmentMust(),
|
||||
// docker.FromEnvironmentMust(),
|
||||
// )
|
||||
//
|
||||
// client := pool.Reserve()
|
||||
// defer pool.Release(client)
|
Reference in New Issue
Block a user