Compare commits

...

3 Commits

Author SHA1 Message Date
Foysal Iqbal
cb8c868121 add cache clean 2020-01-17 15:03:01 -05:00
Foysal Iqbal
8535e70dfa add cache clean 2020-01-17 14:58:42 -05:00
Foysal Iqbal
87ebd74daf fix image pull (#24) 2020-01-17 13:47:36 -05:00
4 changed files with 84 additions and 17 deletions

View File

@@ -20,3 +20,20 @@ The above command runs the checks in the default namespace. If you want to speci
Packaging of Qlik Sense on Kubernetes is done through a [Porter](https://porter.sh/) definition in the [Qlik Sense on Kubernetes configuration repository](https://github.com/qlik-oss/qliksense-k8s/blob/master/porter.yaml), the resulting bundle published on DockerHub as a [Cloud Natvie Application Bundle](https://cnab.io/) called [qliksense-cnab-bundle](https://hub.docker.com/r/qlik/qliksense-cnab-bundle).
### Versioning
A version of [qliksense-cnab-bundle](https://hub.docker.com/r/qlik/qliksense-cnab-bundle) is published corresponding to an edge release. To get the latest edge release simply specify `qliksense-cnab-bundle:latest`
## Known Issues
if you see the error message like this
```console
invoking custom action about on Qliksense...
Unable to find image 'qlik/qliksense-cnab-bundle@sha256:b41a3be13914daee9fb5b9b2d39e68aa99526600d9a99448b346992d6de48171' locally
Error: 1 error occurred:
* failed to invoke the bundle: Error response from daemon: manifest for qlik/qliksense-cnab-bundle@sha256:b41a3be13914daee9fb5b9b2d39e68aa99526600d9a99448b346992d6de48171 not found: manifest unknown: manifest unknown
```
please issue this command
```console
qliksense cache clear
```

View File

@@ -7,16 +7,27 @@ import (
func pullQliksenseImages(q *qliksense.Qliksense) *cobra.Command {
var (
cmd *cobra.Command
cmd *cobra.Command
opts *aboutOptions
)
opts = &aboutOptions{}
cmd = &cobra.Command{
Use: "pull",
Short: "Pull docke images for offline install",
Example: ` qliksense pull`,
Example: `qliksense pull`,
RunE: func(cmd *cobra.Command, args []string) error {
return q.PullImages()
return q.PullImages(opts.getTagDefaults(args))
},
}
f := cmd.Flags()
f.StringVarP(&opts.Version, "version", "v", "latest",
"From version of Qlik Sense The images will be pulled")
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 cmd
}

View File

@@ -46,8 +46,8 @@ func installPorter() (string, error) {
var (
porterPermaLink = pkg.Version
//porterPermaLink = "v0.3.0"
destination, homeDir, mixin, mixinOpts, qlikSenseHome, porterExe, ext string
mixinsVar = map[string]string{
destination, mixin, mixinOpts, qlikSenseHome, porterExe, ext string
mixinsVar = map[string]string{
"kustomize": "-v 0.2-beta-3-0e19ca4 --url https://github.com/donmstewart/porter-kustomize/releases/download",
"qliksense": "-v v0.14.0 --url https://github.com/qlik-oss/porter-qliksense/releases/download",
"exec": "-v latest",
@@ -68,14 +68,8 @@ func installPorter() (string, error) {
if runtime.GOOS == "windows" {
porterExe = porterExe + ".exe"
}
if qlikSenseHome = os.Getenv(qlikSenseHomeVar); qlikSenseHome == "" {
if homeDir, err = homedir.Dir(); err != nil {
return "", err
}
if homeDir, err = homedir.Expand(homeDir); err != nil {
return "", err
}
qlikSenseHome = filepath.Join(homeDir, qlikSenseDirVar)
if qlikSenseHome, err = getQliksenseHomeDir(); err != nil {
return "", err
}
os.Setenv(porterHomeVar, qlikSenseHome)
//TODO: Check if porter version is one alreadu is one for this build
@@ -157,6 +151,30 @@ var versionCmd = &cobra.Command{
},
}
var cacheClearCmd = &cobra.Command{
Use: "clear",
Short: "Clear the qliksense loacal cache",
Long: `Remove the everything from ~/.qliksense/cache directory`,
Run: func(cmd *cobra.Command, args []string) {
qsHome, err := getQliksenseHomeDir()
if err != nil {
fmt.Println("Cannot find qliksense home diretory")
return
}
cacheDir := filepath.Join(qsHome, "cache")
if _, err = os.Stat(cacheDir); err != nil {
// cache directory not exist
fmt.Println("Cache Cleaned")
return
}
if err = os.RemoveAll(cacheDir); err != nil {
fmt.Println("cannot remove cache", err)
return
}
fmt.Println("Cache Cleaned")
},
}
func rootCmd(p *qliksense.Qliksense) *cobra.Command {
var (
cmd, porterCmd, alias *cobra.Command
@@ -185,6 +203,11 @@ func rootCmd(p *qliksense.Qliksense) *cobra.Command {
}
// add version command
cmd.AddCommand(versionCmd)
// add cache command
var cahcheCommand = &cobra.Command{Use: "cache", Short: "Perform operations on cache"}
cmd.AddCommand(cahcheCommand)
cahcheCommand.AddCommand(cacheClearCmd)
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
return cmd
@@ -248,3 +271,19 @@ func copy(src, dst string) (int64, error) {
nBytes, err = io.Copy(destination, source)
return nBytes, err
}
func getQliksenseHomeDir() (string, error) {
var qlikSenseHome string
if qlikSenseHome = os.Getenv(qlikSenseHomeVar); qlikSenseHome == "" {
var homeDir string
var err error
if homeDir, err = homedir.Dir(); err != nil {
return "", err
}
if homeDir, err = homedir.Expand(homeDir); err != nil {
return "", err
}
qlikSenseHome = filepath.Join(homeDir, qlikSenseDirVar)
}
return qlikSenseHome, nil
}

View File

@@ -27,7 +27,7 @@ type Images struct {
}
// PullImages ...
func (p *Qliksense) PullImages() error {
func (p *Qliksense) PullImages(args []string) error {
var (
image string
err error
@@ -35,8 +35,8 @@ func (p *Qliksense) PullImages() error {
valid bool
images Images
)
if yamlVersion, err = p.CallPorter([]string{"invoke", "--action", "about"},
println("getting images list...")
if yamlVersion, err = p.CallPorter(append([]string{"invoke", "--action", "about"}, args...),
func(x string) (out *string) {
if strings.HasPrefix(x, "qlikSenseVersion") {
valid = true