Skip to content

Commit

Permalink
Merge branch 'master' of github.com:KubeOperator/KubePi
Browse files Browse the repository at this point in the history
  • Loading branch information
ssongliu committed Nov 9, 2021
2 parents 478177b + cc549f1 commit 4445188
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 51 deletions.
7 changes: 2 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM node:14-alpine as stage-web-build
FROM node:14.18.1 as stage-web-build

LABEL stage=stage-web-build

RUN apk add make python gcc g++
RUN apt-get install -y make python gcc g++

WORKDIR /build/kubepi/web

Expand All @@ -12,7 +12,6 @@ RUN make build_web

RUN rm -fr web


FROM golang:1.16 as stage-bin-build

ENV GOPROXY="https://goproxy.cn,direct"
Expand All @@ -27,7 +26,6 @@ WORKDIR /build/kubepi/bin

COPY --from=stage-web-build /build/kubepi/web .


RUN go mod download

RUN make build_gotty
Expand Down Expand Up @@ -56,7 +54,6 @@ RUN ARCH=$(uname -m) && case $ARCH in aarch64) ARCH="arm64";; x86_64) ARCH="amd6

COPY vimrc.local /etc/vim


EXPOSE 80

USER root
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ KubePi 允许管理员导入多个 Kubernetes 集群,并且通过权限控制

sudo docker run --privileged -d --restart=unless-stopped -p 80:80 kubeoperator/kubepi-server

打开浏览器访问http://localhost
打开浏览器访问:http://localhost:80/

### 在线体验

Expand All @@ -41,7 +41,7 @@ KubePi 允许管理员导入多个 Kubernetes 集群,并且通过权限控制
### 致谢

