Build integration image.
diff --git a/pkg/cmd/local_create.go b/pkg/cmd/local_create.go
index 721255e..fb6b479 100644
--- a/pkg/cmd/local_create.go
+++ b/pkg/cmd/local_create.go
@@ -162,13 +162,16 @@
return err
}
+ // Copy routes to a routes folder under a local directory.
+ err = updateIntegrationRoutes(args)
+ if err != nil {
+ return err
+ }
+
// Get integration run command to be run inside the container. This means the command
// has to be created with the paths which will be valid inside the container.
containerCmd := GetContainerIntegrationRunCommand(propertyFiles, dependencies, args)
-
err = createAndBuildIntegrationImage(command.DockerRegistry, containerCmd, command.ImageName)
- // // Run integration locally.
- // err = containerCmd.Run()
if err != nil {
return nil
}
diff --git a/pkg/cmd/local_run.go b/pkg/cmd/local_run.go
index a59cdb7..99a6fd2 100644
--- a/pkg/cmd/local_run.go
+++ b/pkg/cmd/local_run.go
@@ -19,6 +19,7 @@
import (
"fmt"
+ "strings"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -117,26 +118,12 @@
return nil
}
- // // Run integration inside a local container.
- // if command.Containerize {
- // // Get base image name.
-
- // // Assemble Dockerfile for containerized run.
- // // - copy properties
- // // - copy dependencies
- // // - copy sources
- // // = assemble run command: GetIntegrationRunCommand
-
- // // Build container image.
-
- // // Run container image.
-
- // return nil
- // }
-
// Get integration run command.
cmd := GetLocalIntegrationRunCommand(propertyFiles, dependencies, args)
+ // Output command we are about to run.
+ fmt.Printf("Executing: %s", strings.Join(cmd.Args, " "))
+
// Run integration locally.
err = cmd.Run()
if err != nil {
diff --git a/pkg/cmd/util_commands.go b/pkg/cmd/util_commands.go
index dc0ec17..4ddbf9e 100644
--- a/pkg/cmd/util_commands.go
+++ b/pkg/cmd/util_commands.go
@@ -19,7 +19,6 @@
import (
"context"
- "fmt"
"os"
"os/exec"
"strings"
@@ -81,8 +80,6 @@
// Add files to the command line under the CAMEL_K_ROUTES flag.
cmd.Env = append(cmd.Env, "CAMEL_K_ROUTES="+strings.Join(formatRoutes(routes), ","))
- fmt.Printf("executing: %s", strings.Join(cmd.Args, " "))
-
return cmd
}
diff --git a/pkg/cmd/util_dependencies.go b/pkg/cmd/util_dependencies.go
index bfe6d1c..eb4271a 100644
--- a/pkg/cmd/util_dependencies.go
+++ b/pkg/cmd/util_dependencies.go
@@ -349,8 +349,24 @@
// Relocate dependencies files to this integration's dependencies directory.
for _, dependency := range dependencies {
- relocatedDependency := path.Join(util.GetLocalDependenciesDir(), path.Base(dependency))
- util.CopyFile(dependency, relocatedDependency)
+ util.CopyFile(dependency, path.Join(util.GetLocalDependenciesDir(), path.Base(dependency)))
+ }
+
+ // Return relocated PropertyFiles.
+ return nil
+}
+
+func updateIntegrationRoutes(routes []string) error {
+ // Create dependencies directory under Maven working directory. This ensures that
+ // dependencies will be removed after they are not needed.
+ err := util.CreateLocalRoutesDirectory()
+ if err != nil {
+ return err
+ }
+
+ // Relocate dependencies files to this integration's dependencies directory.
+ for _, route := range routes {
+ util.CopyFile(route, path.Join(util.GetLocalRoutesDir(), path.Base(route)))
}
// Return relocated PropertyFiles.
diff --git a/pkg/util/docker/docker.go b/pkg/util/docker/docker.go
index 8d02367..d377533 100644
--- a/pkg/util/docker/docker.go
+++ b/pkg/util/docker/docker.go
@@ -18,7 +18,6 @@
package docker
import (
- "errors"
"os/exec"
"path"
"strings"
@@ -54,24 +53,20 @@
dockerFile = append(dockerFile, FROM(GetFullDockerImage(BaseImageName, latestTag)))
// Create container workspace directory.
- dockerFile = append(dockerFile, RUNMakeDir(IntegrationWorkingDirectory))
+ dockerFile = append(dockerFile, RUNMakeDir(GetContainerWorkspaceDir()))
// Set workspace directory.
- dockerFile = append(dockerFile, WORKDIR(IntegrationWorkingDirectory))
+ dockerFile = append(dockerFile, WORKDIR(GetContainerWorkspaceDir()))
// Copy files from local directory to container directories.
- dockerFile = append(dockerFile, COPY(util.GetLocalRoutesDir(), GetContainerRoutesDir()))
- dockerFile = append(dockerFile, COPY(util.GetLocalPropertiesDir(), GetContainerPropertiesDir()))
- dockerFile = append(dockerFile, COPY(util.GetLocalDependenciesDir(), GetContainerDependenciesDir()))
+ dockerFile = append(dockerFile, COPY(util.DefaultRoutesDirectoryName, util.DefaultRoutesDirectoryName))
+ dockerFile = append(dockerFile, COPY(util.DefaultPropertiesDirectoryName, util.DefaultPropertiesDirectoryName))
+ dockerFile = append(dockerFile, COPY(util.DefaultDependenciesDirectoryName, util.DefaultDependenciesDirectoryName))
// All Env variables the command requires need to be set in the container.
for _, keyValue := range integrationRunCmd.Env {
values := strings.Split(keyValue, "=")
- if len(values) != 2 {
- return errors.New("env var was not of key=value form")
- }
-
- dockerFile = append(dockerFile, ENV(values[0], values[1]))
+ dockerFile = append(dockerFile, ENV(values[0], strings.Join(values[1:], "=")))
}
// Compose command line.
@@ -107,7 +102,7 @@
// GetContainerWorkspaceDir -- directory inside the container where all the integration files are copied.
func GetContainerWorkspaceDir() string {
- return containerFileSeparator + "workspace"
+ return containerFileSeparator + util.DefaultWorkingDirectoryName
}
// GetContainerPropertiesDir -- directory inside the container where all the integration property files are copied.
diff --git a/pkg/util/docker/docker_base.go b/pkg/util/docker/docker_base.go
index 9d90935..e1ed17a 100644
--- a/pkg/util/docker/docker_base.go
+++ b/pkg/util/docker/docker_base.go
@@ -58,9 +58,7 @@
args = append(args, ImageArg(imageName, "")...)
// Root of source directory.
- if sourceDir != "" {
- args = append(args, sourceDir)
- }
+ args = append(args, sourceDir)
return args
}
diff --git a/pkg/util/util.go b/pkg/util/util.go
index a2ac051..a5d34da 100644
--- a/pkg/util/util.go
+++ b/pkg/util/util.go
@@ -50,6 +50,9 @@
// DefaultRoutesDirectoryName --
const DefaultRoutesDirectoryName = "routes"
+// DefaultWorkingDirectoryName --
+const DefaultWorkingDirectoryName = "workspace"
+
// StringSliceJoin --
func StringSliceJoin(slices ...[]string) []string {
size := 0
@@ -367,7 +370,7 @@
// GetLocalRoutesDir -- <mavenWorkingDirectory>/routes
func GetLocalRoutesDir() string {
- return path.Join(MavenWorkingDirectory, DefaultDependenciesDirectoryName)
+ return path.Join(MavenWorkingDirectory, DefaultRoutesDirectoryName)
}
// CreateLocalPropertiesDirectory --