Skip to content

Commit

Permalink
Remove old Deploy code
Browse files Browse the repository at this point in the history
  • Loading branch information
feloy committed Feb 15, 2022
1 parent ea29565 commit f867c10
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 296 deletions.
7 changes: 0 additions & 7 deletions pkg/devfile/adapters/common/apply.go

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/devfile/adapters/common/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func New(devfile devfilev1.Command, knowCommands map[string]devfilev1.Command, e
} else if devfile.Exec != nil {
return newExecCommand(devfile, executor)
} else {
return newApplyCommand(devfile, executor)
return nil, errors.New("apply command not implemented")
}
}

Expand Down
32 changes: 0 additions & 32 deletions pkg/devfile/adapters/common/command_apply.go

This file was deleted.

1 change: 0 additions & 1 deletion pkg/devfile/adapters/common/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
// commandExecutor defines the interface adapters must implement to be able to execute commands in a generic way
type commandExecutor interface {
ExecClient
ApplyClient
// Logger returns the MachineEventLoggingClient associated with this executor
Logger() machineoutput.MachineEventLoggingClient
// ComponentInfo retrieves the component information associated with the specified command
Expand Down
8 changes: 0 additions & 8 deletions pkg/devfile/adapters/common/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,3 @@ func (a GenericAdapter) addToComposite(commandsMap PushCommandsMap, groupType de
}
return commands, nil
}

func (a GenericAdapter) ApplyComponent(component string) error {
return nil
}

func (a GenericAdapter) UnApplyComponent(component string) error {
return nil
}
1 change: 0 additions & 1 deletion pkg/devfile/adapters/common/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

// ComponentAdapter defines the functions that platform-specific adapters must implement
type ComponentAdapter interface {
commandExecutor
Push(parameters PushParameters) error
CheckSupervisordCommandStatus(command devfilev1.Command) error
}
26 changes: 0 additions & 26 deletions pkg/devfile/adapters/kubernetes/adapter.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package kubernetes

import (
"io"

devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
"github.com/redhat-developer/odo/pkg/kclient"
"github.com/redhat-developer/odo/pkg/machineoutput"
"github.com/redhat-developer/odo/pkg/preference"

"github.com/pkg/errors"
Expand Down Expand Up @@ -52,26 +49,3 @@ func (k Adapter) CheckSupervisordCommandStatus(command devfilev1.Command) error

return nil
}

func (k Adapter) ExecCMDInContainer(info common.ComponentInfo, cmd []string, stdOut io.Writer, stdErr io.Writer, stdIn io.Reader, show bool) error {
return k.componentAdapter.ExecCMDInContainer(info, cmd, stdOut, stdErr, stdIn, show)
}
func (k Adapter) Logger() machineoutput.MachineEventLoggingClient {
return k.componentAdapter.Logger()
}

func (k Adapter) ComponentInfo(command devfilev1.Command) (common.ComponentInfo, error) {
return k.componentAdapter.ComponentInfo(command)
}

func (k Adapter) SupervisorComponentInfo(command devfilev1.Command) (common.ComponentInfo, error) {
return k.componentAdapter.SupervisorComponentInfo(command)
}

func (k Adapter) ApplyComponent(component string) error {
return k.componentAdapter.ApplyComponent(component)
}

func (k Adapter) UnApplyComponent(component string) error {
return k.componentAdapter.UnApplyComponent(component)
}
97 changes: 0 additions & 97 deletions pkg/devfile/adapters/kubernetes/component/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,59 +645,6 @@ func getFirstContainerWithSourceVolume(containers []corev1.Container) (string, s
return "", "", fmt.Errorf("in order to sync files, odo requires at least one component in a devfile to set 'mountSources: true'")
}