- [Vue](https://cn.vuejs.org) 前端框架
- [FIT2CLOUD UI](https://github.com/fit2cloud-ui/fit2cloud-ui/) FIT2CLOUD UI组件库
- [FIT2CLOUD UI](https://github.com/fit2cloud-ui/fit2cloud-ui/) FIT2CLOUD UI 组件库
- [Vue-element-admin](https://github.com/PanJiaChen/vue-element-admin) 项目脚手架

### License & Copyright
Expand Down
64 changes: 24 additions & 40 deletions pkg/util/helm/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ type Config struct {
KubeConfig *rest.Config
}
type Client struct {
installActionConfig *action.Configuration
unInstallActionConfig *action.Configuration
listActionConfig *action.Configuration
getActionConfig *action.Configuration
Namespace string
settings *cli.EnvSettings
Architectures string
ClusterName string
//installActionConfig *action.Configuration
//unInstallActionConfig *action.Configuration
//listActionConfig *action.Configuration
//getActionConfig *action.Configuration
actionConfig *action.Configuration
Namespace string
settings *cli.EnvSettings
Architectures string
ClusterName string
}

func GetSettings(cluster string) *cli.EnvSettings {
Expand All @@ -74,11 +75,9 @@ func checkFiles(cluster string) {
}
if _, err := os.Stat(repositoryPath); os.IsNotExist(err) {
os.Create(repositoryPath)
os.Create(repositoryPath)
}
if _, err := os.Stat(registryPath); os.IsNotExist(err) {
os.Create(registryPath)
os.Create(registryPath)
}
return
}
Expand All @@ -89,44 +88,29 @@ func NewClient(config *Config) (*Client, error) {
}
client.settings = GetSettings(config.ClusterName)
cf := genericclioptions.NewConfigFlags(true)
inscure := true
apiServer := config.Host
cf.APIServer = &apiServer
cf.BearerToken = &config.BearerToken
cf.Insecure = &inscure
if config.Namespace == "" {
client.Namespace = "default"
} else {
kubeConfig := config.KubeConfig
cf.WrapConfigFn = func(config *rest.Config) *rest.Config {
return kubeConfig
}
cf.CacheDir = nil
if config.Namespace != "" {
client.Namespace = config.Namespace
cf.Namespace = &client.Namespace
}
cf.Namespace = &client.Namespace
client.ClusterName = config.ClusterName
installActionConfig := new(action.Configuration)
if err := installActionConfig.Init(cf, client.Namespace, helmDriver, nolog); err != nil {
actionConfig := new(action.Configuration)
if err := actionConfig.Init(cf, config.Namespace, helmDriver, nolog); err != nil {
return nil, err
}
client.installActionConfig = installActionConfig
unInstallActionConfig := new(action.Configuration)
if err := unInstallActionConfig.Init(cf, config.OldNamespace, helmDriver, nolog); err != nil {
return nil, err
}
client.unInstallActionConfig = installActionConfig
listActionConfig := new(action.Configuration)
if err := listActionConfig.Init(cf, config.Namespace, helmDriver, nolog); err != nil {
return nil, err
}
client.listActionConfig = listActionConfig
client.actionConfig = actionConfig

getActionConfig := new(action.Configuration)
if err := getActionConfig.Init(cf, config.Namespace, helmDriver, nolog); err != nil {
return nil, err
}
client.getActionConfig = getActionConfig
return &client, nil
}

func (c Client) List(limit, offset int, pattern string) ([]*release.Release, int, error) {
client := action.NewList(c.listActionConfig)
client := action.NewList(c.actionConfig)
if c.Namespace == "" {
client.AllNamespaces = true
client.All = true
Expand All @@ -150,7 +134,7 @@ func (c Client) List(limit, offset int, pattern string) ([]*release.Release, int
}

func (c Client) GetDetail(name string) (*release.Release, error) {
client := action.NewGet(c.getActionConfig)
client := action.NewGet(c.actionConfig)
result, err := client.Run(name)
if err != nil {
return nil, err
Expand All @@ -172,7 +156,7 @@ func (c Client) Install(name, repoName, chartName, chartVersion string, values m
if rp == nil {
return nil, errors.New("get chart detail failed, repo not found")
}
client := action.NewInstall(c.installActionConfig)
client := action.NewInstall(c.actionConfig)
client.ReleaseName = name
client.Namespace = c.Namespace
client.RepoURL = rp.URL
Expand Down Expand Up @@ -212,7 +196,7 @@ func (c Client) Upgrade(name, repoName, chartName, chartVersion string, values m
return nil, errors.New("get chart detail failed, repo not found")
}

client := action.NewUpgrade(c.installActionConfig)
client := action.NewUpgrade(c.actionConfig)
client.Namespace = c.Namespace
client.RepoURL = rp.URL
client.Username = rp.Username
Expand All @@ -238,7 +222,7 @@ func (c Client) Upgrade(name, repoName, chartName, chartVersion string, values m
}

func (c Client) Uninstall(name string) (*release.UninstallReleaseResponse, error) {
client := action.NewUninstall(c.unInstallActionConfig)
client := action.NewUninstall(c.actionConfig)
res, err := client.Run(name)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("uninstall tool %s failed: %v", name, err))
Expand Down
8 changes: 4 additions & 4 deletions web/dashboard/src/components/detail/detail-key-value.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
</el-link>
<div v-if="showItem">
<div v-for="(value,key,index) in valueObj" v-bind:key="index" class="myTag">
<el-tag type="info" size="small" v-if="value.length < 100">
<el-tag type="info" size="small" v-if="value.length < 50">
{{ key }} = {{ value }}
</el-tag>
<el-tooltip v-if="value.length > 100" :content="value" placement="top">
<el-tag type="info" size="small" v-if="value.length >= 100">
{{ key }} = {{ value.substring(0, 100) + "..." }}
<el-tooltip v-if="value.length > 50" :content="value" placement="top">
<el-tag type="info" size="small" v-if="value.length >= 50">
{{ key }} = {{ value.substring(0, 50) + "..." }}
</el-tag>
</el-tooltip>
</div>
Expand Down

0 comments on commit 4445188

Please sign in to comment.