Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 46 additions & 25 deletions cmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,15 @@ func AppCommand() cli.Command {
Name: "no-prompt",
Copy link
Contributor

Choose a reason for hiding this comment

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

Could add an example in description that includes these flags

Usage: "Suppress asking questions and use the default values when required answers are not provided",
},
cli.IntFlag{
Name: "timeout",
Usage: "Amount of time to wait for k8s commands (default is 300 secs). Example: --timeout 600",
Value: 300,
},
cli.BoolFlag{
Name: "wait",
Usage: "Wait, as long as timeout value, for installed resources to be ready (pods, PVCs, deployments, etc.). Example: --wait",
},
},
},
cli.Command{
Expand Down Expand Up @@ -253,6 +262,12 @@ func AppCommand() cli.Command {
formatFlag,
},
},
cli.Command{
Name: "show-notes",
Usage: "Show contents of apps notes.txt",
Action: appNotes,
ArgsUsage: "[APP_NAME/APP_ID]",
},
},
}
}
Expand Down Expand Up @@ -658,38 +673,44 @@ func templateInstall(ctx *cli.Context) error {
app.TargetNamespace = namespace
}

app.Wait = ctx.Bool("wait")
Copy link
Contributor

Choose a reason for hiding this comment

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

should wait boolflag have a default of true? false? what happens if you set app.Wait to nil or whatever comes through from the not setting BoolFlag Value?

Copy link
Contributor Author

@rmweir rmweir Jul 23, 2019

Choose a reason for hiding this comment

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

default on bool flags is false, which is intended. I tested without using wait.

Copy link
Contributor

Choose a reason for hiding this comment

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

then we're good

app.Timeout = ctx.Int64("timeout")

madeApp, err := c.ProjectClient.App.Create(app)
if err != nil {
return err
}

// wait for the app to be installed to print the notes
var (
timeout int
installed bool
)
for !installed {
if timeout == 60 {
return errors.New("timed out waiting for app to install. Run 'rancher apps' to verify status")
}
timeout++
time.Sleep(2 * time.Second)
madeApp, err = c.ProjectClient.App.ByID(madeApp.ID)
if err != nil {
return err
}
for _, condition := range madeApp.Conditions {
condType := strings.ToLower(condition.Type)
condStatus := strings.ToLower(condition.Status)
if condType == "installed" && condStatus == "true" {
installed = true
break
}
}
fmt.Printf("run \"app show-notes %s\" to view app notes once app is ready\n", madeApp.Name)

return nil
}

// appNotes prints notes from app's notes.txt file
func appNotes(ctx *cli.Context) error {
c, err := GetClient(ctx)
if err != nil {
return err
}

if ctx.NArg() < 1 {
return cli.ShowSubcommandHelp(ctx)
}

resource, err := Lookup(c, ctx.Args().First(), "app")
if err != nil {
return err
}

if len(madeApp.Notes) != 0 {
fmt.Println(madeApp.Notes)
app, err := c.ProjectClient.App.ByID(resource.ID)
if err != nil {
return err
}

if len(app.Notes) > 0 {
fmt.Println(app.Notes)
} else {
fmt.Println("no notes to print")
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion vendor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ github.com/pmezard/go-difflib v1.0.0
github.com/stretchr/testify v1.2.2

github.com/rancher/norman 457c15b94acae52afb5290aa315452c7621d452a
github.com/rancher/types ee87bbdceacff5c566f901bdc57eec8330e7ed13
github.com/rancher/types 830a7b6821e671ee072464138af6ef2b44114a48 https://github.com/rmweir/types
30 changes: 22 additions & 8 deletions vendor/github.com/rancher/types/.drone.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/github.com/rancher/types/Dockerfile.dapper

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading