Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
aerokite committed May 23, 2018
1 parent 435c54e commit 3a8d7ea
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ var _ = BeforeSuite(func() {
}

cfg.BasicAuth.Username = ICINGA_API_USER
cfg.BasicAuth.Password = ICINGA_API_PASSWORD
cfg.BasicAuth.Password, err = root.Invoke().GetIcingaApiPassword(om)
Expect(err).NotTo(HaveOccurred())

// Icinga Client
icingaClient := icinga.NewClient(*cfg)
Expand Down
17 changes: 17 additions & 0 deletions test/e2e/framework/secret.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package framework

import (
"fmt"

"github.com/appscode/go/crypto/rand"
"github.com/appscode/searchlight/pkg/icinga"
core_v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand All @@ -20,3 +23,17 @@ func (f *Framework) CreateWebHookSecret(obj *core_v1.Secret) error {
_, err := f.kubeClient.CoreV1().Secrets(obj.Namespace).Create(obj)
return err
}

func (f *Invocation) GetIcingaApiPassword(objectMeta metav1.ObjectMeta) (string, error) {
secret, err := f.kubeClient.CoreV1().Secrets(objectMeta.Namespace).Get(objectMeta.Name, metav1.GetOptions{})
if err != nil {
return "", err
}

pass, found := secret.Data[icinga.ICINGA_API_PASSWORD]
if !found {
return "", fmt.Errorf(`key "%s" is not found in Secret "%s/%s"`, icinga.ICINGA_API_PASSWORD, objectMeta.Namespace, objectMeta.Name)
}

return string(pass), nil
}

0 comments on commit 3a8d7ea

Please sign in to comment.