Files
odo/pkg/devfile/adapters/kubernetes/adapter.go
Philippe Martin 0e4e55bdd0 Deploy, Events without devfile/adapters (#5460)
* Execute devfile command

* Undeploy

* cleanup devfile/adapters

* refactor

* Move GetOnePod to component package

* Move DoesComponentExist and Log from devfile/adapter to component package

* Exec without devfile/adapters

* Move Delete from devfile/adapters to component

* Remove old Deploy code

* review

* Add tests for issue 5454

* Review
2022-02-23 03:48:52 -05:00

52 lines
1.4 KiB
Go

package kubernetes
import (
devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
"github.com/redhat-developer/odo/pkg/kclient"
"github.com/redhat-developer/odo/pkg/preference"
"github.com/pkg/errors"
"github.com/redhat-developer/odo/pkg/devfile/adapters/common"
"github.com/redhat-developer/odo/pkg/devfile/adapters/kubernetes/component"
)
// Adapter maps Devfiles to Kubernetes resources and actions
type Adapter struct {
componentAdapter common.ComponentAdapter
}
type KubernetesContext struct {
Namespace string
}
// New instantiates a kubernetes adapter
func New(adapterContext common.AdapterContext, client kclient.ClientInterface, prefClient preference.Client) Adapter {
compAdapter := component.New(adapterContext, client, prefClient)
return Adapter{
componentAdapter: &compAdapter,
}
}
// Push creates Kubernetes resources that correspond to the devfile if they don't already exist
func (k Adapter) Push(parameters common.PushParameters) error {
err := k.componentAdapter.Push(parameters)
if err != nil {
return errors.Wrap(err, "Failed to create the component")
}
return nil
}
// CheckSupervisordCommandStatus calls the component adapter's CheckSupervisordCommandStatus
func (k Adapter) CheckSupervisordCommandStatus(command devfilev1.Command) error {
err := k.componentAdapter.CheckSupervisordCommandStatus(command)
if err != nil {
return errors.Wrap(err, "Failed to check the status")
}
return nil
}