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

Task: CLI artifact add command rstuf artifact add #39

Open
Tracked by #334
kairoaraujo opened this issue Aug 19, 2022 · 11 comments
Open
Tracked by #334

Task: CLI artifact add command rstuf artifact add #39

kairoaraujo opened this issue Aug 19, 2022 · 11 comments
Assignees
Milestone

Comments

@kairoaraujo
Copy link
Member

kairoaraujo commented Aug 19, 2022

Implement to the rstuf CLI the functionality to add artifacts.

Two specific features to add targets:

Add Artifact (Feature)

This target adds the target using the RSTUF REST API. This feature is an interface to add targets using the command line.

1. Simple one artifact file

Note: the user can use the token (-t/--token) when API requires authentication/authorization, if the user uses rstuf --auth it ignores the token parameter.

Giving the artifact

rstuf artifact add <file> [-p/--path <file-path>, -c/--custom, -t/--token <token>]

Example: rstuf artifact add file-v1.0.3.tar.gz -p projectA/download/

It gets from the file the hash, size and add a custom path in the metadata projectA/download/file-v1.0.3.tar.gz

Without file, just the information

rstuf artifact add -p/--path [file-path], -l/lenght [length] -h/hashes [b2sum] -c/--custom

2. From JSON

rstuf artifact add -d @file.json

{
  "targets": [
    {
      "info": {
        "length": "int",
        "hashes": {
          "blake2b-256": "str"
        },
        "custom": {
          "key": "value"
        }
      },
      "path": "str"
    },
    {
      "info": {
        "length": "int",
        "hashes": {
          "blake2b-256": "str"
        },
        "custom": {
          "key": "value"
        }
      },
      "path": "str"
    },
  ]
}

It should return the task id.

Import targets (Feature)

This feature adds a huge amount of targets, importing from CSV directly to RSTUF Database
The feature description is detailed in these links

@kairoaraujo
Copy link
Member Author

CLI Implementation

The RSTUF user will be required to create a CSV file that contains the following information
path;size;hash algorithm;hash;
Example:
test/optimistic_lamport-v1.0.tar.gz;12345;blake2b-256;716f6e863f744b9ac22c97ec7b76ea5f5908bc5b2f67c61510bfc4751384ea7a;

The CSV file limit will be half-million of targets (500,000 lines)

The CLI will implement as an admin command, and it will require some parameters

metadata-url: Address where the CLI can download the RSTUF TUF Metadata. i.e.: http://127.0.0.1:8080

db-uri: the RSTUF SQL DB URI. i.e.: postgresql://postgres:secret@127.0.0.1:5433
csv the CSV path. i.e targets-1of2.csv
Example:

rstuf admin add-targets -metadata-url http://127.0.0.1:8080 -db-uri postgresql://postgres:secret@127.0.0.1:5433 -csv ../repository-service-tuf/tests/data/targets-1of2.csv
The CLI will insert all the targets to the RSTUF SQL DB directly.
Running in a Macbook Pro (2019) 2,4 GHz 8-Core Intel Core i9/32GB 2667 MHz DDR4

import time: ~15 seconds

@kairoaraujo
Copy link
Member Author

kairoaraujo commented Feb 1, 2023

Requires for implementation:

Add targets (Feature)

  • Requires a Feature: BDD test implementation for refinement

Import targets (Feature)

@kairoaraujo
Copy link
Member Author

I updated the Issue description and the comment above.

@MVrachev
Copy link
Member

I think we can close that one, am I right @kairoaraujo?

@kairoaraujo
Copy link
Member Author

We added only part of this.

  • add targets
  • import targets

@MVrachev
Copy link
Member

MVrachev commented Mar 2, 2023

Sorry, but the comment you are referring to has three todo items and all of them are marked as complete.
What do I miss?

@kairoaraujo
Copy link
Member Author

Sorry, but the comment you are referring to has three todo items and all of them are marked as complete.
What do I miss?

There are two feauteres there (subtitles) there: Add targets (Feature) and Import targets (Feature)

@kairoaraujo kairoaraujo changed the title Add targets in the CLI Task: CLI artifact add command rstuf artifact add Aug 1, 2023
@kairoaraujo
Copy link
Member Author

kairoaraujo commented Aug 8, 2023

@KAUTH

I suggest breaking down this feature into three sub-tasks

So we can delivery small features and discuss more details in each.

@KAUTH
Copy link
Collaborator

KAUTH commented Aug 8, 2023

@kairoaraujo good point! I was thinking of breaking it similarly as well.

I was also considering that giving file information can also be substituted with giving JSON file with information for only one file. Adding an actual file I see the immediate value, but do you think we need both JSON file and file info as well?

@kairoaraujo
Copy link
Member Author

The JSON file is for adding a list of files, but it is a low priority.

@KAUTH
Copy link
Collaborator

KAUTH commented Aug 9, 2023

The JSON file is for adding a list of files, but it is a low priority.

Yeah, my point is one file is also a list of one. So, do we want both JSON file and passing file information?
In any case, I am working on "Implement rstuf artifact add giving a file. I will create tasks for each one and link them to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

3 participants