doru1004 commented on a change in pull request #1777:
URL: https://github.com/apache/camel-k/pull/1777#discussion_r512944750



##########
File path: pkg/cmd/inspect.go
##########
@@ -86,32 +116,110 @@ func (command *inspectCmdOptions) validate(args []string) 
error {
                }
        }
 
+       // Validate list of additional dependencies i.e. make sure that each 
dependency has
+       // a valid type.
+       if command.AdditionalDependencies != nil {
+               for _, additionalDependency := range 
command.AdditionalDependencies {
+                       additionalDependencies := 
strings.Split(additionalDependency, ",")
+
+                       for _, dependency := range additionalDependencies {
+                               dependencyComponents := 
strings.Split(dependency, ":")
+
+                               TypeIsValid := false
+                               for _, dependencyType := range 
acceptedDependencyTypes {
+                                       if dependencyType == 
dependencyComponents[0] {
+                                               TypeIsValid = true
+                                       }
+                               }
+
+                               if !TypeIsValid {
+                                       return errors.New("Unexpected type for 
user-provided dependency: " + dependency + ", check command usage for valid 
format.")
+                               }
+                       }
+               }
+       }
+
+       // If provided, ensure that that the dependencies directory exists.
+       if command.DependenciesDirectory != "" {
+               dependenciesDirectoryExists, err := 
util.DirectoryExists(command.DependenciesDirectory)
+               // Report any error.
+               if err != nil {
+                       return err
+               }
+
+               // Signal file not found.
+               if !dependenciesDirectoryExists {
+                       return errors.New("input file " + 
command.DependenciesDirectory + " file does not exist")
+               }
+       }
+
+       return nil
+}
+
+func (command *inspectCmdOptions) initialize(args []string) error {
+       // If --all-dependencies flag is set the workspace and dependencies 
directories need to have
+       // valid values. If not provided on the command line, the values need 
to be initialized with
+       // their default values.
+       if command.AllDependencies {
+               // Create workspace directory to hold all intermediate files.
+               err := createAndSetWorkspaceDirectory(command)
+               if err != nil {
+                       return err
+               }
+
+               // Move the integration dependecies to the dependencies 
directory.
+               err = createAndSetDependenciesDirectory(command)
+               if err != nil {
+                       return err
+               }
+       }
        return nil
 }
 
 func (command *inspectCmdOptions) run(args []string) error {
-       // Attempt to reuse existing Camel catalog if one is present.
-       catalog, err := camel.MainCatalog()
+       // Fetch existing catalog or create new one if one does not already 
exist.
+       catalog, err := createCamelCatalog()
+
+       // Output top-level dependencies.
+       outputTopLevel := !command.AllDependencies

Review comment:
       I have included them in the output if the format flag is enabled. When 
outputting transitive dependencies they are dumped in a folder accessible by 
the user. Top level dependencies should not be included in the output if 
transitive dependencies are enabled.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to