Skip to content

Commit

Permalink
Default to latest qliksense bundle
Browse files Browse the repository at this point in the history
Signed-off-by: Boris Kuschel <boris.kuschel@qlik.com>
  • Loading branch information
Boris Kuschel committed Dec 19, 2019
1 parent 0623ebd commit 51bc8fd
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
41 changes: 37 additions & 4 deletions cmd/qliksense/aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,17 @@ func buildBuildAlias(porterCmd *cobra.Command) *cobra.Command {
}

type paramOptions struct {
aboutOptions
Params []string
ParamFiles []string
File string
Name string
InsecureRegistry bool
CNABFile string

// CredentialIdentifiers is a list of credential names or paths to make available to the bundle.
CredentialIdentifiers []string
Driver string
Force bool
Insecure bool
Tag string
}

func buildInstallAlias(porterCmd *cobra.Command, q *qliksense.Qliksense) *cobra.Command {
Expand All @@ -72,6 +71,7 @@ The first argument is the bundle instance name to create for the installation. T
Porter uses the Docker driver as the default runtime for executing a bundle's invocation image, but an alternate driver may be supplied via '--driver/-d'.
For example, the 'debug' driver may be specified, which simply logs the info given to it and then exits.`,
Example: ` qliksense install
qliksense install --version v1.0.0
qliksense install --insecure
qliksense install qliksense --file qliksense/bundle.json
qliksense install --param-file base-values.txt --param-file dev-values.txt --param test-mode=true --param header-color=blue
Expand All @@ -83,6 +83,7 @@ For example, the 'debug' driver may be specified, which simply logs the info giv
RunE: func(cmd *cobra.Command, args []string) error {
// Push images here.
// TODO: Need to get the private reg from params
args = opts.getTagDefaults(args)
if registry = opts.findKey("dockerRegistry"); registry != nil {
if len(*registry) > 0 {
q.TagAndPushImages(*registry)
Expand All @@ -95,6 +96,8 @@ For example, the 'debug' driver may be specified, which simply logs the info giv
},
}
f := c.Flags()
f.StringVarP(&opts.Version, "version", "v", "latest",
"Version of Qlik Sense to install")
f.BoolVar(&opts.Insecure, "insecure", true,
"Allow working with untrusted bundles")
f.StringVarP(&opts.File, "file", "f", "",
Expand All @@ -117,23 +120,53 @@ For example, the 'debug' driver may be specified, which simply logs the info giv
"Force a fresh pull of the bundle and all dependencies")
return c
}
func (o *aboutOptions) getTagDefaults(args []string) []string {
var err error
if len(o.Tag) <= 0 && len(o.File) <= 0 && len(o.CNABFile) <= 0 {
if _, err = os.Stat("porter.yaml"); err != nil {
args = append(args, []string{"--tag", "qlik/qliksense-cnab-bundle:" + o.Version}...)
}
}
return args
}

type aboutOptions struct {
Version string
Tag string
File string
CNABFile string
}

func buildAboutAlias(porterCmd *cobra.Command) *cobra.Command {
var (
c *cobra.Command
c *cobra.Command
opts *aboutOptions
)

opts = &aboutOptions{}

c = &cobra.Command{
Use: "about",
Short: "About Qlik Sense",
Long: "Gives the verion of QLik Sense on Kuberntetes and versions of images.",
DisableFlagParsing: true,
RunE: func(cmd *cobra.Command, args []string) error {
args = opts.getTagDefaults(args)
return porterCmd.RunE(porterCmd, append([]string{"invoke", "--action", "about"}, args...))
},
Annotations: map[string]string{
"group": "alias",
},
}
f := c.Flags()
f.StringVarP(&opts.Version, "version", "v", "latest",
"Version of Qlik Sense to install")
f.StringVarP(&opts.Tag, "tag", "t", "",
"Use a bundle in an OCI registry specified by the given tag")
f.StringVarP(&opts.File, "file", "f", "",
"Path to the porter manifest file. Defaults to the bundle in the current directory.")
f.StringVar(&opts.CNABFile, "cnab-file", "",
"Path to the CNAB bundle.json file.")
return c
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/qliksense/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func installPorter() (string, error) {
homeDir, mixin, mixinOpts, porterHome, porterExe string
mixinsVar = map[string]string{
"kustomize": "-v 0.2-beta-3-0e19ca4 --url https://github.com/donmstewart/porter-kustomize/releases/download",
"qliksense": "-v v0.9.0 --url https://github.com/qlik-oss/porter-qliksense/releases/download",
"qliksense": "-v v0.11.0 --url https://github.com/qlik-oss/porter-qliksense/releases/download",
"exec": "-v latest",
"kubernetes": "-v latest",
"helm": "-v latest",
Expand Down Expand Up @@ -158,7 +158,7 @@ func rootCmd(p *qliksense.Qliksense) *cobra.Command {
cmd.AddCommand(pullQliksenseImages(p))
porterCmd = porter(p)
cmd.AddCommand(porterCmd)
for _, alias = range buildAliasCommands(porterCmd,p) {
for _, alias = range buildAliasCommands(porterCmd, p) {
cmd.AddCommand(alias)
}

Expand Down

0 comments on commit 51bc8fd

Please sign in to comment.