Skip to content

ngclient: review argument names #1638

Closed

Description

@jku

Now that API seems to stabilizing (and before we have a stable release) let's check that argument names ngclient uses are consistent.

Lukas in #1604:

The pairs repository_dir - metadata_base_url, and target_dir - target_base_url both describe the local and remote location respectively for the given file type. Maybe we could use names that show this duality more directly? Here are some naming suggestions

  1. Rename repository_dir to metadata_dir. IMO repository_dir sounds more like something that contains metadata, targets and keys (at least that was the case in the old implementation), whereas here it only contains metadata.
  2. Use remote and local prefixes, e.g. local_metadata_dir and remote_metadata_base_url or, to make the latter shorter, remote_metadata_dir?

At least metadata vs repository seems like an obvious flaw: no need to use two different terms.

The second one I'm not so sure about: the names are long enough that I already avoid naming the args because of it, and for me "url" vs "dir" does give a hint that one is remote and one is not remote...

Activity

  1. lukpueh commented on Oct 27, 2021

    @lukpueh
    Member

    ... "url" vs "dir" does give a hint that one is remote and one is not remote

    I did have a similar hunch. Just wanted to briefly rethink this together. But I'm fine with leaving those and don't make the names any longer.

  2. lukpueh commented on Oct 27, 2021

    @lukpueh
    Member

    Since we have this issue, I'll bring up another very mild naming concern I had.

    When I read target_dir, I inevitably think of the man pages for ln or cp and that something is moved somewhere. There's probably not much we can do, but would targets_dir (plural) make it a little better? Or will that make it look like a directory for targets metadata? Not trying to bikeshed here, and happy to let it go if nobody thinks this is an issue or has a better idea.

  3. added
    backlog
    on Oct 27, 2021
  4. added this to the Sprint 14 milestone on Dec 8, 2021
  5. jku commented on Dec 8, 2021

    @jku
    MemberAuthor

    Argument names currently

    Constructor: 
        repository_dir
        metadata_base_url
        target_dir
        target_base_url
    
    get_targetinfo()
        target_path
    
    find_cached_target()
        targetinfo
        filepath
    
    download_target()
        targetinfo
        filepath
        target_base_url 
    
    

    possible changes:

    • make repository_dir clearer: rename to metadata_dir
    • make target_dir clearer: maybe rename to targets_dir or download_dir? same rename should probably be done to target_base_url
    • maybe filepath should be better tied to the targets directory name: if we have download_dir we could also rename filepath to download_path?
  6. added a commit that references this issue on Dec 15, 2021
    2a6e773
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

backlogngclient

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions