Fix creation of intermediate files in the local folder.
diff --git a/pkg/cmd/local_create.go b/pkg/cmd/local_create.go
index ee47a43..715beaf 100644
--- a/pkg/cmd/local_create.go
+++ b/pkg/cmd/local_create.go
@@ -136,21 +136,27 @@
}
func (command *localCreateCmdOptions) run(args []string) error {
- // Fetch dependencies.
- dependencies, err := getDependencies(args, command.AdditionalDependencies, true)
- if err != nil {
- return err
- }
+ dependenciesList := []string{}
+ propertyFilesList := []string{}
+ if !command.BaseImage {
+ // Fetch dependencies.
+ dependencies, err := getDependencies(args, command.AdditionalDependencies, true)
+ if err != nil {
+ return err
+ }
+ dependenciesList = dependencies
- // Manage integration properties which may come from files or CLI.
- propertyFiles, err := updateIntegrationProperties(command.Properties, command.PropertyFiles)
- if err != nil {
- return err
+ // Manage integration properties which may come from files or CLI.
+ propertyFiles, err := updateIntegrationProperties(command.Properties, command.PropertyFiles)
+ if err != nil {
+ return err
+ }
+ propertyFilesList = propertyFiles
}
// Create and build integration image.
- err = createAndBuildIntegrationImage(command.ContainerRegistry, command.BaseImage,
- command.Image, propertyFiles, dependencies, args)
+ err := createAndBuildIntegrationImage(command.ContainerRegistry, command.BaseImage,
+ command.Image, propertyFilesList, dependenciesList, args)
if err != nil {
return err
}
diff --git a/pkg/cmd/util_containerization.go b/pkg/cmd/util_containerization.go
index 425db3e..86e7653 100644
--- a/pkg/cmd/util_containerization.go
+++ b/pkg/cmd/util_containerization.go
@@ -110,41 +110,43 @@
return err
}
+ if justBaseImage {
+ return nil
+ }
+
// Create integration image if integration files were provided.
- if !justBaseImage {
- // Copy dependencies to a dependencies folder under a local directory.
- err = updateIntegrationDependencies(dependencies)
- if err != nil {
- return err
- }
+ // Copy dependencies to a dependencies folder under a local directory.
+ err = updateIntegrationDependencies(dependencies)
+ if err != nil {
+ return err
+ }
- // Copy routes to a routes folder under a local directory.
- err = updateIntegrationRoutes(routes)
- if err != nil {
- return err
- }
+ // Copy routes to a routes folder under a local directory.
+ err = updateIntegrationRoutes(routes)
+ 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, routes)
+ // 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, routes)
- // Create the integration image Docker file.
- err = docker.CreateIntegrationImageDockerFile(containerCmd)
- if err != nil {
- return err
- }
+ // Create the integration image Docker file.
+ err = docker.CreateIntegrationImageDockerFile(containerCmd)
+ if err != nil {
+ return err
+ }
- // Get the Docker command arguments for building the base image and create the command.
- args := docker.BuildIntegrationImageArgs(image)
- cmd := exec.CommandContext(ctx, "docker", args...)
+ // Get the Docker command arguments for building the base image and create the command.
+ args := docker.BuildIntegrationImageArgs(image)
+ cmd := exec.CommandContext(ctx, "docker", args...)
- // Output executed command.
- fmt.Printf("Executing: " + strings.Join(cmd.Args, " ") + "\n")
+ // Output executed command.
+ fmt.Printf("Executing: " + strings.Join(cmd.Args, " ") + "\n")
- // Run the command.
- if err := cmd.Run(); err != nil {
- errors.Errorf("integration image containerization did not run successfully: %v", err)
- }
+ // Run the command.
+ if err := cmd.Run(); err != nil {
+ return errors.Errorf("integration image containerization did not run successfully: %v", err)
}
return nil
diff --git a/pkg/util/util.go b/pkg/util/util.go
index a5d34da..49c5bac 100644
--- a/pkg/util/util.go
+++ b/pkg/util/util.go
@@ -375,6 +375,11 @@
// CreateLocalPropertiesDirectory --
func CreateLocalPropertiesDirectory() error {
+ // Do not create a directory unless the maven directory contains a valid value.
+ if MavenWorkingDirectory == "" {
+ return nil
+ }
+
directoryExists, err := DirectoryExists(GetLocalPropertiesDir())
if err != nil {
return err
@@ -391,6 +396,11 @@
// CreateLocalDependenciesDirectory --
func CreateLocalDependenciesDirectory() error {
+ // Do not create a directory unless the maven directory contains a valid value.
+ if MavenWorkingDirectory == "" {
+ return nil
+ }
+
directoryExists, err := DirectoryExists(GetLocalDependenciesDir())
if err != nil {
return err
@@ -407,6 +417,11 @@
// CreateLocalRoutesDirectory --
func CreateLocalRoutesDirectory() error {
+ // Do not create a directory unless the maven directory contains a valid value.
+ if MavenWorkingDirectory == "" {
+ return nil
+ }
+
directoryExists, err := DirectoryExists(GetLocalRoutesDir())
if err != nil {
return err