Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make odo work if optional metadata.name field is missing in Devfile #6015

Commits on Aug 29, 2022

  1. Move 'starter_project.go' from 'pkg/component' to 'pkg/registry'

    Functions in this file are only called from the 'registry' package,
    so it makes sense for this file to belong to this package.
    
    Furthermore, this paves the way to calling 'alizer.DetectName' from 'component.go',
    thus avoiding a cyclic dependency between packages.
    rm3l committed Aug 29, 2022
    Configuration menu
    Copy the full SHA
    bb2ccc2 View commit details
    Browse the repository at this point in the history
  2. Introduce central logic for determining component names in 'pkg/compo…

    …nent/component.go'
    
    This rewrites the 'component#GatherName' function that was already there,
    but not used, to meet the expectations, i.e.:
    
    - use 'metadata.name' field (after sanitizing it) if it is defined in the Devfile
    - otherwise, use Alizer to detect the name. Under the hood, this leverages the 'alizer#DetectName' introduced in 83ad3ee, which means that:
    -- use Alizer to detect the name automatically
    -- otherwise, use the name of the Devfile base directory after sanitizing it
    rm3l committed Aug 29, 2022
    Configuration menu
    Copy the full SHA
    0fe155f View commit details
    Browse the repository at this point in the history
  3. Compute and store the component name in the CLI context, and pass it …

    …as needed
    
    As commented out in [1], the context should ideally be built
    and passed down to the business clients structs.
    
    [1] redhat-developer#6015 (comment)
    rm3l committed Aug 29, 2022
    Configuration menu
    Copy the full SHA
    2d9af3e View commit details
    Browse the repository at this point in the history
  4. Enrich relevant integration test cases

    For the sake of both performance and readability,
    only the tests that break in the absence of a 'metadata.name'
    field in their Devfiles have been updated (to test this specific case).
    rm3l committed Aug 29, 2022
    Configuration menu
    Copy the full SHA
    88c360b View commit details
    Browse the repository at this point in the history
  5. Add test case for 'odo dev' when a project with no source code is use…

    …d with no 'metadata.name' in the Devfile
    
    The rationale behind this is to purposely make
    the Alizer library unable to detect the project.
    Per the requirements, this would force us to use the project
    directory name as component name.
    
    This highlights an interesting behavior if the project
    directory name is all-numeric (as is the case in our tests);
    our sanitization logic automatically prepends an "x" prefix
    to the directory name, so it can be used as a valid name
    for the component.
    rm3l committed Aug 29, 2022
    Configuration menu
    Copy the full SHA
    3aa7bc0 View commit details
    Browse the repository at this point in the history