Compare commits

...

8 Commits

Author SHA1 Message Date
Foysal Iqbal
9248ec8c6b fix release 2020-02-07 13:49:31 -05:00
Foysal Iqbal
1dd51a5bf6 Merge branch 'keys-backup-restore' into fix-default-install 2020-02-07 13:08:54 -05:00
Foysal Iqbal
023956aba6 use default install
Signed-off-by: Foysal Iqbal <mqb@qlik.com>
2020-02-07 13:08:12 -05:00
Andriy Bulynko
f8630eb26a Storing/referencing ejson keys at path: ${qliksenseHome}/ejson/keys 2020-02-07 13:01:28 -05:00
Foysal Iqbal
42b10a87ea Merge branch 'ms-3' into fix-default-install 2020-02-06 15:10:14 -05:00
Foysal Iqbal
b7f7a65b5c temp fix 2020-02-06 15:09:53 -05:00
Foysal Iqbal
36b6d6f708 merge conflict 2020-02-06 14:05:40 -05:00
Foysal Iqbal
b9fc829256 add mongoDbUri
Signed-off-by: Foysal Iqbal <mqb@qlik.com>
2020-02-06 14:03:57 -05:00
9 changed files with 54 additions and 22 deletions

View File

@@ -2,7 +2,6 @@ package main
import (
"errors"
"github.com/Masterminds/semver/v3"
"github.com/qlik-oss/sense-installer/pkg/qliksense"
"github.com/spf13/cobra"
)
@@ -17,9 +16,6 @@ func fetchCmd(q *qliksense.Qliksense) *cobra.Command {
if len(args) != 1 {
return errors.New("requires a version (i.e. v1.0.0)")
}
if _, err := semver.NewVersion(args[0]); err != nil {
return errors.New("is it not a valid version. should be something like this v1.0.0")
}
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {

View File

@@ -2,7 +2,6 @@ package main
import (
"errors"
"github.com/Masterminds/semver/v3"
"github.com/qlik-oss/sense-installer/pkg/qliksense"
"github.com/spf13/cobra"
)
@@ -18,9 +17,6 @@ func installCmd(q *qliksense.Qliksense) *cobra.Command {
if len(args) != 1 {
return errors.New("requires a version (i.e. v1.0.0)")
}
if _, err := semver.NewVersion(args[0]); err != nil {
return errors.New("is it not a valid version. should be something like this v1.0.0")
}
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
@@ -32,6 +28,7 @@ func installCmd(q *qliksense.Qliksense) *cobra.Command {
f.StringVarP(&opts.AcceptEULA, "acceptEULA", "a", "", "AcceptEULA for qliksense")
f.StringVarP(&opts.Namespace, "namespace", "n", "", "Namespace where to install the qliksense")
f.StringVarP(&opts.StorageClass, "storageClass", "s", "", "Storage class for qliksense")
f.StringVarP(&opts.MongoDbUri, "mongoDbUri", "m", "", "mongoDbUri for qliksense (i.e. mongodb://qliksense-mongodb:27017/qliksense?ssl=false)")
return c
}

View File

@@ -41,7 +41,9 @@ func initAndExecute() error {
qliksense.LogDebugMessage("QliksenseHomeDir: %s", qlikSenseHome)
qliksense.SetUpQliksenseDefaultContext(qlikSenseHome)
if err = rootCmd(qliksense.New(qlikSenseHome)).Execute(); err != nil {
if qliksenseClient, err := qliksense.New(qlikSenseHome); err != nil {
return err
} else if err := rootCmd(qliksenseClient).Execute(); err != nil {
return err
}
@@ -63,7 +65,11 @@ func setUpPaths() (string, error) {
}
qlikSenseHome = filepath.Join(homeDir, qlikSenseDirVar)
}
os.Mkdir(qlikSenseHome, os.ModePerm)
if err := os.MkdirAll(qlikSenseHome, os.ModePerm); err != nil {
return "", err
}
return qlikSenseHome, nil
}

4
go.mod
View File

@@ -16,7 +16,7 @@ replace (
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20191004115801-a2eda9f80ab8
k8s.io/client-go => k8s.io/client-go v0.0.0-20191016111102-bec269661e48
k8s.io/kubectl => k8s.io/kubectl v0.0.0-20191016120415-2ed914427d51
sigs.k8s.io/kustomize/api => github.com/qlik-oss/kustomize/api v0.3.3-0.20200129153315-09eb26c762c8
sigs.k8s.io/kustomize/api => github.com/qlik-oss/kustomize/api v0.3.3-0.20200206224201-2e697eccbad9
)
require (
@@ -52,7 +52,7 @@ require (
github.com/mitchellh/go-homedir v1.1.0
github.com/morikuni/aec v1.0.0 // indirect
github.com/pkg/errors v0.8.1
github.com/qlik-oss/k-apis v0.0.4
github.com/qlik-oss/k-apis v0.0.8
github.com/sirupsen/logrus v1.4.2
github.com/spf13/cobra v0.0.5
github.com/spf13/viper v1.6.1

8
go.sum
View File

@@ -909,8 +909,16 @@ github.com/qlik-oss/k-apis v0.0.3 h1:LJTQik87Rcsl+rphXfyPtxQc9UgQy+XGdT+epQqi+YY
github.com/qlik-oss/k-apis v0.0.3/go.mod h1:KOFzKVIdRqp47ytnHg3+9zb8fTlnrQjO6aKiwcrCJUE=
github.com/qlik-oss/k-apis v0.0.4 h1:fNX1LsGbNZtR7X/0o/2HAnQkuEJs6JcnedHzacBcbfM=
github.com/qlik-oss/k-apis v0.0.4/go.mod h1:KOFzKVIdRqp47ytnHg3+9zb8fTlnrQjO6aKiwcrCJUE=
github.com/qlik-oss/k-apis v0.0.5 h1:CpiujicAo+clZqy7Pe3CDAqNhTx8cCC3qmzz3ovG7OU=
github.com/qlik-oss/k-apis v0.0.5/go.mod h1:KOFzKVIdRqp47ytnHg3+9zb8fTlnrQjO6aKiwcrCJUE=
github.com/qlik-oss/k-apis v0.0.7 h1:IBp5U5S9GM889J34yKXEHWEQBA+2rv/dWil+YVGTAd4=
github.com/qlik-oss/k-apis v0.0.7/go.mod h1:KOFzKVIdRqp47ytnHg3+9zb8fTlnrQjO6aKiwcrCJUE=
github.com/qlik-oss/k-apis v0.0.8 h1:8ZZefgFT+rI4PuE/sp3Wpc+d5LtZBKZuDb2G/YelTOs=
github.com/qlik-oss/k-apis v0.0.8/go.mod h1:KOFzKVIdRqp47ytnHg3+9zb8fTlnrQjO6aKiwcrCJUE=
github.com/qlik-oss/kustomize/api v0.3.3-0.20200129153315-09eb26c762c8 h1:WLVkArXf58T+3SHDvSddE8P6OjkeeUtGEgHk8LDdfeo=
github.com/qlik-oss/kustomize/api v0.3.3-0.20200129153315-09eb26c762c8/go.mod h1:OCt7FTrRVHj4kmR2xLJJUIqu00BTr6GeF09hSmM17Kw=
github.com/qlik-oss/kustomize/api v0.3.3-0.20200206224201-2e697eccbad9 h1:iqeqTS4zjp6rPEaxmFB7pemA2CMjOEN5dYSXZaQ82uw=
github.com/qlik-oss/kustomize/api v0.3.3-0.20200206224201-2e697eccbad9/go.mod h1:OCt7FTrRVHj4kmR2xLJJUIqu00BTr6GeF09hSmM17Kw=
github.com/quasilyte/go-consistent v0.0.0-20190521200055-c6f3937de18c/go.mod h1:5STLWrekHfjyYwxBRVRXNOSewLJ3PWfDJd1VyTS21fI=
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be h1:ta7tUOvsPHVHGom5hKW5VXNc2xZIkfCKP8iaqOyYtUQ=
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be/go.mod h1:MIDFMn7db1kT65GmV94GzpX9Qdi7N/pQlwb+AN8wh+Q=

View File

@@ -2,10 +2,12 @@ package qliksense
import (
"fmt"
"github.com/mitchellh/go-homedir"
"os"
"path"
"path/filepath"
"github.com/mitchellh/go-homedir"
"github.com/qlik-oss/k-apis/pkg/cr"
qapi "github.com/qlik-oss/sense-installer/pkg/api"
"gopkg.in/yaml.v2"
@@ -24,14 +26,19 @@ func (q *Qliksense) ConfigApplyQK8s() error {
fmt.Println("cannot get the current-context cr", err)
return err
}
return applyConfigToK8s(qcr)
return q.applyConfigToK8s(qcr)
}
func applyConfigToK8s(qcr *qapi.QliksenseCR) error {
func (q *Qliksense) applyConfigToK8s(qcr *qapi.QliksenseCR) error {
// apply qliksense-init crd first
mroot := qcr.Spec.GetManifestsRoot()
qInitMsPath := filepath.Join(mroot, Q_INIT_CRD_PATH)
if err := os.Setenv("EJSON_KEYDIR", q.QliksenseEjsonKeyDir); err != nil {
fmt.Printf("error setting EJSON_KEYDIR environment variable: %v\n", err)
return err
}
qInitByte, err := executeKustomizeBuild(qInitMsPath)
if err != nil {
fmt.Println("cannot generate crds for qliksense-init", err)

View File

@@ -29,7 +29,7 @@ func fetchAndUpdateCR(qConfig *qapi.QliksenseConfig, version string) error {
if repo, err := kapis_git.CloneRepository(destDir, QLIK_GIT_REPO, nil); err != nil {
return err
} else if err = kapis_git.Checkout(repo, version, "", nil); err != nil {
} else if err = kapis_git.Checkout(repo, version, version, nil); err != nil {
return err
}
qcr.Spec.ManifestsRoot = qConfig.BuildCurrentManifestsRoot(version)

View File

@@ -2,6 +2,7 @@ package qliksense
import (
"fmt"
qapi "github.com/qlik-oss/sense-installer/pkg/api"
)
@@ -9,6 +10,7 @@ type InstallCommandOptions struct {
AcceptEULA string
Namespace string
StorageClass string
MongoDbUri string
}
func (q *Qliksense) InstallQK8s(version string, opts *InstallCommandOptions) error {
@@ -39,15 +41,21 @@ func (q *Qliksense) InstallQK8s(version string, opts *InstallCommandOptions) err
if opts.AcceptEULA != "" {
qcr.Spec.AddToConfigs("qliksense", "acceptEULA", opts.AcceptEULA)
}
if opts.MongoDbUri != "" {
qcr.Spec.AddToSecrets("qliksense", "mongoDbUri", opts.MongoDbUri)
}
if opts.StorageClass != "" {
qcr.Spec.StorageClassName = opts.StorageClass
}
if opts.Namespace != "" {
qcr.Spec.NameSpace = opts.Namespace
}
// during install always rotate JWT keys
// ref: https://github.com/qlik-oss/k-apis/blob/68414dd6c000d4acb15c8cfb3a6b2c4cfa707510/pkg/cr/cr-main.go#L104
qcr.Spec.RotateKeys = "yes"
qcr.Spec.ReleaseName = qcr.Metadata.Name
qConfig.WriteCurrentContextCR(qcr)
if err := applyConfigToK8s(qcr); err != nil {
if err := q.applyConfigToK8s(qcr); err != nil {
fmt.Println("cannot do kubectl apply on manifests")
return err
}

View File

@@ -2,19 +2,29 @@
package qliksense
import (
"os"
"path"
"github.com/gobuffalo/packr/v2"
)
// Qliksense is the logic behind the qliksense client
type Qliksense struct {
QliksenseHome string
CrdBox *packr.Box
QliksenseHome string
QliksenseEjsonKeyDir string
CrdBox *packr.Box ``
}
// New qliksense client, initialized with useful defaults.
func New(qliksenseHome string) *Qliksense {
return &Qliksense{
func New(qliksenseHome string) (*Qliksense, error) {
qliksenseClient := &Qliksense{
QliksenseHome: qliksenseHome,
CrdBox: packr.New("crds", "./crds"),
}
qliksenseClient.QliksenseEjsonKeyDir = path.Join(qliksenseHome, "ejson", "keys")
if err := os.MkdirAll(qliksenseClient.QliksenseEjsonKeyDir, os.ModePerm); err != nil {
return nil, err
}
return qliksenseClient, nil
}