format code
This commit is contained in:
181
Godeps/Godeps.json
generated
181
Godeps/Godeps.json
generated
@@ -1,181 +0,0 @@
|
|||||||
{
|
|
||||||
"ImportPath": "kubesphere.io/kubesphere",
|
|
||||||
"GoVersion": "go1.10",
|
|
||||||
"GodepVersion": "v80",
|
|
||||||
"Packages": [
|
|
||||||
"./..."
|
|
||||||
],
|
|
||||||
"Deps": [
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/distribution/digestset",
|
|
||||||
"Comment": "v2.6.0-rc.1-277-g83389a14",
|
|
||||||
"Rev": "83389a148052d74ac602f5f1d62f86ff2f3c4aa5"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/distribution/reference",
|
|
||||||
"Comment": "v2.6.0-rc.1-277-g83389a14",
|
|
||||||
"Rev": "83389a148052d74ac602f5f1d62f86ff2f3c4aa5"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/docker/api",
|
|
||||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-9343-gb7b6b6929",
|
|
||||||
"Rev": "b7b6b6929c6436145bd12e6fef7efb7d01fa170b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/docker/api/types",
|
|
||||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-9343-gb7b6b6929",
|
|
||||||
"Rev": "b7b6b6929c6436145bd12e6fef7efb7d01fa170b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/docker/api/types/blkiodev",
|
|
||||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-9343-gb7b6b6929",
|
|
||||||
"Rev": "b7b6b6929c6436145bd12e6fef7efb7d01fa170b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/docker/api/types/container",
|
|
||||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-9343-gb7b6b6929",
|
|
||||||
"Rev": "b7b6b6929c6436145bd12e6fef7efb7d01fa170b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/docker/api/types/events",
|
|
||||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-9343-gb7b6b6929",
|
|
||||||
"Rev": "b7b6b6929c6436145bd12e6fef7efb7d01fa170b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/docker/api/types/filters",
|
|
||||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-9343-gb7b6b6929",
|
|
||||||
"Rev": "b7b6b6929c6436145bd12e6fef7efb7d01fa170b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/docker/api/types/image",
|
|
||||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-9343-gb7b6b6929",
|
|
||||||
"Rev": "b7b6b6929c6436145bd12e6fef7efb7d01fa170b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/docker/api/types/mount",
|
|
||||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-9343-gb7b6b6929",
|
|
||||||
"Rev": "b7b6b6929c6436145bd12e6fef7efb7d01fa170b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/docker/api/types/network",
|
|
||||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-9343-gb7b6b6929",
|
|
||||||
"Rev": "b7b6b6929c6436145bd12e6fef7efb7d01fa170b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/docker/api/types/registry",
|
|
||||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-9343-gb7b6b6929",
|
|
||||||
"Rev": "b7b6b6929c6436145bd12e6fef7efb7d01fa170b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/docker/api/types/strslice",
|
|
||||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-9343-gb7b6b6929",
|
|
||||||
"Rev": "b7b6b6929c6436145bd12e6fef7efb7d01fa170b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/docker/api/types/swarm",
|
|
||||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-9343-gb7b6b6929",
|
|
||||||
"Rev": "b7b6b6929c6436145bd12e6fef7efb7d01fa170b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/docker/api/types/swarm/runtime",
|
|
||||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-9343-gb7b6b6929",
|
|
||||||
"Rev": "b7b6b6929c6436145bd12e6fef7efb7d01fa170b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/docker/api/types/time",
|
|
||||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-9343-gb7b6b6929",
|
|
||||||
"Rev": "b7b6b6929c6436145bd12e6fef7efb7d01fa170b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/docker/api/types/versions",
|
|
||||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-9343-gb7b6b6929",
|
|
||||||
"Rev": "b7b6b6929c6436145bd12e6fef7efb7d01fa170b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/docker/api/types/volume",
|
|
||||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-9343-gb7b6b6929",
|
|
||||||
"Rev": "b7b6b6929c6436145bd12e6fef7efb7d01fa170b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/docker/client",
|
|
||||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-9343-gb7b6b6929",
|
|
||||||
"Rev": "b7b6b6929c6436145bd12e6fef7efb7d01fa170b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/go-connections/nat",
|
|
||||||
"Comment": "v0.3.0-13-g7395e3f",
|
|
||||||
"Rev": "7395e3f8aa162843a74ed6d48e79627d9792ac55"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/go-connections/sockets",
|
|
||||||
"Comment": "v0.3.0-13-g7395e3f",
|
|
||||||
"Rev": "7395e3f8aa162843a74ed6d48e79627d9792ac55"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/go-connections/tlsconfig",
|
|
||||||
"Comment": "v0.3.0-13-g7395e3f",
|
|
||||||
"Rev": "7395e3f8aa162843a74ed6d48e79627d9792ac55"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/docker/go-units",
|
|
||||||
"Comment": "v0.3.2-4-g47565b4",
|
|
||||||
"Rev": "47565b4f722fb6ceae66b95f853feed578a4a51c"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/emicklei/go-restful",
|
|
||||||
"Comment": "v2.6.1",
|
|
||||||
"Rev": "92cd0815dd1a028a6e69faee9757c7436238e252"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/emicklei/go-restful/log",
|
|
||||||
"Comment": "v2.6.1",
|
|
||||||
"Rev": "92cd0815dd1a028a6e69faee9757c7436238e252"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/gogo/protobuf/proto",
|
|
||||||
"Comment": "v1.0.0-16-g30cf7ac3",
|
|
||||||
"Rev": "30cf7ac33676b5786e78c746683f0d4cd64fa75b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/golang/glog",
|
|
||||||
"Rev": "23def4e6c14b4da8ac2ed8007337bc5eb5007998"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/opencontainers/go-digest",
|
|
||||||
"Comment": "v1.0.0-rc1-2-gc928146",
|
|
||||||
"Rev": "c9281466c8b2f606084ac71339773efd177436e7"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/opencontainers/image-spec/specs-go",
|
|
||||||
"Comment": "v1.0.0-35-ge562b04",
|
|
||||||
"Rev": "e562b04403929d582d449ae5386ff79dd7961a11"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/opencontainers/image-spec/specs-go/v1",
|
|
||||||
"Comment": "v1.0.0-35-ge562b04",
|
|
||||||
"Rev": "e562b04403929d582d449ae5386ff79dd7961a11"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/pkg/errors",
|
|
||||||
"Comment": "v0.8.0-12-g816c908",
|
|
||||||
"Rev": "816c9085562cd7ee03e7f8188a1cfd942858cded"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "github.com/spf13/pflag",
|
|
||||||
"Comment": "v1.0.1",
|
|
||||||
"Rev": "583c0c0531f06d5278b7d917446061adc344b5cd"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "golang.org/x/net/context",
|
|
||||||
"Rev": "6078986fec03a1dcc236c34816c71b0e05018fda"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "golang.org/x/net/context/ctxhttp",
|
|
||||||
"Rev": "6078986fec03a1dcc236c34816c71b0e05018fda"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ImportPath": "golang.org/x/net/proxy",
|
|
||||||
"Rev": "6078986fec03a1dcc236c34816c71b0e05018fda"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
5
Godeps/Readme
generated
5
Godeps/Readme
generated
@@ -1,5 +0,0 @@
|
|||||||
This directory tree is generated automatically by godep.
|
|
||||||
|
|
||||||
Please do not edit.
|
|
||||||
|
|
||||||
See https://github.com/tools/godep for more information.
|
|
||||||
@@ -18,6 +18,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
|
||||||
"kubesphere.io/kubesphere/pkg/app"
|
"kubesphere.io/kubesphere/pkg/app"
|
||||||
"kubesphere.io/kubesphere/pkg/logs"
|
"kubesphere.io/kubesphere/pkg/logs"
|
||||||
"kubesphere.io/kubesphere/pkg/options"
|
"kubesphere.io/kubesphere/pkg/options"
|
||||||
|
|||||||
@@ -17,11 +17,13 @@ limitations under the License.
|
|||||||
package components
|
package components
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/emicklei/go-restful"
|
"github.com/emicklei/go-restful"
|
||||||
|
|
||||||
|
"kubesphere.io/kubesphere/pkg/constants"
|
||||||
"kubesphere.io/kubesphere/pkg/filter/route"
|
"kubesphere.io/kubesphere/pkg/filter/route"
|
||||||
"kubesphere.io/kubesphere/pkg/models"
|
"kubesphere.io/kubesphere/pkg/models"
|
||||||
"net/http"
|
|
||||||
"kubesphere.io/kubesphere/pkg/constants"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Register(ws *restful.WebService, subPath string) {
|
func Register(ws *restful.WebService, subPath string) {
|
||||||
|
|||||||
@@ -13,19 +13,21 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package iam
|
package iam
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"kubesphere.io/kubesphere/pkg/filter/route"
|
|
||||||
"kubesphere.io/kubesphere/pkg/models"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"kubesphere.io/kubesphere/pkg/constants"
|
|
||||||
|
"github.com/emicklei/go-restful"
|
||||||
"k8s.io/api/rbac/v1"
|
"k8s.io/api/rbac/v1"
|
||||||
"k8s.io/kubernetes/pkg/util/slice"
|
"k8s.io/kubernetes/pkg/util/slice"
|
||||||
|
|
||||||
|
"kubesphere.io/kubesphere/pkg/constants"
|
||||||
|
"kubesphere.io/kubesphere/pkg/filter/route"
|
||||||
|
"kubesphere.io/kubesphere/pkg/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Register(ws *restful.WebService) {
|
func Register(ws *restful.WebService) {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package iam
|
package iam
|
||||||
|
|
||||||
|
|||||||
@@ -13,13 +13,14 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package iam
|
package iam
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"k8s.io/api/rbac/v1"
|
"k8s.io/api/rbac/v1"
|
||||||
"k8s.io/kubernetes/pkg/util/slice"
|
"k8s.io/kubernetes/pkg/util/slice"
|
||||||
|
|
||||||
"kubesphere.io/kubesphere/pkg/models"
|
"kubesphere.io/kubesphere/pkg/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -121,7 +122,7 @@ func getClusterRoleRules(name string) ([]rule, error) {
|
|||||||
|
|
||||||
rules := make([]rule, 0)
|
rules := make([]rule, 0)
|
||||||
|
|
||||||
for i := 0; i < len(clusterRoleRuleGroup); i ++ {
|
for i := 0; i < len(clusterRoleRuleGroup); i++ {
|
||||||
rule := rule{Name: clusterRoleRuleGroup[i].Name}
|
rule := rule{Name: clusterRoleRuleGroup[i].Name}
|
||||||
rule.Actions = make([]action, 0)
|
rule.Actions = make([]action, 0)
|
||||||
for j := 0; j < (len(clusterRoleRuleGroup[i].Actions)); j++ {
|
for j := 0; j < (len(clusterRoleRuleGroup[i].Actions)); j++ {
|
||||||
@@ -143,7 +144,7 @@ func getRoleRules(namespace string, name string) ([]rule, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
rules := make([]rule, 0)
|
rules := make([]rule, 0)
|
||||||
for i := 0; i < len(roleRuleGroup); i ++ {
|
for i := 0; i < len(roleRuleGroup); i++ {
|
||||||
rule := rule{Name: roleRuleGroup[i].Name}
|
rule := rule{Name: roleRuleGroup[i].Name}
|
||||||
rule.Actions = make([]action, 0)
|
rule.Actions = make([]action, 0)
|
||||||
for j := 0; j < len(roleRuleGroup[i].Actions); j++ {
|
for j := 0; j < len(roleRuleGroup[i].Actions); j++ {
|
||||||
|
|||||||
@@ -18,17 +18,18 @@ package v1alpha
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/emicklei/go-restful"
|
"github.com/emicklei/go-restful"
|
||||||
|
|
||||||
|
"kubesphere.io/kubesphere/pkg/apis/v1alpha/components"
|
||||||
"kubesphere.io/kubesphere/pkg/apis/v1alpha/containers"
|
"kubesphere.io/kubesphere/pkg/apis/v1alpha/containers"
|
||||||
|
"kubesphere.io/kubesphere/pkg/apis/v1alpha/iam"
|
||||||
"kubesphere.io/kubesphere/pkg/apis/v1alpha/kubeconfig"
|
"kubesphere.io/kubesphere/pkg/apis/v1alpha/kubeconfig"
|
||||||
"kubesphere.io/kubesphere/pkg/apis/v1alpha/kubectl"
|
"kubesphere.io/kubesphere/pkg/apis/v1alpha/kubectl"
|
||||||
"kubesphere.io/kubesphere/pkg/apis/v1alpha/nodes"
|
"kubesphere.io/kubesphere/pkg/apis/v1alpha/nodes"
|
||||||
"kubesphere.io/kubesphere/pkg/apis/v1alpha/pods"
|
"kubesphere.io/kubesphere/pkg/apis/v1alpha/pods"
|
||||||
"kubesphere.io/kubesphere/pkg/apis/v1alpha/registries"
|
"kubesphere.io/kubesphere/pkg/apis/v1alpha/registries"
|
||||||
|
"kubesphere.io/kubesphere/pkg/apis/v1alpha/routes"
|
||||||
"kubesphere.io/kubesphere/pkg/apis/v1alpha/storage"
|
"kubesphere.io/kubesphere/pkg/apis/v1alpha/storage"
|
||||||
"kubesphere.io/kubesphere/pkg/apis/v1alpha/volumes"
|
"kubesphere.io/kubesphere/pkg/apis/v1alpha/volumes"
|
||||||
"kubesphere.io/kubesphere/pkg/apis/v1alpha/iam"
|
|
||||||
"kubesphere.io/kubesphere/pkg/apis/v1alpha/components"
|
|
||||||
"kubesphere.io/kubesphere/pkg/apis/v1alpha/routes"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -45,7 +46,7 @@ func init() {
|
|||||||
pods.Register(ws)
|
pods.Register(ws)
|
||||||
containers.Register(ws)
|
containers.Register(ws)
|
||||||
iam.Register(ws)
|
iam.Register(ws)
|
||||||
components.Register(ws,"/components")
|
components.Register(ws, "/components")
|
||||||
|
|
||||||
routes.Register(ws)
|
routes.Register(ws)
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,10 @@
|
|||||||
package kubeconfig
|
package kubeconfig
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/emicklei/go-restful"
|
||||||
|
|
||||||
"kubesphere.io/kubesphere/pkg/models"
|
"kubesphere.io/kubesphere/pkg/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24,12 +26,11 @@ const DefaultServiceAccount = "default"
|
|||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Certificate string
|
Certificate string
|
||||||
Server string
|
Server string
|
||||||
User string
|
User string
|
||||||
Token string
|
Token string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func Register(ws *restful.WebService, subPath string) {
|
func Register(ws *restful.WebService, subPath string) {
|
||||||
|
|
||||||
ws.Route(ws.GET(subPath).To(handleKubeconfig))
|
ws.Route(ws.GET(subPath).To(handleKubeconfig))
|
||||||
|
|||||||
@@ -17,16 +17,18 @@ limitations under the License.
|
|||||||
package kubectl
|
package kubectl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"kubesphere.io/kubesphere/pkg/models"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/emicklei/go-restful"
|
||||||
|
|
||||||
|
"kubesphere.io/kubesphere/pkg/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Register(ws *restful.WebService, subPath string) {
|
func Register(ws *restful.WebService, subPath string) {
|
||||||
|
|
||||||
ws.Route(ws.GET(subPath).Consumes("*/*").Produces(restful.MIME_JSON).To(handleKubectl).Doc("use to " +
|
ws.Route(ws.GET(subPath).Consumes("*/*").Produces(restful.MIME_JSON).To(handleKubectl).Doc("use to "+
|
||||||
"get a kubectl pod in specified namespaces").Param(ws.PathParameter("namespace",
|
"get a kubectl pod in specified namespaces").Param(ws.PathParameter("namespace",
|
||||||
"namespace").DataType("string")).Do(returns200,returns500))
|
"namespace").DataType("string")).Do(returns200, returns500))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ func GetAllRouters(request *restful.Request, response *restful.Response) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Error(err)
|
glog.Error(err)
|
||||||
response.WriteHeaderAndEntity(http.StatusInternalServerError, constants.MessageResponse{Message: err.Error()})
|
response.WriteHeaderAndEntity(http.StatusInternalServerError, constants.MessageResponse{Message: err.Error()})
|
||||||
} else {
|
} else {
|
||||||
response.WriteAsJson(routers)
|
response.WriteAsJson(routers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package storage
|
package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/emicklei/go-restful"
|
"github.com/emicklei/go-restful"
|
||||||
|
|
||||||
"kubesphere.io/kubesphere/pkg/filter/route"
|
"kubesphere.io/kubesphere/pkg/filter/route"
|
||||||
"kubesphere.io/kubesphere/pkg/models"
|
"kubesphere.io/kubesphere/pkg/models"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Register(ws *restful.WebService, subPath string) {
|
func Register(ws *restful.WebService, subPath string) {
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package volumes
|
package volumes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/emicklei/go-restful"
|
"github.com/emicklei/go-restful"
|
||||||
|
|
||||||
"kubesphere.io/kubesphere/pkg/filter/route"
|
"kubesphere.io/kubesphere/pkg/filter/route"
|
||||||
"kubesphere.io/kubesphere/pkg/models"
|
"kubesphere.io/kubesphere/pkg/models"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Register(ws *restful.WebService, subPath string) {
|
func Register(ws *restful.WebService, subPath string) {
|
||||||
|
|||||||
@@ -19,12 +19,14 @@ package app
|
|||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"github.com/golang/glog"
|
|
||||||
_ "kubesphere.io/kubesphere/pkg/apis/v1alpha"
|
|
||||||
"kubesphere.io/kubesphere/pkg/options"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/emicklei/go-restful"
|
||||||
|
"github.com/golang/glog"
|
||||||
|
|
||||||
|
_ "kubesphere.io/kubesphere/pkg/apis/v1alpha"
|
||||||
|
"kubesphere.io/kubesphere/pkg/options"
|
||||||
)
|
)
|
||||||
|
|
||||||
type kubeSphereServer struct {
|
type kubeSphereServer struct {
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ limitations under the License.
|
|||||||
|
|
||||||
package client
|
package client
|
||||||
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"kubesphere.io/kubesphere/pkg/options"
|
"github.com/golang/glog"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
"github.com/golang/glog"
|
|
||||||
|
"kubesphere.io/kubesphere/pkg/options"
|
||||||
)
|
)
|
||||||
|
|
||||||
var k8sClient *kubernetes.Clientset
|
var k8sClient *kubernetes.Clientset
|
||||||
@@ -41,7 +41,7 @@ func getKubeConfig() (kubeConfig *rest.Config, err error) {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
kubeConfig, err = rest.InClusterConfig()
|
kubeConfig, err = rest.InClusterConfig()
|
||||||
if err != nil{
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ func NewK8sClient() *kubernetes.Clientset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
k8sClient, err = kubernetes.NewForConfig(kubeConfig)
|
k8sClient, err = kubernetes.NewForConfig(kubeConfig)
|
||||||
if err != nil{
|
if err != nil {
|
||||||
glog.Error(err)
|
glog.Error(err)
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,6 @@ type PageableResponse struct {
|
|||||||
TotalCount int `json:"total_count"`
|
TotalCount int `json:"total_count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
const APIVERSION = "v1alpha1"
|
const APIVERSION = "v1alpha1"
|
||||||
|
|
||||||
const KIND = "kubesphere"
|
const KIND = "kubesphere"
|
||||||
|
|||||||
@@ -17,9 +17,10 @@ limitations under the License.
|
|||||||
package container
|
package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/emicklei/go-restful"
|
"github.com/emicklei/go-restful"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func logFilter() restful.FilterFunction {
|
func logFilter() restful.FilterFunction {
|
||||||
|
|||||||
@@ -17,24 +17,25 @@ limitations under the License.
|
|||||||
package route
|
package route
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"github.com/golang/glog"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/emicklei/go-restful"
|
||||||
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Route Filter (defines FilterFunction)
|
// Route Filter (defines FilterFunction)
|
||||||
func RouteLogging(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) {
|
func RouteLogging(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) {
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
chain.ProcessFilter(req, resp)
|
chain.ProcessFilter(req, resp)
|
||||||
glog.Infof("%s - \"%s %s %s\" %d %dms",
|
glog.Infof("%s - \"%s %s %s\" %d %dms",
|
||||||
strings.Split(req.Request.RemoteAddr, ":")[0],
|
strings.Split(req.Request.RemoteAddr, ":")[0],
|
||||||
req.Request.Method,
|
req.Request.Method,
|
||||||
req.Request.URL.RequestURI(),
|
req.Request.URL.RequestURI(),
|
||||||
req.Request.Proto,
|
req.Request.Proto,
|
||||||
resp.StatusCode(),
|
resp.StatusCode(),
|
||||||
time.Now().Sub(start)/1000000,
|
time.Now().Sub(start)/1000000,
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -18,16 +18,17 @@ package models
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"github.com/golang/glog"
|
|
||||||
"text/template"
|
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"text/template"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
"kubesphere.io/kubesphere/pkg/client"
|
"kubesphere.io/kubesphere/pkg/client"
|
||||||
"kubesphere.io/kubesphere/pkg/options"
|
"kubesphere.io/kubesphere/pkg/options"
|
||||||
)
|
)
|
||||||
|
|
||||||
var kubeconfigTemp =
|
var kubeconfigTemp = "apiVersion: v1\n" +
|
||||||
"apiVersion: v1\n" +
|
|
||||||
"clusters:\n" +
|
"clusters:\n" +
|
||||||
"- cluster:\n" +
|
"- cluster:\n" +
|
||||||
" certificate-authority-data: {{.Certificate}}\n" +
|
" certificate-authority-data: {{.Certificate}}\n" +
|
||||||
@@ -51,9 +52,9 @@ const DefaultServiceAccount = "default"
|
|||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Certificate string
|
Certificate string
|
||||||
Server string
|
Server string
|
||||||
User string
|
User string
|
||||||
Token string
|
Token string
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetKubeConfig(namespace string) (string, error) {
|
func GetKubeConfig(namespace string) (string, error) {
|
||||||
@@ -77,24 +78,24 @@ func GetKubeConfig(namespace string) (string, error) {
|
|||||||
func getKubeConfig(namespace, apiserverHost string) (*Config, error) {
|
func getKubeConfig(namespace, apiserverHost string) (*Config, error) {
|
||||||
k8sClient := client.NewK8sClient()
|
k8sClient := client.NewK8sClient()
|
||||||
saInfo, err := k8sClient.CoreV1().ServiceAccounts(namespace).Get(DefaultServiceAccount, meta_v1.GetOptions{})
|
saInfo, err := k8sClient.CoreV1().ServiceAccounts(namespace).Get(DefaultServiceAccount, meta_v1.GetOptions{})
|
||||||
if err != nil{
|
if err != nil {
|
||||||
glog.Errorln(err)
|
glog.Errorln(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
secretName := saInfo.Secrets[0].Name
|
secretName := saInfo.Secrets[0].Name
|
||||||
|
|
||||||
secretInfo, err := k8sClient.CoreV1().Secrets(namespace).Get(secretName, meta_v1.GetOptions{})
|
secretInfo, err := k8sClient.CoreV1().Secrets(namespace).Get(secretName, meta_v1.GetOptions{})
|
||||||
if err != nil{
|
if err != nil {
|
||||||
glog.Errorln(err)
|
glog.Errorln(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
secretData := secretInfo.Data
|
secretData := secretInfo.Data
|
||||||
certificate := string(secretData["ca.crt"])
|
certificate := string(secretData["ca.crt"])
|
||||||
certificate= base64.StdEncoding.EncodeToString([]byte(certificate))
|
certificate = base64.StdEncoding.EncodeToString([]byte(certificate))
|
||||||
server := apiserverHost
|
server := apiserverHost
|
||||||
token := string(secretData["token"])
|
token := string(secretData["token"])
|
||||||
user := string(secretData["namespace"])
|
user := string(secretData["namespace"])
|
||||||
|
|
||||||
return &Config{Certificate:certificate, Server:server, Token:token, User:user}, nil
|
return &Config{Certificate: certificate, Server: server, Token: token, User: user}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,13 +19,14 @@ package models
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
|
||||||
"kubesphere.io/kubesphere/pkg/client"
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
)
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
|
|
||||||
|
"kubesphere.io/kubesphere/pkg/client"
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
deploymentName = "kubectl"
|
deploymentName = "kubectl"
|
||||||
@@ -33,7 +34,7 @@ const (
|
|||||||
|
|
||||||
type kubectlPodInfo struct {
|
type kubectlPodInfo struct {
|
||||||
Namespace string `json: "namespace"`
|
Namespace string `json: "namespace"`
|
||||||
Pod string `json: "podname"`
|
Pod string `json: "podname"`
|
||||||
Container string `json: "container"`
|
Container string `json: "container"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,36 +48,35 @@ func GetKubectlPod(namespace string) (kubectlPodInfo, error) {
|
|||||||
|
|
||||||
selectors := deploy.Spec.Selector.MatchLabels
|
selectors := deploy.Spec.Selector.MatchLabels
|
||||||
labelSelector := labels.Set(selectors).AsSelector().String()
|
labelSelector := labels.Set(selectors).AsSelector().String()
|
||||||
podList, err := k8sClient.CoreV1().Pods(namespace).List(meta_v1.ListOptions{LabelSelector:labelSelector})
|
podList, err := k8sClient.CoreV1().Pods(namespace).List(meta_v1.ListOptions{LabelSelector: labelSelector})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorln(err)
|
glog.Errorln(err)
|
||||||
return kubectlPodInfo{}, err
|
return kubectlPodInfo{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
pod, err := selectCorrectPod(namespace, podList.Items)
|
pod, err := selectCorrectPod(namespace, podList.Items)
|
||||||
if err != nil{
|
if err != nil {
|
||||||
glog.Errorln(err)
|
glog.Errorln(err)
|
||||||
return kubectlPodInfo{}, err
|
return kubectlPodInfo{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := kubectlPodInfo{Namespace:pod.Namespace, Pod:pod.Name, Container:pod.Status.ContainerStatuses[0].Name}
|
info := kubectlPodInfo{Namespace: pod.Namespace, Pod: pod.Name, Container: pod.Status.ContainerStatuses[0].Name}
|
||||||
|
|
||||||
return info, nil
|
return info, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func selectCorrectPod(namespace string, pods []v1.Pod) (kubectlPod v1.Pod, err error) {
|
func selectCorrectPod(namespace string, pods []v1.Pod) (kubectlPod v1.Pod, err error) {
|
||||||
|
|
||||||
var kubectPodList []v1.Pod
|
var kubectPodList []v1.Pod
|
||||||
for _, pod := range pods{
|
for _, pod := range pods {
|
||||||
for _, condition := range pod.Status.Conditions{
|
for _, condition := range pod.Status.Conditions {
|
||||||
if condition.Type == "Ready" && condition.Status == "True"{
|
if condition.Type == "Ready" && condition.Status == "True" {
|
||||||
kubectPodList = append(kubectPodList, pod)
|
kubectPodList = append(kubectPodList, pod)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(kubectPodList) < 1{
|
if len(kubectPodList) < 1 {
|
||||||
err = fmt.Errorf("cannot find valid kubectl pod in namespace:%s", namespace)
|
err = fmt.Errorf("cannot find valid kubectl pod in namespace:%s", namespace)
|
||||||
return v1.Pod{}, err
|
return v1.Pod{}, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import (
|
|||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
"kubesphere.io/kubesphere/pkg/client"
|
"kubesphere.io/kubesphere/pkg/client"
|
||||||
ksutil "kubesphere.io/kubesphere/pkg/util"
|
ksutil "kubesphere.io/kubesphere/pkg/util"
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"kubesphere.io/kubesphere/pkg/constants"
|
|
||||||
"math"
|
"math"
|
||||||
|
|
||||||
|
"k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
|
"kubesphere.io/kubesphere/pkg/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ResultPod struct {
|
type ResultPod struct {
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ package models
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"k8s.io/api/rbac/v1"
|
"k8s.io/api/rbac/v1"
|
||||||
"kubesphere.io/kubesphere/pkg/client"
|
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
|
"kubesphere.io/kubesphere/pkg/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
const ClusterRoleKind = "ClusterRole"
|
const ClusterRoleKind = "ClusterRole"
|
||||||
|
|||||||
@@ -17,15 +17,15 @@ limitations under the License.
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
coreV1 "k8s.io/api/core/v1"
|
coreV1 "k8s.io/api/core/v1"
|
||||||
metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/client-go/kubernetes/scheme"
|
|
||||||
extensionsV1beta1 "k8s.io/api/extensions/v1beta1"
|
extensionsV1beta1 "k8s.io/api/extensions/v1beta1"
|
||||||
"k8s.io/api/rbac/v1beta1"
|
"k8s.io/api/rbac/v1beta1"
|
||||||
"github.com/golang/glog"
|
metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/client-go/kubernetes/scheme"
|
||||||
|
|
||||||
"kubesphere.io/kubesphere/pkg/client"
|
"kubesphere.io/kubesphere/pkg/client"
|
||||||
)
|
)
|
||||||
@@ -37,7 +37,7 @@ type Router struct {
|
|||||||
Annotations string `json:"annotations"`
|
Annotations string `json:"annotations"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAllRouters() ([] *coreV1.Service, error) {
|
func GetAllRouters() ([]*coreV1.Service, error) {
|
||||||
|
|
||||||
k8sClient := client.NewK8sClient()
|
k8sClient := client.NewK8sClient()
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
v12 "k8s.io/api/core/v1"
|
v12 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1"
|
"k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
"kubesphere.io/kubesphere/pkg/client"
|
"kubesphere.io/kubesphere/pkg/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package models
|
|||||||
import (
|
import (
|
||||||
v12 "k8s.io/api/core/v1"
|
v12 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1"
|
"k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
"kubesphere.io/kubesphere/pkg/client"
|
"kubesphere.io/kubesphere/pkg/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,9 @@ package options
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
goflag "flag"
|
goflag "flag"
|
||||||
"github.com/spf13/pflag"
|
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
|
"github.com/spf13/pflag"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ServerRunOptions runs a kubernetes api server.
|
// ServerRunOptions runs a kubernetes api server.
|
||||||
|
|||||||
@@ -18,8 +18,9 @@ package util
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/golang/glog"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
|
|
||||||
type JsonRawMessage []byte
|
type JsonRawMessage []byte
|
||||||
|
|||||||
@@ -18,8 +18,10 @@ package version
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/spf13/pflag"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/spf13/pflag"
|
||||||
|
|
||||||
"kubesphere.io/kubesphere/pkg/constants"
|
"kubesphere.io/kubesphere/pkg/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user