-
Notifications
You must be signed in to change notification settings - Fork 5
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
root command to list unverified upstream sources #148
base: main
Are you sure you want to change the base?
Conversation
d9a0b02
to
96ebecb
Compare
96ebecb
to
721253d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some questions, suggestions posted below.
Overall the function introduced here does some logic and writes a file in the end. Which makes the testing of it difficult. If the logic would be separate from writing the tests could be easier to write, stateless, and would not need to be run in a container.
721253d
to
59cdbba
Compare
I have made some previously discussed changes to code. Now I have removed some part of code and made changes to existing ones. I think most of the review comments are addressed in these new changes. |
2b2c92b
to
8e75411
Compare
cmd/list_unverified_sources.go
Outdated
PreRunE: func(cmd *cobra.Command, args []string) error { | ||
pkg, _ := cmd.Flags().GetString("package") | ||
if pkg == "" { | ||
return fmt.Errorf("package not specified. Use : eext list-unverified-sources -p <package>") | ||
} | ||
return nil | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can avoid this and just use listUnverifiedSourcesCmd.MarkFlagRequired("package")
} | ||
pkgFound = true | ||
upstreamSources = append(upstreamSources, fetchUpstreamSrcsWithSkipCheck(pkgSpec.UpstreamSrc)...) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a break ?
impl/list_unverified_sources.go
Outdated
} | ||
|
||
if !pkgFound { | ||
return fmt.Errorf("listUnverifiedSources - '%s' package is not part of this repo", pkg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you make the error message in the same format as other subcommands
impl/list_unverified_sources.go
Outdated
if len(upstreamSources) != 0 { | ||
yamlUpstreamSources, err := yaml.Marshal(upstreamSources) | ||
if err != nil { | ||
return fmt.Errorf("listUnverifiedSources - errored with %s", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fmt.Errorf( "impl.ListUnVerifiedSources: Error '%s' unmarshaling yaml" )
to be consistent with rest of the code
impl/list_unverified_sources.go
Outdated
) | ||
|
||
// fetch upstream sources from manifest | ||
func fetchUpstreamSrcsWithSkipCheck(upstreamSrcManifest []manifest.UpstreamSrc) []manifest.UpstreamSrc { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rename this as getUpstreamSrcsWithSkipCheck
to not confuse with fetchUpstream
which actually downloads the sources.
impl/list_unverified_sources_test.go
Outdated
// Copyright (c) 2023 Arista Networks, Inc. All rights reserved. | ||
// Arista Networks, Inc. Confidential and Proprietary. | ||
|
||
//go:build containerized |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't have to be containerized.
This new root command is part of the `stest` and is designed to list all upstream sources with the `skip-check` flag set to `true`. - If `-p <package>` is specified, it lists unverified sources for the specified package. - If <package> not forund in repo, error is thrown The output is written to stdout This will enable better tracking of unverified sources.
8e75411
to
4d820ec
Compare
This new root command is part of the
stest
and is designed to list all upstream sources with theskip-check
flag set totrue
.-p <package>
is specified, it lists unverified sources for the specified package.The output is written to:
/dest/code.arista.io/eos/eext/{rep}/{package}.unverifiedSources.json
.This file will be included in the Barney snapshot build, enabling better tracking of unverified sources.