Add namespace dropdown (#67)

* add get namespace endpoint

* add namespace dropdown

* misc fix
This commit is contained in:
Duy Nguyen
2022-11-06 15:19:32 +02:00
committed by GitHub
parent ef31263797
commit 612352d69f
6 changed files with 61 additions and 11 deletions

View File

@@ -5,6 +5,12 @@ import (
"encoding/json"
"errors"
"fmt"
"regexp"
"sort"
"strconv"
"strings"
"time"
"github.com/hexops/gotextdiff"
"github.com/hexops/gotextdiff/myers"
"github.com/hexops/gotextdiff/span"
@@ -13,11 +19,6 @@ import (
"gopkg.in/yaml.v3"
"helm.sh/helm/v3/pkg/release"
v1 "k8s.io/apimachinery/pkg/apis/testapigroup/v1"
"regexp"
"sort"
"strconv"
"strings"
"time"
)
type DataLayer struct {
@@ -478,6 +479,20 @@ func (d *DataLayer) ChartRepoDelete(name string) (string, error) {
return out, nil
}
func (d *DataLayer) GetNameSpaces() (res *NamespaceElement, err error) {
out, err := d.runCommandKubectl("get", "namespaces", "-o", "json")
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(out), &res)
if err != nil {
return nil, err
}
return res, nil
}
func RevisionDiff(functor SectionFn, ext string, namespace string, name string, revision1 int, revision2 int, flag bool) (string, error) {
if revision1 == 0 || revision2 == 0 {
log.Debugf("One of revisions is zero: %d %d", revision1, revision2)

View File

@@ -42,3 +42,11 @@ type RepositoryElement struct {
Name string `json:"name"`
URL string `json:"url"`
}
type NamespaceElement struct {
Items []struct {
Metadata struct {
Name string `json:"name"`
} `json:"metadata"`
} `json:"items"`
}