mirror of
https://codeberg.org/crowci/crow.git
synced 2025-08-09 07:42:52 +03:00
Fix pipeline backend autodetect (#545)
* refactor: - rename IsAvivable -> IsAvailable - drop depricated Kill - make sure backends implement interface - rename backend struct for ide (better info) * docker backend fix autodetect
This commit is contained in:
@@ -8,68 +8,65 @@ import (
|
||||
"github.com/woodpecker-ci/woodpecker/pipeline/backend/types"
|
||||
)
|
||||
|
||||
type engine struct {
|
||||
type kube struct {
|
||||
namespace string
|
||||
endpoint string
|
||||
token string
|
||||
}
|
||||
|
||||
// make sure kube implements Engine
|
||||
var _ types.Engine = &kube{}
|
||||
|
||||
// New returns a new Kubernetes Engine.
|
||||
func New(namespace, endpoint, token string) types.Engine {
|
||||
return &engine{
|
||||
return &kube{
|
||||
namespace: namespace,
|
||||
endpoint: endpoint,
|
||||
token: token,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *engine) Name() string {
|
||||
func (e *kube) Name() string {
|
||||
return "kubernetes"
|
||||
}
|
||||
|
||||
func (e *engine) IsAvivable() bool {
|
||||
func (e *kube) IsAvailable() bool {
|
||||
host := os.Getenv("KUBERNETES_SERVICE_HOST")
|
||||
return len(host) > 0
|
||||
}
|
||||
|
||||
func (e *engine) Load() error {
|
||||
func (e *kube) Load() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Setup the pipeline environment.
|
||||
func (e *engine) Setup(context.Context, *types.Config) error {
|
||||
func (e *kube) Setup(context.Context, *types.Config) error {
|
||||
// POST /api/v1/namespaces
|
||||
return nil
|
||||
}
|
||||
|
||||
// Start the pipeline step.
|
||||
func (e *engine) Exec(context.Context, *types.Step) error {
|
||||
// Exec the pipeline step.
|
||||
func (e *kube) Exec(context.Context, *types.Step) error {
|
||||
// POST /api/v1/namespaces/{namespace}/pods
|
||||
return nil
|
||||
}
|
||||
|
||||
// DEPRECATED
|
||||
// Kill the pipeline step.
|
||||
func (e *engine) Kill(context.Context, *types.Step) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Wait for the pipeline step to complete and returns
|
||||
// the completion results.
|
||||
func (e *engine) Wait(context.Context, *types.Step) (*types.State, error) {
|
||||
func (e *kube) Wait(context.Context, *types.Step) (*types.State, error) {
|
||||
// GET /api/v1/watch/namespaces/{namespace}/pods
|
||||
// GET /api/v1/watch/namespaces/{namespace}/pods/{name}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Tail the pipeline step logs.
|
||||
func (e *engine) Tail(context.Context, *types.Step) (io.ReadCloser, error) {
|
||||
func (e *kube) Tail(context.Context, *types.Step) (io.ReadCloser, error) {
|
||||
// GET /api/v1/namespaces/{namespace}/pods/{name}/log
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Destroy the pipeline environment.
|
||||
func (e *engine) Destroy(context.Context, *types.Config) error {
|
||||
func (e *kube) Destroy(context.Context, *types.Config) error {
|
||||
// DELETE /api/v1/namespaces/{name}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user