Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

fix -h, verison, and add global --dir flag with refactor#847

Merged
underrun merged 1 commit intoksonnet:masterfrom
underrun:issue-756-app-loading
Sep 7, 2018
Merged

fix -h, verison, and add global --dir flag with refactor#847
underrun merged 1 commit intoksonnet:masterfrom
underrun:issue-756-app-loading

Conversation

@underrun
Copy link
Collaborator

@underrun underrun commented Sep 2, 2018

this addresses both #756 and #836 but requires moving app loading to action handling rather than during cli command processing.

there are still some messy bits and it could use tests before merge - but i'd like feedback on the refactor first. specifically is there a cleaner/better way to do this, and/or is there anything else along side app initialization that I could move to make command parsing and code execution more cleanly separated?

@underrun underrun requested a review from a team September 2, 2018 22:08
@coveralls
Copy link

coveralls commented Sep 2, 2018

Pull Request Test Coverage Report for Build 1318

  • 250 of 309 (80.91%) changed or added relevant lines in 54 files are covered.
  • 8 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.2%) to 70.454%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/upgrade/upgrade.go 0 1 0.0%
pkg/app/app.go 1 2 50.0%
pkg/clicmd/jsonnet_args.go 1 3 33.33%
pkg/client/client.go 0 4 0.0%
pkg/clicmd/root.go 18 27 66.67%
pkg/actions/actions.go 24 42 57.14%
pkg/clicmd/prototype_use.go 25 49 51.02%
Files with Coverage Reduction New Missed Lines %
pkg/actions/actions.go 8 85.39%
Totals Coverage Status
Change from base Build 1316: -0.2%
Covered Lines: 12283
Relevant Lines: 17434

💛 - Coveralls

func genKsRoot(appName, ksDir, wd string) (string, error) {
if ksDir == "" {
return "", errors.New("invalid working directory")
func genKsRoot(appName, ksExecDir, newAppDir string) (string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

A comment with examples of the different ways of calling would be helpful to me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i will give an example or two, but i think the tests do a good job of showing all the cases?

func removePersistentFlags(flags *pflag.FlagSet, args []string) []string {
flags.Visit(func(flag *pflag.Flag) {
for i, arg := range args {
if len(arg) == 0 || arg[0] != '-' || len(arg) == 1 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

len(arg) < 2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

heh - yeah - just borrowed some of this code from cobra itself because i wanted to make sure i'm parsing flags the same way they do. i'll tweak it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

actually it needs to be this way but i'll add a comment


// long flag that might be known by ks
splitFlag := strings.SplitN(arg[2:], "=", 2)
if splitFlag[0] == flag.Name {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We may run into trouble if we ever use FlagSet.SetNormalizeFunc.

@underrun underrun force-pushed the issue-756-app-loading branch 2 times, most recently from 571699b to 077e092 Compare September 6, 2018 23:20
@underrun underrun force-pushed the issue-756-app-loading branch from 077e092 to f499ad5 Compare September 7, 2018 16:46
@underrun underrun changed the title fix -h, verison, and add --ks-root flag with refactor fix -h, verison, and add global --dir flag with refactor Sep 7, 2018
@underrun underrun force-pushed the issue-756-app-loading branch from f499ad5 to 6817498 Compare September 7, 2018 16:57
includes refactor moving app creation to later in the initialization
process and only when needed. also fixes regression preventing commands
that don't need an app from running outside an app directory.

Signed-off-by: Derek Wilson <derek@heptio.com>
@underrun underrun force-pushed the issue-756-app-loading branch from 6817498 to 3ff6fb1 Compare September 7, 2018 16:58
@underrun underrun merged commit 6f47d32 into ksonnet:master Sep 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants