Skip to content
This repository has been archived by the owner on Jun 12, 2020. It is now read-only.

Commit

Permalink
fix: changed hostnetwork usage and grafana
Browse files Browse the repository at this point in the history
  • Loading branch information
stebenz committed Jan 7, 2020
1 parent 5073be9 commit 29bf4d8
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 27 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ tools/*

/*.go
!main.go

examples/gitops/privatrepo/secret
8 changes: 4 additions & 4 deletions cmd/boom/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ func main() {
"Disable the controller manager and only use the operator to handle gitcrds")

flag.StringVar(&gitOrbConfig, "git-orbconfig", "", "The orbconfig path. If not provided, --git-crd-url and --git-crd-secret are used")
flag.StringVar(&gitCrdURL, "git-crd-url", "git@github.com:caos/tools.git", "The url for the git-repo to clone for the CRD")
flag.StringVar(&gitCrdPrivateKey, "git-crd-private-key", "../../config/manager/secret/id_rsa-boom-tools-read", "Path to private key required to clone the git-repo for the CRD")
flag.StringVar(&gitCrdURL, "git-crd-url", "https://github.com/stebenz/boom-crd.git", "The url for the git-repo to clone for the CRD")
flag.StringVar(&gitCrdPrivateKey, "git-crd-private-key", "", "Path to private key required to clone the git-repo for the CRD")
flag.StringVar(&gitCrdDirectoryPath, "git-crd-directory-path", "/tmp/crd", "Local path where the CRD git-repo will be cloned into")
flag.StringVar(&gitCrdPath, "git-crd-path", "crd/example/crd.yaml", "The path to the CRD in the cloned git-repo ")
flag.StringVar(&gitCrdPath, "git-crd-path", "crd.yaml", "The path to the CRD in the cloned git-repo ")

flag.StringVar(&toolsDirectoryPath, "tools-directory-path", "../../tools", "The local path where the tools folder should be")
flag.StringVar(&toolsetsPath, "toolsq-toolset-path", "toolsets", "The path to the fold structue which defines the toolsets and their versions")
Expand All @@ -98,7 +98,7 @@ func main() {
gitCrdURL = orb.URL
}

if gitCrdPrivateKeyBytes == nil {
if gitCrdPrivateKeyBytes == nil && gitCrdPrivateKey != "" {
var err error
gitCrdPrivateKeyBytes, err = ioutil.ReadFile(gitCrdPrivateKey)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/app/v1beta1/crd/grafana/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package grafana
import (
"os/exec"
"path/filepath"
"reflect"
"strings"

"github.com/caos/orbiter/logging"
Expand Down Expand Up @@ -58,7 +59,7 @@ func (g *Grafana) Reconcile(overlay, specNamespace string, helm *template.Helm,
return err
}

if spec.Deploy {
if spec.Deploy || !reflect.DeepEqual(g.spec, spec) {
if err := defaults.PrepareForResultOutput(defaults.GetResultFileDirectory(overlay, g.ApplicationDirectoryPath, applicationName)); err != nil {
return err
}
Expand Down Expand Up @@ -102,7 +103,7 @@ func specToValues(imageTags map[string]string, spec *toolsetsv1beta1.Grafana) *V
FullnameOverride: "grafana",
Rbac: &Rbac{
Create: true,
PspEnabled: true,
PspEnabled: false,
PspUseAppArmor: true,
Namespaced: false,
},
Expand Down Expand Up @@ -283,7 +284,6 @@ func applyKustomize(folders []string) error {
func getProvider(appName string) *Provider {
return &Provider{
Name: appName,
Folder: "",
Type: "file",
DisableDeletion: false,
Editable: true,
Expand Down
2 changes: 1 addition & 1 deletion internal/app/v1beta1/crd/grafana/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ type Providersyaml struct {
type Provider struct {
Name string `yaml:"name"`
OrgID int `yaml:"ordId"`
Folder string `yaml:"folder"`
Folder string `yaml:"folder,omitempty"`
Type string `yaml:"type"`
DisableDeletion bool `yaml:"disableDeletion"`
Editable bool `yaml:"editable"`
Expand Down
2 changes: 1 addition & 1 deletion internal/app/v1beta1/crd/prometheusnodeexporter/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func specToValues(imageTags map[string]string, spec *toolsetsv1beta1.PrometheusN
Create: true,
PspEnabled: true,
},
HostNetwork: true,
HostNetwork: false,
Tolerations: []*Toleration{&Toleration{
Effect: "NoSchedule",
Operator: "Exists",
Expand Down
30 changes: 23 additions & 7 deletions internal/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ type Git struct {

func New(logger logging.Logger, localPath, url string, privateKey []byte) (*Git, error) {

signer, err := ssh.ParsePrivateKey(privateKey)
if err != nil {
return nil, err
var auth *gitssh.PublicKeys
if privateKey != nil {
signer, err := ssh.ParsePrivateKey(privateKey)
if err != nil {
return nil, err
}

auth = &gitssh.PublicKeys{User: "git", Signer: signer}
auth.HostKeyCallback = ssh.InsecureIgnoreHostKey()
}

auth := &gitssh.PublicKeys{User: "git", Signer: signer}
auth.HostKeyCallback = ssh.InsecureIgnoreHostKey()

g := &Git{
logger: logger,
auth: auth,
Expand Down Expand Up @@ -88,12 +91,25 @@ func (g *Git) cloneRepo() (*git.Repository, error) {

ctx := context.TODO()
toCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
if g.auth != nil {
repo, err := git.PlainCloneContext(toCtx, g.localPath, false, &git.CloneOptions{
URL: g.url,
SingleBranch: true,
Depth: 1,
Progress: os.Stdout,
Auth: g.auth,
})
cancel()
if err != nil {
return nil, err
}
return repo, nil
}
repo, err := git.PlainCloneContext(toCtx, g.localPath, false, &git.CloneOptions{
URL: g.url,
SingleBranch: true,
Depth: 1,
Progress: os.Stdout,
Auth: g.auth,
})
cancel()
if err != nil {
Expand Down
11 changes: 0 additions & 11 deletions skaffold.yaml

This file was deleted.

0 comments on commit 29bf4d8

Please sign in to comment.