Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/adrianliechti/devkube into …
Browse files Browse the repository at this point in the history
…feature/registry
  • Loading branch information
adrianliechti committed Sep 18, 2022
2 parents 0adfc78 + 75e7810 commit 353e30b
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 33 deletions.
6 changes: 4 additions & 2 deletions app/cluster/cluster_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cluster

import (
"os"
"path"
"path/filepath"

"github.com/adrianliechti/devkube/app"
"github.com/adrianliechti/devkube/pkg/cli"
Expand Down Expand Up @@ -55,12 +55,14 @@ func CreateCommand() *cli.Command {

defer os.RemoveAll(dir)

kubeconfig := path.Join(dir, "kubeconfig")
kubeconfig := filepath.Join(dir, "kubeconfig")

if err := provider.Create(c.Context, cluster, kubeconfig); err != nil {
return err
}

kubectl.Invoke(c.Context, []string{"create", "namespace", DefaultNamespace}, kubectl.WithKubeconfig(kubeconfig))

if err := observability.InstallCRD(c.Context, kubeconfig, DefaultNamespace); err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions app/flag_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package app
import (
"errors"
"os"
"path"
"path/filepath"
"strings"

"github.com/adrianliechti/devkube/pkg/cli"
Expand Down Expand Up @@ -150,7 +150,7 @@ func MustClusterKubeconfig(c *cli.Context, provider provider.Provider, name stri
os.RemoveAll(dir)
}

path := path.Join(dir, "kubeconfig")
path := filepath.Join(dir, "kubeconfig")

if err := provider.Export(c.Context, name, path); err != nil {
closer()
Expand Down
24 changes: 10 additions & 14 deletions extension/certmanager/certmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
)

const (
certmanagerRepo = "https://charts.jetstack.io"
certmanagerNamespace1 = "cert-manager"
certmanagerRepo = "https://charts.jetstack.io"
certmanagerNamespace = "cert-manager"

certmanager = "cert-manager"
certmanagerChart = "cert-manager"
Expand All @@ -28,11 +28,9 @@ var (
)

func Install(ctx context.Context, kubeconfig, namespace string) error {
// if namespace == "" {
// namespace = "default"
// }

namespace = certmanagerNamespace1
if namespace == "" {
namespace = "default"
}

client, err := kubernetes.NewFromConfig(kubeconfig)

Expand Down Expand Up @@ -63,7 +61,7 @@ func Install(ctx context.Context, kubeconfig, namespace string) error {
}
}

if err := helm.Install(ctx, certmanager, certmanagerRepo, certmanagerChart, certmanagerVersion, values, helm.WithKubeconfig(kubeconfig), helm.WithNamespace(namespace), helm.WithWait(true), helm.WithDefaultOutput()); err != nil {
if err := helm.Install(ctx, certmanager, certmanagerRepo, certmanagerChart, certmanagerVersion, values, helm.WithKubeconfig(kubeconfig), helm.WithNamespace(certmanagerNamespace), helm.WithWait(true), helm.WithDefaultOutput()); err != nil {
return err
}

Expand All @@ -75,17 +73,15 @@ func Install(ctx context.Context, kubeconfig, namespace string) error {
}

func Uninstall(ctx context.Context, kubeconfig, namespace string) error {
// if namespace == "" {
// namespace = "default"
// }

namespace = certmanagerNamespace1
if namespace == "" {
namespace = "default"
}

if err := kubectl.Invoke(ctx, []string{"delete", "-f", "-"}, kubectl.WithKubeconfig(kubeconfig), kubectl.WithNamespace(namespace), kubectl.WithInput(strings.NewReader(manifest)), kubectl.WithDefaultOutput()); err != nil {
// return err
}

if err := helm.Uninstall(ctx, certmanager, helm.WithKubeconfig(kubeconfig), helm.WithNamespace(namespace)); err != nil {
if err := helm.Uninstall(ctx, certmanager, helm.WithKubeconfig(kubeconfig), helm.WithNamespace(certmanagerNamespace)); err != nil {
//return err
}

Expand Down
6 changes: 3 additions & 3 deletions extension/certmanager/manifest.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
kind: Issuer
metadata:
name: selfsigned
spec:
selfSigned: {}
---
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
kind: Issuer
metadata:
name: platform
spec:
Expand All @@ -27,7 +27,7 @@ spec:
size: 256
issuerRef:
name: selfsigned
kind: ClusterIssuer
kind: Issuer
group: cert-manager.io
---
apiVersion: apps/v1
Expand Down
6 changes: 3 additions & 3 deletions provider/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"errors"
"os"
"path"
"path/filepath"
"strings"

"github.com/adrianliechti/devkube/pkg/to"
Expand Down Expand Up @@ -200,13 +200,13 @@ func (p *Provider) Export(ctx context.Context, name, kubeconfig string) error {
return err
}

dir := path.Join(home, ".kube")
dir := filepath.Join(home, ".kube")

if err := os.MkdirAll(dir, 0700); err != nil {
return err
}

kubeconfig = path.Join(home, ".kube", "config")
kubeconfig = filepath.Join(home, ".kube", "config")
}

resourcegroup := groupName(name)
Expand Down
6 changes: 3 additions & 3 deletions provider/digitalocean/digitalocean.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"errors"
"fmt"
"os"
"path"
"path/filepath"
"strings"
"time"

Expand Down Expand Up @@ -150,13 +150,13 @@ func (p *Provider) Export(ctx context.Context, name, kubeconfig string) error {
return err
}

dir := path.Join(home, ".kube")
dir := filepath.Join(home, ".kube")

if err := os.MkdirAll(dir, 0700); err != nil {
return err
}

kubeconfig = path.Join(home, ".kube", "config")
kubeconfig = filepath.Join(home, ".kube", "config")
}

id, err := p.clusterID(ctx, name)
Expand Down
6 changes: 3 additions & 3 deletions provider/linode/linode.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"net/http"
"os"
"path"
"path/filepath"
"strings"

"github.com/linode/linodego"
Expand Down Expand Up @@ -158,13 +158,13 @@ func writeKubeconfig(kubeconfig string, config *linodego.LKEClusterKubeconfig) e
return err
}

dir := path.Join(home, ".kube")
dir := filepath.Join(home, ".kube")

if err := os.MkdirAll(dir, 0700); err != nil {
return err
}

kubeconfig = path.Join(home, ".kube", "config")
kubeconfig = filepath.Join(home, ".kube", "config")
}

data, err := base64.StdEncoding.DecodeString(config.KubeConfig)
Expand Down
6 changes: 3 additions & 3 deletions provider/vultr/vultr.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"net/http"
"os"
"path"
"path/filepath"
"strings"
"time"

Expand Down Expand Up @@ -171,13 +171,13 @@ func writeKubeconfig(kubeconfig string, config *govultr.KubeConfig) error {
return err
}

dir := path.Join(home, ".kube")
dir := filepath.Join(home, ".kube")

if err := os.MkdirAll(dir, 0700); err != nil {
return err
}

kubeconfig = path.Join(home, ".kube", "config")
kubeconfig = filepath.Join(home, ".kube", "config")
}

data, err := base64.StdEncoding.DecodeString(config.KubeConfig)
Expand Down

0 comments on commit 353e30b

Please sign in to comment.