未验证 提交 3156362f 编写于 作者: R runzexia

Merge branch 'master' into s2ibin-upload

Signed-off-by: Nrunzexia <runzexia@yunify.com>

# Conflicts:
#	vendor/modules.txt
......@@ -9,6 +9,8 @@
## What is KubeSphere
> English | [中文](README_zh.md)
[KubeSphere](https://kubesphere.io/) is an enterprise-grade multi-tenant container management platform that built on [Kubernetes](https://kubernetes.io). It provides an easy-to-use UI for users to manage computing resources with a few clicks, which reduces the learning curve and empowers the DevOps teams. It greatly reduces the complexity of the daily work of development, testing, operation and maintenance, aiming to alleviate the pain points of Kubernetes' storage, network, security and ease of use, etc.
> See this [document](https://docs.kubesphere.io/advanced-v2.0/zh-CN/introduction/intro/) that describes the KubeSphere landscape and details.
......@@ -54,7 +56,11 @@ KubeSphere Advanced Edition 2.0.2 was released on **July 9th, 2019**. See the [R
## Installation
### Minimum Requirements
### Deploy On Kubernetes
You can deploy KubeSphere on any Kubernetes cluster,please refer to [KubeSphere on Kubernetes](https://github.com/kubesphere/ks-installer).
### Deploy on Linux
- Operating Systems
- CentOS 7.5 (64 bit)
......@@ -69,18 +75,16 @@ KubeSphere Advanced Edition 2.0.2 was released on **July 9th, 2019**. See the [R
[All-in-One](https://docs.kubesphere.io/advanced-v2.0/zh-CN/installation/all-in-one/): For those who are new to KubeSphere and looking for the fastest way to install and experience the dashboard. Execute following commands to download and install KubeSphere in a single node.
```bash
$ curl -L https://kubesphere.io/download/stable/advanced-2.0.2 > advanced-2.0.2.tar.gz && tar -zxf advanced-2.0.2.tar.gz && cd kubesphere-all-advanced-2.0.2/scripts
$ curl -L https://kubesphere.io/download/stable/advanced-2.0.2 > advanced-2.0.2.tar.gz \
&& tar -zxf advanced-2.0.2.tar.gz && cd kubesphere-all-advanced-2.0.2/conf
$ ./install.sh
```
Choose `"1) All-in-one"` to trigger the installation. Generally, you can install it directly without any configuration. For details please reference [All-in-One](https://docs.kubesphere.io/advanced-v2.0/zh-CN/installation/all-in-one/).
> Click [here](https://asciinema.org/~lilin) to preview the installation demo.
### Multi-Node
[Multi-Node](https://docs.kubesphere.io/advanced-v2.0/zh-CN/installation/multi-node/) is used for installing KubeSphere on multiple instances, supports for installing a highly available cluster in a mission-critical environment. Multi-node installation requires pre-configuration steps, see [Multi-Node Guide](https://docs.kubesphere.io/advanced-v2.0/zh-CN/installation/multi-node/).
> Note:
> - In a formal environment, it's highly recommended to install KubeSphere with [Multi-Node Installation](https://docs.kubesphere.io/advanced-v2.0/zh-CN/installation/multi-node/).
> - Click [here](https://asciinema.org/~lilin) to preview the installation demo.
## To start using KubeSphere
......@@ -110,7 +114,7 @@ Currently, KubeSphere has released the following 4 major editions. The future re
## Support, Discussion, and Community
If you need any help with KubeSphere, please join us at [Slack channel](http://kubesphere.slack.com/).
If you need any help with KubeSphere, please join us at [Slack Channel](https://join.slack.com/t/kubesphere/shared_invite/enQtNTE3MDIxNzUxNzQ0LTZkNTdkYWNiYTVkMTM5ZThhODY1MjAyZmVlYWEwZmQ3ODQ1NmM1MGVkNWEzZTRhNzk0MzM5MmY4NDc3ZWVhMjE).
Please submit any KubeSphere bugs, issues, and feature requests to [KubeSphere GitHub Issue](https://github.com/kubesphere/kubesphere/issues).
......
# KubeSphere
[![License](http://img.shields.io/badge/license-apache%20v2-blue.svg)](https://github.com/KubeSphere/KubeSphere/blob/master/LICENSE)
[![Build Status](https://travis-ci.org/kubesphere/kubesphere.svg?branch=master)](https://travis-ci.org/kubesphere/kubesphere)
[![KubeSphere release](https://img.shields.io/github/release/kubesphere/kubesphere.svg?color=release&label=release&logo=release&logoColor=release)](https://github.com/kubesphere/kubesphere/releases/tag/advanced-2.0.2)
![logo](docs/images/kubesphere-logo.png)
----
## KubeSphere 是什么
> [English](README.md) | 中文
[KubeSphere](https://kubesphere.io/) 是在 [Kubernetes](https://kubernetes.io) 之上构建的以**应用为中心的**多租户**容器管理平台**,支持部署和运行在**任何基础设施之上**,提供**简单易用的操作界面**以及**向导式操作**方式,在降低用户使用容器调度平台学习成本的同时,极大减轻开发、测试、运维的日常工作的复杂度,旨在解决 Kubernetes 本身存在的存储、网络、安全和易用性等痛点。帮助企业轻松应对**敏捷开发、自动化运维、应用快速交付、微服务治理、多租户管理、监控日志告警、服务与网络管理、镜像仓库**等业务场景。
KubeSphere 已大规模服务于社区用户,广泛地应用在以容器为中心的开发测试及生产环境,大量服务平稳地运行在 KubeSphere 之上。
> 说明:KubeSphere 目前最新的版本为高级版 2.0.2,并且所有版本 100% 开源,关于 KubeSphere 更详细的介绍与说明请参阅 [产品介绍](https://docs.kubesphere.io/advanced-v2.0/zh-CN/introduction/intro/)。
![Dashboard](docs/images/dashboard-zh.png)
## 核心功能
- Kubernetes 资源管理:纳管多种类型的 K8s 资源,提供易用友好的向导式 UI
- 应用编排与管理:包括**一键部署应用****Helm Chart 可视化管理****应用生命周期管理**,后续将支持计量计费
- 微服务治理:基于 Istio 提供可视化无代码侵入的**灰度发布、熔断、流量管控、Tracing**,兼容**Spring Cloud & Dubbo**
- 容器化 DevOps:提供**可视化编辑 CI/CD 流水线**,包括从开发测试到持续部署上线的**全流程管理**,提供 [S2i](https://kubesphere.io/docs/advanced-v2.0/zh-CN/quick-start/source-to-image/)
- 多租户管理:提供基于角色的细粒度**多租户统一认证**,支持**对接企业 LDAP/AD**,提供多层级的权限管理满足多组织架构的企业用户
- 日志查询与收集:提供基于多租户和多维度的日志查询,并支持快速对接多种日志收集平台
- 多维度监控:提供集群与应用级别多项监控指标,提供按节点、企业空间、项目等资源用量的排行
- 多租户告警系统:支持基于多租户、多维度的告警,提供丰富的监控告警指标,可自定义告警策略,支持邮件通知
- 基础设施管理:提供主机管理、存储类型管理、CPU 与内存等资源配额管理
- 支持多种网络方案:支持 Calico、Flannel,提供面向物理部署 Kubernetes 的 LB 插件 [Porter](https://github.com/kubesphere/porter) 和云上[负载均衡器插件](https://github.com/yunify/qingcloud-cloud-controller-manager)
- 支持多种存储:支持 GlusterFS、CephRBD、NFS,支持 [企业级分布式存储 NeonSAN](https://www.qingcloud.com/products/qingstor-neonsan/)[QingCloud 云平台块存储](https://docs.qingcloud.com/product/storage/volume/)
- 支持 GPU 节点
> 说明
> - 点击 [KubeSphere 快览](docs/screenshots.md) 快速查看 KubeSphere UI;
> - 更多详细的功能解读与说明,请查阅 [产品功能](https://docs.kubesphere.io/advanced-v2.0/zh-CN/introduction/features/)。
----
## 架构
KubeSphere 采用了前后端分离的架构设计,后端的各个功能组件可通过 REST API 对接外部系统,KubeSphere 可以运行在任何 Kubernetes、私有云、公有云、VM 或物理环境之上。
![](docs/images/architecture-zh.png)
## 最新发布
KubeSphere 高级版 (Advanced Edition 2.0.2) 已于 2019 年 7 月 9 日 正式发布,点击 [Release Notes For 2.0.2](https://docs.kubesphere.io/advanced-v2.0/zh-CN/release/release-v202/) 查看 2.0.2 版本的更新详情。
## 快速安装
### 部署在 Linux
- 操作系统
- CentOS 7.5 (64 bit)
- Ubuntu 16.04/18.04 LTS (64 bit)
- Red Hat Enterprise Linux Server 7.4 (64 bit)
- Debian Stretch 9.5 (64 bit)
- 配置规格(最低)
- CPU:8 Core, 内存:16 G, 硬盘:100 G
#### All-in-One
[All-in-One](https://docs.kubesphere.io/advanced-v2.0/zh-CN/installation/all-in-one/): 对于首次接触 KubeSphere 高级版的用户,想寻找一个最快安装和体验 KubeSphere 高级版核心功能的方式,All-in-one 模式支持一键安装 KubeSphere 至一台目标机器。
```bash
$ curl -L https://kubesphere.io/download/stable/advanced-2.0.2 > advanced-2.0.2.tar.gz \
&& tar -zxf advanced-2.0.2.tar.gz && cd kubesphere-all-advanced-2.0.2/conf
$ ./install.sh
```
直接选择 `"1) All-in-one"` 即可开始快速安装,可点击 [安装 Demo](https://asciinema.org/~lilin) 预览 All-in-one 安装。
> 注意:All-in-One 仅适用于**测试体验**,**正式环境**安装和使用请参考 [Multi-Node 安装指南](https://docs.kubesphere.io/advanced-v2.0/zh-CN/installation/multi-node/) 安装多节点环境。
### 部署在 Kubernetes
KubeSphere 支持部署在现有的 Kubernetes 集群之上,请参考 [KubeSphere on Kubernetes](https://github.com/kubesphere/ks-installer)
## 开始使用 KubeSphere
### 快速入门
[KubeSphere 快速入门](https://docs.kubesphere.io/advanced-v2.0/quick-start/admin-quick-start/) 通过 13 个 Step-by-Step 的快速入门的示例教程帮助您了解 KubeSphere 容器平台的基本使用流程,带您快速上手 KubeSphere。
### 文档
- [KubeSphere 文档中心 (En/中) ](https://docs.kubesphere.io/)
- [KubeSphere 文档 (PDF)](https://docs.kubesphere.io/KubeSphere-advanced-v2.0.pdf)
- [API 文档](https://kubesphere.io/docs/advanced-v2.0/zh-CN/api-reference/api-docs/)
## 开发 KubeSphere
[开发指南](CONTRIBUTING.md) 详细说明了如何从源码编译、KubeSphere 的 GitHub 工作流、如何贡献代码以及如何测试等。
## 路线图
目前,KubeSphere 已发布了 4 个大版本和 3 个小版本,所有版本都是完全开源的,为 KubeSphere 社区用户提供服务。下一个版本 KubeSphere 将对各个功能组件的依赖进行解耦,各模块都设计成可插拔式,并将支持多集群、大数据、AI 平台以及 SDN 等应用场景。
**Community Edition** => **Express Edition** => **Advanced Edition 1.0.0** => **Advanced Edition 2.0.x**
![Roadmap](docs/images/roadmap-2.0.2-zh.png)
## 技术社区
- [Slack Channel](https://join.slack.com/t/kubesphere/shared_invite/enQtNTE3MDIxNzUxNzQ0LTZkNTdkYWNiYTVkMTM5ZThhODY1MjAyZmVlYWEwZmQ3ODQ1NmM1MGVkNWEzZTRhNzk0MzM5MmY4NDc3ZWVhMjE)
- 微信群 (与工程师和用户们交流云原生技术,请备注 “公司 - 名字”)
<img width="150px" src="https://pek3b.qingstor.com/kubesphere-docs/png/20190902002055.png" />
## Bug 与建议反馈
KubeSphere 的日益完善与快速发展离不开社区用户的支持,KubeSphere 也一直在反哺社区,为开源用户提供更多的支持。若您安装使用时有任何建议问题、反馈或发现的 Bug,欢迎在 [GitHub Issue](https://github.com/kubesphere/kubesphere/issues) 提交 Issue。
docs/images/roadmap-2.0.2-en.png

263.3 KB | W: | H:

docs/images/roadmap-2.0.2-en.png

185.6 KB | W: | H:

docs/images/roadmap-2.0.2-en.png
docs/images/roadmap-2.0.2-en.png
docs/images/roadmap-2.0.2-en.png
docs/images/roadmap-2.0.2-en.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -78,7 +78,7 @@ require (
github.com/knative/pkg v0.0.0-20190314204845-cd278f2d3394
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/kubernetes-sigs/application v0.0.0-20190404151855-67ae7f915d4e
github.com/kubesphere/s2ioperator v0.0.12
github.com/kubesphere/s2ioperator v0.0.13
github.com/kubesphere/sonargo v0.0.2
github.com/leodido/go-urn v1.1.0 // indirect
github.com/lib/pq v1.2.0 // indirect
......
......@@ -351,6 +351,25 @@ The last one is encrypted info, such as the password of the username-password ty
Returns(http.StatusOK, RespOK, []devops.SCMOrg{}).
Writes([]devops.SCMOrg{}))
// match "/blue/rest/organizations/jenkins/scm/%s/servers/"
webservice.Route(webservice.GET("/scms/{scm}/servers").
To(devopsapi.GetSCMServers).
Metadata(restfulspec.KeyOpenAPITags, []string{constants.DevOpsScmTag}).
Doc("List all servers in the jenkins.").
Param(webservice.PathParameter("scm", "The ID of the source configuration management (SCM).")).
Returns(http.StatusOK, RespOK, []devops.SCMServer{}).
Writes([]devops.SCMServer{}))
// match "/blue/rest/organizations/jenkins/scm/%s/servers/"
webservice.Route(webservice.POST("/scms/{scm}/servers").
To(devopsapi.CreateSCMServers).
Metadata(restfulspec.KeyOpenAPITags, []string{constants.DevOpsScmTag}).
Doc("Create scm server in the jenkins.").
Param(webservice.PathParameter("scm", "The ID of the source configuration management (SCM).")).
Reads(devops.CreateScmServerReq{}).
Returns(http.StatusOK, RespOK, devops.SCMServer{}).
Writes(devops.SCMServer{}))
// match "/blue/rest/organizations/jenkins/scm/{scm}/organizations/{organization}/repositories/?credentialId=&pageNumber&pageSize="
webservice.Route(webservice.GET("/scms/{scm}/organizations/{organization}/repositories").
To(devopsapi.GetOrgRepo).
......
......@@ -134,6 +134,13 @@ func addWebService(c *restful.Container) error {
Returns(http.StatusOK, ok, models.PageableResponse{}).
Doc("List the devops projects for the workspace member").
Metadata(restfulspec.KeyOpenAPITags, []string{constants.TenantResourcesTag}))
ws.Route(ws.GET("/devopscount").
To(tenant.GetDevOpsProjectsCount).
Returns(http.StatusOK, ok, struct {
Count uint32 `json:"count"`
}{}).
Doc("Get the devops projects count for the member").
Metadata(restfulspec.KeyOpenAPITags, []string{constants.TenantResourcesTag}))
ws.Route(ws.POST("/workspaces/{workspace}/devops").
To(tenant.CreateDevopsProject).
Param(ws.PathParameter("workspace", "workspace name")).
......
......@@ -141,6 +141,32 @@ func GetStepLog(req *restful.Request, resp *restful.Response) {
resp.Write(res)
}
func GetSCMServers(req *restful.Request, resp *restful.Response) {
scmId := req.PathParameter("scm")
res, err := devops.GetSCMServers(scmId, req.Request)
if err != nil {
parseErr(err, resp)
return
}
resp.Header().Set(restful.HEADER_ContentType, restful.MIME_JSON)
resp.Write(res)
}
func CreateSCMServers(req *restful.Request, resp *restful.Response) {
scmId := req.PathParameter("scm")
res, err := devops.CreateSCMServers(scmId, req.Request)
if err != nil {
parseErr(err, resp)
return
}
resp.Header().Set(restful.HEADER_ContentType, restful.MIME_JSON)
resp.Write(res)
}
func Validate(req *restful.Request, resp *restful.Response) {
scmId := req.PathParameter("scm")
......
......@@ -24,6 +24,7 @@ import (
rbacv1 "k8s.io/api/rbac/v1"
k8serr "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/util/net"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/apis/tenant/v1alpha1"
"kubesphere.io/kubesphere/pkg/apiserver/logging"
"kubesphere.io/kubesphere/pkg/constants"
......@@ -244,6 +245,19 @@ func ListDevopsProjects(req *restful.Request, resp *restful.Response) {
resp.WriteAsJson(result)
}
func GetDevOpsProjectsCount(req *restful.Request, resp *restful.Response) {
username := req.HeaderParameter(constants.UserNameHeader)
result, err := tenant.GetDevOpsProjectsCount(username)
if err != nil {
klog.Errorf("%+v", err)
errors.ParseSvcErr(err, resp)
return
}
resp.WriteAsJson(struct {
Count uint32 `json:"count"`
}{Count: result})
}
func DeleteDevopsProject(req *restful.Request, resp *restful.Response) {
projectId := req.PathParameter("devops")
workspaceName := req.PathParameter("workspace")
......
......@@ -135,6 +135,55 @@ func GetStepLog(projectName, pipelineName, runId, nodeId, stepId string, req *ht
}
func GetSCMServers(scmId string, req *http.Request) ([]byte, error) {
baseUrl := fmt.Sprintf(jenkins.Server+GetSCMServersUrl, scmId)
log.Info("Jenkins-url: " + baseUrl)
req.Method = http.MethodGet
resBody, err := sendJenkinsRequest(baseUrl, req)
if err != nil {
log.Error(err)
return nil, err
}
return resBody, err
}
func CreateSCMServers(scmId string, req *http.Request) ([]byte, error) {
requestBody, err := ioutil.ReadAll(req.Body)
if err != nil {
log.Error(err)
return nil, err
}
createReq := &CreateScmServerReq{}
err = json.Unmarshal(requestBody, createReq)
if err != nil {
log.Error(err)
return nil, err
}
req.Body = nil
byteServers, err := GetSCMServers(scmId, req)
if err != nil {
log.Error(err)
return nil, err
}
var servers []*SCMServer
_ = json.Unmarshal(byteServers, &servers)
for _, server := range servers {
if server.ApiURL == createReq.ApiURL {
return json.Marshal(server)
}
}
req.Body = ioutil.NopCloser(bytes.NewReader(requestBody))
baseUrl := fmt.Sprintf(jenkins.Server+CreateSCMServersUrl, scmId)
log.Info("Jenkins-url: " + baseUrl)
req.Method = http.MethodPost
resBody, err := sendJenkinsRequest(baseUrl, req)
if err != nil {
log.Error(err)
return nil, err
}
return resBody, err
}
func Validate(scmId string, req *http.Request) ([]byte, error) {
baseUrl := fmt.Sprintf(jenkins.Server+ValidateUrl, scmId)
log.Info("Jenkins-url: " + baseUrl)
......@@ -731,7 +780,7 @@ func jenkinsClient(baseUrl string, req *http.Request) ([]byte, http.Header, erro
log.Errorf("%+v", string(resBody))
jkerr := new(JkError)
jkerr.Code = resp.StatusCode
jkerr.Message = http.StatusText(resp.StatusCode)
jkerr.Message = string(resBody)
return nil, nil, jkerr
}
......
......@@ -260,6 +260,19 @@ type SCMOrg struct {
Name string `json:"name,omitempty" description:"organization name"`
}
type SCMServer struct {
Class string `json:"_class,omitempty" description:"It’s a fully qualified name and is an identifier of the producer of this resource's capability."`
Links struct {
Self struct {
Class string `json:"_class,omitempty" description:"It’s a fully qualified name and is an identifier of the producer of this resource's capability."`
Href string `json:"href,omitempty" description:"self url in api"`
} `json:"self,omitempty" description:"scm server self info"`
} `json:"_links,omitempty" description:"references the reachable path to this resource"`
ID string `json:"id,omitempty" description:"server id of scm server"`
Name string `json:"name,omitempty" description:"name of scm server"`
ApiURL string `json:"apiUrl,omitempty" description:"url of scm server"`
}
// GetOrgRepo
type OrgRepo struct {
Class string `json:"_class,omitempty" description:"It’s a fully qualified name and is an identifier of the producer of this resource's capability."`
......@@ -721,6 +734,11 @@ type CheckPlayload struct {
Abort bool `json:"abort,omitempty" description:"abort or not"`
}
type CreateScmServerReq struct {
Name string `json:"name,omitempty" description:"name of scm server"`
ApiURL string `json:"apiUrl,omitempty" description:"url of scm server"`
}
type CheckPlayloadParameters struct {
Name string `json:"name,omitempty" description:"name"`
Value string `json:"value,omitempty" description:"value"`
......
......@@ -110,7 +110,7 @@ func Test_NoScmPipelineConfig_Param(t *testing.T) {
Name: "",
Description: "for test",
Jenkinsfile: "node{echo 'hello'}",
Parameters: []*Parameter{
Parameters: &Parameters{
&Parameter{
Name: "d",
DefaultValue: "a\nb",
......@@ -123,7 +123,7 @@ func Test_NoScmPipelineConfig_Param(t *testing.T) {
Name: "",
Description: "for test",
Jenkinsfile: "node{echo 'hello'}",
Parameters: []*Parameter{
Parameters: &Parameters{
&Parameter{
Name: "a",
DefaultValue: "abc",
......@@ -355,7 +355,28 @@ func Test_MultiBranchPipelineConfig_Source(t *testing.T) {
ApiUri: "https://api.github.com",
DiscoverBranches: 1,
DiscoverPRFromOrigin: 2,
DiscoverPRFromForks: &GithubDiscoverPRFromForks{
DiscoverPRFromForks: &DiscoverPRFromForks{
Strategy: 1,
Trust: 1,
},
},
},
&MultiBranchPipeline{
Name: "",
Description: "for test",
ScriptPath: "Jenkinsfile",
SourceType: "bitbucket_server",
TimerTrigger: &TimerTrigger{
Interval: "12345566",
},
BitbucketServerSource: &BitbucketServerSource{
Owner: "kubesphere",
Repo: "devops",
CredentialId: "github",
ApiUri: "https://api.github.com",
DiscoverBranches: 1,
DiscoverPRFromOrigin: 2,
DiscoverPRFromForks: &DiscoverPRFromForks{
Strategy: 1,
Trust: 1,
},
......@@ -439,7 +460,7 @@ func Test_MultiBranchPipelineCloneConfig(t *testing.T) {
ApiUri: "https://api.github.com",
DiscoverBranches: 1,
DiscoverPRFromOrigin: 2,
DiscoverPRFromForks: &GithubDiscoverPRFromForks{
DiscoverPRFromForks: &DiscoverPRFromForks{
Strategy: 1,
Trust: 1,
},
......@@ -496,7 +517,7 @@ func Test_MultiBranchPipelineRegexFilter(t *testing.T) {
ApiUri: "https://api.github.com",
DiscoverBranches: 1,
DiscoverPRFromOrigin: 2,
DiscoverPRFromForks: &GithubDiscoverPRFromForks{
DiscoverPRFromForks: &DiscoverPRFromForks{
Strategy: 1,
Trust: 1,
},
......
......@@ -44,6 +44,8 @@ const (
CheckPipelineUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/nodes/%s/steps/%s/"
GetBranchNodeStepsUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/nodes/%s/steps/?"
GetNodeStepsUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/nodes/%s/steps/?"
GetSCMServersUrl = "/blue/rest/organizations/jenkins/scm/%s/servers/"
CreateSCMServersUrl = "/blue/rest/organizations/jenkins/scm/%s/servers/"
ValidateUrl = "/blue/rest/organizations/jenkins/scm/%s/validate"
GetSCMOrgUrl = "/blue/rest/organizations/jenkins/scm/%s/organizations/?"
GetOrgRepoUrl = "/blue/rest/organizations/jenkins/scm/%s/organizations/%s/repositories/?"
......
......@@ -22,6 +22,7 @@ import (
"github.com/emicklei/go-restful"
"github.com/gocraft/dbr"
"github.com/golang/glog"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/db"
"kubesphere.io/kubesphere/pkg/gojenkins"
"kubesphere.io/kubesphere/pkg/gojenkins/utils"
......@@ -105,6 +106,34 @@ func ListDevopsProjects(workspace, username string, conditions *params.Condition
return &models.PageableResponse{Items: result, TotalCount: int(count)}, nil
}
func GetDevOpsProjectsCount(username string) (uint32, error) {
dbconn := devops_mysql.OpenDatabase()
query := dbconn.Select(devops.GetColumnsFromStructWithPrefix(devops.DevOpsProjectTableName, devops.DevOpsProject{})...).
From(devops.DevOpsProjectTableName)
var sqconditions []dbr.Builder
if username != devops.KS_ADMIN {
onCondition := fmt.Sprintf("%s = %s", devops.DevOpsProjectMembershipProjectIdColumn, devops.DevOpsProjectIdColumn)
query.Join(devops.DevOpsProjectMembershipTableName, onCondition)
sqconditions = append(sqconditions, db.Eq(devops.DevOpsProjectMembershipUsernameColumn, username))
sqconditions = append(sqconditions, db.Eq(
devops.DevOpsProjectMembershipTableName+"."+devops.StatusColumn, devops.StatusActive))
}
sqconditions = append(sqconditions, db.Eq(
devops.DevOpsProjectTableName+"."+devops.StatusColumn, devops.StatusActive))
if len(sqconditions) > 0 {
query.Where(db.And(sqconditions...))
}
count, err := query.Count()
if err != nil {
klog.Errorf("%+v", err)
return 0, restful.NewError(http.StatusInternalServerError, err.Error())
}
return count, nil
}
func DeleteDevOpsProject(projectId, username string) error {
err := devops.CheckProjectUserInRole(username, projectId, []string{devops.ProjectOwner})
if err != nil {
......
......@@ -42,6 +42,8 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
"github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1.Parameter": schema_pkg_apis_devops_v1alpha1_Parameter(ref),
"github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1.ProxyConfig": schema_pkg_apis_devops_v1alpha1_ProxyConfig(ref),
"github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1.S2iAutoScale": schema_pkg_apis_devops_v1alpha1_S2iAutoScale(ref),
"github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1.S2iBuildResult": schema_pkg_apis_devops_v1alpha1_S2iBuildResult(ref),
"github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1.S2iBuildSource": schema_pkg_apis_devops_v1alpha1_S2iBuildSource(ref),
"github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1.S2iBuilder": schema_pkg_apis_devops_v1alpha1_S2iBuilder(ref),
"github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1.S2iBuilderList": schema_pkg_apis_devops_v1alpha1_S2iBuilderList(ref),
"github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1.S2iBuilderSpec": schema_pkg_apis_devops_v1alpha1_S2iBuilderSpec(ref),
......@@ -772,6 +774,144 @@ func schema_pkg_apis_devops_v1alpha1_S2iAutoScale(ref common.ReferenceCallback)
}
}
func schema_pkg_apis_devops_v1alpha1_S2iBuildResult(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"imageName": {
SchemaProps: spec.SchemaProps{
Description: "ImageName is the name of artifact",
Type: []string{"string"},
Format: "",
},
},
"imageSize": {
SchemaProps: spec.SchemaProps{
Description: "The size in bytes of the image",
Type: []string{"integer"},
Format: "int64",
},
},
"imageID": {
SchemaProps: spec.SchemaProps{
Description: "Image ID.",
Type: []string{"string"},
Format: "",
},
},
"imageCreated": {
SchemaProps: spec.SchemaProps{
Description: "Image created time.",
Type: []string{"string"},
Format: "",
},
},
"imageRepoTags": {
SchemaProps: spec.SchemaProps{
Description: "image tags.",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
},
},
},
"commandPull": {
SchemaProps: spec.SchemaProps{
Description: "Command for pull image.",
Type: []string{"string"},
Format: "",
},
},
},
},
},
Dependencies: []string{},
}
}
func schema_pkg_apis_devops_v1alpha1_S2iBuildSource(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
Properties: map[string]spec.Schema{
"sourceUrl": {
SchemaProps: spec.SchemaProps{
Description: "SourceURL is url of the codes such as https://github.com/a/b.git",
Type: []string{"string"},
Format: "",
},
},
"revisionId": {
SchemaProps: spec.SchemaProps{
Description: "The RevisionId is a branch name or a SHA-1 hash of every important thing about the commit",
Type: []string{"string"},
Format: "",
},
},
"binaryName": {
SchemaProps: spec.SchemaProps{
Description: "Binary file Name",
Type: []string{"string"},
Format: "",
},
},
"binarySize": {
SchemaProps: spec.SchemaProps{
Description: "Binary file Size",
Type: []string{"integer"},
Format: "int64",
},
},
"builderImage": {
SchemaProps: spec.SchemaProps{
Description: "// BuilderImage describes which image is used for building the result images.",
Type: []string{"string"},
Format: "",
},
},
"description": {
SchemaProps: spec.SchemaProps{
Description: "Description is a result image description label. The default is no description.",
Type: []string{"string"},
Format: "",
},
},
"commitID": {
SchemaProps: spec.SchemaProps{
Description: "CommitID represents an arbitrary extended object reference in Git as SHA-1",
Type: []string{"string"},
Format: "",
},
},
"committerName": {
SchemaProps: spec.SchemaProps{
Description: "CommitterName contains the name of the committer",
Type: []string{"string"},
Format: "",
},
},
"committerEmail": {
SchemaProps: spec.SchemaProps{
Description: "CommitterEmail contains the e-mail of the committer",
Type: []string{"string"},
Format: "",
},
},
},
},
},
Dependencies: []string{},
}
}
func schema_pkg_apis_devops_v1alpha1_S2iBuilder(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
......@@ -1577,6 +1717,13 @@ func schema_pkg_apis_devops_v1alpha1_S2iConfig(ref common.ReferenceCallback) com
},
},
},
"outputBuildResult": {
SchemaProps: spec.SchemaProps{
Description: "Whether output build result to status.",
Type: []string{"boolean"},
Format: "",
},
},
},
Required: []string{"imageName", "sourceUrl"},
},
......@@ -1774,18 +1921,23 @@ func schema_pkg_apis_devops_v1alpha1_S2iRunStatus(ref common.ReferenceCallback)
Format: "",
},
},
"imageName": {
"s2iBuildResult": {
SchemaProps: spec.SchemaProps{
Description: "ImageName is the name of artifact",
Type: []string{"string"},
Format: "",
Description: "S2i build result info.",
Ref: ref("github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1.S2iBuildResult"),
},
},
"s2iBuildSource": {
SchemaProps: spec.SchemaProps{
Description: "S2i build source info.",
Ref: ref("github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1.S2iBuildSource"),
},
},
},
},
},
Dependencies: []string{
"k8s.io/apimachinery/pkg/apis/meta/v1.Time"},
"github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1.S2iBuildResult", "github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1.S2iBuildSource", "k8s.io/apimachinery/pkg/apis/meta/v1.Time"},
}
}
......
......@@ -419,6 +419,9 @@ type S2iConfig struct {
// The values of Node Affinity.
NodeAffinityValues []string `json:"nodeAffinityValues,omitempty"`
// Whether output build result to status.
OutputBuildResult bool `json:"outputBuildResult,omitempty"`
}
type UserDefineTemplate struct {
......
......@@ -61,8 +61,50 @@ type S2iRunStatus struct {
LogURL string `json:"logURL,omitempty"`
//KubernetesJobName is the job name in k8s
KubernetesJobName string `json:"kubernetesJobName,omitempty"`
// S2i build result info.
S2iBuildResult *S2iBuildResult `json:"s2iBuildResult,omitempty"`
// S2i build source info.
S2iBuildSource *S2iBuildSource `json:"s2iBuildSource,omitempty"`
}
type S2iBuildResult struct {
//ImageName is the name of artifact
ImageName string `json:"imageName,omitempty"`
//The size in bytes of the image
ImageSize int64 `json:"imageSize,omitempty"`
// Image ID.
ImageID string `json:"imageID,omitempty"`
// Image created time.
ImageCreated string `json:"imageCreated,omitempty"`
// image tags.
ImageRepoTags []string `json:"imageRepoTags,omitempty"`
// Command for pull image.
CommandPull string `json:"commandPull,omitempty"`
}
type S2iBuildSource struct {
// SourceURL is url of the codes such as https://github.com/a/b.git
SourceUrl string `json:"sourceUrl,omitempty"`
// The RevisionId is a branch name or a SHA-1 hash of every important thing about the commit
RevisionId string `json:"revisionId,omitempty"`
// Binary file Name
BinaryName string `json:"binaryName,omitempty"`
// Binary file Size
BinarySize uint64 `json:"binarySize,omitempty"`
// // BuilderImage describes which image is used for building the result images.
BuilderImage string `json:"builderImage,omitempty"`
// Description is a result image description label. The default is no
// description.
Description string `json:"description,omitempty"`
// CommitID represents an arbitrary extended object reference in Git as SHA-1
CommitID string `json:"commitID,omitempty"`
// CommitterName contains the name of the committer
CommitterName string `json:"committerName,omitempty"`
// CommitterEmail contains the e-mail of the committer
CommitterEmail string `json:"committerEmail,omitempty"`
}
// +genclient
......@@ -76,7 +118,7 @@ type S2iRunStatus struct {
// +kubebuilder:printcolumn:name="K8sJobName",type="string",JSONPath=".status.kubernetesJobName"
// +kubebuilder:printcolumn:name="StartTime",type="date",JSONPath=".status.startTime"
// +kubebuilder:printcolumn:name="CompletionTime",type="date",JSONPath=".status.completionTime"
// +kubebuilder:printcolumn:name="ImageName",type="string",JSONPath=".status.imageName"
// +kubebuilder:printcolumn:name="ImageName",type="string",JSONPath=".status.s2iBuildResult.imageName"
type S2iRun struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
......
......@@ -271,6 +271,43 @@ func (in *S2iAutoScale) DeepCopy() *S2iAutoScale {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *S2iBuildResult) DeepCopyInto(out *S2iBuildResult) {
*out = *in
if in.ImageRepoTags != nil {
in, out := &in.ImageRepoTags, &out.ImageRepoTags
*out = make([]string, len(*in))
copy(*out, *in)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iBuildResult.
func (in *S2iBuildResult) DeepCopy() *S2iBuildResult {
if in == nil {
return nil
}
out := new(S2iBuildResult)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *S2iBuildSource) DeepCopyInto(out *S2iBuildSource) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S2iBuildSource.
func (in *S2iBuildSource) DeepCopy() *S2iBuildSource {
if in == nil {
return nil
}
out := new(S2iBuildSource)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *S2iBuilder) DeepCopyInto(out *S2iBuilder) {
*out = *in
......@@ -681,6 +718,16 @@ func (in *S2iRunStatus) DeepCopyInto(out *S2iRunStatus) {
in, out := &in.CompletionTime, &out.CompletionTime
*out = (*in).DeepCopy()
}
if in.S2iBuildResult != nil {
in, out := &in.S2iBuildResult, &out.S2iBuildResult
*out = new(S2iBuildResult)
(*in).DeepCopyInto(*out)
}
if in.S2iBuildSource != nil {
in, out := &in.S2iBuildSource, &out.S2iBuildSource
*out = new(S2iBuildSource)
**out = **in
}
return
}
......
......@@ -367,7 +367,7 @@ github.com/kubernetes-sigs/application/pkg/resource
github.com/kubernetes-sigs/application/pkg/genericreconciler
github.com/kubernetes-sigs/application/pkg/kbcontroller
github.com/kubernetes-sigs/application/pkg/client/clientset/versioned/scheme
# github.com/kubesphere/s2ioperator v0.0.12
# github.com/kubesphere/s2ioperator v0.0.13
github.com/kubesphere/s2ioperator/pkg/client/clientset/versioned
github.com/kubesphere/s2ioperator/pkg/client/informers/externalversions
github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册