/*
// Delete deletes the component
func (a Adapter) Delete(labels map[string]string, show bool, wait bool) error {
if labels == nil {
return fmt.Errorf("cannot delete with labels being nil")
}
log.Printf("Gathering information for component: %q", a.ComponentName)
podSpinner := log.Spinner("Checking status for component")
defer podSpinner.End(false)
pod, err := component.GetOnePod(a.Client, a.ComponentName, a.AppName)
if kerrors.IsForbidden(err) {
klog.V(2).Infof("Resource for %s forbidden", a.ComponentName)
// log the error if it failed to determine if the component exists due to insufficient RBACs
podSpinner.End(false)
log.Warningf("%v", err)
return nil
} else if e, ok := err.(*kclient.PodNotFoundError); ok {
podSpinner.End(false)
log.Warningf("%v", e)
return nil
} else if err != nil {
return errors.Wrapf(err, "unable to determine if component %s exists", a.ComponentName)
}
podSpinner.End(true)
// if there are preStop events, execute them before deleting the deployment
if libdevfile.HasPreStopEvents(a.Devfile) {
if pod.Status.Phase != corev1.PodRunning {
return fmt.Errorf("unable to execute preStop events, pod for component %s is not running", a.ComponentName)
}
log.Infof("\nExecuting %s event commands for component %s", libdevfile.PreStop, a.ComponentName)
err = libdevfile.ExecPreStopEvents(a.Devfile, a.ComponentName, newExecHandler(a.Client, pod.Name, show))
if err != nil {
return err
}
}
log.Infof("\nDeleting component %s", a.ComponentName)
spinner := log.Spinner("Deleting Kubernetes resources for component")
defer spinner.End(false)
err = a.Client.Delete(labels, wait)
if err != nil {
return err
}
spinner.End(true)
log.Successf("Successfully deleted component")
return nil
}*/

func (a Adapter) ExecCMDInContainer(componentInfo common.ComponentInfo, cmd []string, stdout io.Writer, stderr io.Writer, stdin io.Reader, tty bool) error {
return a.Client.ExecCMDInContainer(componentInfo.ContainerName, componentInfo.PodName, cmd, stdout, stderr, stdin, tty)
}
Expand All @@ -706,47 +653,3 @@ func (a Adapter) ExecCMDInContainer(componentInfo common.ComponentInfo, cmd []st
func (a Adapter) ExtractProjectToComponent(componentInfo common.ComponentInfo, targetPath string, stdin io.Reader) error {
return a.Client.ExtractProjectToComponent(componentInfo.ContainerName, componentInfo.PodName, targetPath, stdin)
}

// ApplyComponent 'applies' a devfile component
func (a Adapter) ApplyComponent(componentName string) error {
cmp, err := a.getApplyComponent(componentName)
if err != nil {
return err
}

return cmp.Apply(a.Devfile, a.Context)
}

// UnApplyComponent un-'applies' a devfile component
func (a Adapter) UnApplyComponent(componentName string) error {
cmp, err := a.getApplyComponent(componentName)
if err != nil {
return err
}
return cmp.UnApply(a.Context)
}

// getApplyComponent returns the 'Apply' command's component(kubernetes/image)
func (a Adapter) getApplyComponent(componentName string) (componentToApply, error) {
components, err := a.Devfile.Data.GetComponents(parsercommon.DevfileOptions{})
if err != nil {
return nil, err
}
var component devfilev1.Component
var found bool
for _, component = range components {
if component.Name == componentName {
found = true
break
}
}
if !found {
return nil, fmt.Errorf("component %q not found", componentName)
}

cmp, err := createComponent(a, component)
if err != nil {
return nil, err
}
return cmp, nil
}
24 changes: 0 additions & 24 deletions pkg/devfile/adapters/kubernetes/component/component.go

This file was deleted.

25 changes: 0 additions & 25 deletions pkg/devfile/adapters/kubernetes/component/component_image.go

This file was deleted.

74 changes: 0 additions & 74 deletions pkg/devfile/adapters/kubernetes/component/component_kubernetes.go

This file was deleted.

0 comments on commit f867c10

Please sign in to comment.