Skip to content

Commit

Permalink
fix: give better error when running plan phase without a source direc…
Browse files Browse the repository at this point in the history
…tory (#949)

Signed-off-by: Harikrishnan Balagopal <[email protected]>
  • Loading branch information
HarikrishnanBalagopal authored Jan 17, 2023
1 parent 90a5e26 commit 73ab286
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 7 additions & 3 deletions environment/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ type Local struct {

// NewLocal creates a new Local environment
func NewLocal(envInfo EnvInfo, grpcQAReceiver net.Addr) (EnvironmentInstance, error) {
logrus.Trace("NewLocal start")
defer logrus.Trace("NewLocal end")
local := &Local{
EnvInfo: envInfo,
GRPCQAReceiver: grpcQAReceiver,
Expand Down Expand Up @@ -72,10 +74,12 @@ func NewLocal(envInfo EnvInfo, grpcQAReceiver net.Addr) (EnvironmentInstance, er
func (e *Local) Reset() error {
if e.Isolated {
if err := filesystem.Replicate(e.Context, e.WorkspaceContext); err != nil {
return fmt.Errorf("failed to copy contents to directory %s, %s . Error: %w", e.Context, e.WorkspaceContext, err)
return fmt.Errorf("failed to copy contents from '%s' to directory '%s' . Error: %w", e.Context, e.WorkspaceContext, err)
}
if err := filesystem.Replicate(e.Source, e.WorkspaceSource); err != nil {
return fmt.Errorf("failed to copy contents to directory %s, %s . Error: %w", e.Source, e.WorkspaceSource, err)
if e.Source != "" {
if err := filesystem.Replicate(e.Source, e.WorkspaceSource); err != nil {
return fmt.Errorf("failed to copy contents from '%s' to directory '%s' . Error: %w", e.Source, e.WorkspaceSource, err)
}
}
}
return nil
Expand Down
4 changes: 3 additions & 1 deletion transformer/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ const (
const (
// DEFAULT_SELECTED_LABEL is a label that can be used to remove a transformer from the list of transformers that are selected by default.
DEFAULT_SELECTED_LABEL = types.GroupName + "/default-selected"
// CONTAINER_BASED_LABEL is a label that indicates that the transformer needs to spawn containers to run.
CONTAINER_BASED_LABEL = types.GroupName + "/container-based"
)

var (
Expand Down Expand Up @@ -262,7 +264,7 @@ func InitTransformers(transformerYamlPaths map[string]string, selector labels.Se
}
}
if preExistingPlan {
if v, ok := transformerConfig.Labels["move2kube.konveyor.io/container-based"]; ok && cast.ToBool(v) {
if v, ok := transformerConfig.Labels[CONTAINER_BASED_LABEL]; ok && cast.ToBool(v) {
envInfo.SpawnContainers = true
}
}
Expand Down

0 comments on commit 73ab286

Please sign in to comment.