-
Notifications
You must be signed in to change notification settings - Fork 103
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
Repo Index #730
Merged
Merged
Repo Index #730
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
9c7a6ab
Feature package command
kensipe 7d7b21a
add afero as a file system abstraction. Tests currently still use OsFs
kensipe bb13f23
adding in checks for tarball creation
kensipe 3ce5768
happy linter.. happy life
kensipe 154cbfa
tar test written for in-mem
kensipe e6042ad
hash on gzip is problematic, tar and untar with a check of a file is …
kensipe be0c21a
switched to using testdata for package cmd test
kensipe 2058b09
linter needs to be my precondition of git push
kensipe 62f2564
reducing visiblity of fs
kensipe d6b9090
tarball code needs to use tarball writer
kensipe 7f0634b
move afero out of main and into cmd package
kensipe 615a323
Apply suggestions from code review
kensipe b9b1ec4
updates based on pr feedback
kensipe d2d76a5
adding details based on PR feedback
kensipe d22b67c
start of repo cmd
kensipe c6e980b
todo list
kensipe 12d12bb
temp stop
kensipe 2d2e0df
Merge branch 'master' into ken/repo-index
kensipe 8f055f2
merge to master complete
kensipe 090d06d
tests for bundle verisons and index files
kensipe 8763b0a
switched bundle for package
kensipe c81348a
mapping package files to package versions with tests
kensipe dd7398d
adding newIndexFile function and updated tests
kensipe 2c3ec82
adding url component to index
kensipe c8486d8
latest
kensipe 855ed8a
Merge branch 'master' into ken/repo-index
kensipe e723dd9
tar to crd to package
kensipe 06a851c
working index
kensipe f338190
Merge branch 'master' into ken/repo-index
kensipe 48e6332
Merge branch 'master' into ken/repo-index
kensipe 30bcbc2
grammar fix
kensipe a2ec239
removed apivresion from index
kensipe cb70549
adding appVersion to metadata and min k8s version is 1.15.0
kensipe 0c6b8ca
remove create date to packages
kensipe 5c04ea4
writing from cmd
kensipe 8f0aaa2
Merge branch 'master' into ken/repo-index
kensipe adcd1f3
renaming source file name
kensipe 841283b
clean up
kensipe b9015e8
code and comment cleanup
kensipe 39405b2
refactor to index
kensipe 04a49e1
Merge branch 'master' into ken/repo-index
kensipe db14af4
happy linter happy life
kensipe 429157d
Apply suggestions from code review
kensipe 1bdeb00
updates based on pr feedback
kensipe b7cca7f
update based on pr feedback
kensipe 7e49009
update desc for length
kensipe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package cmd | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/spf13/afero" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
const repoDesc = ` | ||
This command consists of multiple sub-commands to interact with KUDO repositories. | ||
|
||
It can be used to add, remove, list, and index kudo repositories. | ||
Example usage: | ||
$ kubectl kudo repo add [NAME] [REPO_URL]` | ||
|
||
// newRepoCmd for repo commands such as building a repo index | ||
func newRepoCmd(fs afero.Fs, out io.Writer) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "repo [FLAGS] add|remove|list|index| update [ARGS]", | ||
Short: "Package an official KUDO operator.", | ||
Long: `Add, list, remove, update, and index kudo repositories`, | ||
Example: repoDesc, | ||
} | ||
|
||
cmd.AddCommand(newRepoIndexCmd(fs, out)) | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"time" | ||
|
||
"github.com/kudobuilder/kudo/pkg/kudoctl/files" | ||
"github.com/kudobuilder/kudo/pkg/kudoctl/util/repo" | ||
|
||
"github.com/spf13/afero" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
const repoIndexDesc = ` | ||
Read the provided directory and generate an index file based on the packages found. | ||
|
||
This tool is used for creating an 'index.yaml' file for a KUDO package repository. To | ||
set an absolute URL to the operators, use '--url' flag. | ||
|
||
# Create an index file for all KUDO packages in the repo-dir. | ||
$ kubectl kudo repo index repo-dir` | ||
|
||
type repoIndexCmd struct { | ||
path string | ||
url string | ||
overwrite bool | ||
out io.Writer | ||
fs afero.Fs | ||
} | ||
|
||
// newRepoIndexCmd for repo commands such as building a repo index file. | ||
func newRepoIndexCmd(fs afero.Fs, out io.Writer) *cobra.Command { | ||
index := &repoIndexCmd{out: out, fs: fs} | ||
cmd := &cobra.Command{ | ||
Use: "index [flags] <DIR>", | ||
Short: "Generate an index file given a directory containing KUDO packages", | ||
Long: repoIndexDesc, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if err := validateRepoIndex(args); err != nil { | ||
return err | ||
} | ||
index.path = args[0] | ||
if err := index.run(); err != nil { | ||
return err | ||
} | ||
return nil | ||
}, | ||
SilenceUsage: true, | ||
} | ||
|
||
f := cmd.Flags() | ||
f.StringVar(&index.url, "url", "", "URL of the operator repository") | ||
f.BoolVarP(&index.overwrite, "overwrite", "o", false, "Overwrite existing package") | ||
|
||
return cmd | ||
} | ||
|
||
func validateRepoIndex(args []string) error { | ||
if len(args) != 1 { | ||
return fmt.Errorf("expecting exactly one argument - directory containing the operators to package") | ||
} | ||
return nil | ||
} | ||
|
||
// run returns the errors associated with cmd env | ||
func (ri *repoIndexCmd) run() error { | ||
target, err := files.FullPathToTarget(ri.fs, ri.path, "index.yaml", ri.overwrite) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
t := time.Now() | ||
i, err := repo.IndexDirectory(ri.fs, ri.path, ri.url, &t) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
i.WriteFile(fs, target) | ||
fmt.Fprintf(ri.out, "index %v created.\n", target) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should we use
log.Println()
instead? Or at least print to stderr.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.
lets let this go... we don't have proper logging yet and I have a PR that is built off this PR which introduces a debug flag with debug printing. This seems like something that should be a debug print out. (or logging).