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

Improve separation between type implementations and CLI code #339

Merged
merged 12 commits into from
Jul 14, 2021

Conversation

bobcallaway
Copy link
Member

@bobcallaway bobcallaway commented Jun 23, 2021

This is the first of a few patches to try to clean up & simplify the CLI implementation, as well as make responsibility more clear for the pluggable type interface.

  • Adds support for specifying specific versions of pluggable types (using --type type(:version_string)? command line flag)
  • Use go-playground/validator instead of custom validation functions where possible
  • Have CLI help enumerate supported types (and versions), as well as PKI formats
  • Remove all type-specific code from CLI (except for RFC3161 timestamping)
  • Move calls to create format-agnostic entry objects (i.e. models.ProposedEntry) into versioned type implementations instead of within CLI
  • Remove duplicated flag checking code in various CLI functions
  • Added SupportedVersions() method to TypeImpl for enumerating the versions of pluggable types supported
  • Added DefaultVersion() method to TypeImpl so if a type is requested without a version, the default version will be used

Fixes #273

This allows for more DRY addition of new PKI types, and stricter
type checking. This also allows for simpler enumeration of
supported PKI formats which will be used in further updates to
simplify the CLI codebase.

Signed-off-by: Bob Callaway <[email protected]>
This adds support for the alpine package format used by Alpine Linux,
which is the concatenation of three tgz files (signature, control data,
and then the actual package files).

Signed-off-by: Bob Callaway <[email protected]>
@cpanato cpanato added this to the 0.3.0 milestone Jun 24, 2021
@puerco puerco mentioned this pull request Jul 12, 2021

"github.com/sigstore/rekor/pkg/log"

// these imports are to call the packages' init methods
Copy link
Member

@loosebazooka loosebazooka Jul 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels strange to me, but maybe I'm not familiar enough with the flags/command library in use here? If this has to know about its sub commands -- should it not just be responsible for initializing them? the whole init back and forth here feels like it's hard to trace things in code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before this change, the types weren't imported because we were directly creating objects of each type. Since the object creation code now lies in pkg/types/..., we need to trigger the type's init() methods to fire to populate the type & version maps accordingly, so that's why we have the imports here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think my problem is that we need to trigger the init() functions explicitly like without ever actually using anything from the package explicitly. The pattern just feels off to me, but I dunno, I don't have any better/alternative solutions.

pkg/log/log.go Outdated Show resolved Hide resolved
pkg/types/entries.go Outdated Show resolved Hide resolved
Copy link
Member

@loosebazooka loosebazooka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, just some personal confusion about how init should be used in this cli library.

Signed-off-by: Bob Callaway <[email protected]>
@bobcallaway
Copy link
Member Author

looks good to me, just some personal confusion about how init should be used in this cli library.

@loosebazooka I addressed the points you raised - appreciate any other feedback you might have.

@loosebazooka
Copy link
Member

/lgtm

@dlorenc
Copy link
Member

dlorenc commented Jul 14, 2021

Sorry for the delay - I got confused about whether we were moving this one forward or the other one.

@dlorenc dlorenc merged commit 53d71cd into sigstore:main Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor CLI type handling
4 participants