woodpecker/pipeline/backend/kubernetes/kubernetes.go

76 lines
1.6 KiB
Go
Raw Normal View History

2019-04-06 13:44:04 +00:00
package kubernetes
import (
"context"
"io"
"os"
2019-04-06 13:44:04 +00:00
"github.com/woodpecker-ci/woodpecker/pipeline/backend/types"
2019-04-06 13:44:04 +00:00
)
type engine struct {
namespace string
endpoint string
token string
}
// New returns a new Kubernetes Engine.
func New(namespace, endpoint, token string) types.Engine {
2019-04-06 13:44:04 +00:00
return &engine{
namespace: namespace,
endpoint: endpoint,
token: token,
}
}
func (e *engine) Name() string {
return "kubernetes"
}
func (e *engine) IsAvivable() bool {
host := os.Getenv("KUBERNETES_SERVICE_HOST")
return len(host) > 0
}
func (e *engine) Load() error {
return nil
}
2019-04-06 13:44:04 +00:00
// Setup the pipeline environment.
func (e *engine) Setup(context.Context, *types.Config) error {
2019-04-06 13:44:04 +00:00
// POST /api/v1/namespaces
return nil
}
// Start the pipeline step.
func (e *engine) Exec(context.Context, *types.Step) error {
2019-04-06 13:44:04 +00:00
// POST /api/v1/namespaces/{namespace}/pods
return nil
}
// DEPRECATED
// Kill the pipeline step.
func (e *engine) Kill(context.Context, *types.Step) error {
2019-04-06 13:44:04 +00:00
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) {
2019-04-06 13:44:04 +00:00
// 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) {
2019-04-06 13:44:04 +00:00
// GET /api/v1/namespaces/{namespace}/pods/{name}/log
return nil, nil
}
// Destroy the pipeline environment.
func (e *engine) Destroy(context.Context, *types.Config) error {
2019-04-06 13:44:04 +00:00
// DELETE /api/v1/namespaces/{name}
return nil
}