Merge branch 'master' into master-lock-port

This commit is contained in:
yangkaa 2021-07-03 04:19:40 -05:00 committed by GitHub
commit a436d08829
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
155 changed files with 13022 additions and 1164 deletions

View File

@ -47,4 +47,40 @@ mock:
help: ## this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
precommit:
./precheck.sh
./precheck.sh
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true"
# Generate manifests e.g. CRD, RBAC etc.
manifests: controller-gen
$(CONTROLLER_GEN) $(CRD_OPTIONS) paths="./pkg/apis/..." output:crd:artifacts:config=config/crd
# Generate code
generate: controller-gen
chmod +x vendor/k8s.io/code-generator/generate-groups.sh
./hack/k8s/codegen/update-generated.sh
$(CONTROLLER_GEN) object:headerFile="hack/k8s/codegen/boilerplate.go.txt" paths="./pkg/apis/..."
cp -r github.com/goodrain/rainbond/pkg/ ./pkg/
rm -rf github.com/
# find or download controller-gen
# download controller-gen if necessary
controller-gen:
ifeq (, $(shell which controller-gen))
@{ \
set -e ;\
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
go mod init tmp ;\
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.5 ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif
.PHONY: test
test:
KUBE_CONFIG=~/.kube/config PROJECT_HOME=${shell pwd} ginkgo -v worker/controllers/helmapp

View File

@ -52,6 +52,7 @@ type TenantInterface interface {
GetManyDeployVersion(w http.ResponseWriter, r *http.Request)
LimitTenantMemory(w http.ResponseWriter, r *http.Request)
TenantResourcesStatus(w http.ResponseWriter, r *http.Request)
CheckResourceName(w http.ResponseWriter, r *http.Request)
}
//ServiceInterface ServiceInterface
@ -159,7 +160,7 @@ type ApplicationInterface interface {
BatchCreateApp(w http.ResponseWriter, r *http.Request)
UpdateApp(w http.ResponseWriter, r *http.Request)
ListApps(w http.ResponseWriter, r *http.Request)
ListServices(w http.ResponseWriter, r *http.Request)
ListComponents(w http.ResponseWriter, r *http.Request)
BatchBindService(w http.ResponseWriter, r *http.Request)
DeleteApp(w http.ResponseWriter, r *http.Request)
AddConfigGroup(w http.ResponseWriter, r *http.Request)
@ -167,6 +168,9 @@ type ApplicationInterface interface {
BatchUpdateComponentPorts(w http.ResponseWriter, r *http.Request)
GetAppStatus(w http.ResponseWriter, r *http.Request)
Install(w http.ResponseWriter, r *http.Request)
ListServices(w http.ResponseWriter, r *http.Request)
ListHelmAppReleases(w http.ResponseWriter, r *http.Request)
DeleteConfigGroup(w http.ResponseWriter, r *http.Request)
ListConfigGroups(w http.ResponseWriter, r *http.Request)

View File

@ -139,9 +139,11 @@ func (v2 *V2) tenantNameRouter() chi.Router {
r.Get("/event", controller.GetManager().Event)
r.Get("/chargesverify", controller.ChargesVerifyController)
//tenant app
r.Get("/pods/{pod_name}", controller.GetManager().PodDetail)
r.Post("/apps", controller.GetManager().CreateApp)
r.Post("/batch_create_apps", controller.GetManager().BatchCreateApp)
r.Get("/apps", controller.GetManager().ListApps)
r.Post("/checkResourceName", controller.GetManager().CheckResourceName)
r.Mount("/apps/{app_id}", v2.applicationRouter())
//get some service pod info
r.Get("/pods", controller.Pods)
@ -314,6 +316,7 @@ func (v2 *V2) applicationRouter() chi.Router {
r.Delete("/", controller.GetManager().DeleteApp)
// Get services under application
r.Get("/services", controller.GetManager().ListServices)
// bind components
r.Put("/services", controller.GetManager().BatchBindService)
// Application configuration group
r.Post("/configgroups", controller.GetManager().AddConfigGroup)
@ -321,6 +324,9 @@ func (v2 *V2) applicationRouter() chi.Router {
r.Put("/ports", controller.GetManager().BatchUpdateComponentPorts)
r.Put("/status", controller.GetManager().GetAppStatus)
// status
r.Post("/install", controller.GetManager().Install)
r.Get("/releases", controller.GetManager().ListHelmAppReleases)
r.Delete("/configgroups/{config_group_name}", controller.GetManager().DeleteConfigGroup)
r.Get("/configgroups", controller.GetManager().ListConfigGroups)

View File

@ -7,9 +7,11 @@ import (
"github.com/go-chi/chi"
"github.com/goodrain/rainbond/api/handler"
"github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/api/util/bcode"
ctxutil "github.com/goodrain/rainbond/api/util/ctx"
dbmodel "github.com/goodrain/rainbond/db/model"
httputil "github.com/goodrain/rainbond/util/http"
"github.com/sirupsen/logrus"
)
// ApplicationController -
@ -21,14 +23,33 @@ func (a *ApplicationController) CreateApp(w http.ResponseWriter, r *http.Request
if !httputil.ValidatorRequestStructAndErrorResponse(r, w, &tenantReq, nil) {
return
}
if tenantReq.AppType == model.AppTypeHelm {
if tenantReq.AppStoreName == "" {
httputil.ReturnBcodeError(r, w, bcode.NewBadRequest("the field 'app_tore_name' is required"))
return
}
if tenantReq.AppTemplateName == "" {
httputil.ReturnBcodeError(r, w, bcode.NewBadRequest("the field 'app_template_name' is required"))
return
}
if tenantReq.AppName == "" {
httputil.ReturnBcodeError(r, w, bcode.NewBadRequest("the field 'helm_app_name' is required"))
return
}
if tenantReq.Version == "" {
httputil.ReturnBcodeError(r, w, bcode.NewBadRequest("the field 'version' is required"))
return
}
}
// get current tenant
tenant := r.Context().Value(ctxutil.ContextKey("tenant")).(*dbmodel.Tenants)
tenantReq.TenantID = tenant.UUID
// create app
app, err := handler.GetApplicationHandler().CreateApp(&tenantReq)
app, err := handler.GetApplicationHandler().CreateApp(r.Context(), &tenantReq)
if err != nil {
logrus.Errorf("create app: %+v", err)
httputil.ReturnBcodeError(r, w, err)
return
}
@ -45,7 +66,7 @@ func (a *ApplicationController) BatchCreateApp(w http.ResponseWriter, r *http.Re
// get current tenant
tenant := r.Context().Value(ctxutil.ContextKey("tenant")).(*dbmodel.Tenants)
respList, err := handler.GetApplicationHandler().BatchCreateApp(&apps, tenant.UUID)
respList, err := handler.GetApplicationHandler().BatchCreateApp(r.Context(), &apps, tenant.UUID)
if err != nil {
httputil.ReturnBcodeError(r, w, err)
return
@ -62,7 +83,7 @@ func (a *ApplicationController) UpdateApp(w http.ResponseWriter, r *http.Request
app := r.Context().Value(ctxutil.ContextKey("application")).(*dbmodel.Application)
// update app
app, err := handler.GetApplicationHandler().UpdateApp(app, updateAppReq)
app, err := handler.GetApplicationHandler().UpdateApp(r.Context(), app, updateAppReq)
if err != nil {
httputil.ReturnBcodeError(r, w, err)
return
@ -100,8 +121,8 @@ func (a *ApplicationController) ListApps(w http.ResponseWriter, r *http.Request)
httputil.ReturnSuccess(r, w, resp)
}
// ListServices -
func (a *ApplicationController) ListServices(w http.ResponseWriter, r *http.Request) {
// ListComponents -
func (a *ApplicationController) ListComponents(w http.ResponseWriter, r *http.Request) {
appID := chi.URLParam(r, "app_id")
query := r.URL.Query()
pageQuery := query.Get("page")
@ -128,10 +149,10 @@ func (a *ApplicationController) ListServices(w http.ResponseWriter, r *http.Requ
// DeleteApp -
func (a *ApplicationController) DeleteApp(w http.ResponseWriter, r *http.Request) {
appID := chi.URLParam(r, "app_id")
app := r.Context().Value(ctxutil.ContextKey("application")).(*dbmodel.Application)
// Delete application
err := handler.GetApplicationHandler().DeleteApp(appID)
err := handler.GetApplicationHandler().DeleteApp(r.Context(), app)
if err != nil {
httputil.ReturnBcodeError(r, w, err)
return
@ -139,6 +160,7 @@ func (a *ApplicationController) DeleteApp(w http.ResponseWriter, r *http.Request
httputil.ReturnSuccess(r, w, nil)
}
// BatchUpdateComponentPorts update component ports in batch.
func (a *ApplicationController) BatchUpdateComponentPorts(w http.ResponseWriter, r *http.Request) {
var appPorts []*model.AppPort
if err := httputil.ReadEntity(r, &appPorts); err != nil {
@ -162,10 +184,11 @@ func (a *ApplicationController) BatchUpdateComponentPorts(w http.ResponseWriter,
httputil.ReturnSuccess(r, w, nil)
}
// GetAppStatus returns the status of the application.
func (a *ApplicationController) GetAppStatus(w http.ResponseWriter, r *http.Request) {
appID := r.Context().Value(ctxutil.ContextKey("app_id")).(string)
app := r.Context().Value(ctxutil.ContextKey("application")).(*dbmodel.Application)
res, err := handler.GetApplicationHandler().GetStatus(appID)
res, err := handler.GetApplicationHandler().GetStatus(r.Context(), app)
if err != nil {
httputil.ReturnBcodeError(r, w, err)
return
@ -174,6 +197,34 @@ func (a *ApplicationController) GetAppStatus(w http.ResponseWriter, r *http.Requ
httputil.ReturnSuccess(r, w, res)
}
// Install installs the application.
func (a *ApplicationController) Install(w http.ResponseWriter, r *http.Request) {
app := r.Context().Value(ctxutil.ContextKey("application")).(*dbmodel.Application)
var installAppReq model.InstallAppReq
if !httputil.ValidatorRequestStructAndErrorResponse(r, w, &installAppReq, nil) {
return
}
if err := handler.GetApplicationHandler().Install(r.Context(), app, installAppReq.Overrides); err != nil {
httputil.ReturnBcodeError(r, w, err)
return
}
}
// ListServices returns the list fo the application.
func (a *ApplicationController) ListServices(w http.ResponseWriter, r *http.Request) {
app := r.Context().Value(ctxutil.ContextKey("application")).(*dbmodel.Application)
services, err := handler.GetApplicationHandler().ListServices(r.Context(), app)
if err != nil {
httputil.ReturnBcodeError(r, w, err)
return
}
httputil.ReturnSuccess(r, w, services)
}
// BatchBindService -
func (a *ApplicationController) BatchBindService(w http.ResponseWriter, r *http.Request) {
appID := chi.URLParam(r, "app_id")
@ -190,3 +241,16 @@ func (a *ApplicationController) BatchBindService(w http.ResponseWriter, r *http.
}
httputil.ReturnSuccess(r, w, nil)
}
// ListHelmAppReleases returns the list of helm releases.
func (a *ApplicationController) ListHelmAppReleases(w http.ResponseWriter, r *http.Request) {
app := r.Context().Value(ctxutil.ContextKey("application")).(*dbmodel.Application)
releases, err := handler.GetApplicationHandler().ListHelmAppReleases(r.Context(), app)
if err != nil {
httputil.ReturnBcodeError(r, w, err)
return
}
httputil.ReturnSuccess(r, w, releases)
}

View File

@ -99,8 +99,8 @@ func PodNums(w http.ResponseWriter, r *http.Request) {
// PodDetail -
func (p *PodController) PodDetail(w http.ResponseWriter, r *http.Request) {
podName := chi.URLParam(r, "pod_name")
serviceID := r.Context().Value(ctxutil.ContextKey("service_id")).(string)
pd, err := handler.GetPodHandler().PodDetail(serviceID, podName)
namespace := r.Context().Value(ctxutil.ContextKey("tenant_id")).(string)
pd, err := handler.GetPodHandler().PodDetail(namespace, podName)
if err != nil {
logrus.Errorf("error getting pod detail: %v", err)
if err == server.ErrPodNotFound {

View File

@ -30,6 +30,7 @@ import (
"github.com/go-chi/chi"
"github.com/goodrain/rainbond/api/handler"
"github.com/goodrain/rainbond/api/model"
api_model "github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/api/util/bcode"
ctxutil "github.com/goodrain/rainbond/api/util/ctx"
@ -550,7 +551,7 @@ func (t *TenantStruct) GetTenants(w http.ResponseWriter, r *http.Request) {
func (t *TenantStruct) DeleteTenant(w http.ResponseWriter, r *http.Request) {
tenantID := r.Context().Value(ctxutil.ContextKey("tenant_id")).(string)
if err := handler.GetTenantManager().DeleteTenant(tenantID); err != nil {
if err := handler.GetTenantManager().DeleteTenant(r.Context(), tenantID); err != nil {
if err == handler.ErrTenantStillHasServices || err == handler.ErrTenantStillHasPlugins {
httputil.ReturnError(r, w, 400, err.Error())
return
@ -665,14 +666,16 @@ func (t *TenantStruct) CreateService(w http.ResponseWriter, r *http.Request) {
handler.GetEtcdHandler().CleanServiceCheckData(ss.EtcdKey)
values := url.Values{}
if ss.Endpoints != nil && strings.TrimSpace(ss.Endpoints.Static) != "" {
if strings.Contains(ss.Endpoints.Static, "127.0.0.1") {
values["ip"] = []string{"The ip field is can't contains '127.0.0.1'"}
if ss.Endpoints != nil {
for _, endpoint := range ss.Endpoints.Static {
if strings.Contains(endpoint, "127.0.0.1") {
values["ip"] = []string{"The ip field is can't contains '127.0.0.1'"}
}
}
if len(values) > 0 {
httputil.ReturnValidationError(r, w, values)
return
}
}
if len(values) > 0 {
httputil.ReturnValidationError(r, w, values)
return
}
tenantID := r.Context().Value(ctxutil.ContextKey("tenant_id")).(string)
@ -680,6 +683,7 @@ func (t *TenantStruct) CreateService(w http.ResponseWriter, r *http.Request) {
if err := handler.GetServiceManager().ServiceCreate(&ss); err != nil {
if strings.Contains(err.Error(), "is exist in tenant") {
httputil.ReturnError(r, w, 400, fmt.Sprintf("create service error, %v", err))
return
}
httputil.ReturnError(r, w, 500, fmt.Sprintf("create service error, %v", err))
return
@ -1005,7 +1009,7 @@ func (t *TenantStruct) DeleteSingleServiceInfo(w http.ResponseWriter, r *http.Re
handler.GetEtcdHandler().CleanAllServiceData(req.Keys)
}
if err := handler.GetServiceManager().TransServieToDelete(tenantID, serviceID); err != nil {
if err := handler.GetServiceManager().TransServieToDelete(r.Context(), tenantID, serviceID); err != nil {
if err == handler.ErrServiceNotClosed {
httputil.ReturnError(r, w, 400, fmt.Sprintf("Service must be closed"))
return
@ -1524,7 +1528,7 @@ func (t *TenantStruct) PortOuterController(w http.ResponseWriter, r *http.Reques
rc["port"] = fmt.Sprintf("%v", vsPort.Port)
}
if err := handler.GetGatewayHandler().SendTask(map[string]interface{}{
if err := handler.GetGatewayHandler().SendTaskDeprecated(map[string]interface{}{
"service_id": serviceID,
"action": "port-" + data.Body.Operation,
"port": containerPort,
@ -1583,7 +1587,7 @@ func (t *TenantStruct) PortInnerController(w http.ResponseWriter, r *http.Reques
}
}
if err := handler.GetGatewayHandler().SendTask(map[string]interface{}{
if err := handler.GetGatewayHandler().SendTaskDeprecated(map[string]interface{}{
"service_id": serviceID,
"action": "port-" + data.Body.Operation,
"port": containerPort,
@ -1928,5 +1932,22 @@ func (t *TenantStruct) TransPlugins(w http.ResponseWriter, r *http.Request) {
}
rc["result"] = "success"
httputil.ReturnSuccess(r, w, rc)
return
}
// CheckResourceName checks the resource name.
func (t *TenantStruct) CheckResourceName(w http.ResponseWriter, r *http.Request) {
var req model.CheckResourceNameReq
if !httputil.ValidatorRequestStructAndErrorResponse(r, w, &req, nil) {
return
}
tenant := r.Context().Value(ctxutil.ContextKey("tenant")).(*dbmodel.Tenants)
res, err := handler.GetTenantManager().CheckResourceName(r.Context(), tenant.UUID, &req)
if err != nil {
httputil.ReturnBcodeError(r, w, err)
return
}
httputil.ReturnSuccess(r, w, res)
}

View File

@ -240,7 +240,7 @@ func (a *AppRestoreAction) RestoreDepVols(tenantID, serviceID string, req *apimo
if err != nil {
// err contains gorm.ErrRecordNotFound
tx.Rollback()
return fmt.Errorf("Dep service id: %s; error getting dep volume: %s", item.DepServiceID, err)
return fmt.Errorf("dep service id: %s; error getting dep volume: %s", item.DepServiceID, err)
}
mr := &model.TenantServiceMountRelation{

View File

@ -87,8 +87,8 @@ func (a *ApplicationAction) AddConfigGroup(appID string, req *model.ApplicationC
if err != nil {
return nil, err
}
var resp *model.ApplicationConfigGroupResp
resp = &model.ApplicationConfigGroupResp{
return &model.ApplicationConfigGroupResp{
CreateTime: appconfig.CreatedAt,
AppID: appID,
ConfigGroupName: appconfig.ConfigGroupName,
@ -96,8 +96,7 @@ func (a *ApplicationAction) AddConfigGroup(appID string, req *model.ApplicationC
ConfigItems: configGroupItems,
Services: configGroupServices,
Enable: appconfig.Enable,
}
return resp, nil
}, nil
}
// UpdateConfigGroup -
@ -180,9 +179,7 @@ func (a *ApplicationAction) UpdateConfigGroup(appID, configGroupName string, req
return nil, err
}
// Build return data
var resp *model.ApplicationConfigGroupResp
resp = &model.ApplicationConfigGroupResp{
return &model.ApplicationConfigGroupResp{
CreateTime: appconfig.CreatedAt,
AppID: appconfig.AppID,
ConfigGroupName: appconfig.ConfigGroupName,
@ -190,8 +187,7 @@ func (a *ApplicationAction) UpdateConfigGroup(appID, configGroupName string, req
ConfigItems: configGroupItems,
Services: configGroupServices,
Enable: appconfig.Enable,
}
return resp, nil
}, nil
}
// DeleteConfigGroup -

View File

@ -282,7 +282,7 @@ func TestListConfigGroups(t *testing.T) {
db.SetTestManager(manager)
tc.mockFunc(manager, ctrl)
appAction := NewApplicationHandler(nil, nil)
appAction := NewApplicationHandler(nil, nil, nil, nil)
resp, err := appAction.ListConfigGroups(tc.appID, 1, 10)
if (err != nil) != tc.wanterr {
t.Errorf("Unexpected error = %v, wantErr %v", err, tc.wanterr)

View File

@ -3,6 +3,7 @@ package handler
import (
"context"
"fmt"
"sort"
"strconv"
"time"
@ -11,34 +12,48 @@ import (
"github.com/goodrain/rainbond/api/util/bcode"
"github.com/goodrain/rainbond/db"
dbmodel "github.com/goodrain/rainbond/db/model"
"github.com/goodrain/rainbond/util"
"github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
"github.com/goodrain/rainbond/pkg/generated/clientset/versioned"
util "github.com/goodrain/rainbond/util"
"github.com/goodrain/rainbond/util/commonutil"
"github.com/goodrain/rainbond/util/constants"
"github.com/goodrain/rainbond/worker/client"
"github.com/goodrain/rainbond/worker/server/pb"
"github.com/jinzhu/gorm"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clientset "k8s.io/client-go/kubernetes"
)
// ApplicationAction -
type ApplicationAction struct {
statusCli *client.AppRuntimeSyncClient
promClient prometheus.Interface
statusCli *client.AppRuntimeSyncClient
promClient prometheus.Interface
rainbondClient versioned.Interface
kubeClient clientset.Interface
}
// ApplicationHandler defines handler methods to TenantApplication.
type ApplicationHandler interface {
CreateApp(req *model.Application) (*model.Application, error)
BatchCreateApp(req *model.CreateAppRequest, tenantID string) ([]model.CreateAppResponse, error)
UpdateApp(srcApp *dbmodel.Application, req model.UpdateAppRequest) (*dbmodel.Application, error)
CreateApp(ctx context.Context, req *model.Application) (*model.Application, error)
BatchCreateApp(ctx context.Context, req *model.CreateAppRequest, tenantID string) ([]model.CreateAppResponse, error)
UpdateApp(ctx context.Context, app *dbmodel.Application, req model.UpdateAppRequest) (*dbmodel.Application, error)
ListApps(tenantID, appName string, page, pageSize int) (*model.ListAppResponse, error)
GetAppByID(appID string) (*dbmodel.Application, error)
BatchBindService(appID string, req model.BindServiceRequest) error
DeleteApp(appID string) error
DeleteApp(ctx context.Context, app *dbmodel.Application) error
AddConfigGroup(appID string, req *model.ApplicationConfigGroup) (*model.ApplicationConfigGroupResp, error)
UpdateConfigGroup(appID, configGroupName string, req *model.UpdateAppConfigGroupReq) (*model.ApplicationConfigGroupResp, error)
BatchUpdateComponentPorts(appID string, ports []*model.AppPort) error
GetStatus(appID string) (*model.AppStatus, error)
GetStatus(ctx context.Context, app *dbmodel.Application) (*model.AppStatus, error)
Install(ctx context.Context, app *dbmodel.Application, overrides []string) error
ListServices(ctx context.Context, app *dbmodel.Application) ([]*model.AppService, error)
ListHelmAppReleases(ctx context.Context, app *dbmodel.Application) ([]*model.HelmAppRelease, error)
DeleteConfigGroup(appID, configGroupName string) error
ListConfigGroups(appID string, page, pageSize int) (*model.ListApplicationConfigGroupResp, error)
@ -48,57 +63,103 @@ type ApplicationHandler interface {
}
// NewApplicationHandler creates a new Tenant Application Handler.
func NewApplicationHandler(statusCli *client.AppRuntimeSyncClient, promClient prometheus.Interface) ApplicationHandler {
func NewApplicationHandler(statusCli *client.AppRuntimeSyncClient, promClient prometheus.Interface, rainbondClient versioned.Interface, kubeClient clientset.Interface) ApplicationHandler {
return &ApplicationAction{
statusCli: statusCli,
promClient: promClient,
statusCli: statusCli,
promClient: promClient,
rainbondClient: rainbondClient,
kubeClient: kubeClient,
}
}
// CreateApp -
func (a *ApplicationAction) CreateApp(req *model.Application) (*model.Application, error) {
func (a *ApplicationAction) CreateApp(ctx context.Context, req *model.Application) (*model.Application, error) {
appReq := &dbmodel.Application{
AppName: req.AppName,
AppID: util.NewUUID(),
TenantID: req.TenantID,
EID: req.EID,
TenantID: req.TenantID,
AppID: util.NewUUID(),
AppName: req.AppName,
AppType: req.AppType,
AppStoreName: req.AppStoreName,
AppStoreURL: req.AppStoreURL,
AppTemplateName: req.AppTemplateName,
Version: req.Version,
}
req.AppID = appReq.AppID
tx := db.GetManager().Begin()
defer func() {
if r := recover(); r != nil {
logrus.Errorf("Unexpected panic occurred, rollback transaction: %v", r)
tx.Rollback()
err := db.GetManager().DB().Transaction(func(tx *gorm.DB) error {
if err := db.GetManager().ApplicationDaoTransactions(tx).AddModel(appReq); err != nil {
return err
}
if len(req.ServiceIDs) != 0 {
if err := db.GetManager().TenantServiceDaoTransactions(tx).BindAppByServiceIDs(appReq.AppID, req.ServiceIDs); err != nil {
return err
}
}
}()
if err := db.GetManager().ApplicationDao().AddModel(appReq); err != nil {
tx.Rollback()
return nil, err
}
if len(req.ServiceIDs) != 0 {
if err := db.GetManager().TenantServiceDao().BindAppByServiceIDs(appReq.AppID, req.ServiceIDs); err != nil {
tx.Rollback()
return nil, err
if appReq.AppType == model.AppTypeHelm {
// create helmapp.rainbond.io
return a.createHelmApp(ctx, appReq)
}
return nil
})
return req, err
}
func (a *ApplicationAction) createHelmApp(ctx context.Context, app *dbmodel.Application) error {
labels := map[string]string{
constants.ResourceManagedByLabel: constants.Rainbond,
}
helmApp := &v1alpha1.HelmApp{
ObjectMeta: metav1.ObjectMeta{
Name: app.AppName,
Namespace: app.TenantID,
Labels: labels,
},
Spec: v1alpha1.HelmAppSpec{
EID: app.EID,
TemplateName: app.AppTemplateName,
Version: app.Version,
AppStore: &v1alpha1.HelmAppStore{
Name: app.AppStoreName,
URL: app.AppStoreURL,
},
}}
ctx1, cancel := context.WithTimeout(ctx, 3*time.Second)
defer cancel()
_, err := a.kubeClient.CoreV1().Namespaces().Create(ctx1, &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: app.TenantID,
Labels: labels,
},
}, metav1.CreateOptions{})
if err != nil && !k8sErrors.IsAlreadyExists(err) {
return errors.Wrap(err, "create namespace for helm app")
}
if err := tx.Commit().Error; err != nil {
tx.Rollback()
return nil, err
ctx2, cancel := context.WithTimeout(ctx, 3*time.Second)
defer cancel()
_, err = a.rainbondClient.RainbondV1alpha1().HelmApps(helmApp.Namespace).Create(ctx2, helmApp, metav1.CreateOptions{})
if err != nil {
if k8sErrors.IsAlreadyExists(err) {
return errors.Wrap(bcode.ErrApplicationExist, "create helm app")
}
return errors.Wrap(err, "create helm app")
}
return req, nil
return nil
}
// BatchCreateApp -
func (a *ApplicationAction) BatchCreateApp(apps *model.CreateAppRequest, tenantID string) ([]model.CreateAppResponse, error) {
func (a *ApplicationAction) BatchCreateApp(ctx context.Context, apps *model.CreateAppRequest, tenantID string) ([]model.CreateAppResponse, error) {
var (
resp model.CreateAppResponse
respList []model.CreateAppResponse
)
for _, app := range apps.AppsInfo {
app.TenantID = tenantID
regionApp, err := GetApplicationHandler().CreateApp(&app)
regionApp, err := GetApplicationHandler().CreateApp(ctx, &app)
if err != nil {
logrus.Errorf("Batch Create App [%v] error is [%v] ", app.AppName, err)
continue
@ -111,20 +172,53 @@ func (a *ApplicationAction) BatchCreateApp(apps *model.CreateAppRequest, tenantI
}
// UpdateApp -
func (a *ApplicationAction) UpdateApp(srcApp *dbmodel.Application, req model.UpdateAppRequest) (*dbmodel.Application, error) {
func (a *ApplicationAction) UpdateApp(ctx context.Context, app *dbmodel.Application, req model.UpdateAppRequest) (*dbmodel.Application, error) {
if req.AppName != "" {
srcApp.AppName = req.AppName
app.AppName = req.AppName
}
if req.GovernanceMode != "" {
if !dbmodel.IsGovernanceModeValid(req.GovernanceMode) {
return nil, bcode.NewBadRequest(fmt.Sprintf("governance mode '%s' is valid", req.GovernanceMode))
}
srcApp.GovernanceMode = req.GovernanceMode
app.GovernanceMode = req.GovernanceMode
}
if err := db.GetManager().ApplicationDao().UpdateModel(srcApp); err != nil {
return nil, err
err := db.GetManager().DB().Transaction(func(tx *gorm.DB) error {
if err := db.GetManager().ApplicationDao().UpdateModel(app); err != nil {
return err
}
if req.NeedUpdateHelmApp() {
if err := a.updateHelmApp(ctx, app, req); err != nil {
return err
}
}
return nil
})
return app, err
}
func (a *ApplicationAction) updateHelmApp(ctx context.Context, app *dbmodel.Application, req model.UpdateAppRequest) error {
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
helmApp, err := a.rainbondClient.RainbondV1alpha1().HelmApps(app.TenantID).Get(ctx, app.AppName, metav1.GetOptions{})
if err != nil {
if k8sErrors.IsNotFound(err) {
return errors.Wrap(bcode.ErrApplicationNotFound, "update app")
}
return errors.Wrap(err, "update app")
}
return srcApp, nil
helmApp.Spec.Overrides = req.Overrides
if req.Version != "" {
helmApp.Spec.Version = req.Version
}
if req.Revision != 0 {
helmApp.Spec.Revision = req.Revision
}
_, err = a.rainbondClient.RainbondV1alpha1().HelmApps(app.TenantID).Update(ctx, helmApp, metav1.UpdateOptions{})
return err
}
// ListApps -
@ -156,8 +250,27 @@ func (a *ApplicationAction) GetAppByID(appID string) (*dbmodel.Application, erro
}
// DeleteApp -
func (a *ApplicationAction) DeleteApp(appID string) error {
// Get the number of services under the application
func (a *ApplicationAction) DeleteApp(ctx context.Context, app *dbmodel.Application) error {
if app.AppType == dbmodel.AppTypeHelm {
return a.deleteHelmApp(ctx, app)
}
return a.deleteRainbondApp(app)
}
func (a *ApplicationAction) deleteRainbondApp(app *dbmodel.Application) error {
// can't delete rainbond app with components
if err := a.isContainComponents(app.AppID); err != nil {
return err
}
return db.GetManager().DB().Transaction(func(tx *gorm.DB) error {
return errors.WithMessage(a.deleteApp(tx, app), "delete app from db")
})
}
// isContainComponents checks if the app contains components.
func (a *ApplicationAction) isContainComponents(appID string) error {
total, err := db.GetManager().TenantServiceDao().CountServiceByAppID(appID)
if err != nil {
return err
@ -165,7 +278,45 @@ func (a *ApplicationAction) DeleteApp(appID string) error {
if total != 0 {
return bcode.ErrDeleteDueToBindService
}
return db.GetManager().ApplicationDao().DeleteApp(appID)
return nil
}
func (a *ApplicationAction) deleteHelmApp(ctx context.Context, app *dbmodel.Application) error {
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
return db.GetManager().DB().Transaction(func(tx *gorm.DB) error {
if err := a.deleteApp(tx, app); err != nil {
return err
}
if err := a.rainbondClient.RainbondV1alpha1().HelmApps(app.TenantID).Delete(ctx, app.AppName, metav1.DeleteOptions{}); err != nil {
if !k8sErrors.IsNotFound(err) {
return err
}
}
return nil
})
}
func (a *ApplicationAction) deleteApp(tx *gorm.DB, app *dbmodel.Application) error {
// delete app config group service
if err := db.GetManager().AppConfigGroupServiceDaoTransactions(tx).DeleteByAppID(app.AppID); err != nil {
return err
}
// delete config group items
if err := db.GetManager().AppConfigGroupItemDaoTransactions(tx).DeleteByAppID(app.AppID); err != nil {
return err
}
// delete config group
if err := db.GetManager().AppConfigGroupDaoTransactions(tx).DeleteByAppID(app.AppID); err != nil {
return err
}
// delete application
return db.GetManager().ApplicationDaoTransactions(tx).DeleteApp(app.AppID)
}
// BatchUpdateComponentPorts -
@ -244,26 +395,113 @@ func (a *ApplicationAction) checkPorts(appID string, ports []*model.AppPort) err
}
// GetStatus -
func (a *ApplicationAction) GetStatus(appID string) (*model.AppStatus, error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
func (a *ApplicationAction) GetStatus(ctx context.Context, app *dbmodel.Application) (*model.AppStatus, error) {
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
status, err := a.statusCli.GetAppStatus(ctx, &pb.AppStatusReq{
AppId: appID,
AppId: app.AppID,
})
if err != nil {
return nil, errors.Wrap(err, "get app status")
}
var conditions []*model.AppStatusCondition
for _, cdt := range status.Conditions {
conditions = append(conditions, &model.AppStatusCondition{
Type: cdt.Type,
Status: cdt.Status,
Reason: cdt.Reason,
Message: cdt.Message,
})
}
diskUsage := a.getDiskUsage(app.AppID)
var cpu *int64
if status.SetCPU {
cpu = commonutil.Int64(status.Cpu)
}
var memory *int64
if status.SetMemory {
memory = commonutil.Int64(status.Memory)
}
res := &model.AppStatus{
Status: status.Status,
CPU: cpu,
Memory: memory,
Disk: int64(diskUsage),
Phase: status.Phase,
Overrides: status.Overrides,
Version: status.Version,
Conditions: conditions,
}
return res, nil
}
// Install installs the application.
func (a *ApplicationAction) Install(ctx context.Context, app *dbmodel.Application, overrides []string) error {
ctx1, cancel := context.WithTimeout(ctx, 3*time.Second)
defer cancel()
helmApp, err := a.rainbondClient.RainbondV1alpha1().HelmApps(app.TenantID).Get(ctx1, app.AppName, metav1.GetOptions{})
if err != nil {
if k8sErrors.IsNotFound(err) {
return errors.Wrap(bcode.ErrApplicationNotFound, "install app")
}
return errors.Wrap(err, "install app")
}
ctx3, cancel := context.WithTimeout(ctx, 3*time.Second)
defer cancel()
helmApp.Spec.Overrides = overrides
helmApp.Spec.PreStatus = v1alpha1.HelmAppPreStatusConfigured
_, err = a.rainbondClient.RainbondV1alpha1().HelmApps(app.TenantID).Update(ctx3, helmApp, metav1.UpdateOptions{})
if err != nil {
return err
}
return errors.Wrap(err, "install app")
}
// ListServices returns the list of the application.
func (a *ApplicationAction) ListServices(ctx context.Context, app *dbmodel.Application) ([]*model.AppService, error) {
nctx, cancel := context.WithTimeout(ctx, 3*time.Second)
defer cancel()
appServices, err := a.statusCli.ListAppServices(nctx, &pb.AppReq{AppId: app.AppID})
if err != nil {
return nil, err
}
diskUsage := a.getDiskUsage(appID)
var services []*model.AppService
for _, service := range appServices.Services {
svc := &model.AppService{
ServiceName: service.Name,
Address: service.Address,
}
res := &model.AppStatus{
Status: status.Status.String(),
Cpu: status.Cpu,
Memory: status.Memory,
Disk: int64(diskUsage),
svc.Pods = a.convertPods(service.Pods)
svc.OldPods = a.convertPods(service.OldPods)
svc.Ports = append(svc.Ports, service.Ports...)
services = append(services, svc)
}
return res, nil
sort.Sort(model.ByServiceName(services))
return services, nil
}
func (a *ApplicationAction) convertPods(pods []*pb.AppService_Pod) []*model.AppPod {
var res []*model.AppPod
for _, pod := range pods {
res = append(res, &model.AppPod{
PodName: pod.Name,
PodStatus: pod.Status,
})
}
sort.Sort(model.ByPodName(res))
return res
}
func (a *ApplicationAction) getDiskUsage(appID string) float64 {
@ -291,6 +529,37 @@ func (a *ApplicationAction) BatchBindService(appID string, req model.BindService
return db.GetManager().TenantServiceDao().BindAppByServiceIDs(appID, serviceIDs)
}
// ListHelmAppReleases returns the list of the helm app.
func (a *ApplicationAction) ListHelmAppReleases(ctx context.Context, app *dbmodel.Application) ([]*model.HelmAppRelease, error) {
// only for helm app
if app.AppType != model.AppTypeHelm {
return nil, nil
}
nctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
releases, err := a.statusCli.ListHelmAppRelease(nctx, &pb.AppReq{
AppId: app.AppID,
})
if err != nil {
return nil, err
}
var result []*model.HelmAppRelease
for _, rel := range releases.HelmAppRelease {
result = append(result, &model.HelmAppRelease{
Revision: int(rel.Revision),
Updated: rel.Updated,
Status: rel.Status,
Chart: rel.Chart,
AppVersion: rel.AppVersion,
Description: rel.Description,
})
}
return result, nil
}
// SyncComponents -
func (a *ApplicationAction) SyncComponents(app *dbmodel.Application, components []*model.Component, deleteComponentIDs []string) error {
return db.GetManager().DB().Transaction(func(tx *gorm.DB) error {
@ -339,6 +608,9 @@ func (a *ApplicationAction) SyncComponents(app *dbmodel.Application, components
if err := GetServiceManager().SyncComponentScaleRules(tx, components); err != nil {
return err
}
if err := GetServiceManager().SyncComponentEndpoints(tx, components); err != nil {
return err
}
if len(deleteComponentIDs) != 0 {
return a.deleteByComponentIDs(tx, app, deleteComponentIDs)
}
@ -398,6 +670,9 @@ func (a *ApplicationAction) deleteByComponentIDs(tx *gorm.DB, app *dbmodel.Appli
if err := db.GetManager().TenantServiceLabelDaoTransactions(tx).DeleteByComponentIDs(componentIDs); err != nil {
return err
}
if err := db.GetManager().ThirdPartySvcDiscoveryCfgDaoTransactions(tx).DeleteByComponentIDs(componentIDs); err != nil {
return err
}
autoScaleRules, err := db.GetManager().TenantServceAutoscalerRulesDaoTransactions(tx).ListByComponentIDs(componentIDs)
if err != nil {
return err

View File

@ -159,7 +159,7 @@ func (c *CloudAction) CertDispatcher(gt *api_model.GetUserToken) ([]byte, []byte
SerialNumber: big.NewInt(1), //证书序列号
Subject: pkix.Name{
CommonName: fmt.Sprintf("%s@%d", gt.Body.EID, time.Now().Unix()),
Locality: []string{fmt.Sprintf("%s", c.RegionTag)},
Locality: []string{c.RegionTag},
},
NotBefore: time.Now(), //证书有效期开始时间
NotAfter: time.Now().Add(time.Second * time.Duration(validHourTime)), //证书有效期结束时间

View File

@ -29,6 +29,7 @@ func NewEtcdHandler(etcdCli *clientv3.Client) *EtcdHandler {
return &EtcdHandler{etcdCli}
}
// CleanAllServiceData -
func (h *EtcdHandler) CleanAllServiceData(keys []string) {
for _, key := range keys {
h.cleanEtcdByKey(key, ServiceCheckEtcdKey, ShareResultEtcdKey, BackupRestoreEtcdKey)

View File

@ -20,7 +20,6 @@ package handler
import (
"context"
"errors"
"fmt"
"os"
"sort"
@ -36,6 +35,7 @@ import (
"github.com/goodrain/rainbond/mq/client"
"github.com/goodrain/rainbond/util"
"github.com/jinzhu/gorm"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@ -57,21 +57,23 @@ func CreateGatewayManager(dbmanager db.Manager, mqclient client.MQClient, etcdCl
// AddHTTPRule adds http rule to db if it doesn't exists.
func (g *GatewayAction) AddHTTPRule(req *apimodel.AddHTTPRuleStruct) error {
if err := db.GetManager().DB().Transaction(func(tx *gorm.DB) error {
return g.CreateHTTPRule(tx, req)
}); err != nil {
return err
}
return db.GetManager().DB().Transaction(func(tx *gorm.DB) error {
if err := g.CreateHTTPRule(tx, req); err != nil {
return err
}
// Effective immediately
if err := g.SendTask(map[string]interface{}{
"service_id": req.ServiceID,
"action": "add-http-rule",
"limit": map[string]string{"domain": req.Domain},
}); err != nil {
logrus.Errorf("send runtime message about gateway failure %s", err.Error())
}
return nil
// Effective immediately
err := g.SendTaskDeprecated(map[string]interface{}{
"service_id": req.ServiceID,
"action": "add-http-rule",
"limit": map[string]string{"domain": req.Domain},
})
if err != nil {
return fmt.Errorf("send http rule task: %v", err)
}
return nil
})
}
// CreateHTTPRule Create http rules through transactions
@ -120,6 +122,7 @@ func (g *GatewayAction) CreateHTTPRule(tx *gorm.DB, req *apimodel.AddHTTPRuleStr
return fmt.Errorf("create rule extensions: %v", err)
}
}
return nil
}
@ -208,7 +211,7 @@ func (g *GatewayAction) UpdateHTTPRule(req *apimodel.UpdateHTTPRuleStruct) error
return err
}
if err := g.SendTask(map[string]interface{}{
if err := g.SendTaskDeprecated(map[string]interface{}{
"service_id": rule.ServiceID,
"action": "update-http-rule",
"limit": map[string]string{"domain": req.Domain},
@ -218,14 +221,6 @@ func (g *GatewayAction) UpdateHTTPRule(req *apimodel.UpdateHTTPRuleStruct) error
return nil
}
func (g *GatewayAction) isCertificateBeingUsed(certID string) (bool, error) {
rules, err := g.dbmanager.HTTPRuleDao().GetHTTPRulesByCertificateID(certID)
if err != nil {
return false, fmt.Errorf("list rules by certificate id: %v", err)
}
return len(rules) > 0, nil
}
// DeleteHTTPRule deletes http rule, including certificate and rule extensions
func (g *GatewayAction) DeleteHTTPRule(req *apimodel.DeleteHTTPRuleStruct) error {
// begin transaction
@ -258,7 +253,7 @@ func (g *GatewayAction) DeleteHTTPRule(req *apimodel.DeleteHTTPRuleStruct) error
return err
}
if err := g.SendTask(map[string]interface{}{
if err := g.SendTaskDeprecated(map[string]interface{}{
"service_id": svcID,
"action": "delete-http-rule",
"limit": map[string]string{"domain": httpRule.Domain},
@ -312,7 +307,7 @@ func (g *GatewayAction) UpdateCertificate(req apimodel.AddHTTPRuleStruct, httpRu
return err
}
if cert == nil {
return fmt.Errorf("Certificate doesn't exist based on certificateID(%s)", req.CertificateID)
return fmt.Errorf("certificate doesn't exist based on certificateID(%s)", req.CertificateID)
}
cert.CertificateName = fmt.Sprintf("cert-%s", util.NewUUID()[0:8])
@ -323,19 +318,22 @@ func (g *GatewayAction) UpdateCertificate(req apimodel.AddHTTPRuleStruct, httpRu
// AddTCPRule adds tcp rule.
func (g *GatewayAction) AddTCPRule(req *apimodel.AddTCPRuleStruct) error {
if err := g.dbmanager.DB().Transaction(func(tx *gorm.DB) error {
return g.CreateTCPRule(tx, req)
}); err != nil {
return err
}
if err := g.SendTask(map[string]interface{}{
"service_id": req.ServiceID,
"action": "add-tcp-rule",
"limit": map[string]string{"tcp-address": fmt.Sprintf("%s:%d", req.IP, req.Port)},
}); err != nil {
logrus.Errorf("send runtime message about gateway failure %s", err.Error())
}
return nil
return g.dbmanager.DB().Transaction(func(tx *gorm.DB) error {
if err := g.CreateTCPRule(tx, req); err != nil {
return err
}
err := g.SendTaskDeprecated(map[string]interface{}{
"service_id": req.ServiceID,
"action": "add-tcp-rule",
"limit": map[string]string{"tcp-address": fmt.Sprintf("%s:%d", req.IP, req.Port)},
})
if err != nil {
return fmt.Errorf("send tcp rule task: %v", err)
}
return nil
})
}
// CreateTCPRule Create tcp rules through transactions
@ -362,6 +360,7 @@ func (g *GatewayAction) CreateTCPRule(tx *gorm.DB, req *apimodel.AddTCPRuleStruc
return err
}
}
return nil
}
@ -424,7 +423,7 @@ func (g *GatewayAction) UpdateTCPRule(req *apimodel.UpdateTCPRuleStruct, minPort
logrus.Debugf("TCP rule id: %s;error end transaction %v", tcpRule.UUID, err)
return err
}
if err := g.SendTask(map[string]interface{}{
if err := g.SendTaskDeprecated(map[string]interface{}{
"service_id": tcpRule.ServiceID,
"action": "update-tcp-rule",
"limit": map[string]string{"tcp-address": fmt.Sprintf("%s:%d", tcpRule.IP, tcpRule.Port)},
@ -472,7 +471,7 @@ func (g *GatewayAction) DeleteTCPRule(req *apimodel.DeleteTCPRuleStruct) error {
return err
}
if err := g.SendTask(map[string]interface{}{
if err := g.SendTaskDeprecated(map[string]interface{}{
"service_id": tcpRule.ServiceID,
"action": "delete-tcp-rule",
"limit": map[string]string{"tcp-address": fmt.Sprintf("%s:%d", tcpRule.IP, tcpRule.Port)},
@ -612,12 +611,12 @@ func (g *GatewayAction) TCPIPPortExists(host string, port int) bool {
return false
}
// SendTask sends apply rules task
func (g *GatewayAction) SendTask(in map[string]interface{}) error {
// SendTaskDeprecated sends apply rules task
func (g *GatewayAction) SendTaskDeprecated(in map[string]interface{}) error {
sid := in["service_id"].(string)
service, err := db.GetManager().TenantServiceDao().GetServiceByID(sid)
if err != nil {
return fmt.Errorf("Unexpected error occurred while getting Service by ServiceID(%s): %v", sid, err)
return fmt.Errorf("unexpected error occurred while getting Service by ServiceID(%s): %v", sid, err)
}
body := make(map[string]interface{})
body["deploy_version"] = service.DeployVersion
@ -630,7 +629,20 @@ func (g *GatewayAction) SendTask(in map[string]interface{}) error {
TaskBody: body,
})
if err != nil {
return fmt.Errorf("Unexpected error occurred while sending task: %v", err)
return fmt.Errorf("unexpected error occurred while sending task: %v", err)
}
return nil
}
// SendTask sends apply rules task
func (g *GatewayAction) SendTask(task *ComponentIngressTask) error {
err := g.mqclient.SendBuilderTopic(client.TaskStruct{
Topic: client.WorkerTopic,
TaskType: "apply_rule",
TaskBody: task,
})
if err != nil {
return errors.WithMessage(err, "send gateway task")
}
return nil
}
@ -720,7 +732,7 @@ func (g *GatewayAction) RuleConfig(req *apimodel.RuleConfigReq) error {
return err
}
if err := g.SendTask(map[string]interface{}{
if err := g.SendTaskDeprecated(map[string]interface{}{
"service_id": req.ServiceID,
"action": "update-rule-config",
"event_id": req.EventID,
@ -771,7 +783,7 @@ func (g *GatewayAction) UpdCertificate(req *apimodel.UpdCertificateReq) error {
for _, rule := range rules {
eventID := util.NewUUID()
if err := g.SendTask(map[string]interface{}{
if err := g.SendTaskDeprecated(map[string]interface{}{
"service_id": rule.ServiceID,
"action": "update-rule-config",
"event_id": eventID,

View File

@ -24,6 +24,14 @@ import (
"github.com/jinzhu/gorm"
)
// ComponentIngressTask -
type ComponentIngressTask struct {
ComponentID string `json:"service_id"`
Action string `json:"action"`
Port int `json:"port"`
IsInner bool `json:"is_inner"`
}
//GatewayHandler gateway api handler
type GatewayHandler interface {
AddHTTPRule(req *apimodel.AddHTTPRuleStruct) error
@ -43,7 +51,9 @@ type GatewayHandler interface {
AddRuleExtensions(ruleID string, ruleExtensions []*apimodel.RuleExtensionStruct, tx *gorm.DB) error
GetAvailablePort(ip string, lock bool) (int, error)
TCPIPPortExists(ip string, port int) bool
SendTask(in map[string]interface{}) error
// Deprecated.
SendTaskDeprecated(in map[string]interface{}) error
SendTask(task *ComponentIngressTask) error
RuleConfig(req *apimodel.RuleConfigReq) error
UpdCertificate(req *apimodel.UpdCertificateReq) error
GetGatewayIPs() []IPAndAvailablePort

View File

@ -26,10 +26,12 @@ import (
"github.com/goodrain/rainbond/api/handler/share"
"github.com/goodrain/rainbond/cmd/api/option"
"github.com/goodrain/rainbond/db"
"github.com/goodrain/rainbond/pkg/generated/clientset/versioned"
etcdutil "github.com/goodrain/rainbond/util/etcd"
"github.com/goodrain/rainbond/worker/client"
"github.com/sirupsen/logrus"
"k8s.io/client-go/kubernetes"
k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
)
//InitHandle 初始化handle
@ -38,6 +40,8 @@ func InitHandle(conf option.Config,
statusCli *client.AppRuntimeSyncClient,
etcdcli *clientv3.Client,
kubeClient *kubernetes.Clientset,
rainbondClient versioned.Interface,
k8sClient k8sclient.Client,
) error {
mq := api_db.MQManager{
EtcdClientArgs: etcdClientArgs,
@ -56,10 +60,10 @@ func InitHandle(conf option.Config,
return err
}
dbmanager := db.GetManager()
defaultServieHandler = CreateManager(conf, mqClient, etcdcli, statusCli, prometheusCli)
defaultServieHandler = CreateManager(conf, mqClient, etcdcli, statusCli, prometheusCli, rainbondClient)
defaultPluginHandler = CreatePluginManager(mqClient)
defaultAppHandler = CreateAppManager(mqClient)
defaultTenantHandler = CreateTenManager(mqClient, statusCli, &conf, kubeClient, prometheusCli)
defaultTenantHandler = CreateTenManager(mqClient, statusCli, &conf, kubeClient, prometheusCli, k8sClient)
defaultNetRulesHandler = CreateNetRulesManager(etcdcli)
defaultCloudHandler = CreateCloudManager(conf)
defaultAPPBackupHandler = group.CreateBackupHandle(mqClient, statusCli, etcdcli)
@ -80,8 +84,8 @@ func InitHandle(conf option.Config,
defaultVolumeTypeHandler = CreateVolumeTypeManger(statusCli)
defaultEtcdHandler = NewEtcdHandler(etcdcli)
defaultmonitorHandler = NewMonitorHandler(prometheusCli)
defApplicationHandler = NewApplicationHandler(statusCli, prometheusCli)
defServiceEventHandler = NewServiceEventHandler()
defApplicationHandler = NewApplicationHandler(statusCli, prometheusCli, rainbondClient, kubeClient)
return nil
}

View File

@ -14,8 +14,8 @@ type PodAction struct {
}
// PodDetail -
func (p *PodAction) PodDetail(serviceID, podName string) (*pb.PodDetail, error) {
pd, err := p.statusCli.GetPodDetail(serviceID, podName)
func (p *PodAction) PodDetail(namespace, podName string) (*pb.PodDetail, error) {
pd, err := p.statusCli.GetPodDetail(namespace, podName)
if err != nil {
if strings.Contains(err.Error(), server.ErrPodNotFound.Error()) {
return nil, server.ErrPodNotFound

View File

@ -7,7 +7,7 @@ import (
// PodHandler defines handler methods about k8s pods.
type PodHandler interface {
PodDetail(serviceID, podName string) (*pb.PodDetail, error)
PodDetail(namespace, podName string) (*pb.PodDetail, error)
}
// NewPodHandler creates a new PodHandler.

View File

@ -36,6 +36,7 @@ import (
"github.com/goodrain/rainbond/cmd/api/option"
"github.com/goodrain/rainbond/db"
"github.com/goodrain/rainbond/event"
"github.com/goodrain/rainbond/pkg/generated/clientset/versioned"
"github.com/goodrain/rainbond/worker/client"
"github.com/goodrain/rainbond/worker/discover/model"
"github.com/goodrain/rainbond/worker/server"
@ -45,6 +46,8 @@ import (
"github.com/pquerna/ffjson/ffjson"
"github.com/sirupsen/logrus"
"github.com/twinj/uuid"
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
api_model "github.com/goodrain/rainbond/api/model"
dberr "github.com/goodrain/rainbond/db/errors"
@ -61,11 +64,12 @@ var ErrServiceNotClosed = errors.New("Service has not been closed")
//ServiceAction service act
type ServiceAction struct {
MQClient gclient.MQClient
EtcdCli *clientv3.Client
statusCli *client.AppRuntimeSyncClient
prometheusCli prometheus.Interface
conf option.Config
MQClient gclient.MQClient
EtcdCli *clientv3.Client
statusCli *client.AppRuntimeSyncClient
prometheusCli prometheus.Interface
conf option.Config
rainbondClient versioned.Interface
}
type dCfg struct {
@ -77,14 +81,19 @@ type dCfg struct {
}
//CreateManager create Manger
func CreateManager(conf option.Config, mqClient gclient.MQClient,
etcdCli *clientv3.Client, statusCli *client.AppRuntimeSyncClient, prometheusCli prometheus.Interface) *ServiceAction {
func CreateManager(conf option.Config,
mqClient gclient.MQClient,
etcdCli *clientv3.Client,
statusCli *client.AppRuntimeSyncClient,
prometheusCli prometheus.Interface,
rainbondClient versioned.Interface) *ServiceAction {
return &ServiceAction{
MQClient: mqClient,
EtcdCli: etcdCli,
statusCli: statusCli,
conf: conf,
prometheusCli: prometheusCli,
MQClient: mqClient,
EtcdCli: etcdCli,
statusCli: statusCli,
conf: conf,
prometheusCli: prometheusCli,
rainbondClient: rainbondClient,
}
}
@ -719,20 +728,12 @@ func (s *ServiceAction) ServiceCreate(sc *api_model.ServiceStruct) error {
tx.Rollback()
return fmt.Errorf("endpoints can not be empty for third-party service")
}
if config := strings.Replace(sc.Endpoints.Discovery, " ", "", -1); config != "" {
var cfg dCfg
err := json.Unmarshal([]byte(config), &cfg)
if err != nil {
tx.Rollback()
return err
}
if sc.Endpoints.Kubernetes != nil {
c := &dbmodel.ThirdPartySvcDiscoveryCfg{
ServiceID: sc.ServiceID,
Type: cfg.Type,
Servers: strings.Join(cfg.Servers, ","),
Key: cfg.Key,
Username: cfg.Username,
Password: cfg.Password,
ServiceID: sc.ServiceID,
Type: string(dbmodel.DiscorveryTypeKubernetes),
Namespace: sc.Endpoints.Kubernetes.Namespace,
ServiceName: sc.Endpoints.Kubernetes.ServiceName,
}
if err := db.GetManager().ThirdPartySvcDiscoveryCfgDaoTransactions(tx).
AddModel(c); err != nil {
@ -740,15 +741,10 @@ func (s *ServiceAction) ServiceCreate(sc *api_model.ServiceStruct) error {
tx.Rollback()
return err
}
} else if static := strings.Replace(sc.Endpoints.Static, " ", "", -1); static != "" {
var obj []string
err := json.Unmarshal([]byte(static), &obj)
if err != nil {
tx.Rollback()
return err
}
}
if sc.Endpoints.Static != nil {
trueValue := true
for _, o := range obj {
for _, o := range sc.Endpoints.Static {
ep := &dbmodel.Endpoint{
ServiceID: sc.ServiceID,
UUID: core_util.NewUUID(),
@ -852,6 +848,7 @@ func (s *ServiceAction) ServiceCreate(sc *api_model.ServiceStruct) error {
return err
}
logrus.Debugf("create a new app %s success", ts.ServiceAlias)
return nil
}
@ -2168,7 +2165,7 @@ func (s *ServiceAction) GetPodContainerMemory(podNames []string) (map[string]map
}
//TransServieToDelete trans service info to delete table
func (s *ServiceAction) TransServieToDelete(tenantID, serviceID string) error {
func (s *ServiceAction) TransServieToDelete(ctx context.Context, tenantID, serviceID string) error {
_, err := db.GetManager().TenantServiceDao().GetServiceByID(serviceID)
if err != nil && gorm.ErrRecordNotFound == err {
logrus.Infof("service[%s] of tenant[%s] do not exist, ignore it", serviceID, tenantID)
@ -2183,7 +2180,7 @@ func (s *ServiceAction) TransServieToDelete(tenantID, serviceID string) error {
return fmt.Errorf("GC task body: %v", err)
}
if err := s.delServiceMetadata(serviceID); err != nil {
if err := s.delServiceMetadata(ctx, serviceID); err != nil {
return fmt.Errorf("delete service-related metadata: %v", err)
}
@ -2216,24 +2213,10 @@ func (s *ServiceAction) isServiceClosed(serviceID string) error {
return nil
}
// delServiceMetadata deletes service-related metadata in the database.
func (s *ServiceAction) delServiceMetadata(serviceID string) error {
service, err := db.GetManager().TenantServiceDao().GetServiceByID(serviceID)
if err != nil {
return err
}
logrus.Infof("delete service %s %s", serviceID, service.ServiceAlias)
tx := db.GetManager().Begin()
defer func() {
if r := recover(); r != nil {
logrus.Errorf("Unexpected panic occurred, rollback transaction: %v", r)
tx.Rollback()
}
}()
func (s *ServiceAction) deleteComponent(tx *gorm.DB, service *dbmodel.TenantServices) error {
delService := service.ChangeDelete()
delService.ID = 0
if err := db.GetManager().TenantServiceDeleteDaoTransactions(tx).AddModel(delService); err != nil {
tx.Rollback()
return err
}
var deleteServicePropertyFunc = []func(serviceID string) error{
@ -2258,24 +2241,58 @@ func (s *ServiceAction) delServiceMetadata(serviceID string) error {
db.GetManager().TenantServiceMonitorDaoTransactions(tx).DeleteServiceMonitorByServiceID,
db.GetManager().AppConfigGroupServiceDaoTransactions(tx).DeleteEffectiveServiceByServiceID,
}
if err := GetGatewayHandler().DeleteTCPRuleByServiceIDWithTransaction(serviceID, tx); err != nil {
tx.Rollback()
if err := GetGatewayHandler().DeleteTCPRuleByServiceIDWithTransaction(service.ServiceID, tx); err != nil {
return err
}
if err := GetGatewayHandler().DeleteHTTPRuleByServiceIDWithTransaction(serviceID, tx); err != nil {
tx.Rollback()
if err := GetGatewayHandler().DeleteHTTPRuleByServiceIDWithTransaction(service.ServiceID, tx); err != nil {
return err
}
for _, del := range deleteServicePropertyFunc {
if err := del(serviceID); err != nil {
if err := del(service.ServiceID); err != nil {
if err != gorm.ErrRecordNotFound {
tx.Rollback()
return err
}
}
}
if err := tx.Commit().Error; err != nil {
tx.Rollback()
return nil
}
// delServiceMetadata deletes service-related metadata in the database.
func (s *ServiceAction) delServiceMetadata(ctx context.Context, serviceID string) error {
service, err := db.GetManager().TenantServiceDao().GetServiceByID(serviceID)
if err != nil {
return err
}
logrus.Infof("delete service %s %s", serviceID, service.ServiceAlias)
return db.GetManager().DB().Transaction(func(tx *gorm.DB) error {
if err := s.deleteThirdComponent(ctx, service); err != nil {
return err
}
return s.deleteComponent(tx, service)
})
}
func (s *ServiceAction) deleteThirdComponent(ctx context.Context, component *dbmodel.TenantServices) error {
if component.Kind != "third_party" {
return nil
}
thirdPartySvcDiscoveryCfg, err := db.GetManager().ThirdPartySvcDiscoveryCfgDao().GetByServiceID(component.ServiceID)
if err != nil {
return err
}
if thirdPartySvcDiscoveryCfg == nil {
return nil
}
if thirdPartySvcDiscoveryCfg.Type != string(dbmodel.DiscorveryTypeKubernetes) {
return nil
}
newCtx, cancel := context.WithTimeout(ctx, 3*time.Second)
defer cancel()
err = s.rainbondClient.RainbondV1alpha1().ThirdComponents(component.TenantID).Delete(newCtx, component.ServiceID, metav1.DeleteOptions{})
if err != nil && !k8sErrors.IsNotFound(err) {
return err
}
return nil
@ -2855,6 +2872,28 @@ func (s *ServiceAction) SyncComponentScaleRules(tx *gorm.DB, components []*api_m
return db.GetManager().TenantServceAutoscalerRuleMetricsDaoTransactions(tx).CreateOrUpdateScaleRuleMetricsInBatch(autoScaleRuleMetrics)
}
// SyncComponentEndpoints -
func (s *ServiceAction) SyncComponentEndpoints(tx *gorm.DB, components []*api_model.Component) error {
var (
componentIDs []string
thirdPartySvcDiscoveryCfgs []*dbmodel.ThirdPartySvcDiscoveryCfg
)
for _, component := range components {
if component.Endpoint == nil {
continue
}
componentIDs = append(componentIDs, component.ComponentBase.ComponentID)
if component.Endpoint.Kubernetes != nil {
thirdPartySvcDiscoveryCfgs = append(thirdPartySvcDiscoveryCfgs, component.Endpoint.DbModel(component.ComponentBase.ComponentID))
}
}
if err := db.GetManager().ThirdPartySvcDiscoveryCfgDaoTransactions(tx).DeleteByComponentIDs(componentIDs); err != nil {
return err
}
return db.GetManager().ThirdPartySvcDiscoveryCfgDaoTransactions(tx).CreateOrUpdate3rdSvcDiscoveryCfgInBatch(thirdPartySvcDiscoveryCfgs)
}
//TransStatus trans service status
func TransStatus(eStatus string) string {
switch eStatus {

View File

@ -69,7 +69,7 @@ type ServiceHandler interface {
GetPods(serviceID string) (*K8sPodInfos, error)
GetMultiServicePods(serviceIDs []string) (*K8sPodInfos, error)
GetComponentPodNums(ctx context.Context, componentIDs []string) (map[string]int32, error)
TransServieToDelete(tenantID, serviceID string) error
TransServieToDelete(ctx context.Context, tenantID, serviceID string) error
TenantServiceDeletePluginRelation(tenantID, serviceID, pluginID string) *util.APIHandleError
GetTenantServicePluginRelation(serviceID string) ([]*dbmodel.TenantServicePluginRelation, *util.APIHandleError)
SetTenantServicePluginRelation(tenantID, serviceID string, pss *api_model.PluginSetStruct) (*dbmodel.TenantServicePluginRelation, *util.APIHandleError)
@ -101,4 +101,5 @@ type ServiceHandler interface {
SyncComponentLabels(tx *gorm.DB, components []*api_model.Component) error
SyncComponentPlugins(tx *gorm.DB, app *dbmodel.Application, components []*api_model.Component) error
SyncComponentScaleRules(tx *gorm.DB, components []*api_model.Component) error
SyncComponentEndpoints(tx *gorm.DB, components []*api_model.Component) error
}

View File

@ -129,9 +129,6 @@ func (o *OperationHandler) Stop(batchOpReq model.ComponentOpReq) error {
if err != nil {
return err
}
if dbmodel.ServiceKind(service.Kind) == dbmodel.ServiceKindThirdParty {
return nil
}
body := batchOpReq.TaskBody(service)
err = o.mqCli.SendBuilderTopic(gclient.TaskStruct{
TaskType: "stop",
@ -150,9 +147,6 @@ func (o *OperationHandler) Start(batchOpReq model.ComponentOpReq) error {
if err != nil {
return err
}
if dbmodel.ServiceKind(service.Kind) == dbmodel.ServiceKindThirdParty {
return nil
}
body := batchOpReq.TaskBody(service)
err = o.mqCli.SendBuilderTopic(gclient.TaskStruct{

View File

@ -26,18 +26,28 @@ import (
"time"
"github.com/goodrain/rainbond/api/client/prometheus"
"github.com/goodrain/rainbond/api/model"
api_model "github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/api/util"
"github.com/goodrain/rainbond/api/util/bcode"
"github.com/goodrain/rainbond/cmd/api/option"
"github.com/goodrain/rainbond/db"
dbmodel "github.com/goodrain/rainbond/db/model"
mqclient "github.com/goodrain/rainbond/mq/client"
"github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
rutil "github.com/goodrain/rainbond/util"
"github.com/goodrain/rainbond/worker/client"
"github.com/goodrain/rainbond/worker/server/pb"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes"
k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
)
//TenantAction tenant act
@ -49,17 +59,30 @@ type TenantAction struct {
cacheClusterResourceStats *ClusterResourceStats
cacheTime time.Time
prometheusCli prometheus.Interface
k8sClient k8sclient.Client
resources map[string]runtime.Object
}
//CreateTenManager create Manger
func CreateTenManager(mqc mqclient.MQClient, statusCli *client.AppRuntimeSyncClient,
optCfg *option.Config, kubeClient *kubernetes.Clientset, prometheusCli prometheus.Interface) *TenantAction {
optCfg *option.Config,
kubeClient *kubernetes.Clientset,
prometheusCli prometheus.Interface,
k8sClient k8sclient.Client) *TenantAction {
resources := map[string]runtime.Object{
"helmApp": &v1alpha1.HelmApp{},
"service": &corev1.Service{},
}
return &TenantAction{
MQClient: mqc,
statusCli: statusCli,
OptCfg: optCfg,
kubeClient: kubeClient,
prometheusCli: prometheusCli,
k8sClient: k8sClient,
resources: resources,
}
}
@ -130,7 +153,7 @@ func (t *TenantAction) UpdateTenant(tenant *dbmodel.Tenants) error {
// DeleteTenant deletes tenant based on the given tenantID.
//
// tenant can only be deleted without service or plugin
func (t *TenantAction) DeleteTenant(tenantID string) error {
func (t *TenantAction) DeleteTenant(ctx context.Context, tenantID string) error {
// check if there are still services
services, err := db.GetManager().TenantServiceDao().ListServicesByTenantID(tenantID)
if err != nil {
@ -138,7 +161,7 @@ func (t *TenantAction) DeleteTenant(tenantID string) error {
}
if len(services) > 0 {
for _, service := range services {
GetServiceManager().TransServieToDelete(tenantID, service.ServiceID)
GetServiceManager().TransServieToDelete(ctx, tenantID, service.ServiceID)
}
}
@ -588,3 +611,29 @@ func (t *TenantAction) GetClusterResource(ctx context.Context) *ClusterResourceS
}
return t.cacheClusterResourceStats
}
// CheckResourceName checks resource name.
func (t *TenantAction) CheckResourceName(ctx context.Context, namespace string, req *model.CheckResourceNameReq) (*model.CheckResourceNameResp, error) {
obj, ok := t.resources[req.Type]
if !ok {
return nil, bcode.NewBadRequest("unsupported resource: " + req.Type)
}
nctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
retries := 3
for i := 0; i < retries; i++ {
if err := t.k8sClient.Get(nctx, types.NamespacedName{Namespace: namespace, Name: req.Name}, obj); err != nil {
if k8sErrors.IsNotFound(err) {
break
}
return nil, errors.Wrap(err, "ensure app name")
}
req.Name += "-" + rutil.NewUUID()[:5]
}
return &model.CheckResourceNameResp{
Name: req.Name,
}, nil
}

View File

@ -21,6 +21,7 @@ package handler
import (
"context"
"github.com/goodrain/rainbond/api/model"
api_model "github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/api/util"
dbmodel "github.com/goodrain/rainbond/db/model"
@ -46,6 +47,7 @@ type TenantHandler interface {
IsClosedStatus(status string) bool
BindTenantsResource(source []*dbmodel.Tenants) api_model.TenantList
UpdateTenant(*dbmodel.Tenants) error
DeleteTenant(tenantID string) error
DeleteTenant(ctx context.Context, tenantID string) error
GetClusterResource(ctx context.Context) *ClusterResourceStats
CheckResourceName(ctx context.Context, namespace string, req *model.CheckResourceNameReq) (*model.CheckResourceNameResp, error)
}

View File

@ -1,5 +1,7 @@
package model
import "github.com/goodrain/rainbond/worker/server/pb"
// AppPort -
type AppPort struct {
ServiceID string `json:"service_id" validate:"required"`
@ -10,8 +12,51 @@ type AppPort struct {
// AppStatus -
type AppStatus struct {
Status string `json:"status"`
Cpu int64 `json:"cpu"`
Memory int64 `json:"memory"`
Disk int64 `json:"disk"`
Status string `json:"status"`
CPU *int64 `json:"cpu"`
Memory *int64 `json:"memory"`
Disk int64 `json:"disk"`
Phase string `json:"phase"`
Version string `json:"version"`
Overrides []string `json:"overrides"`
Conditions []*AppStatusCondition `json:"conditions"`
}
// AppStatusCondition is the conditon of app status.
type AppStatusCondition struct {
Type string `json:"type"`
Status bool `json:"status"`
Reason string `json:"reason"`
Message string `json:"message"`
}
// AppService -
type AppService struct {
ServiceName string `json:"service_name"`
Address string `json:"address"`
Ports []*pb.AppService_Port `json:"ports"`
OldPods []*AppPod `json:"oldPods"`
Pods []*AppPod `json:"pods"`
}
// ByServiceName implements sort.Interface for []*AppService based on
// the ServiceName field.
type ByServiceName []*AppService
func (a ByServiceName) Len() int { return len(a) }
func (a ByServiceName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByServiceName) Less(i, j int) bool { return a[i].ServiceName < a[j].ServiceName }
// AppPod -
type AppPod struct {
PodName string `json:"pod_name"`
PodStatus string `json:"pod_status"`
}
// ByPodName implements sort.Interface for []*AppPod based on
// the PodName field.
type ByPodName []*AppPod
func (a ByPodName) Len() int { return len(a) }
func (a ByPodName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByPodName) Less(i, j int) bool { return a[i].PodName < a[j].PodName }

View File

@ -251,6 +251,7 @@ type Component struct {
ConfigFiles []ComponentConfigFile `json:"config_files"`
VolumeRelations []VolumeRelation `json:"volume_relations"`
Volumes []ComponentVolume `json:"volumes"`
Endpoint *Endpoints `json:"endpoint"`
}
// SyncComponentReq -

View File

@ -28,6 +28,12 @@ import (
dmodel "github.com/goodrain/rainbond/worker/discover/model"
)
// AppType
const (
AppTypeRainbond = "rainbond"
AppTypeHelm = "helm"
)
//ServiceGetCommon path参数
//swagger:parameters getVolumes getDepVolumes
type ServiceGetCommon struct {
@ -356,8 +362,22 @@ type ServiceStruct struct {
// Endpoints holds third-party service endpoints or configuraion to get endpoints.
type Endpoints struct {
Static string `json:"static" validate:"static"`
Discovery string `json:"discovery" validate:"discovery"`
Static []string `json:"static" validate:"static"`
Kubernetes *EndpointKubernetes `json:"kubernetes" validate:"kubernetes"`
}
func (e *Endpoints) DbModel(componentID string) *dbmodel.ThirdPartySvcDiscoveryCfg {
return &dbmodel.ThirdPartySvcDiscoveryCfg{
ServiceID: componentID,
Type: string(dbmodel.DiscorveryTypeKubernetes),
Namespace: e.Kubernetes.Namespace,
ServiceName: e.Kubernetes.ServiceName,
}
}
type EndpointKubernetes struct {
Namespace string `json:"namespace"`
ServiceName string `json:"serviceName"`
}
//TenantServiceVolumeStruct -
@ -1785,11 +1805,17 @@ func NewAppStatusFromImport(app *ImportAppStruct) *dbmodel.AppStatus {
// Application -
type Application struct {
AppName string `json:"app_name" validate:"required"`
ConsoleAppID int64 `json:"console_app_id"`
AppID string `json:"app_id"`
TenantID string `json:"tenant_id"`
ServiceIDs []string `json:"service_ids"`
EID string `json:"eid" validate:"required"`
AppName string `json:"app_name" validate:"required"`
AppType string `json:"app_type" validate:"required,oneof=rainbond helm"`
ConsoleAppID int64 `json:"console_app_id"`
AppID string `json:"app_id"`
TenantID string `json:"tenant_id"`
ServiceIDs []string `json:"service_ids"`
AppStoreName string `json:"app_store_name"`
AppStoreURL string `json:"app_store_url"`
AppTemplateName string `json:"app_template_name"`
Version string `json:"version"`
}
// CreateAppRequest -
@ -1821,8 +1847,16 @@ type ListServiceResponse struct {
// UpdateAppRequest -
type UpdateAppRequest struct {
AppName string `json:"app_name"`
GovernanceMode string `json:"governance_mode"`
AppName string `json:"app_name"`
GovernanceMode string `json:"governance_mode"`
Overrides []string `json:"overrides"`
Version string `json:"version"`
Revision int `json:"revision"`
}
// NeedUpdateHelmApp check if necessary to update the helm app.
func (u *UpdateAppRequest) NeedUpdateHelmApp() bool {
return len(u.Overrides) > 0 || u.Version != "" || u.Revision != 0
}
// BindServiceRequest -
@ -1830,10 +1864,20 @@ type BindServiceRequest struct {
ServiceIDs []string `json:"service_ids"`
}
// InstallAppReq -
type InstallAppReq struct {
Overrides []string `json:"overrides"`
}
// ParseAppServicesReq -
type ParseAppServicesReq struct {
Values string `json:"values"`
}
// ConfigGroupService -
type ConfigGroupService struct {
ServiceID string `json:"service_id"`
ServiceAlias string `json:"service_alias"`
ServiceID string `json:"service_id"`
ServiceAlias string `json:"service_alias"`
}
// DbModel return database model
@ -1866,12 +1910,12 @@ func (c ConfigItem) DbModel(appID, configGroupName string) *dbmodel.ConfigGroupI
// ApplicationConfigGroup -
type ApplicationConfigGroup struct {
AppID string `json:"app_id"`
ConfigGroupName string `json:"config_group_name" validate:"required,alphanum,min=2,max=64"`
DeployType string `json:"deploy_type" validate:"required,oneof=env configfile"`
ServiceIDs []string `json:"service_ids"`
ConfigItems []ConfigItem `json:"config_items"`
Enable bool `json:"enable"`
AppID string `json:"app_id"`
ConfigGroupName string `json:"config_group_name" validate:"required,alphanum,min=2,max=64"`
DeployType string `json:"deploy_type" validate:"required,oneof=env configfile"`
ServiceIDs []string `json:"service_ids"`
ConfigItems []ConfigItem `json:"config_items"`
Enable bool `json:"enable"`
}
// AppConfigGroup Interface for synchronizing application configuration groups
@ -1919,6 +1963,27 @@ type ListApplicationConfigGroupResp struct {
PageSize int `json:"pageSize"`
}
// CheckResourceNameReq -
type CheckResourceNameReq struct {
Name string `json:"name"`
Type string `json:"type"`
}
// CheckResourceNameResp -
type CheckResourceNameResp struct {
Name string `json:"name"`
}
// HelmAppRelease -
type HelmAppRelease struct {
Revision int `json:"revision"`
Updated string `json:"updated"`
Status string `json:"status"`
Chart string `json:"chart"`
AppVersion string `json:"app_version"`
Description string `json:"description"`
}
// AppConfigGroupRelations -
type AppConfigGroupRelations struct {
ConfigGroupName string `json:"config_group_name"`

View File

@ -49,7 +49,7 @@ type EndpointResp struct {
// ThridPartyServiceProbe is the json obejct in the request
// to update or fetch the ThridPartyServiceProbe.
type ThridPartyServiceProbe struct {
Scheme string `json:"scheme;"`
Scheme string `json:"scheme"`
Path string `json:"path"`
Port int `json:"port"`
TimeInterval int `json:"time_interval"`

View File

@ -32,7 +32,7 @@ import (
"os"
)
//ClusterInterface cluster api
// MonitorInterface cluster api
type MonitorInterface interface {
GetRule(name string) (*model.AlertingNameConfig, *util.APIHandleError)
GetAllRule() (*model.AlertingRulesConfig, *util.APIHandleError)

View File

@ -14,6 +14,8 @@ var (
ErrDeleteDueToBindService = newByMessage(400, 11005, "the application cannot be deleted because there are bound services")
ErrK8sServiceNameExists = newByMessage(400, 11006, "kubernetes service name already exists")
ErrInvalidHelmAppValues = newByMessage(400, 11007, "invalid helm app values")
)
// app config group 11100~11199

View File

@ -23,7 +23,9 @@ import (
"os"
"os/signal"
"syscall"
rainbondscheme "github.com/goodrain/rainbond/pkg/generated/clientset/versioned/scheme"
"github.com/goodrain/rainbond/api/controller"
"github.com/goodrain/rainbond/api/db"
"github.com/goodrain/rainbond/api/discover"
@ -31,12 +33,16 @@ import (
"github.com/goodrain/rainbond/api/server"
"github.com/goodrain/rainbond/cmd/api/option"
"github.com/goodrain/rainbond/event"
"github.com/goodrain/rainbond/pkg/generated/clientset/versioned"
etcdutil "github.com/goodrain/rainbond/util/etcd"
k8sutil "github.com/goodrain/rainbond/util/k8s"
"github.com/goodrain/rainbond/worker/client"
"k8s.io/client-go/kubernetes"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
)
//Run start run
@ -64,6 +70,7 @@ func Run(s *option.APIServer) error {
if err := db.CreateEventManager(s.Config); err != nil {
logrus.Debugf("create event manager error, %v", err)
}
config, err := k8sutil.NewRestConfig(s.KubeConfigPath)
if err != nil {
return err
@ -72,6 +79,19 @@ func Run(s *option.APIServer) error {
if err != nil {
return err
}
rainbondClient := versioned.NewForConfigOrDie(config)
// k8s runtime client
scheme := runtime.NewScheme()
clientgoscheme.AddToScheme(scheme)
rainbondscheme.AddToScheme(scheme)
k8sClient, err := k8sclient.New(config, k8sclient.Options{
Scheme: scheme,
})
if err != nil {
return errors.WithMessage(err, "create k8s client")
}
if err := event.NewManager(event.EventConfig{
EventLogServers: s.Config.EventLogServers,
DiscoverArgs: etcdClientArgs,
@ -85,6 +105,7 @@ func Run(s *option.APIServer) error {
EtcdCaFile: s.Config.EtcdCaFile,
EtcdCertFile: s.Config.EtcdCertFile,
EtcdKeyFile: s.Config.EtcdKeyFile,
NonBlock: s.Config.Debug,
})
if err != nil {
logrus.Errorf("create app status client error, %v", err)
@ -100,7 +121,7 @@ func Run(s *option.APIServer) error {
//初始化 middleware
handler.InitProxy(s.Config)
//创建handle
if err := handler.InitHandle(s.Config, etcdClientArgs, cli, etcdcli, clientset); err != nil {
if err := handler.InitHandle(s.Config, etcdClientArgs, cli, etcdcli, clientset, rainbondClient, k8sClient); err != nil {
logrus.Errorf("init all handle error, %v", err)
return err
}

View File

@ -37,6 +37,10 @@ import (
)
func main() {
if os.Getenv("LOG_LEVEL") != "" {
level, _ := logrus.ParseLevel(os.Getenv("LOG_LEVEL"))
logrus.SetLevel(level)
}
if len(os.Args) > 1 && os.Args[1] == "version" {
cmd.ShowVersion("sidecar")
}
@ -49,7 +53,7 @@ func main() {
client := &http.Client{
Timeout: time.Duration(requestTimeoutMillis) * time.Millisecond,
}
logrus.Infof("Waiting for Envoy proxy to be ready (timeout: %d seconds)...", timeoutSeconds)
logrus.Debugf("Waiting for Envoy proxy to be ready (timeout: %d seconds)...", timeoutSeconds)
var err error
timeoutAt := time.Now().Add(time.Duration(timeoutSeconds) * time.Second)
@ -59,7 +63,7 @@ func main() {
logrus.Infof("Sidecar server is ready!")
break
}
logrus.Infof("Not ready yet: %v", err)
logrus.Debugf("Not ready yet: %v", err)
time.Sleep(time.Duration(periodMillis) * time.Millisecond)
}
if len(os.Args) > 2 && os.Args[2] != "0" {
@ -69,14 +73,14 @@ func main() {
logrus.Infof("Sidecar is ready!")
os.Exit(0)
}
logrus.Infof("Not ready yet: %v", err)
logrus.Debugf("Not ready yet: %v", err)
time.Sleep(time.Duration(periodMillis) * time.Millisecond)
}
} else {
logrus.Infof("Sidecar is ready!")
os.Exit(0)
}
logrus.Errorf("timeout waiting for Envoy proxy to become ready. Last error: %v", err)
logrus.Errorf("timeout waiting for Mesh Sidecar to become ready. Last error: %v", err)
os.Exit(1)
}
if len(os.Args) > 1 && os.Args[1] == "run" {
@ -106,7 +110,7 @@ func Run() error {
ticker := time.NewTicker(time.Second * 5)
defer ticker.Stop()
//step finally: listen Signal
term := make(chan os.Signal)
term := make(chan os.Signal, 1)
signal.Notify(term, os.Interrupt, syscall.SIGTERM)
for {
select {

View File

@ -21,6 +21,7 @@ package option
import (
"fmt"
"os"
"path"
"github.com/sirupsen/logrus"
"github.com/spf13/pflag"
@ -54,6 +55,15 @@ type Config struct {
LeaderElectionIdentity string
RBDNamespace string
GrdataPVCName string
Helm Helm
}
// Helm helm configuration.
type Helm struct {
DataDir string
RepoFile string
RepoCache string
ChartCache string
}
//Worker worker server
@ -95,6 +105,14 @@ func (a *Worker) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&a.LeaderElectionIdentity, "leader-election-identity", "", "Unique idenity of this attcher. Typically name of the pod where the attacher runs.")
fs.StringVar(&a.RBDNamespace, "rbd-system-namespace", "rbd-system", "rbd components kubernetes namespace")
fs.StringVar(&a.GrdataPVCName, "grdata-pvc-name", "rbd-cpt-grdata", "The name of grdata persistent volume claim")
fs.StringVar(&a.Helm.DataDir, "helm-data-dir", "helm-data-dir", "The data directory of Helm.")
if a.Helm.DataDir == "" {
a.Helm.DataDir = "/grdata/helm"
}
a.Helm.RepoFile = path.Join(a.Helm.DataDir, "repo/repositories.yaml")
a.Helm.RepoCache = path.Join(a.Helm.DataDir, "cache")
a.Helm.ChartCache = path.Join(a.Helm.DataDir, "chart")
}
//SetLog 设置log

View File

@ -28,9 +28,12 @@ import (
"github.com/goodrain/rainbond/db"
"github.com/goodrain/rainbond/db/config"
"github.com/goodrain/rainbond/event"
"github.com/goodrain/rainbond/pkg/common"
"github.com/goodrain/rainbond/pkg/generated/clientset/versioned"
etcdutil "github.com/goodrain/rainbond/util/etcd"
k8sutil "github.com/goodrain/rainbond/util/k8s"
"github.com/goodrain/rainbond/worker/appm"
"github.com/goodrain/rainbond/worker/appm/componentdefinition"
"github.com/goodrain/rainbond/worker/appm/controller"
"github.com/goodrain/rainbond/worker/appm/store"
"github.com/goodrain/rainbond/worker/discover"
@ -41,6 +44,7 @@ import (
"github.com/sirupsen/logrus"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/util/flowcontrol"
"sigs.k8s.io/controller-runtime/pkg/client"
)
//Run start run
@ -84,12 +88,20 @@ func Run(s *option.Worker) error {
return err
}
s.Config.KubeClient = clientset
runtimeClient, err := client.New(restConfig, client.Options{Scheme: common.Scheme})
if err != nil {
logrus.Errorf("create kube runtime client error: %s", err.Error())
return err
}
rainbondClient := versioned.NewForConfigOrDie(restConfig)
//step 3: create componentdefinition builder factory
componentdefinition.NewComponentDefinitionBuilder(s.Config.RBDNamespace)
//step 3: create resource store
//step 4: create component resource store
startCh := channels.NewRingChannel(1024)
updateCh := channels.NewRingChannel(1024)
probeCh := channels.NewRingChannel(1024)
cachestore := store.NewStore(restConfig, clientset, db.GetManager(), s.Config, startCh, probeCh)
cachestore := store.NewStore(restConfig, clientset, rainbondClient, db.GetManager(), s.Config, startCh, probeCh)
appmController := appm.NewAPPMController(clientset, cachestore, startCh, updateCh, probeCh)
if err := appmController.Start(); err != nil {
logrus.Errorf("error starting appm controller: %v", err)
@ -100,13 +112,12 @@ func Run(s *option.Worker) error {
return err
}
//step 4: create controller manager
controllerManager := controller.NewManager(cachestore, clientset)
//step 5: create controller manager
controllerManager := controller.NewManager(cachestore, clientset, runtimeClient)
defer controllerManager.Stop()
//step 5 : start runtime master
masterCon, err := master.NewMasterController(s.Config, restConfig, cachestore)
//step 6 : start runtime master
masterCon, err := master.NewMasterController(s.Config, cachestore, clientset, rainbondClient, restConfig)
if err != nil {
return err
}
@ -115,18 +126,19 @@ func Run(s *option.Worker) error {
}
defer masterCon.Stop()
//step 6 : create discover module
//step 7 : create discover module
garbageCollector := gc.NewGarbageCollector(clientset)
taskManager := discover.NewTaskManager(s.Config, cachestore, controllerManager, garbageCollector, startCh)
if err := taskManager.Start(); err != nil {
return err
}
defer taskManager.Stop()
//step 7: start app runtimer server
//step 8: start app runtimer server
runtimeServer := server.CreaterRuntimeServer(s.Config, cachestore, clientset, updateCh)
runtimeServer.Start(errChan)
//step 8: create application use resource exporter.
//step 9: create application use resource exporter.
exporterManager := monitor.NewManager(s.Config, masterCon, controllerManager)
if err := exporterManager.Start(); err != nil {
return err
@ -136,7 +148,7 @@ func Run(s *option.Worker) error {
logrus.Info("worker begin running...")
//step finally: listen Signal
term := make(chan os.Signal)
term := make(chan os.Signal, 1)
signal.Notify(term, os.Interrupt, syscall.SIGTERM)
select {
case <-term:

View File

@ -0,0 +1,209 @@
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.3.0
creationTimestamp: null
name: componentdefinitions.rainbond.io
spec:
additionalPrinterColumns:
- JSONPath: .spec.workload.definition.kind
name: WORKLOAD-KIND
type: string
- JSONPath: .metadata.annotations.definition\.oam\.dev/description
name: DESCRIPTION
type: string
group: rainbond.io
names:
categories:
- oam
kind: ComponentDefinition
listKind: ComponentDefinitionList
plural: componentdefinitions
shortNames:
- comp
singular: componentdefinition
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: ComponentDefinition is the Schema for the componentdefinitions
API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ComponentDefinitionSpec defines the desired state of ComponentDefinition
properties:
childResourceKinds:
description: ChildResourceKinds are the list of GVK of the child resources
this workload generates
items:
description: A ChildResourceKind defines a child Kubernetes resource
kind with a selector
properties:
apiVersion:
description: APIVersion of the child resource
type: string
kind:
description: Kind of the child resource
type: string
selector:
additionalProperties:
type: string
description: Selector to select the child resources that the workload
wants to expose to traits
type: object
required:
- apiVersion
- kind
type: object
type: array
extension:
description: Extension is used for extension needs by OAM platform builders
type: object
x-kubernetes-preserve-unknown-fields: true
podSpecPath:
description: PodSpecPath indicates where/if this workload has K8s podSpec
field if one workload has podSpec, trait can do lot's of assumption
such as port, env, volume fields.
type: string
revisionLabel:
description: RevisionLabel indicates which label for underlying resources(e.g.
pods) of this workload can be used by trait to create resource selectors(e.g.
label selector for pods).
type: string
schematic:
description: Schematic defines the data format and template of the encapsulation
of the workload
properties:
cue:
description: CUE defines the encapsulation in CUE format
properties:
template:
description: Template defines the abstraction template data
of the capability, it will replace the old CUE template in
extension field. Template is a required field if CUE is defined
in Capability Definition.
type: string
required:
- template
type: object
type: object
status:
description: Status defines the custom health policy and status message
for workload
properties:
customStatus:
description: CustomStatus defines the custom status message that
could display to user
type: string
healthPolicy:
description: HealthPolicy defines the health check policy for the
abstraction
type: string
type: object
workload:
description: Workload is a workload type descriptor
properties:
definition:
description: Definition mutually exclusive to workload.type, a embedded
WorkloadDefinition
properties:
apiVersion:
type: string
kind:
type: string
required:
- apiVersion
- kind
type: object
type:
description: Type ref to a WorkloadDefinition via name
type: string
type: object
required:
- workload
type: object
status:
description: ComponentDefinitionStatus is the status of ComponentDefinition
properties:
conditions:
description: Conditions of the resource.
items:
description: A Condition that may apply to a resource.
properties:
lastTransitionTime:
description: LastTransitionTime is the last time this condition
transitioned from one status to another.
format: date-time
type: string
message:
description: A Message containing details about this condition's
last transition from one status to another, if any.
type: string
reason:
description: A Reason for this condition's last transition from
one status to another.
type: string
status:
description: Status of this condition; is it currently True, False,
or Unknown?
type: string
type:
description: Type of this condition. At most one of each condition
type may apply to a resource at any point in time.
type: string
required:
- lastTransitionTime
- reason
- status
- type
type: object
type: array
configMapRef:
description: ConfigMapRef refer to a ConfigMap which contains OpenAPI
V3 JSON schema of Component parameters.
type: string
latestRevision:
description: LatestRevision of the component definition
properties:
name:
type: string
revision:
format: int64
type: integer
revisionHash:
description: RevisionHash record the hash value of the spec of ApplicationRevision
object.
type: string
required:
- name
- revision
type: object
type: object
type: object
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

View File

@ -0,0 +1,159 @@
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.3.0
creationTimestamp: null
name: helmapps.rainbond.io
spec:
group: rainbond.io
names:
kind: HelmApp
listKind: HelmAppList
plural: helmapps
singular: helmapp
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: HelmApp -
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: HelmAppSpec defines the desired state of HelmApp
properties:
appStore:
description: The helm app store.
properties:
branch:
description: The branch of a git repo.
type: string
name:
description: The name of app store.
type: string
password:
description: The chart repository password where to locate the requested
chart
type: string
url:
description: The url of helm repo, sholud be a helm native repo
url or a git url.
type: string
username:
description: The chart repository username where to locate the requested
chart
type: string
version:
description: The verision of the helm app store.
type: string
required:
- name
- url
- version
type: object
eid:
type: string
overrides:
description: Overrides will overrides the values in the chart.
items:
type: string
type: array
preStatus:
description: The prerequisite status.
enum:
- NotConfigured
- Configured
type: string
revision:
description: The application revision.
type: integer
templateName:
description: The application name.
type: string
version:
description: The application version.
type: string
required:
- appStore
- eid
- templateName
- version
type: object
status:
description: HelmAppStatus defines the observed state of HelmApp
properties:
conditions:
description: Current state of helm app.
items:
description: HelmAppCondition contains details for the current condition
of this helm application.
properties:
lastTransitionTime:
description: Last time the condition transitioned from one status
to another.
format: date-time
type: string
message:
description: Human-readable message indicating details about last
transition.
type: string
reason:
description: Unique, one-word, CamelCase reason for the condition's
last transition.
type: string
status:
description: 'Status is the status of the condition. Can be True,
False, Unknown. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions'
type: string
type:
description: Type is the type of the condition.
type: string
required:
- status
- type
type: object
type: array
currentVersion:
description: The version infect.
type: string
overrides:
description: Overrides in effect.
items:
type: string
type: array
phase:
description: The phase of the helm app.
type: string
status:
description: The status of helm app.
type: string
required:
- phase
- status
type: object
type: object
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

View File

@ -0,0 +1,208 @@
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.3.0
creationTimestamp: null
name: thirdcomponents.rainbond.io
spec:
group: rainbond.io
names:
kind: ThirdComponent
listKind: ThirdComponentList
plural: thirdcomponents
singular: thirdcomponent
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: HelmApp -
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
properties:
endpointSource:
description: endpoint source config
properties:
endpoints:
items:
properties:
address:
description: The address including the port number.
type: string
clientSecret:
description: Specify a private certificate when the protocol
is HTTPS
type: string
protocol:
description: 'Address protocols, including: HTTP, TCP, UDP,
HTTPS'
type: string
required:
- address
type: object
type: array
kubernetesService:
properties:
name:
type: string
namespace:
description: If not specified, the namespace is the namespace
of the current resource
type: string
required:
- name
type: object
type: object
ports:
description: component regist ports
items:
description: ComponentPort component port define
properties:
name:
type: string
openInner:
type: boolean
openOuter:
type: boolean
port:
type: integer
required:
- name
- openInner
- openOuter
- port
type: object
type: array
probe:
description: health check probe
properties:
httpGet:
description: HTTPGet specifies the http request to perform.
properties:
httpHeaders:
description: Custom headers to set in the request. HTTP allows
repeated headers.
items:
description: HTTPHeader describes a custom header to be used
in HTTP probes
properties:
name:
description: The header field name
type: string
value:
description: The header field value
type: string
required:
- name
- value
type: object
type: array
path:
description: Path to access on the HTTP server.
type: string
type: object
tcpSocket:
description: 'TCPSocket specifies an action involving a TCP port.
TCP hooks not yet supported TODO: implement a realistic TCP lifecycle
hook'
type: object
type: object
required:
- endpointSource
- ports
type: object
status:
properties:
endpoints:
items:
description: ThirdComponentEndpointStatus endpoint status
properties:
address:
description: The address including the port number.
type: string
reason:
description: Reason probe not passed reason
type: string
servicePort:
description: ServicePort if address build from kubernetes endpoint,
The corresponding service port
type: integer
status:
description: Status endpoint status
type: string
targetRef:
description: Reference to object providing the endpoint.
properties:
apiVersion:
description: API version of the referent.
type: string
fieldPath:
description: 'If referring to a piece of an object instead
of an entire object, this string should contain a valid
JSON/Go field access statement, such as desiredState.manifest.containers[2].
For example, if the object reference is to a container within
a pod, this would take on a value like: "spec.containers{name}"
(where "name" refers to the name of the container that triggered
the event) or if no container name is specified "spec.containers[2]"
(container with index 2 in this pod). This syntax is chosen
only to have some well-defined way of referencing a part
of an object. TODO: this design is not final and this field
is subject to change in the future.'
type: string
kind:
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
type: string
namespace:
description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
type: string
resourceVersion:
description: 'Specific resourceVersion to which this reference
is made, if any. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency'
type: string
uid:
description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
type: string
type: object
required:
- address
- status
type: object
type: array
phase:
type: string
reason:
type: string
required:
- endpoints
- phase
type: object
type: object
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

View File

@ -553,6 +553,8 @@ type ThirdPartySvcDiscoveryCfgDao interface {
Dao
GetByServiceID(sid string) (*model.ThirdPartySvcDiscoveryCfg, error)
DeleteByServiceID(sid string) error
DeleteByComponentIDs(componentIDs []string) error
CreateOrUpdate3rdSvcDiscoveryCfgInBatch(cfgs []*model.ThirdPartySvcDiscoveryCfg) error
}
// GwRuleConfigDao is the interface that wraps the required methods to execute

View File

@ -40,6 +40,7 @@ type Manager interface {
LicenseDao() dao.LicenseDao
AppDao() dao.AppDao
ApplicationDao() dao.ApplicationDao
ApplicationDaoTransactions(db *gorm.DB) dao.ApplicationDao
AppConfigGroupDao() dao.AppConfigGroupDao
AppConfigGroupDaoTransactions(db *gorm.DB) dao.AppConfigGroupDao
AppConfigGroupServiceDao() dao.AppConfigGroupServiceDao

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,12 @@ const (
GovernanceModeKubernetesNativeService = "KUBERNETES_NATIVE_SERVICE"
)
// app type
const (
AppTypeRainbond = "rainbond"
AppTypeHelm = "helm"
)
// IsGovernanceModeValid checks if the governanceMode is valid.
func IsGovernanceModeValid(governanceMode string) bool {
return governanceMode == GovernanceModeBuildInServiceMesh || governanceMode == GovernanceModeKubernetesNativeService
@ -15,10 +21,16 @@ func IsGovernanceModeValid(governanceMode string) bool {
// Application -
type Application struct {
Model
AppName string `gorm:"column:app_name" json:"app_name"`
AppID string `gorm:"column:app_id" json:"app_id"`
TenantID string `gorm:"column:tenant_id" json:"tenant_id"`
GovernanceMode string `gorm:"column:governance_mode;default:'BUILD_IN_SERVICE_MESH'" json:"governance_mode"`
EID string `gorm:"column:eid" json:"eid"`
TenantID string `gorm:"column:tenant_id" json:"tenant_id"`
AppName string `gorm:"column:app_name" json:"app_name"`
AppID string `gorm:"column:app_id" json:"app_id"`
AppType string `gorm:"column:app_type;default:'rainbond'" json:"app_type"`
AppStoreName string `gorm:"column:app_store_name" json:"app_store_name"`
AppStoreURL string `gorm:"column:app_store_url" json:"app_store_url"`
AppTemplateName string `gorm:"column:app_template_name" json:"app_template_name"`
Version string `gorm:"column:version" json:"version"`
GovernanceMode string `gorm:"column:governance_mode;default:'BUILD_IN_SERVICE_MESH'" json:"governance_mode"`
}
// TableName return tableName "application"

View File

@ -23,6 +23,8 @@ import (
"os"
"strings"
"time"
"github.com/goodrain/rainbond/util/commonutil"
)
//Model 默认字段
@ -81,6 +83,9 @@ var ServiceKindThirdParty ServiceKind = "third_party"
// ServiceKindInternal means internal service
var ServiceKindInternal ServiceKind = "internal"
// ServiceKindCustom means custom component define
var ServiceKindCustom ServiceKind = "custom.componentdefinition."
func (s ServiceKind) String() string {
return string(s)
}
@ -189,7 +194,7 @@ type TenantServices struct {
UpdateTime time.Time `gorm:"column:update_time" json:"update_time"`
// 服务创建类型cloud云市服务,assistant云帮服务
ServiceOrigin string `gorm:"column:service_origin;default:'assistant'" json:"service_origin"`
// kind of service. option: internal, third_party
// kind of service. option: internal, third_party, custom
Kind string `gorm:"column:kind;default:'internal'" json:"kind"`
// service bind appID
AppID string `gorm:"column:app_id" json:"app_id"`
@ -335,6 +340,11 @@ func (t *TenantServicesPort) TableName() string {
return "tenant_services_port"
}
// IsOpen checks if the port is opened.
func (t *TenantServicesPort) IsOpen() bool {
return commonutil.BoolValue(t.IsOuterService) || commonutil.BoolValue(t.IsInnerService)
}
//TenantServiceLBMappingPort stream应用端口映射情况
type TenantServiceLBMappingPort struct {
Model

View File

@ -40,6 +40,9 @@ type DiscorveryType string
// DiscorveryTypeEtcd etcd
var DiscorveryTypeEtcd DiscorveryType = "etcd"
// DiscorveryTypeKubernetes kubernetes service
var DiscorveryTypeKubernetes DiscorveryType = "kubernetes"
func (d DiscorveryType) String() string {
return string(d)
}
@ -55,6 +58,9 @@ type ThirdPartySvcDiscoveryCfg struct {
Key string `gorm:"key"`
Username string `gorm:"username"`
Password string `gorm:"password"`
//for kubernetes service
Namespace string `gorm:"namespace"`
ServiceName string `gorm:"serviceName"`
}
// TableName returns table name of ThirdPartySvcDiscoveryCfg.

View File

@ -20,6 +20,8 @@ package dao
import (
"fmt"
gormbulkups "github.com/atcdot/gorm-bulk-upsert"
pkgerr "github.com/pkg/errors"
"reflect"
"strings"
@ -152,3 +154,20 @@ func (t *ThirdPartySvcDiscoveryCfgDaoImpl) GetByServiceID(sid string) (*model.Th
func (t *ThirdPartySvcDiscoveryCfgDaoImpl) DeleteByServiceID(sid string) error {
return t.DB.Where("service_id=?", sid).Delete(&model.ThirdPartySvcDiscoveryCfg{}).Error
}
// DeleteByComponentIDs delete discovery config based on componentIDs.
func (t *ThirdPartySvcDiscoveryCfgDaoImpl) DeleteByComponentIDs(componentIDs []string) error {
return t.DB.Where("service_id in (?)", componentIDs).Delete(&model.ThirdPartySvcDiscoveryCfg{}).Error
}
// CreateOrUpdate3rdSvcDiscoveryCfgInBatch -
func (t *ThirdPartySvcDiscoveryCfgDaoImpl) CreateOrUpdate3rdSvcDiscoveryCfgInBatch(cfgs []*model.ThirdPartySvcDiscoveryCfg) error {
var objects []interface{}
for _, cfg := range cfgs {
objects = append(objects, *cfg)
}
if err := gormbulkups.BulkUpsert(t.DB, objects, 2000); err != nil {
return pkgerr.Wrap(err, "create or update third party svc discovery config in batch")
}
return nil
}

View File

@ -136,7 +136,7 @@ func (a *AppConfigGroupServiceDaoImpl) DeleteByComponentIDs(componentIDs []strin
return a.DB.Where("service_id in (?)", componentIDs).Delete(model.ConfigGroupService{}).Error
}
//DeleteByAppID -
// DeleteByAppID deletes ConfigGroupService based on the given appID.
func (a *AppConfigGroupServiceDaoImpl) DeleteByAppID(appID string) error {
return a.DB.Where("app_id = ?", appID).Delete(model.ConfigGroupService{}).Error
}

View File

@ -410,6 +410,13 @@ func (m *Manager) ApplicationDao() dao.ApplicationDao {
}
}
//ApplicationDaoTransactions -
func (m *Manager) ApplicationDaoTransactions(db *gorm.DB) dao.ApplicationDao {
return &mysqldao.ApplicationDaoImpl{
DB: db,
}
}
// AppConfigGroupDao -
func (m *Manager) AppConfigGroupDao() dao.AppConfigGroupDao {
return &mysqldao.AppConfigGroupDaoImpl{

View File

@ -1,12 +0,0 @@
# 云帮解决用户痛点
---
## 微服务架构落地
“微服务架构”概念自提出以来,深受业界喜爱。各类历史架构纷纷转向微服务架构。企业如何快速解决传统应用服务化,服务治理,服务发现,服务监控等等难题从而获得微服务架构带来的种种优势?云帮,原生的微服务管理平台,无需任何设置,默认提供微服务高效管理服务。也可以通过云帮强大的应用插件体系带来丰富多彩的微服务治理扩展,使企业微服务架构落地完全无障碍。
## 持续集成/持续交付落地
云帮作为以应用为中心的交付平台,支持各类流行开发语言一键部署,自动部署。商业应用对接好雨云市平台,应用提供商可以快速交付生产级应用环境。对于企业自研应用,云帮助你持续构建应用,平滑升级应用,无需人工干预。
## 复杂架构快速上云
云帮平台运行各类应用数据库消息中间件Web应用大数据处理应用人工智能应用等等你的各类型复杂的架构经过简单得改造即可运行于云帮平台即可实现云端扩展。
## 高并发应用快速伸缩
云帮借助Docker,Kubernetes等容器技术作为应用的运行载体赋予能够应用快速伸缩得特性。云帮应用级实时性能分析系统提供数据参考实现应用按需自动伸缩。或者用户指定伸缩策略例如指定高峰时间段实现半自动应用伸缩。
## 海量应用高效便捷管理
云帮作为以应用为中心的跨数据中心应用管理平台一套平台具有海量的计算能力。云帮智能化自动化的资源管理系统让用户无需投入时间精力关注物理资源。海量的应用同一个管理方式。使用一个简单的操作UI,即可对海量的应用实现多元化的控制。

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

View File

@ -1,50 +0,0 @@
# Pod status
## 实例(Pod)详情
**url**
http://xxx/v2/tenants/<tenant_name>/service/<service_alias>/pod/<pod_name>/detail
**响应**
| 字段 | 类型 | 说明 |
|:-----------|:-------|:-----------------------------------------------------|
| name | string | 名字 |
| node | string | 所在节点 |
| start_time | string | 创建时间 |
| status | object | 实例状态, <a href="#podstatus">`status`</a> |
| ip | string | 实例IP地址 |
| containers | array | 实例中的容器, <a href="#containers">`containers`</a> |
| events | array | 事件 , <a href="#events">`events`</a> |
<a id="podstatus">podstatus</a>
| 字段 | 类型 | 说明 |
|:--------|:-------|:---------|
| status | string | 实例状态 |
| reason | string | 原因 |
| message | string | 说明 |
| advice | string | 建议 |
<a id="containers">containers</a>
| 字段 | 类型 | 说明 |
|:---------------|:-------|:--------------------------------------------------|
| image | string | 镜像名 |
| state | string | 状态 |
| reason | string | 原因, 对应上一个字段State, 异常状态的原因 |
| started | string | 原因, 对应上一个字段State, 容器开始正常运行的时间 |
| limit_memory | 待定 | 内存上限 |
| limit_cpu | 待定 | CPU上限 |
| request_memory | 待定 | 内存下限 |
| request_cpu | 待定 | CPU下限 |
<a id="events">events</a>
| 字段 | 类型 | 说明 |
|:--------|:-------|:-----|
| type | string | 类型 |
| reason | string | 原因 |
| age | string | 时间 |
| Message | string | 说明 |

100
go.mod
View File

@ -1,11 +1,10 @@
module github.com/goodrain/rainbond
go 1.13
go 1.15
require (
github.com/DATA-DOG/go-sqlmock v1.3.3
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
cuelang.org/go v0.2.2
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/alecthomas/units v0.0.0-20201120081800-1786d5ef83d4 // indirect
github.com/aliyun/aliyun-oss-go-sdk v2.1.5+incompatible
@ -15,17 +14,15 @@ require (
github.com/beorn7/perks v1.0.1
github.com/bitly/go-simplejson v0.5.0
github.com/bluebreezecf/opentsdb-goclient v0.0.0-20190921120552-796138372df3
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
github.com/cockroachdb/cmux v0.0.0-20170110192607-30d10be49292 // indirect
github.com/containerd/continuity v0.0.0-20200228182428-0f16d7a0959c // indirect
github.com/coreos/etcd v3.3.17+incompatible
github.com/creack/pty v1.1.11 // indirect
github.com/docker/cli v0.0.0-20190711175710-5b38d82aa076
github.com/crossplane/crossplane-runtime v0.10.0
github.com/docker/cli v20.10.3+incompatible
github.com/docker/distribution v2.7.1+incompatible
github.com/docker/docker v20.10.2+incompatible
github.com/docker/go-units v0.4.0
github.com/docker/libcompose v0.4.1-0.20190808084053-143e0f3f1ab9
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
github.com/eapache/channels v1.1.0
github.com/emicklei/go-restful v2.14.2+incompatible
github.com/emicklei/go-restful-swagger12 v0.0.0-20170926063155-7524189396c6
@ -39,17 +36,18 @@ require (
github.com/go-kit/kit v0.10.0
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/go-playground/assert/v2 v2.0.1
github.com/go-playground/validator/v10 v10.2.0
github.com/go-playground/validator/v10 v10.4.1
github.com/go-sql-driver/mysql v1.5.0
github.com/godbus/dbus v4.1.0+incompatible // indirect
github.com/gofrs/flock v0.8.0
github.com/gogo/protobuf v1.3.1
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/mock v1.4.4
github.com/golang/protobuf v1.4.3
github.com/goodrain/rainbond-oam v0.0.0-20210527094216-782b95046e0d
github.com/goodrain/rainbond-oam v0.0.0-20210206075623-511d0796af43
github.com/goodrain/rainbond-operator v1.3.1-0.20210401055914-f8fe4bf89a21
github.com/google/go-cmp v0.5.4 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/gopherjs/gopherjs v0.0.0-20191106031601-ce3c9ade29de // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gorilla/websocket v1.4.2
github.com/gosuri/uitable v0.0.4
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
@ -59,15 +57,14 @@ require (
github.com/json-iterator/go v1.1.10
github.com/kr/pretty v0.2.1 // indirect
github.com/kr/pty v1.1.8
github.com/lib/pq v1.3.0 // indirect
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/mattn/go-runewidth v0.0.6
github.com/mattn/go-shellwords v1.0.10 // indirect
github.com/mitchellh/go-ps v1.0.0
github.com/mitchellh/go-wordwrap v1.0.0
github.com/mitchellh/mapstructure v1.3.3
github.com/ncabatoff/process-exporter v0.7.1
github.com/onsi/gomega v1.10.5 // indirect
github.com/oam-dev/kubevela v1.1.0-alpha.4.0.20210625105426-e176fcfc56f0
github.com/onsi/ginkgo v1.14.1
github.com/onsi/gomega v1.10.3
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/runc v1.0.0-rc91.0.20200707015106-819fcc687efb // indirect
github.com/pborman/uuid v1.2.1
@ -82,80 +79,55 @@ require (
github.com/prometheus/common v0.15.0
github.com/prometheus/node_exporter v1.0.1
github.com/prometheus/procfs v0.2.0
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b // indirect
github.com/shirou/gopsutil v3.21.4+incompatible
github.com/sirupsen/logrus v1.6.0
github.com/smartystreets/assertions v1.0.1 // indirect
github.com/shirou/gopsutil v3.21.3+incompatible
github.com/sirupsen/logrus v1.7.0
github.com/smartystreets/goconvey v1.6.4
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.7.0
github.com/testcontainers/testcontainers-go v0.8.0
github.com/thejerf/suture v3.0.3+incompatible
github.com/tidwall/gjson v1.6.1
github.com/tidwall/gjson v1.6.8
github.com/twinj/uuid v1.0.0
github.com/urfave/cli v1.22.2
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.1.0 // indirect
github.com/yudai/umutex v0.0.0-20150817080136-18216d265c6b
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.16.0 // indirect
golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 // indirect
golang.org/x/mod v0.4.1 // indirect
golang.org/x/net v0.0.0-20210119194325-5f4716e94777
golang.org/x/oauth2 v0.0.0-20210201163806-010130855d6c // indirect
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a // indirect
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
golang.org/x/net v0.0.0-20201224014010-6772e930b67b
golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5 // indirect
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c
golang.org/x/text v0.3.5 // indirect
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324
golang.org/x/tools v0.1.0 // indirect
google.golang.org/appengine v1.6.7
google.golang.org/genproto v0.0.0-20210218151259-fe80b386bf06 // indirect
google.golang.org/grpc v1.35.0
golang.org/x/tools v0.0.0-20201228162255-34cd474b9958 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e // indirect
google.golang.org/grpc v1.33.2
gopkg.in/alecthomas/kingpin.v2 v2.2.6
gopkg.in/src-d/go-git.v4 v4.13.1
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.20.1
k8s.io/apiextensions-apiserver v0.20.1
k8s.io/apimachinery v0.20.1
k8s.io/apiserver v0.20.0
k8s.io/client-go v0.20.1
k8s.io/component-base v0.20.1 // indirect
k8s.io/klog/v2 v2.5.0 // indirect
helm.sh/helm/v3 v3.5.4
k8s.io/api v0.20.4
k8s.io/apiextensions-apiserver v0.20.4
k8s.io/apimachinery v0.20.4
k8s.io/apiserver v0.20.4
k8s.io/cli-runtime v0.20.4
k8s.io/client-go v12.0.0+incompatible
k8s.io/code-generator v0.20.4
sigs.k8s.io/controller-runtime v0.7.0
sigs.k8s.io/yaml v1.2.0
)
// Pinned to kubernetes-1.20.0
replace (
github.com/atcdot/gorm-bulk-upsert => github.com/goodrain/gorm-bulk-upsert v1.0.1-0.20210608013724-7e7870d16357
github.com/coreos/etcd => github.com/coreos/etcd v3.2.31+incompatible
github.com/docker/cli => github.com/docker/cli v0.0.0-20181026144139-6b71e84ec8bf
github.com/docker/docker => github.com/docker/engine v0.0.0-20181106193140-f5749085e9cb
github.com/docker/libcompose => github.com/docker/libcompose v0.4.1-0.20181019154650-213509acef0f
github.com/godbus/dbus/v5 => github.com/godbus/dbus/v5 v5.0.3
github.com/xeipuuv/gojsonschema => github.com/xeipuuv/gojsonschema v0.0.0-20160323030313-93e72a773fad
github.com/docker/distribution => github.com/docker/distribution v0.0.0-20191216044856-a8371794149d
github.com/docker/docker => github.com/docker/docker v17.12.0-ce-rc1.0.20200916142827-bd33bbf0497b+incompatible
github.com/godbus/dbus => github.com/godbus/dbus/v5 v5.0.4
google.golang.org/grpc => google.golang.org/grpc v1.29.0
k8s.io/api => k8s.io/api v0.20.0
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.20.0
k8s.io/apimachinery => k8s.io/apimachinery v0.20.0
k8s.io/apiserver => k8s.io/apiserver v0.20.0
k8s.io/cli-runtime => k8s.io/cli-runtime v0.20.0
k8s.io/client-go => k8s.io/client-go v0.20.0
k8s.io/cloud-provider => k8s.io/cloud-provider v0.20.0
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.20.0
k8s.io/code-generator => k8s.io/code-generator v0.20.0
k8s.io/component-base => k8s.io/component-base v0.20.0
k8s.io/cri-api => k8s.io/cri-api v0.20.0
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.0.0-20191016115521-756ffa5af0bd
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.0.0-20191016112429-9587704a8ad4
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.0.0-20191016114939-2b2b218dc1df
k8s.io/kube-proxy => k8s.io/kube-proxy v0.0.0-20191016114407-2e83b6f20229
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.0.0-20191016114748-65049c67a58b
k8s.io/kubectl => k8s.io/kubectl v0.0.0-20191016120415-2ed914427d51
k8s.io/kubelet => k8s.io/kubelet v0.0.0-20191016114556-7841ed97f1b2
k8s.io/kubernetes => k8s.io/kubernetes v1.16.15
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.0.0-20191016115753-cf0698c3a16b
k8s.io/metrics => k8s.io/metrics v0.0.0-20191016113814-3b1a734dba6e
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.0.0-20191016112829-06bb3c9d77c9
sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.6.2
)

995
go.sum

File diff suppressed because it is too large Load Diff

View File

@ -27,6 +27,7 @@ import (
"github.com/goodrain/rainbond/builder/sources"
k8sutil "github.com/goodrain/rainbond/util/k8s"
"github.com/sirupsen/logrus"
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/kubernetes"
@ -42,6 +43,7 @@ var (
func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(rainbondv1alpha1.AddToScheme(scheme))
utilruntime.Must(apiextensionsv1beta1.AddToScheme(scheme))
}
//K8SClient K8SClient

177
grctl/cluster/cluster.go Normal file
View File

@ -0,0 +1,177 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package cluster
import (
"context"
"fmt"
"strings"
"github.com/docker/distribution/reference"
"github.com/goodrain/rainbond-operator/api/v1alpha1"
"github.com/goodrain/rainbond/grctl/clients"
"github.com/oam-dev/kubevela/pkg/utils/apply"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/yaml"
)
// Cluster represents a rainbond cluster.
type Cluster struct {
rainbondCluster *v1alpha1.RainbondCluster
namespace string
newVersion string
}
// NewCluster creates new cluster.
func NewCluster(namespace, newVersion string) (*Cluster, error) {
rainbondCluster, err := getRainbondCluster(namespace)
if err != nil {
return nil, err
}
return &Cluster{
rainbondCluster: rainbondCluster,
namespace: namespace,
newVersion: newVersion,
}, nil
}
// Upgrade upgrade cluster.
func (c *Cluster) Upgrade() error {
logrus.Infof("upgrade cluster from %s to %s", c.rainbondCluster.Spec.InstallVersion, c.newVersion)
if errs := c.createCrds(); len(errs) > 0 {
return errors.New(strings.Join(errs, ","))
}
if errs := c.updateRbdComponents(); len(errs) > 0 {
return fmt.Errorf("update rainbond components: %s", strings.Join(errs, ","))
}
if err := c.updateCluster(); err != nil {
return err
}
return nil
}
func (c *Cluster) createCrds() []string {
crds := c.getCrds()
if crds == nil {
return nil
}
logrus.Info("start creating crds")
var errs []string
for _, crd := range crds {
if err := c.createCrd(crd); err != nil {
errs = append(errs, err.Error())
}
}
logrus.Info("crds applyed")
return errs
}
func (c *Cluster) createCrd(crdStr string) error {
var crd apiextensionsv1beta1.CustomResourceDefinition
if err := yaml.Unmarshal([]byte(crdStr), &crd); err != nil {
return fmt.Errorf("unmarshal crd: %v", err)
}
applyer := apply.NewAPIApplicator(clients.RainbondKubeClient)
if err := applyer.Apply(context.Background(), &crd); err != nil {
return fmt.Errorf("apply crd: %v", err)
}
return nil
}
func (c *Cluster) getCrds() []string {
for v, versionConfig := range versions {
if strings.Contains(c.newVersion, v) {
return versionConfig.CRDs
}
}
return nil
}
func (c *Cluster) updateRbdComponents() []string {
componentNames := []string{
"rbd-api",
"rbd-chaos",
"rbd-mq",
"rbd-eventlog",
"rbd-gateway",
"rbd-node",
"rbd-resource-proxy",
"rbd-webcli",
"rbd-worker",
}
var errs []string
for _, name := range componentNames {
err := c.updateRbdComponent(name)
if err != nil {
errs = append(errs, err.Error())
}
}
return errs
}
func (c *Cluster) updateRbdComponent(name string) error {
var cpt v1alpha1.RbdComponent
err := clients.RainbondKubeClient.Get(context.Background(),
types.NamespacedName{Namespace: c.namespace, Name: name}, &cpt)
if err != nil {
return fmt.Errorf("get rbdcomponent %s: %v", name, err)
}
ref, err := reference.Parse(cpt.Spec.Image)
if err != nil {
return fmt.Errorf("parse image %s: %v", cpt.Spec.Image, err)
}
repo := ref.(reference.Named)
newImage := repo.Name() + ":" + c.newVersion
oldImageName := cpt.Spec.Image
cpt.Spec.Image = newImage
if err := clients.RainbondKubeClient.Update(context.Background(), &cpt); err != nil {
return fmt.Errorf("update rbdcomponent %s: %v", name, err)
}
logrus.Infof("update rbdcomponent %s \nfrom %s \nto %s", name, oldImageName, newImage)
return nil
}
func (c *Cluster) updateCluster() error {
c.rainbondCluster.Spec.InstallVersion = c.newVersion
if err := clients.RainbondKubeClient.Update(context.Background(), c.rainbondCluster); err != nil {
return fmt.Errorf("update rainbond cluster: %v", err)
}
logrus.Infof("update rainbond cluster to %s", c.newVersion)
return nil
}
func getRainbondCluster(namespace string) (*v1alpha1.RainbondCluster, error) {
var cluster v1alpha1.RainbondCluster
err := clients.RainbondKubeClient.Get(context.Background(),
types.NamespacedName{Namespace: namespace, Name: "rainbondcluster"}, &cluster)
if err != nil {
return nil, fmt.Errorf("get rainbond cluster: %v", err)
}
return &cluster, nil
}

599
grctl/cluster/vergion.go Normal file
View File

@ -0,0 +1,599 @@
package cluster
var versions = map[string]Version{
"5.3.1": {
CRDs: []string{
componentdefinitionsCRD531,
helmappCRD531,
thirdcomponentCRD531,
},
},
}
type Version struct {
CRDs []string
}
var componentdefinitionsCRD531 = `
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.3.0
creationTimestamp: null
name: componentdefinitions.rainbond.io
spec:
additionalPrinterColumns:
- JSONPath: .spec.workload.definition.kind
name: WORKLOAD-KIND
type: string
- JSONPath: .metadata.annotations.definition\.oam\.dev/description
name: DESCRIPTION
type: string
group: rainbond.io
names:
categories:
- oam
kind: ComponentDefinition
listKind: ComponentDefinitionList
plural: componentdefinitions
shortNames:
- comp
singular: componentdefinition
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: ComponentDefinition is the Schema for the componentdefinitions
API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ComponentDefinitionSpec defines the desired state of ComponentDefinition
properties:
childResourceKinds:
description: ChildResourceKinds are the list of GVK of the child resources
this workload generates
items:
description: A ChildResourceKind defines a child Kubernetes resource
kind with a selector
properties:
apiVersion:
description: APIVersion of the child resource
type: string
kind:
description: Kind of the child resource
type: string
selector:
additionalProperties:
type: string
description: Selector to select the child resources that the workload
wants to expose to traits
type: object
required:
- apiVersion
- kind
type: object
type: array
extension:
description: Extension is used for extension needs by OAM platform builders
type: object
x-kubernetes-preserve-unknown-fields: true
podSpecPath:
description: PodSpecPath indicates where/if this workload has K8s podSpec
field if one workload has podSpec, trait can do lot's of assumption
such as port, env, volume fields.
type: string
revisionLabel:
description: RevisionLabel indicates which label for underlying resources(e.g.
pods) of this workload can be used by trait to create resource selectors(e.g.
label selector for pods).
type: string
schematic:
description: Schematic defines the data format and template of the encapsulation
of the workload
properties:
cue:
description: CUE defines the encapsulation in CUE format
properties:
template:
description: Template defines the abstraction template data
of the capability, it will replace the old CUE template in
extension field. Template is a required field if CUE is defined
in Capability Definition.
type: string
required:
- template
type: object
type: object
status:
description: Status defines the custom health policy and status message
for workload
properties:
customStatus:
description: CustomStatus defines the custom status message that
could display to user
type: string
healthPolicy:
description: HealthPolicy defines the health check policy for the
abstraction
type: string
type: object
workload:
description: Workload is a workload type descriptor
properties:
definition:
description: Definition mutually exclusive to workload.type, a embedded
WorkloadDefinition
properties:
apiVersion:
type: string
kind:
type: string
required:
- apiVersion
- kind
type: object
type:
description: Type ref to a WorkloadDefinition via name
type: string
type: object
required:
- workload
type: object
status:
description: ComponentDefinitionStatus is the status of ComponentDefinition
properties:
conditions:
description: Conditions of the resource.
items:
description: A Condition that may apply to a resource.
properties:
lastTransitionTime:
description: LastTransitionTime is the last time this condition
transitioned from one status to another.
format: date-time
type: string
message:
description: A Message containing details about this condition's
last transition from one status to another, if any.
type: string
reason:
description: A Reason for this condition's last transition from
one status to another.
type: string
status:
description: Status of this condition; is it currently True, False,
or Unknown?
type: string
type:
description: Type of this condition. At most one of each condition
type may apply to a resource at any point in time.
type: string
required:
- lastTransitionTime
- reason
- status
- type
type: object
type: array
configMapRef:
description: ConfigMapRef refer to a ConfigMap which contains OpenAPI
V3 JSON schema of Component parameters.
type: string
latestRevision:
description: LatestRevision of the component definition
properties:
name:
type: string
revision:
format: int64
type: integer
revisionHash:
description: RevisionHash record the hash value of the spec of ApplicationRevision
object.
type: string
required:
- name
- revision
type: object
type: object
type: object
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
`
var helmappCRD531 = `
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.3.0
creationTimestamp: null
name: helmapps.rainbond.io
spec:
group: rainbond.io
names:
kind: HelmApp
listKind: HelmAppList
plural: helmapps
singular: helmapp
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: HelmApp -
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: HelmAppSpec defines the desired state of HelmApp
properties:
appStore:
description: The helm app store.
properties:
branch:
description: The branch of a git repo.
type: string
name:
description: The name of app store.
type: string
password:
description: The chart repository password where to locate the requested
chart
type: string
url:
description: The url of helm repo, sholud be a helm native repo
url or a git url.
type: string
username:
description: The chart repository username where to locate the requested
chart
type: string
version:
description: The verision of the helm app store.
type: string
required:
- name
- url
- version
type: object
eid:
type: string
overrides:
description: Overrides will overrides the values in the chart.
items:
type: string
type: array
preStatus:
description: The prerequisite status.
enum:
- NotConfigured
- Configured
type: string
revision:
description: The application revision.
type: integer
templateName:
description: The application name.
type: string
version:
description: The application version.
type: string
required:
- appStore
- eid
- templateName
- version
type: object
status:
description: HelmAppStatus defines the observed state of HelmApp
properties:
conditions:
description: Current state of helm app.
items:
description: HelmAppCondition contains details for the current condition
of this helm application.
properties:
lastTransitionTime:
description: Last time the condition transitioned from one status
to another.
format: date-time
type: string
message:
description: Human-readable message indicating details about last
transition.
type: string
reason:
description: Unique, one-word, CamelCase reason for the condition's
last transition.
type: string
status:
description: 'Status is the status of the condition. Can be True,
False, Unknown. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions'
type: string
type:
description: Type is the type of the condition.
type: string
required:
- status
- type
type: object
type: array
currentVersion:
description: The version infect.
type: string
overrides:
description: Overrides in effect.
items:
type: string
type: array
phase:
description: The phase of the helm app.
type: string
status:
description: The status of helm app.
type: string
required:
- phase
- status
type: object
type: object
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
`
var thirdcomponentCRD531 = `
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.3.0
creationTimestamp: null
name: thirdcomponents.rainbond.io
spec:
group: rainbond.io
names:
kind: ThirdComponent
listKind: ThirdComponentList
plural: thirdcomponents
singular: thirdcomponent
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: HelmApp -
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
properties:
endpointSource:
description: endpoint source config
properties:
endpoints:
items:
properties:
address:
description: The address including the port number.
type: string
clientSecret:
description: Specify a private certificate when the protocol
is HTTPS
type: string
protocol:
description: 'Address protocols, including: HTTP, TCP, UDP,
HTTPS'
type: string
required:
- address
type: object
type: array
kubernetesService:
properties:
name:
type: string
namespace:
description: If not specified, the namespace is the namespace
of the current resource
type: string
required:
- name
type: object
type: object
ports:
description: component regist ports
items:
description: ComponentPort component port define
properties:
name:
type: string
openInner:
type: boolean
openOuter:
type: boolean
port:
type: integer
required:
- name
- openInner
- openOuter
- port
type: object
type: array
probe:
description: health check probe
properties:
httpGet:
description: HTTPGet specifies the http request to perform.
properties:
httpHeaders:
description: Custom headers to set in the request. HTTP allows
repeated headers.
items:
description: HTTPHeader describes a custom header to be used
in HTTP probes
properties:
name:
description: The header field name
type: string
value:
description: The header field value
type: string
required:
- name
- value
type: object
type: array
path:
description: Path to access on the HTTP server.
type: string
type: object
tcpSocket:
description: 'TCPSocket specifies an action involving a TCP port.
TCP hooks not yet supported TODO: implement a realistic TCP lifecycle
hook'
type: object
type: object
required:
- endpointSource
- ports
type: object
status:
properties:
endpoints:
items:
description: ThirdComponentEndpointStatus endpoint status
properties:
address:
description: The address including the port number.
type: string
reason:
description: Reason probe not passed reason
type: string
servicePort:
description: ServicePort if address build from kubernetes endpoint,
The corresponding service port
type: integer
status:
description: Status endpoint status
type: string
targetRef:
description: Reference to object providing the endpoint.
properties:
apiVersion:
description: API version of the referent.
type: string
fieldPath:
description: 'If referring to a piece of an object instead
of an entire object, this string should contain a valid
JSON/Go field access statement, such as desiredState.manifest.containers[2].
For example, if the object reference is to a container within
a pod, this would take on a value like: "spec.containers{name}"
(where "name" refers to the name of the container that triggered
the event) or if no container name is specified "spec.containers[2]"
(container with index 2 in this pod). This syntax is chosen
only to have some well-defined way of referencing a part
of an object. TODO: this design is not final and this field
is subject to change in the future.'
type: string
kind:
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
type: string
namespace:
description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
type: string
resourceVersion:
description: 'Specific resourceVersion to which this reference
is made, if any. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency'
type: string
uid:
description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
type: string
type: object
required:
- address
- status
type: object
type: array
phase:
type: string
reason:
type: string
required:
- endpoints
- phase
type: object
type: object
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
`

View File

@ -28,6 +28,7 @@ import (
rainbondv1alpha1 "github.com/goodrain/rainbond-operator/api/v1alpha1"
"github.com/goodrain/rainbond/grctl/clients"
"github.com/goodrain/rainbond/grctl/cluster"
"github.com/goodrain/rainbond/node/nodem/client"
"github.com/goodrain/rainbond/util/termtables"
"github.com/gosuri/uitable"
@ -42,7 +43,7 @@ func NewCmdCluster() cli.Command {
Name: "cluster",
Usage: "show curren cluster datacenter info",
Subcommands: []cli.Command{
cli.Command{
{
Name: "config",
Usage: "prints the current cluster configuration",
Flags: []cli.Flag{
@ -57,6 +58,30 @@ func NewCmdCluster() cli.Command {
return printConfig(c)
},
},
{
Name: "upgrade",
Usage: "upgrade cluster",
Flags: []cli.Flag{
cli.StringFlag{
Name: "namespace, ns",
Usage: "rainbond default namespace",
Value: "rbd-system",
},
cli.StringFlag{
Name: "new-version",
Usage: "the new version of rainbond cluster",
Required: true,
},
},
Action: func(c *cli.Context) error {
Common(c)
cluster, err := cluster.NewCluster(c.String("namespace"), c.String("new-version"))
if err != nil {
return err
}
return cluster.Upgrade()
},
},
},
Flags: []cli.Flag{
cli.StringFlag{

View File

@ -1,5 +1,6 @@
FROM goodrainapps/alpine:3.4
ARG RELEASE_DESC
COPY rainbond-worker /run/rainbond-worker
COPY entrypoint.sh /run/entrypoint.sh
RUN chmod 655 /run/rainbond-worker

View File

@ -0,0 +1,14 @@
## How to use codegen
```sh
./hack/k8s/codegen/update-generated.sh
```
It should print:
```
Generating deepcopy funcs
Generating clientset for etcd:v1beta2 at github.com/coreos/etcd-operator/pkg/generated/clientset
Generating listers for etcd:v1beta2 at github.com/coreos/etcd-operator/pkg/generated/listers
Generating informers for etcd:v1beta2 at github.com/coreos/etcd-operator/pkg/generated/informers
```

View File

@ -1,5 +1,5 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2017 Goodrain Co., Ltd.
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -15,9 +15,3 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package worker
// MaintainStatus
type MaintainStatus struct {
}

View File

@ -0,0 +1,4 @@
// +build tools
package tools
import _ "k8s.io/code-generator"

View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
vendor/k8s.io/code-generator/generate-groups.sh \
"defaulter,client,lister,informer" \
"github.com/goodrain/rainbond/pkg/generated" \
"github.com/goodrain/rainbond/pkg/apis" \
"rainbond:v1alpha1" \
--go-header-file "./hack/k8s/codegen/boilerplate.go.txt" \
$@

View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
if ! output=$(./hack/k8s/codegen/update-generated.sh --verify-only 2>&1); then
echo "FAILURE: verification of codegen failed:"
echo "${output}"
exit 1
fi
echo "Verified generated code ==="

View File

@ -1,5 +1,5 @@
#! /bin/bash
export VERSION=v5.3.0-release
export VERSION=v5.3.1-release
export BUILD_IMAGE_BASE_NAME=registry.cn-hangzhou.aliyuncs.com/goodrain
./release.sh all push

10
localcheck.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
TARGET_BRANCH=${TARGET_BRANCH:-'master'}
CHANGED_MARKDOWN_FILES=$(git diff --name-only ${TARGET_BRANCH} | grep .go)
for file in ${CHANGED_MARKDOWN_FILES}; do
echo "golint ${file}"
golint -set_exit_status=true ${file} || exit 1
done
echo "code golint check success"

View File

@ -0,0 +1,6 @@
// Package rainbond contains rainbond API versions.
//
// This file ensures Go source parsers acknowledge the rainbond package
// and any child packages. It can be removed if any other Go source files are
// added to this package.
package rainbond

View File

@ -0,0 +1,115 @@
/*
Copyright 2021 The KubeVela Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
// Code from kubevela, Used to generate the SDK.
*/
package v1alpha1
import (
runtimev1alpha1 "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"github.com/oam-dev/kubevela/apis/core.oam.dev/common"
)
// ComponentDefinitionSpec defines the desired state of ComponentDefinition
type ComponentDefinitionSpec struct {
// Workload is a workload type descriptor
Workload common.WorkloadTypeDescriptor `json:"workload"`
// ChildResourceKinds are the list of GVK of the child resources this workload generates
ChildResourceKinds []common.ChildResourceKind `json:"childResourceKinds,omitempty"`
// RevisionLabel indicates which label for underlying resources(e.g. pods) of this workload
// can be used by trait to create resource selectors(e.g. label selector for pods).
// +optional
RevisionLabel string `json:"revisionLabel,omitempty"`
// PodSpecPath indicates where/if this workload has K8s podSpec field
// if one workload has podSpec, trait can do lot's of assumption such as port, env, volume fields.
// +optional
PodSpecPath string `json:"podSpecPath,omitempty"`
// Status defines the custom health policy and status message for workload
// +optional
Status *common.Status `json:"status,omitempty"`
// Schematic defines the data format and template of the encapsulation of the workload
// +optional
Schematic *Schematic `json:"schematic,omitempty"`
// Extension is used for extension needs by OAM platform builders
// +optional
// +kubebuilder:pruning:PreserveUnknownFields
Extension *runtime.RawExtension `json:"extension,omitempty"`
}
// Schematic defines the encapsulation of this capability(workload/trait/scope),
// the encapsulation can be defined in different ways, e.g. CUE/HCL(terraform)/KUBE(K8s Object)/HELM, etc...
type Schematic struct {
CUE *common.CUE `json:"cue,omitempty"`
}
// ComponentDefinitionStatus is the status of ComponentDefinition
type ComponentDefinitionStatus struct {
// ConditionedStatus reflects the observed status of a resource
runtimev1alpha1.ConditionedStatus `json:",inline"`
// ConfigMapRef refer to a ConfigMap which contains OpenAPI V3 JSON schema of Component parameters.
ConfigMapRef string `json:"configMapRef,omitempty"`
// LatestRevision of the component definition
// +optional
LatestRevision *common.Revision `json:"latestRevision,omitempty"`
}
// +kubebuilder:object:root=true
// ComponentDefinition is the Schema for the componentdefinitions API
// +genclient
// +kubebuilder:resource:scope=Namespaced,categories={oam},shortName=comp
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="WORKLOAD-KIND",type=string,JSONPath=".spec.workload.definition.kind"
// +kubebuilder:printcolumn:name="DESCRIPTION",type=string,JSONPath=".metadata.annotations.definition\\.oam\\.dev/description"
type ComponentDefinition struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ComponentDefinitionSpec `json:"spec,omitempty"`
Status ComponentDefinitionStatus `json:"status,omitempty"`
}
// SetConditions set condition for ComponentDefinition
func (cd *ComponentDefinition) SetConditions(c ...runtimev1alpha1.Condition) {
cd.Status.SetConditions(c...)
}
// GetCondition gets condition from ComponentDefinition
func (cd *ComponentDefinition) GetCondition(conditionType runtimev1alpha1.ConditionType) runtimev1alpha1.Condition {
return cd.Status.GetCondition(conditionType)
}
// +kubebuilder:object:root=true
// ComponentDefinitionList contains a list of ComponentDefinition
type ComponentDefinitionList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ComponentDefinition `json:"items"`
}
func init() {
SchemeBuilder.Register(&ComponentDefinition{}, &ComponentDefinitionList{})
}

View File

@ -0,0 +1,4 @@
// Package v1alpha1 contains API Schema definitions for the rainbond v1alpha1 API group
// +k8s:deepcopy-gen=package,register
// +groupName=rainbond.io
package v1alpha1

View File

@ -0,0 +1,111 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2021-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package v1alpha1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// NewHelmAppCondition creates a new HelmApp condition.
func NewHelmAppCondition(condType HelmAppConditionType, status corev1.ConditionStatus, reason, message string) *HelmAppCondition {
return &HelmAppCondition{
Type: condType,
Status: status,
LastTransitionTime: metav1.Now(),
Reason: reason,
Message: message,
}
}
// GetCondition returns a HelmApp condition based on the given type.
func (in *HelmAppStatus) GetCondition(t HelmAppConditionType) (int, *HelmAppCondition) {
for i, c := range in.Conditions {
if t == c.Type {
return i, &c
}
}
return -1, nil
}
// IsConditionTrue checks if the condition is ready or not based on the given condition type.
func (in *HelmAppStatus) IsConditionTrue(t HelmAppConditionType) bool {
idx, condition := in.GetCondition(t)
return idx != -1 && condition.Status == corev1.ConditionTrue
}
// SetCondition setups the given HelmApp condition.
func (in *HelmAppStatus) SetCondition(c HelmAppCondition) {
pos, cp := in.GetCondition(c.Type)
if cp != nil &&
cp.Status == c.Status && cp.Reason == c.Reason && cp.Message == c.Message {
return
}
if cp != nil {
in.Conditions[pos] = c
} else {
in.Conditions = append(in.Conditions, c)
}
}
// UpdateCondition updates existing HelmApp condition or creates a new
// one. Sets LastTransitionTime to now if the status has changed.
// Returns true if HelmApp condition has changed or has been added.
func (in *HelmAppStatus) UpdateCondition(condition *HelmAppCondition) bool {
condition.LastTransitionTime = metav1.Now()
// Try to find this HelmApp condition.
conditionIndex, oldCondition := in.GetCondition(condition.Type)
if oldCondition == nil {
// We are adding new HelmApp condition.
in.Conditions = append(in.Conditions, *condition)
return true
}
// We are updating an existing condition, so we need to check if it has changed.
if condition.Status == oldCondition.Status {
condition.LastTransitionTime = oldCondition.LastTransitionTime
}
isEqual := condition.Status == oldCondition.Status &&
condition.Reason == oldCondition.Reason &&
condition.Message == oldCondition.Message &&
condition.LastTransitionTime.Equal(&oldCondition.LastTransitionTime)
in.Conditions[conditionIndex] = *condition
// Return true if one of the fields have changed.
return !isEqual
}
func (in *HelmAppStatus) UpdateConditionStatus(conditionType HelmAppConditionType, conditionStatus corev1.ConditionStatus) {
_, condition := in.GetCondition(conditionType)
if condition != nil {
condition.Status = conditionStatus
if conditionStatus == corev1.ConditionTrue {
condition.Reason = ""
condition.Message = ""
}
in.UpdateCondition(condition)
return
}
condition = NewHelmAppCondition(conditionType, conditionStatus, "", "")
in.UpdateCondition(condition)
}

View File

@ -0,0 +1,239 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2021-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package v1alpha1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// The phase of helm app
type HelmAppStatusPhase string
// The phase of helm app
const (
HelmAppStatusPhaseInitialing HelmAppStatusPhase = "initialing"
HelmAppStatusPhaseDetecting HelmAppStatusPhase = "detecting"
HelmAppStatusPhaseConfiguring HelmAppStatusPhase = "configuring"
HelmAppStatusPhaseInstalling HelmAppStatusPhase = "installing"
HelmAppStatusPhaseInstalled HelmAppStatusPhase = "installed"
)
// The status of helm app
// Except for `not-configured`, the other statues are the native statues of helm.
type HelmAppStatusStatus string
// The status of helm app
const (
HelmAppStatusNotConfigured HelmAppStatusStatus = "not-configured"
// HelmAppStatusunknown indicates that a release is in an uncertain state.
HelmAppStatusunknown HelmAppStatusStatus = "unknown"
// HelmAppStatusDeployed indicates that the release has been pushed to Kubernetes.
HelmAppStatusDeployed HelmAppStatusStatus = "deployed"
// HelmAppStatusUninstalled indicates that a release has been uninstalled from Kubernetes.
HelmAppStatusUninstalled HelmAppStatusStatus = "uninstalled"
// HelmAppStatusSuperseded indicates that this release object is outdated and a newer one exists.
HelmAppStatusSuperseded HelmAppStatusStatus = "superseded"
// HelmAppStatusFailed indicates that the release was not successfully deployed.
HelmAppStatusFailed HelmAppStatusStatus = "failed"
// HelmAppStatusUninstalling indicates that a uninstall operation is underway.
HelmAppStatusUninstalling HelmAppStatusStatus = "uninstalling"
// HelmAppStatusPendingInstall indicates that an install operation is underway.
HelmAppStatusPendingInstall HelmAppStatusStatus = "pending-install"
// HelmAppStatusPendingUpgrade indicates that an upgrade operation is underway.
HelmAppStatusPendingUpgrade HelmAppStatusStatus = "pending-upgrade"
// HelmAppStatusPendingRollback indicates that an rollback operation is underway.
HelmAppStatusPendingRollback HelmAppStatusStatus = "pending-rollback"
)
// RbdComponentConditionType is a valid value for RbdComponentCondition.Type
type HelmAppConditionType string
// These are valid conditions of helm app.
const (
// HelmAppRepoReady indicates whether the helm repository is ready.
HelmAppRepoReady HelmAppConditionType = "RepoReady"
// HelmAppChartReady indicates whether the chart is ready.
HelmAppChartReady HelmAppConditionType = "ChartReady"
// HelmAppPreInstalled indicates whether the helm app has been pre installed.
HelmAppPreInstalled HelmAppConditionType = "PreInstalled"
// HelmAppInstalled indicates whether the helm app has been installed.
HelmAppInstalled HelmAppConditionType = "HelmAppInstalled"
)
// HelmAppPreStatus is a valid value for the PreStatus of HelmApp.
type HelmAppPreStatus string
// HelmAppPreStatus
const (
HelmAppPreStatusNotConfigured HelmAppPreStatus = "NotConfigured"
HelmAppPreStatusConfigured HelmAppPreStatus = "Configured"
)
// HelmAppCondition contains details for the current condition of this helm application.
type HelmAppCondition struct {
// Type is the type of the condition.
Type HelmAppConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=PodConditionType"`
// Status is the status of the condition.
// Can be True, False, Unknown.
// More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions
Status corev1.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=ConditionStatus"`
// Last time the condition transitioned from one status to another.
// +optional
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,4,opt,name=lastTransitionTime"`
// Unique, one-word, CamelCase reason for the condition's last transition.
// +optional
Reason string `json:"reason,omitempty" protobuf:"bytes,5,opt,name=reason"`
// Human-readable message indicating details about last transition.
// +optional
Message string `json:"message,omitempty" protobuf:"bytes,6,opt,name=message"`
}
// HelmAppSpec defines the desired state of HelmApp
type HelmAppSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
EID string `json:"eid"`
// The prerequisite status.
// +kubebuilder:validation:Enum=NotConfigured;Configured
PreStatus HelmAppPreStatus `json:"preStatus,omitempty"`
// The application name.
TemplateName string `json:"templateName"`
// The application version.
Version string `json:"version"`
// The application revision.
Revision int `json:"revision,omitempty"`
// The helm app store.
AppStore *HelmAppStore `json:"appStore"`
// Overrides will overrides the values in the chart.
Overrides []string `json:"overrides,omitempty"`
}
// FullName returns the full name of the app store.
func (in *HelmAppSpec) FullName() string {
if in.AppStore == nil {
return ""
}
return in.EID + "-" + in.AppStore.Name
}
// HelmAppStore represents a helm repo.
type HelmAppStore struct {
// The verision of the helm app store.
Version string `json:"version"`
// The name of app store.
Name string `json:"name"`
// The url of helm repo, sholud be a helm native repo url or a git url.
URL string `json:"url"`
// The branch of a git repo.
Branch string `json:"branch,omitempty"`
// The chart repository username where to locate the requested chart
Username string `json:"username,omitempty"`
// The chart repository password where to locate the requested chart
Password string `json:"password,omitempty"`
}
// HelmAppStatus defines the observed state of HelmApp
type HelmAppStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
// The status of helm app.
Status HelmAppStatusStatus `json:"status"`
// The phase of the helm app.
Phase HelmAppStatusPhase `json:"phase"`
// Current state of helm app.
Conditions []HelmAppCondition `json:"conditions,omitempty"`
// The version infect.
CurrentVersion string `json:"currentVersion,omitempty"`
// Overrides in effect.
Overrides []string `json:"overrides,omitempty"`
}
// +genclient
// +kubebuilder:object:root=true
// HelmApp -
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=helmapps,scope=Namespaced
type HelmApp struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec HelmAppSpec `json:"spec,omitempty"`
Status HelmAppStatus `json:"status,omitempty"`
}
// OverridesEqual tells whether overrides in spec and status contain the same elements.
func (in *HelmApp) OverridesEqual() bool {
if len(in.Spec.Overrides) != len(in.Status.Overrides) {
return false
}
candidates := make(map[string]struct{})
for _, o := range in.Spec.Overrides {
candidates[o] = struct{}{}
}
for _, o := range in.Status.Overrides {
_, ok := candidates[o]
if !ok {
return false
}
}
return true
}
// +kubebuilder:object:root=true
// HelmAppList contains a list of HelmApp
type HelmAppList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []HelmApp `json:"items"`
}
func init() {
SchemeBuilder.Register(&HelmApp{}, &HelmAppList{})
}

View File

@ -0,0 +1,26 @@
// NOTE: Boilerplate only. Ignore this file.
// Package v1alpha1 contains API Schema definitions for the rainbond v1alpha1 API group
// +k8s:deepcopy-gen=package,register
// +groupName=rainbond.io
package v1alpha1
import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)
var (
// SchemeGroupVersion is group version used to register these objects
SchemeGroupVersion = schema.GroupVersion{Group: "rainbond.io", Version: "v1alpha1"}
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
// AddToScheme adds all registered types to s.
AddToScheme = SchemeBuilder.AddToScheme
)
// Resource gets an EtcdCluster GroupResource for a specified resource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}

View File

@ -0,0 +1,208 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2021-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package v1alpha1
import (
"fmt"
"net"
"strconv"
"strings"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func init() {
SchemeBuilder.Register(&ThirdComponent{}, &ThirdComponentList{})
}
// +genclient
// +kubebuilder:object:root=true
// HelmApp -
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=thirdcomponents,scope=Namespaced
type ThirdComponent struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ThirdComponentSpec `json:"spec,omitempty"`
Status ThirdComponentStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// ThirdComponentList contains a list of ThirdComponent
type ThirdComponentList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ThirdComponent `json:"items"`
}
type ThirdComponentSpec struct {
// health check probe
// +optional
Probe *HealthProbe `json:"probe,omitempty"`
// component regist ports
Ports []*ComponentPort `json:"ports"`
// endpoint source config
EndpointSource ThirdComponentEndpointSource `json:"endpointSource"`
}
type ThirdComponentEndpointSource struct {
StaticEndpoints []*ThirdComponentEndpoint `json:"endpoints,omitempty"`
KubernetesService *KubernetesServiceSource `json:"kubernetesService,omitempty"`
//other source
// NacosSource
// EurekaSource
// ConsulSource
// CustomAPISource
}
type ThirdComponentEndpoint struct {
// The address including the port number.
Address string `json:"address"`
// Address protocols, including: HTTP, TCP, UDP, HTTPS
// +optional
Protocol string `json:"protocol,omitempty"`
// Specify a private certificate when the protocol is HTTPS
// +optional
ClentSecret string `json:"clientSecret,omitempty"`
}
type KubernetesServiceSource struct {
// If not specified, the namespace is the namespace of the current resource
// +optional
Namespace string `json:"namespace,omitempty"`
Name string `json:"name"`
}
type HealthProbe struct {
// HTTPGet specifies the http request to perform.
// +optional
HTTPGet *HTTPGetAction `json:"httpGet,omitempty"`
// TCPSocket specifies an action involving a TCP port.
// TCP hooks not yet supported
// TODO: implement a realistic TCP lifecycle hook
// +optional
TCPSocket *TCPSocketAction `json:"tcpSocket,omitempty"`
}
//ComponentPort component port define
type ComponentPort struct {
Name string `json:"name"`
Port int `json:"port"`
OpenInner bool `json:"openInner"`
OpenOuter bool `json:"openOuter"`
}
//TCPSocketAction enable tcp check
type TCPSocketAction struct {
}
//HTTPGetAction enable http check
type HTTPGetAction struct {
// Path to access on the HTTP server.
// +optional
Path string `json:"path,omitempty"`
// Custom headers to set in the request. HTTP allows repeated headers.
// +optional
HTTPHeaders []HTTPHeader `json:"httpHeaders,omitempty"`
}
// HTTPHeader describes a custom header to be used in HTTP probes
type HTTPHeader struct {
// The header field name
Name string `json:"name"`
// The header field value
Value string `json:"value"`
}
type ComponentPhase string
// These are the valid statuses of pods.
const (
// ComponentPending means the component has been accepted by the system, but one or more of the service or endpoint
// can not create success
ComponentPending ComponentPhase = "Pending"
// ComponentRunning means the the service and endpoints create success.
ComponentRunning ComponentPhase = "Running"
// ComponentFailed means that found endpoint from source failure
ComponentFailed ComponentPhase = "Failed"
)
type ThirdComponentStatus struct {
Phase ComponentPhase `json:"phase"`
Reason string `json:"reason,omitempty"`
Endpoints []*ThirdComponentEndpointStatus `json:"endpoints"`
}
type EndpointStatus string
const (
//EndpointReady If a probe is configured, it means the probe has passed.
EndpointReady EndpointStatus = "Ready"
//EndpointNotReady it means the probe not passed.
EndpointNotReady EndpointStatus = "NotReady"
)
type EndpointAddress string
func (e EndpointAddress) GetIP() string {
info := strings.Split(string(e), ":")
if len(info) == 2 {
return info[0]
}
return ""
}
func (e EndpointAddress) GetPort() int {
info := strings.Split(string(e), ":")
if len(info) == 2 {
port, _ := strconv.Atoi(info[1])
return port
}
return 0
}
func NewEndpointAddress(host string, port int) *EndpointAddress {
if net.ParseIP(host) == nil {
return nil
}
if port < 0 || port > 65533 {
return nil
}
ea := EndpointAddress(fmt.Sprintf("%s:%d", host, port))
return &ea
}
//ThirdComponentEndpointStatus endpoint status
type ThirdComponentEndpointStatus struct {
// The address including the port number.
Address EndpointAddress `json:"address"`
// Reference to object providing the endpoint.
// +optional
TargetRef *v1.ObjectReference `json:"targetRef,omitempty" protobuf:"bytes,2,opt,name=targetRef"`
// ServicePort if address build from kubernetes endpoint, The corresponding service port
ServicePort int `json:"servicePort,omitempty"`
//Status endpoint status
Status EndpointStatus `json:"status"`
//Reason probe not passed reason
Reason string `json:"reason,omitempty"`
}

View File

@ -0,0 +1,597 @@
// +build !ignore_autogenerated
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by controller-gen. DO NOT EDIT.
package v1alpha1
import (
"github.com/oam-dev/kubevela/apis/core.oam.dev/common"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ComponentDefinition) DeepCopyInto(out *ComponentDefinition) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentDefinition.
func (in *ComponentDefinition) DeepCopy() *ComponentDefinition {
if in == nil {
return nil
}
out := new(ComponentDefinition)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ComponentDefinition) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ComponentDefinitionList) DeepCopyInto(out *ComponentDefinitionList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ComponentDefinition, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentDefinitionList.
func (in *ComponentDefinitionList) DeepCopy() *ComponentDefinitionList {
if in == nil {
return nil
}
out := new(ComponentDefinitionList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ComponentDefinitionList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ComponentDefinitionSpec) DeepCopyInto(out *ComponentDefinitionSpec) {
*out = *in
out.Workload = in.Workload
if in.ChildResourceKinds != nil {
in, out := &in.ChildResourceKinds, &out.ChildResourceKinds
*out = make([]common.ChildResourceKind, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.Status != nil {
in, out := &in.Status, &out.Status
*out = new(common.Status)
**out = **in
}
if in.Schematic != nil {
in, out := &in.Schematic, &out.Schematic
*out = new(Schematic)
(*in).DeepCopyInto(*out)
}
if in.Extension != nil {
in, out := &in.Extension, &out.Extension
*out = new(runtime.RawExtension)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentDefinitionSpec.
func (in *ComponentDefinitionSpec) DeepCopy() *ComponentDefinitionSpec {
if in == nil {
return nil
}
out := new(ComponentDefinitionSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ComponentDefinitionStatus) DeepCopyInto(out *ComponentDefinitionStatus) {
*out = *in
in.ConditionedStatus.DeepCopyInto(&out.ConditionedStatus)
if in.LatestRevision != nil {
in, out := &in.LatestRevision, &out.LatestRevision
*out = new(common.Revision)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentDefinitionStatus.
func (in *ComponentDefinitionStatus) DeepCopy() *ComponentDefinitionStatus {
if in == nil {
return nil
}
out := new(ComponentDefinitionStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ComponentPort) DeepCopyInto(out *ComponentPort) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentPort.
func (in *ComponentPort) DeepCopy() *ComponentPort {
if in == nil {
return nil
}
out := new(ComponentPort)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HTTPGetAction) DeepCopyInto(out *HTTPGetAction) {
*out = *in
if in.HTTPHeaders != nil {
in, out := &in.HTTPHeaders, &out.HTTPHeaders
*out = make([]HTTPHeader, len(*in))
copy(*out, *in)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPGetAction.
func (in *HTTPGetAction) DeepCopy() *HTTPGetAction {
if in == nil {
return nil
}
out := new(HTTPGetAction)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HTTPHeader) DeepCopyInto(out *HTTPHeader) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPHeader.
func (in *HTTPHeader) DeepCopy() *HTTPHeader {
if in == nil {
return nil
}
out := new(HTTPHeader)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HealthProbe) DeepCopyInto(out *HealthProbe) {
*out = *in
if in.HTTPGet != nil {
in, out := &in.HTTPGet, &out.HTTPGet
*out = new(HTTPGetAction)
(*in).DeepCopyInto(*out)
}
if in.TCPSocket != nil {
in, out := &in.TCPSocket, &out.TCPSocket
*out = new(TCPSocketAction)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HealthProbe.
func (in *HealthProbe) DeepCopy() *HealthProbe {
if in == nil {
return nil
}
out := new(HealthProbe)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HelmApp) DeepCopyInto(out *HelmApp) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmApp.
func (in *HelmApp) DeepCopy() *HelmApp {
if in == nil {
return nil
}
out := new(HelmApp)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *HelmApp) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HelmAppCondition) DeepCopyInto(out *HelmAppCondition) {
*out = *in
in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmAppCondition.
func (in *HelmAppCondition) DeepCopy() *HelmAppCondition {
if in == nil {
return nil
}
out := new(HelmAppCondition)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HelmAppList) DeepCopyInto(out *HelmAppList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]HelmApp, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmAppList.
func (in *HelmAppList) DeepCopy() *HelmAppList {
if in == nil {
return nil
}
out := new(HelmAppList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *HelmAppList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HelmAppSpec) DeepCopyInto(out *HelmAppSpec) {
*out = *in
if in.AppStore != nil {
in, out := &in.AppStore, &out.AppStore
*out = new(HelmAppStore)
**out = **in
}
if in.Overrides != nil {
in, out := &in.Overrides, &out.Overrides
*out = make([]string, len(*in))
copy(*out, *in)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmAppSpec.
func (in *HelmAppSpec) DeepCopy() *HelmAppSpec {
if in == nil {
return nil
}
out := new(HelmAppSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HelmAppStatus) DeepCopyInto(out *HelmAppStatus) {
*out = *in
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]HelmAppCondition, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.Overrides != nil {
in, out := &in.Overrides, &out.Overrides
*out = make([]string, len(*in))
copy(*out, *in)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmAppStatus.
func (in *HelmAppStatus) DeepCopy() *HelmAppStatus {
if in == nil {
return nil
}
out := new(HelmAppStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HelmAppStore) DeepCopyInto(out *HelmAppStore) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmAppStore.
func (in *HelmAppStore) DeepCopy() *HelmAppStore {
if in == nil {
return nil
}
out := new(HelmAppStore)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *KubernetesServiceSource) DeepCopyInto(out *KubernetesServiceSource) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesServiceSource.
func (in *KubernetesServiceSource) DeepCopy() *KubernetesServiceSource {
if in == nil {
return nil
}
out := new(KubernetesServiceSource)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Schematic) DeepCopyInto(out *Schematic) {
*out = *in
if in.CUE != nil {
in, out := &in.CUE, &out.CUE
*out = new(common.CUE)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Schematic.
func (in *Schematic) DeepCopy() *Schematic {
if in == nil {
return nil
}
out := new(Schematic)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TCPSocketAction) DeepCopyInto(out *TCPSocketAction) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TCPSocketAction.
func (in *TCPSocketAction) DeepCopy() *TCPSocketAction {
if in == nil {
return nil
}
out := new(TCPSocketAction)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ThirdComponent) DeepCopyInto(out *ThirdComponent) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ThirdComponent.
func (in *ThirdComponent) DeepCopy() *ThirdComponent {
if in == nil {
return nil
}
out := new(ThirdComponent)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ThirdComponent) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ThirdComponentEndpoint) DeepCopyInto(out *ThirdComponentEndpoint) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ThirdComponentEndpoint.
func (in *ThirdComponentEndpoint) DeepCopy() *ThirdComponentEndpoint {
if in == nil {
return nil
}
out := new(ThirdComponentEndpoint)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ThirdComponentEndpointSource) DeepCopyInto(out *ThirdComponentEndpointSource) {
*out = *in
if in.StaticEndpoints != nil {
in, out := &in.StaticEndpoints, &out.StaticEndpoints
*out = make([]*ThirdComponentEndpoint, len(*in))
for i := range *in {
if (*in)[i] != nil {
in, out := &(*in)[i], &(*out)[i]
*out = new(ThirdComponentEndpoint)
**out = **in
}
}
}
if in.KubernetesService != nil {
in, out := &in.KubernetesService, &out.KubernetesService
*out = new(KubernetesServiceSource)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ThirdComponentEndpointSource.
func (in *ThirdComponentEndpointSource) DeepCopy() *ThirdComponentEndpointSource {
if in == nil {
return nil
}
out := new(ThirdComponentEndpointSource)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ThirdComponentEndpointStatus) DeepCopyInto(out *ThirdComponentEndpointStatus) {
*out = *in
if in.TargetRef != nil {
in, out := &in.TargetRef, &out.TargetRef
*out = new(v1.ObjectReference)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ThirdComponentEndpointStatus.
func (in *ThirdComponentEndpointStatus) DeepCopy() *ThirdComponentEndpointStatus {
if in == nil {
return nil
}
out := new(ThirdComponentEndpointStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ThirdComponentList) DeepCopyInto(out *ThirdComponentList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ThirdComponent, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ThirdComponentList.
func (in *ThirdComponentList) DeepCopy() *ThirdComponentList {
if in == nil {
return nil
}
out := new(ThirdComponentList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ThirdComponentList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ThirdComponentSpec) DeepCopyInto(out *ThirdComponentSpec) {
*out = *in
if in.Probe != nil {
in, out := &in.Probe, &out.Probe
*out = new(HealthProbe)
(*in).DeepCopyInto(*out)
}
if in.Ports != nil {
in, out := &in.Ports, &out.Ports
*out = make([]*ComponentPort, len(*in))
for i := range *in {
if (*in)[i] != nil {
in, out := &(*in)[i], &(*out)[i]
*out = new(ComponentPort)
**out = **in
}
}
}
in.EndpointSource.DeepCopyInto(&out.EndpointSource)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ThirdComponentSpec.
func (in *ThirdComponentSpec) DeepCopy() *ThirdComponentSpec {
if in == nil {
return nil
}
out := new(ThirdComponentSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ThirdComponentStatus) DeepCopyInto(out *ThirdComponentStatus) {
*out = *in
if in.Endpoints != nil {
in, out := &in.Endpoints, &out.Endpoints
*out = make([]*ThirdComponentEndpointStatus, len(*in))
for i := range *in {
if (*in)[i] != nil {
in, out := &(*in)[i], &(*out)[i]
*out = new(ThirdComponentEndpointStatus)
(*in).DeepCopyInto(*out)
}
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ThirdComponentStatus.
func (in *ThirdComponentStatus) DeepCopy() *ThirdComponentStatus {
if in == nil {
return nil
}
out := new(ThirdComponentStatus)
in.DeepCopyInto(out)
return out
}

42
pkg/common/scheme.go Normal file
View File

@ -0,0 +1,42 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2021-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package common
import (
rainbondv1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
oamcore "github.com/oam-dev/kubevela/apis/core.oam.dev"
oamstandard "github.com/oam-dev/kubevela/apis/standard.oam.dev/v1alpha1"
crdv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
k8sruntime "k8s.io/apimachinery/pkg/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
)
var (
// Scheme defines the default KubeVela schema
Scheme = k8sruntime.NewScheme()
)
func init() {
_ = clientgoscheme.AddToScheme(Scheme)
_ = crdv1.AddToScheme(Scheme)
_ = oamcore.AddToScheme(Scheme)
_ = oamstandard.AddToScheme(Scheme)
_ = rainbondv1alpha1.AddToScheme(Scheme)
// +kubebuilder:scaffold:scheme
}

View File

@ -0,0 +1,99 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by client-gen. DO NOT EDIT.
package versioned
import (
"fmt"
rainbondv1alpha1 "github.com/goodrain/rainbond/pkg/generated/clientset/versioned/typed/rainbond/v1alpha1"
discovery "k8s.io/client-go/discovery"
rest "k8s.io/client-go/rest"
flowcontrol "k8s.io/client-go/util/flowcontrol"
)
type Interface interface {
Discovery() discovery.DiscoveryInterface
RainbondV1alpha1() rainbondv1alpha1.RainbondV1alpha1Interface
}
// Clientset contains the clients for groups. Each group has exactly one
// version included in a Clientset.
type Clientset struct {
*discovery.DiscoveryClient
rainbondV1alpha1 *rainbondv1alpha1.RainbondV1alpha1Client
}
// RainbondV1alpha1 retrieves the RainbondV1alpha1Client
func (c *Clientset) RainbondV1alpha1() rainbondv1alpha1.RainbondV1alpha1Interface {
return c.rainbondV1alpha1
}
// Discovery retrieves the DiscoveryClient
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
if c == nil {
return nil
}
return c.DiscoveryClient
}
// NewForConfig creates a new Clientset for the given config.
// If config's RateLimiter is not set and QPS and Burst are acceptable,
// NewForConfig will generate a rate-limiter in configShallowCopy.
func NewForConfig(c *rest.Config) (*Clientset, error) {
configShallowCopy := *c
if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
if configShallowCopy.Burst <= 0 {
return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0")
}
configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
}
var cs Clientset
var err error
cs.rainbondV1alpha1, err = rainbondv1alpha1.NewForConfig(&configShallowCopy)
if err != nil {
return nil, err
}
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
if err != nil {
return nil, err
}
return &cs, nil
}
// NewForConfigOrDie creates a new Clientset for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *Clientset {
var cs Clientset
cs.rainbondV1alpha1 = rainbondv1alpha1.NewForConfigOrDie(c)
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
return &cs
}
// New creates a new Clientset for the given RESTClient.
func New(c rest.Interface) *Clientset {
var cs Clientset
cs.rainbondV1alpha1 = rainbondv1alpha1.New(c)
cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
return &cs
}

View File

@ -0,0 +1,22 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by client-gen. DO NOT EDIT.
// This package has the automatically generated clientset.
package versioned

View File

@ -0,0 +1,84 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
clientset "github.com/goodrain/rainbond/pkg/generated/clientset/versioned"
rainbondv1alpha1 "github.com/goodrain/rainbond/pkg/generated/clientset/versioned/typed/rainbond/v1alpha1"
fakerainbondv1alpha1 "github.com/goodrain/rainbond/pkg/generated/clientset/versioned/typed/rainbond/v1alpha1/fake"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/discovery"
fakediscovery "k8s.io/client-go/discovery/fake"
"k8s.io/client-go/testing"
)
// NewSimpleClientset returns a clientset that will respond with the provided objects.
// It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
// without applying any validations and/or defaults. It shouldn't be considered a replacement
// for a real clientset and is mostly useful in simple unit tests.
func NewSimpleClientset(objects ...runtime.Object) *Clientset {
o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder())
for _, obj := range objects {
if err := o.Add(obj); err != nil {
panic(err)
}
}
cs := &Clientset{tracker: o}
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
cs.AddReactor("*", "*", testing.ObjectReaction(o))
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
gvr := action.GetResource()
ns := action.GetNamespace()
watch, err := o.Watch(gvr, ns)
if err != nil {
return false, nil, err
}
return true, watch, nil
})
return cs
}
// Clientset implements clientset.Interface. Meant to be embedded into a
// struct to get a default implementation. This makes faking out just the method
// you want to test easier.
type Clientset struct {
testing.Fake
discovery *fakediscovery.FakeDiscovery
tracker testing.ObjectTracker
}
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
return c.discovery
}
func (c *Clientset) Tracker() testing.ObjectTracker {
return c.tracker
}
var _ clientset.Interface = &Clientset{}
// RainbondV1alpha1 retrieves the RainbondV1alpha1Client
func (c *Clientset) RainbondV1alpha1() rainbondv1alpha1.RainbondV1alpha1Interface {
return &fakerainbondv1alpha1.FakeRainbondV1alpha1{Fake: &c.Fake}
}

View File

@ -0,0 +1,22 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by client-gen. DO NOT EDIT.
// This package has the automatically generated fake clientset.
package fake

View File

@ -0,0 +1,58 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
rainbondv1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
)
var scheme = runtime.NewScheme()
var codecs = serializer.NewCodecFactory(scheme)
var localSchemeBuilder = runtime.SchemeBuilder{
rainbondv1alpha1.AddToScheme,
}
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
// of clientsets, like in:
//
// import (
// "k8s.io/client-go/kubernetes"
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
// )
//
// kclientset, _ := kubernetes.NewForConfig(c)
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
//
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
// correctly.
var AddToScheme = localSchemeBuilder.AddToScheme
func init() {
v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"})
utilruntime.Must(AddToScheme(scheme))
}

View File

@ -0,0 +1,22 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by client-gen. DO NOT EDIT.
// This package contains the scheme of the automatically generated clientset.
package scheme

View File

@ -0,0 +1,58 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by client-gen. DO NOT EDIT.
package scheme
import (
rainbondv1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
)
var Scheme = runtime.NewScheme()
var Codecs = serializer.NewCodecFactory(Scheme)
var ParameterCodec = runtime.NewParameterCodec(Scheme)
var localSchemeBuilder = runtime.SchemeBuilder{
rainbondv1alpha1.AddToScheme,
}
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
// of clientsets, like in:
//
// import (
// "k8s.io/client-go/kubernetes"
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
// )
//
// kclientset, _ := kubernetes.NewForConfig(c)
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
//
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
// correctly.
var AddToScheme = localSchemeBuilder.AddToScheme
func init() {
v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
utilruntime.Must(AddToScheme(Scheme))
}

View File

@ -0,0 +1,197 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by client-gen. DO NOT EDIT.
package v1alpha1
import (
"context"
"time"
v1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
scheme "github.com/goodrain/rainbond/pkg/generated/clientset/versioned/scheme"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
)
// ComponentDefinitionsGetter has a method to return a ComponentDefinitionInterface.
// A group's client should implement this interface.
type ComponentDefinitionsGetter interface {
ComponentDefinitions(namespace string) ComponentDefinitionInterface
}
// ComponentDefinitionInterface has methods to work with ComponentDefinition resources.
type ComponentDefinitionInterface interface {
Create(ctx context.Context, componentDefinition *v1alpha1.ComponentDefinition, opts v1.CreateOptions) (*v1alpha1.ComponentDefinition, error)
Update(ctx context.Context, componentDefinition *v1alpha1.ComponentDefinition, opts v1.UpdateOptions) (*v1alpha1.ComponentDefinition, error)
UpdateStatus(ctx context.Context, componentDefinition *v1alpha1.ComponentDefinition, opts v1.UpdateOptions) (*v1alpha1.ComponentDefinition, error)
Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.ComponentDefinition, error)
List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ComponentDefinitionList, error)
Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ComponentDefinition, err error)
ComponentDefinitionExpansion
}
// componentDefinitions implements ComponentDefinitionInterface
type componentDefinitions struct {
client rest.Interface
ns string
}
// newComponentDefinitions returns a ComponentDefinitions
func newComponentDefinitions(c *RainbondV1alpha1Client, namespace string) *componentDefinitions {
return &componentDefinitions{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the componentDefinition, and returns the corresponding componentDefinition object, and an error if there is any.
func (c *componentDefinitions) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ComponentDefinition, err error) {
result = &v1alpha1.ComponentDefinition{}
err = c.client.Get().
Namespace(c.ns).
Resource("componentdefinitions").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of ComponentDefinitions that match those selectors.
func (c *componentDefinitions) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ComponentDefinitionList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1alpha1.ComponentDefinitionList{}
err = c.client.Get().
Namespace(c.ns).
Resource("componentdefinitions").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested componentDefinitions.
func (c *componentDefinitions) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("componentdefinitions").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a componentDefinition and creates it. Returns the server's representation of the componentDefinition, and an error, if there is any.
func (c *componentDefinitions) Create(ctx context.Context, componentDefinition *v1alpha1.ComponentDefinition, opts v1.CreateOptions) (result *v1alpha1.ComponentDefinition, err error) {
result = &v1alpha1.ComponentDefinition{}
err = c.client.Post().
Namespace(c.ns).
Resource("componentdefinitions").
VersionedParams(&opts, scheme.ParameterCodec).
Body(componentDefinition).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a componentDefinition and updates it. Returns the server's representation of the componentDefinition, and an error, if there is any.
func (c *componentDefinitions) Update(ctx context.Context, componentDefinition *v1alpha1.ComponentDefinition, opts v1.UpdateOptions) (result *v1alpha1.ComponentDefinition, err error) {
result = &v1alpha1.ComponentDefinition{}
err = c.client.Put().
Namespace(c.ns).
Resource("componentdefinitions").
Name(componentDefinition.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(componentDefinition).
Do(ctx).
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *componentDefinitions) UpdateStatus(ctx context.Context, componentDefinition *v1alpha1.ComponentDefinition, opts v1.UpdateOptions) (result *v1alpha1.ComponentDefinition, err error) {
result = &v1alpha1.ComponentDefinition{}
err = c.client.Put().
Namespace(c.ns).
Resource("componentdefinitions").
Name(componentDefinition.Name).
SubResource("status").
VersionedParams(&opts, scheme.ParameterCodec).
Body(componentDefinition).
Do(ctx).
Into(result)
return
}
// Delete takes name of the componentDefinition and deletes it. Returns an error if one occurs.
func (c *componentDefinitions) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("componentdefinitions").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *componentDefinitions) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
var timeout time.Duration
if listOpts.TimeoutSeconds != nil {
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("componentdefinitions").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched componentDefinition.
func (c *componentDefinitions) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ComponentDefinition, err error) {
result = &v1alpha1.ComponentDefinition{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("componentdefinitions").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}

View File

@ -0,0 +1,22 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by client-gen. DO NOT EDIT.
// This package has the automatically generated typed clients.
package v1alpha1

View File

@ -0,0 +1,22 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by client-gen. DO NOT EDIT.
// Package fake has the automatically generated clients.
package fake

View File

@ -0,0 +1,144 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
"context"
v1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
)
// FakeComponentDefinitions implements ComponentDefinitionInterface
type FakeComponentDefinitions struct {
Fake *FakeRainbondV1alpha1
ns string
}
var componentdefinitionsResource = schema.GroupVersionResource{Group: "rainbond.io", Version: "v1alpha1", Resource: "componentdefinitions"}
var componentdefinitionsKind = schema.GroupVersionKind{Group: "rainbond.io", Version: "v1alpha1", Kind: "ComponentDefinition"}
// Get takes name of the componentDefinition, and returns the corresponding componentDefinition object, and an error if there is any.
func (c *FakeComponentDefinitions) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ComponentDefinition, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(componentdefinitionsResource, c.ns, name), &v1alpha1.ComponentDefinition{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ComponentDefinition), err
}
// List takes label and field selectors, and returns the list of ComponentDefinitions that match those selectors.
func (c *FakeComponentDefinitions) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ComponentDefinitionList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(componentdefinitionsResource, componentdefinitionsKind, c.ns, opts), &v1alpha1.ComponentDefinitionList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha1.ComponentDefinitionList{ListMeta: obj.(*v1alpha1.ComponentDefinitionList).ListMeta}
for _, item := range obj.(*v1alpha1.ComponentDefinitionList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested componentDefinitions.
func (c *FakeComponentDefinitions) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(componentdefinitionsResource, c.ns, opts))
}
// Create takes the representation of a componentDefinition and creates it. Returns the server's representation of the componentDefinition, and an error, if there is any.
func (c *FakeComponentDefinitions) Create(ctx context.Context, componentDefinition *v1alpha1.ComponentDefinition, opts v1.CreateOptions) (result *v1alpha1.ComponentDefinition, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(componentdefinitionsResource, c.ns, componentDefinition), &v1alpha1.ComponentDefinition{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ComponentDefinition), err
}
// Update takes the representation of a componentDefinition and updates it. Returns the server's representation of the componentDefinition, and an error, if there is any.
func (c *FakeComponentDefinitions) Update(ctx context.Context, componentDefinition *v1alpha1.ComponentDefinition, opts v1.UpdateOptions) (result *v1alpha1.ComponentDefinition, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(componentdefinitionsResource, c.ns, componentDefinition), &v1alpha1.ComponentDefinition{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ComponentDefinition), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeComponentDefinitions) UpdateStatus(ctx context.Context, componentDefinition *v1alpha1.ComponentDefinition, opts v1.UpdateOptions) (*v1alpha1.ComponentDefinition, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(componentdefinitionsResource, "status", c.ns, componentDefinition), &v1alpha1.ComponentDefinition{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ComponentDefinition), err
}
// Delete takes name of the componentDefinition and deletes it. Returns an error if one occurs.
func (c *FakeComponentDefinitions) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(componentdefinitionsResource, c.ns, name), &v1alpha1.ComponentDefinition{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeComponentDefinitions) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(componentdefinitionsResource, c.ns, listOpts)
_, err := c.Fake.Invokes(action, &v1alpha1.ComponentDefinitionList{})
return err
}
// Patch applies the patch and returns the patched componentDefinition.
func (c *FakeComponentDefinitions) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ComponentDefinition, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(componentdefinitionsResource, c.ns, name, pt, data, subresources...), &v1alpha1.ComponentDefinition{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ComponentDefinition), err
}

View File

@ -0,0 +1,144 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
"context"
v1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
)
// FakeHelmApps implements HelmAppInterface
type FakeHelmApps struct {
Fake *FakeRainbondV1alpha1
ns string
}
var helmappsResource = schema.GroupVersionResource{Group: "rainbond.io", Version: "v1alpha1", Resource: "helmapps"}
var helmappsKind = schema.GroupVersionKind{Group: "rainbond.io", Version: "v1alpha1", Kind: "HelmApp"}
// Get takes name of the helmApp, and returns the corresponding helmApp object, and an error if there is any.
func (c *FakeHelmApps) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.HelmApp, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(helmappsResource, c.ns, name), &v1alpha1.HelmApp{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.HelmApp), err
}
// List takes label and field selectors, and returns the list of HelmApps that match those selectors.
func (c *FakeHelmApps) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.HelmAppList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(helmappsResource, helmappsKind, c.ns, opts), &v1alpha1.HelmAppList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha1.HelmAppList{ListMeta: obj.(*v1alpha1.HelmAppList).ListMeta}
for _, item := range obj.(*v1alpha1.HelmAppList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested helmApps.
func (c *FakeHelmApps) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(helmappsResource, c.ns, opts))
}
// Create takes the representation of a helmApp and creates it. Returns the server's representation of the helmApp, and an error, if there is any.
func (c *FakeHelmApps) Create(ctx context.Context, helmApp *v1alpha1.HelmApp, opts v1.CreateOptions) (result *v1alpha1.HelmApp, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(helmappsResource, c.ns, helmApp), &v1alpha1.HelmApp{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.HelmApp), err
}
// Update takes the representation of a helmApp and updates it. Returns the server's representation of the helmApp, and an error, if there is any.
func (c *FakeHelmApps) Update(ctx context.Context, helmApp *v1alpha1.HelmApp, opts v1.UpdateOptions) (result *v1alpha1.HelmApp, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(helmappsResource, c.ns, helmApp), &v1alpha1.HelmApp{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.HelmApp), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeHelmApps) UpdateStatus(ctx context.Context, helmApp *v1alpha1.HelmApp, opts v1.UpdateOptions) (*v1alpha1.HelmApp, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(helmappsResource, "status", c.ns, helmApp), &v1alpha1.HelmApp{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.HelmApp), err
}
// Delete takes name of the helmApp and deletes it. Returns an error if one occurs.
func (c *FakeHelmApps) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(helmappsResource, c.ns, name), &v1alpha1.HelmApp{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeHelmApps) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(helmappsResource, c.ns, listOpts)
_, err := c.Fake.Invokes(action, &v1alpha1.HelmAppList{})
return err
}
// Patch applies the patch and returns the patched helmApp.
func (c *FakeHelmApps) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.HelmApp, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(helmappsResource, c.ns, name, pt, data, subresources...), &v1alpha1.HelmApp{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.HelmApp), err
}

View File

@ -0,0 +1,50 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
v1alpha1 "github.com/goodrain/rainbond/pkg/generated/clientset/versioned/typed/rainbond/v1alpha1"
rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing"
)
type FakeRainbondV1alpha1 struct {
*testing.Fake
}
func (c *FakeRainbondV1alpha1) ComponentDefinitions(namespace string) v1alpha1.ComponentDefinitionInterface {
return &FakeComponentDefinitions{c, namespace}
}
func (c *FakeRainbondV1alpha1) HelmApps(namespace string) v1alpha1.HelmAppInterface {
return &FakeHelmApps{c, namespace}
}
func (c *FakeRainbondV1alpha1) ThirdComponents(namespace string) v1alpha1.ThirdComponentInterface {
return &FakeThirdComponents{c, namespace}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeRainbondV1alpha1) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}

View File

@ -0,0 +1,144 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
"context"
v1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
)
// FakeThirdComponents implements ThirdComponentInterface
type FakeThirdComponents struct {
Fake *FakeRainbondV1alpha1
ns string
}
var thirdcomponentsResource = schema.GroupVersionResource{Group: "rainbond.io", Version: "v1alpha1", Resource: "thirdcomponents"}
var thirdcomponentsKind = schema.GroupVersionKind{Group: "rainbond.io", Version: "v1alpha1", Kind: "ThirdComponent"}
// Get takes name of the thirdComponent, and returns the corresponding thirdComponent object, and an error if there is any.
func (c *FakeThirdComponents) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ThirdComponent, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(thirdcomponentsResource, c.ns, name), &v1alpha1.ThirdComponent{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ThirdComponent), err
}
// List takes label and field selectors, and returns the list of ThirdComponents that match those selectors.
func (c *FakeThirdComponents) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ThirdComponentList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(thirdcomponentsResource, thirdcomponentsKind, c.ns, opts), &v1alpha1.ThirdComponentList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha1.ThirdComponentList{ListMeta: obj.(*v1alpha1.ThirdComponentList).ListMeta}
for _, item := range obj.(*v1alpha1.ThirdComponentList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested thirdComponents.
func (c *FakeThirdComponents) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(thirdcomponentsResource, c.ns, opts))
}
// Create takes the representation of a thirdComponent and creates it. Returns the server's representation of the thirdComponent, and an error, if there is any.
func (c *FakeThirdComponents) Create(ctx context.Context, thirdComponent *v1alpha1.ThirdComponent, opts v1.CreateOptions) (result *v1alpha1.ThirdComponent, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(thirdcomponentsResource, c.ns, thirdComponent), &v1alpha1.ThirdComponent{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ThirdComponent), err
}
// Update takes the representation of a thirdComponent and updates it. Returns the server's representation of the thirdComponent, and an error, if there is any.
func (c *FakeThirdComponents) Update(ctx context.Context, thirdComponent *v1alpha1.ThirdComponent, opts v1.UpdateOptions) (result *v1alpha1.ThirdComponent, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(thirdcomponentsResource, c.ns, thirdComponent), &v1alpha1.ThirdComponent{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ThirdComponent), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeThirdComponents) UpdateStatus(ctx context.Context, thirdComponent *v1alpha1.ThirdComponent, opts v1.UpdateOptions) (*v1alpha1.ThirdComponent, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(thirdcomponentsResource, "status", c.ns, thirdComponent), &v1alpha1.ThirdComponent{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ThirdComponent), err
}
// Delete takes name of the thirdComponent and deletes it. Returns an error if one occurs.
func (c *FakeThirdComponents) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(thirdcomponentsResource, c.ns, name), &v1alpha1.ThirdComponent{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeThirdComponents) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(thirdcomponentsResource, c.ns, listOpts)
_, err := c.Fake.Invokes(action, &v1alpha1.ThirdComponentList{})
return err
}
// Patch applies the patch and returns the patched thirdComponent.
func (c *FakeThirdComponents) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ThirdComponent, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(thirdcomponentsResource, c.ns, name, pt, data, subresources...), &v1alpha1.ThirdComponent{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ThirdComponent), err
}

View File

@ -0,0 +1,27 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by client-gen. DO NOT EDIT.
package v1alpha1
type ComponentDefinitionExpansion interface{}
type HelmAppExpansion interface{}
type ThirdComponentExpansion interface{}

View File

@ -0,0 +1,197 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by client-gen. DO NOT EDIT.
package v1alpha1
import (
"context"
"time"
v1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
scheme "github.com/goodrain/rainbond/pkg/generated/clientset/versioned/scheme"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
)
// HelmAppsGetter has a method to return a HelmAppInterface.
// A group's client should implement this interface.
type HelmAppsGetter interface {
HelmApps(namespace string) HelmAppInterface
}
// HelmAppInterface has methods to work with HelmApp resources.
type HelmAppInterface interface {
Create(ctx context.Context, helmApp *v1alpha1.HelmApp, opts v1.CreateOptions) (*v1alpha1.HelmApp, error)
Update(ctx context.Context, helmApp *v1alpha1.HelmApp, opts v1.UpdateOptions) (*v1alpha1.HelmApp, error)
UpdateStatus(ctx context.Context, helmApp *v1alpha1.HelmApp, opts v1.UpdateOptions) (*v1alpha1.HelmApp, error)
Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.HelmApp, error)
List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.HelmAppList, error)
Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.HelmApp, err error)
HelmAppExpansion
}
// helmApps implements HelmAppInterface
type helmApps struct {
client rest.Interface
ns string
}
// newHelmApps returns a HelmApps
func newHelmApps(c *RainbondV1alpha1Client, namespace string) *helmApps {
return &helmApps{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the helmApp, and returns the corresponding helmApp object, and an error if there is any.
func (c *helmApps) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.HelmApp, err error) {
result = &v1alpha1.HelmApp{}
err = c.client.Get().
Namespace(c.ns).
Resource("helmapps").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of HelmApps that match those selectors.
func (c *helmApps) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.HelmAppList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1alpha1.HelmAppList{}
err = c.client.Get().
Namespace(c.ns).
Resource("helmapps").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested helmApps.
func (c *helmApps) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("helmapps").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a helmApp and creates it. Returns the server's representation of the helmApp, and an error, if there is any.
func (c *helmApps) Create(ctx context.Context, helmApp *v1alpha1.HelmApp, opts v1.CreateOptions) (result *v1alpha1.HelmApp, err error) {
result = &v1alpha1.HelmApp{}
err = c.client.Post().
Namespace(c.ns).
Resource("helmapps").
VersionedParams(&opts, scheme.ParameterCodec).
Body(helmApp).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a helmApp and updates it. Returns the server's representation of the helmApp, and an error, if there is any.
func (c *helmApps) Update(ctx context.Context, helmApp *v1alpha1.HelmApp, opts v1.UpdateOptions) (result *v1alpha1.HelmApp, err error) {
result = &v1alpha1.HelmApp{}
err = c.client.Put().
Namespace(c.ns).
Resource("helmapps").
Name(helmApp.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(helmApp).
Do(ctx).
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *helmApps) UpdateStatus(ctx context.Context, helmApp *v1alpha1.HelmApp, opts v1.UpdateOptions) (result *v1alpha1.HelmApp, err error) {
result = &v1alpha1.HelmApp{}
err = c.client.Put().
Namespace(c.ns).
Resource("helmapps").
Name(helmApp.Name).
SubResource("status").
VersionedParams(&opts, scheme.ParameterCodec).
Body(helmApp).
Do(ctx).
Into(result)
return
}
// Delete takes name of the helmApp and deletes it. Returns an error if one occurs.
func (c *helmApps) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("helmapps").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *helmApps) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
var timeout time.Duration
if listOpts.TimeoutSeconds != nil {
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("helmapps").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched helmApp.
func (c *helmApps) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.HelmApp, err error) {
result = &v1alpha1.HelmApp{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("helmapps").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}

View File

@ -0,0 +1,101 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by client-gen. DO NOT EDIT.
package v1alpha1
import (
v1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
"github.com/goodrain/rainbond/pkg/generated/clientset/versioned/scheme"
rest "k8s.io/client-go/rest"
)
type RainbondV1alpha1Interface interface {
RESTClient() rest.Interface
ComponentDefinitionsGetter
HelmAppsGetter
ThirdComponentsGetter
}
// RainbondV1alpha1Client is used to interact with features provided by the rainbond.io group.
type RainbondV1alpha1Client struct {
restClient rest.Interface
}
func (c *RainbondV1alpha1Client) ComponentDefinitions(namespace string) ComponentDefinitionInterface {
return newComponentDefinitions(c, namespace)
}
func (c *RainbondV1alpha1Client) HelmApps(namespace string) HelmAppInterface {
return newHelmApps(c, namespace)
}
func (c *RainbondV1alpha1Client) ThirdComponents(namespace string) ThirdComponentInterface {
return newThirdComponents(c, namespace)
}
// NewForConfig creates a new RainbondV1alpha1Client for the given config.
func NewForConfig(c *rest.Config) (*RainbondV1alpha1Client, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
}
client, err := rest.RESTClientFor(&config)
if err != nil {
return nil, err
}
return &RainbondV1alpha1Client{client}, nil
}
// NewForConfigOrDie creates a new RainbondV1alpha1Client for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *RainbondV1alpha1Client {
client, err := NewForConfig(c)
if err != nil {
panic(err)
}
return client
}
// New creates a new RainbondV1alpha1Client for the given RESTClient.
func New(c rest.Interface) *RainbondV1alpha1Client {
return &RainbondV1alpha1Client{c}
}
func setConfigDefaults(config *rest.Config) error {
gv := v1alpha1.SchemeGroupVersion
config.GroupVersion = &gv
config.APIPath = "/apis"
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()
}
return nil
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *RainbondV1alpha1Client) RESTClient() rest.Interface {
if c == nil {
return nil
}
return c.restClient
}

View File

@ -0,0 +1,197 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by client-gen. DO NOT EDIT.
package v1alpha1
import (
"context"
"time"
v1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
scheme "github.com/goodrain/rainbond/pkg/generated/clientset/versioned/scheme"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
)
// ThirdComponentsGetter has a method to return a ThirdComponentInterface.
// A group's client should implement this interface.
type ThirdComponentsGetter interface {
ThirdComponents(namespace string) ThirdComponentInterface
}
// ThirdComponentInterface has methods to work with ThirdComponent resources.
type ThirdComponentInterface interface {
Create(ctx context.Context, thirdComponent *v1alpha1.ThirdComponent, opts v1.CreateOptions) (*v1alpha1.ThirdComponent, error)
Update(ctx context.Context, thirdComponent *v1alpha1.ThirdComponent, opts v1.UpdateOptions) (*v1alpha1.ThirdComponent, error)
UpdateStatus(ctx context.Context, thirdComponent *v1alpha1.ThirdComponent, opts v1.UpdateOptions) (*v1alpha1.ThirdComponent, error)
Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.ThirdComponent, error)
List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ThirdComponentList, error)
Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ThirdComponent, err error)
ThirdComponentExpansion
}
// thirdComponents implements ThirdComponentInterface
type thirdComponents struct {
client rest.Interface
ns string
}
// newThirdComponents returns a ThirdComponents
func newThirdComponents(c *RainbondV1alpha1Client, namespace string) *thirdComponents {
return &thirdComponents{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the thirdComponent, and returns the corresponding thirdComponent object, and an error if there is any.
func (c *thirdComponents) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ThirdComponent, err error) {
result = &v1alpha1.ThirdComponent{}
err = c.client.Get().
Namespace(c.ns).
Resource("thirdcomponents").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of ThirdComponents that match those selectors.
func (c *thirdComponents) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ThirdComponentList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1alpha1.ThirdComponentList{}
err = c.client.Get().
Namespace(c.ns).
Resource("thirdcomponents").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested thirdComponents.
func (c *thirdComponents) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("thirdcomponents").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a thirdComponent and creates it. Returns the server's representation of the thirdComponent, and an error, if there is any.
func (c *thirdComponents) Create(ctx context.Context, thirdComponent *v1alpha1.ThirdComponent, opts v1.CreateOptions) (result *v1alpha1.ThirdComponent, err error) {
result = &v1alpha1.ThirdComponent{}
err = c.client.Post().
Namespace(c.ns).
Resource("thirdcomponents").
VersionedParams(&opts, scheme.ParameterCodec).
Body(thirdComponent).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a thirdComponent and updates it. Returns the server's representation of the thirdComponent, and an error, if there is any.
func (c *thirdComponents) Update(ctx context.Context, thirdComponent *v1alpha1.ThirdComponent, opts v1.UpdateOptions) (result *v1alpha1.ThirdComponent, err error) {
result = &v1alpha1.ThirdComponent{}
err = c.client.Put().
Namespace(c.ns).
Resource("thirdcomponents").
Name(thirdComponent.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(thirdComponent).
Do(ctx).
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *thirdComponents) UpdateStatus(ctx context.Context, thirdComponent *v1alpha1.ThirdComponent, opts v1.UpdateOptions) (result *v1alpha1.ThirdComponent, err error) {
result = &v1alpha1.ThirdComponent{}
err = c.client.Put().
Namespace(c.ns).
Resource("thirdcomponents").
Name(thirdComponent.Name).
SubResource("status").
VersionedParams(&opts, scheme.ParameterCodec).
Body(thirdComponent).
Do(ctx).
Into(result)
return
}
// Delete takes name of the thirdComponent and deletes it. Returns an error if one occurs.
func (c *thirdComponents) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("thirdcomponents").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *thirdComponents) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
var timeout time.Duration
if listOpts.TimeoutSeconds != nil {
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("thirdcomponents").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched thirdComponent.
func (c *thirdComponents) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ThirdComponent, err error) {
result = &v1alpha1.ThirdComponent{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("thirdcomponents").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}

View File

@ -0,0 +1,182 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by informer-gen. DO NOT EDIT.
package externalversions
import (
reflect "reflect"
sync "sync"
time "time"
versioned "github.com/goodrain/rainbond/pkg/generated/clientset/versioned"
internalinterfaces "github.com/goodrain/rainbond/pkg/generated/informers/externalversions/internalinterfaces"
rainbond "github.com/goodrain/rainbond/pkg/generated/informers/externalversions/rainbond"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache"
)
// SharedInformerOption defines the functional option type for SharedInformerFactory.
type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory
type sharedInformerFactory struct {
client versioned.Interface
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
lock sync.Mutex
defaultResync time.Duration
customResync map[reflect.Type]time.Duration
informers map[reflect.Type]cache.SharedIndexInformer
// startedInformers is used for tracking which informers have been started.
// This allows Start() to be called multiple times safely.
startedInformers map[reflect.Type]bool
}
// WithCustomResyncConfig sets a custom resync period for the specified informer types.
func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
for k, v := range resyncConfig {
factory.customResync[reflect.TypeOf(k)] = v
}
return factory
}
}
// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory.
func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
factory.tweakListOptions = tweakListOptions
return factory
}
}
// WithNamespace limits the SharedInformerFactory to the specified namespace.
func WithNamespace(namespace string) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
factory.namespace = namespace
return factory
}
}
// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces.
func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory {
return NewSharedInformerFactoryWithOptions(client, defaultResync)
}
// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory.
// Listers obtained via this SharedInformerFactory will be subject to the same filters
// as specified here.
// Deprecated: Please use NewSharedInformerFactoryWithOptions instead
func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory {
return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions))
}
// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options.
func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory {
factory := &sharedInformerFactory{
client: client,
namespace: v1.NamespaceAll,
defaultResync: defaultResync,
informers: make(map[reflect.Type]cache.SharedIndexInformer),
startedInformers: make(map[reflect.Type]bool),
customResync: make(map[reflect.Type]time.Duration),
}
// Apply all options
for _, opt := range options {
factory = opt(factory)
}
return factory
}
// Start initializes all requested informers.
func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) {
f.lock.Lock()
defer f.lock.Unlock()
for informerType, informer := range f.informers {
if !f.startedInformers[informerType] {
go informer.Run(stopCh)
f.startedInformers[informerType] = true
}
}
}
// WaitForCacheSync waits for all started informers' cache were synced.
func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool {
informers := func() map[reflect.Type]cache.SharedIndexInformer {
f.lock.Lock()
defer f.lock.Unlock()
informers := map[reflect.Type]cache.SharedIndexInformer{}
for informerType, informer := range f.informers {
if f.startedInformers[informerType] {
informers[informerType] = informer
}
}
return informers
}()
res := map[reflect.Type]bool{}
for informType, informer := range informers {
res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced)
}
return res
}
// InternalInformerFor returns the SharedIndexInformer for obj using an internal
// client.
func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer {
f.lock.Lock()
defer f.lock.Unlock()
informerType := reflect.TypeOf(obj)
informer, exists := f.informers[informerType]
if exists {
return informer
}
resyncPeriod, exists := f.customResync[informerType]
if !exists {
resyncPeriod = f.defaultResync
}
informer = newFunc(f.client, resyncPeriod)
f.informers[informerType] = informer
return informer
}
// SharedInformerFactory provides shared informers for resources in all known
// API group versions.
type SharedInformerFactory interface {
internalinterfaces.SharedInformerFactory
ForResource(resource schema.GroupVersionResource) (GenericInformer, error)
WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool
Rainbond() rainbond.Interface
}
func (f *sharedInformerFactory) Rainbond() rainbond.Interface {
return rainbond.New(f, f.namespace, f.tweakListOptions)
}

View File

@ -0,0 +1,68 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by informer-gen. DO NOT EDIT.
package externalversions
import (
"fmt"
v1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache"
)
// GenericInformer is type of SharedIndexInformer which will locate and delegate to other
// sharedInformers based on type
type GenericInformer interface {
Informer() cache.SharedIndexInformer
Lister() cache.GenericLister
}
type genericInformer struct {
informer cache.SharedIndexInformer
resource schema.GroupResource
}
// Informer returns the SharedIndexInformer.
func (f *genericInformer) Informer() cache.SharedIndexInformer {
return f.informer
}
// Lister returns the GenericLister.
func (f *genericInformer) Lister() cache.GenericLister {
return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource)
}
// ForResource gives generic access to a shared informer of the matching type
// TODO extend this to unknown resources with a client pool
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
switch resource {
// Group=rainbond.io, Version=v1alpha1
case v1alpha1.SchemeGroupVersion.WithResource("componentdefinitions"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Rainbond().V1alpha1().ComponentDefinitions().Informer()}, nil
case v1alpha1.SchemeGroupVersion.WithResource("helmapps"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Rainbond().V1alpha1().HelmApps().Informer()}, nil
case v1alpha1.SchemeGroupVersion.WithResource("thirdcomponents"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Rainbond().V1alpha1().ThirdComponents().Informer()}, nil
}
return nil, fmt.Errorf("no informer found for %v", resource)
}

View File

@ -0,0 +1,42 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by informer-gen. DO NOT EDIT.
package internalinterfaces
import (
time "time"
versioned "github.com/goodrain/rainbond/pkg/generated/clientset/versioned"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
cache "k8s.io/client-go/tools/cache"
)
// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer.
type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer
// SharedInformerFactory a small interface to allow for adding an informer without an import cycle
type SharedInformerFactory interface {
Start(stopCh <-chan struct{})
InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer
}
// TweakListOptionsFunc is a function that transforms a v1.ListOptions.
type TweakListOptionsFunc func(*v1.ListOptions)

View File

@ -0,0 +1,48 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by informer-gen. DO NOT EDIT.
package rainbond
import (
internalinterfaces "github.com/goodrain/rainbond/pkg/generated/informers/externalversions/internalinterfaces"
v1alpha1 "github.com/goodrain/rainbond/pkg/generated/informers/externalversions/rainbond/v1alpha1"
)
// Interface provides access to each of this group's versions.
type Interface interface {
// V1alpha1 provides access to shared informers for resources in V1alpha1.
V1alpha1() v1alpha1.Interface
}
type group struct {
factory internalinterfaces.SharedInformerFactory
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
}
// V1alpha1 returns a new v1alpha1.Interface.
func (g *group) V1alpha1() v1alpha1.Interface {
return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions)
}

View File

@ -0,0 +1,92 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by informer-gen. DO NOT EDIT.
package v1alpha1
import (
"context"
time "time"
rainbondv1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
versioned "github.com/goodrain/rainbond/pkg/generated/clientset/versioned"
internalinterfaces "github.com/goodrain/rainbond/pkg/generated/informers/externalversions/internalinterfaces"
v1alpha1 "github.com/goodrain/rainbond/pkg/generated/listers/rainbond/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
)
// ComponentDefinitionInformer provides access to a shared informer and lister for
// ComponentDefinitions.
type ComponentDefinitionInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1alpha1.ComponentDefinitionLister
}
type componentDefinitionInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewComponentDefinitionInformer constructs a new informer for ComponentDefinition type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewComponentDefinitionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredComponentDefinitionInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredComponentDefinitionInformer constructs a new informer for ComponentDefinition type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredComponentDefinitionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.RainbondV1alpha1().ComponentDefinitions(namespace).List(context.TODO(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.RainbondV1alpha1().ComponentDefinitions(namespace).Watch(context.TODO(), options)
},
},
&rainbondv1alpha1.ComponentDefinition{},
resyncPeriod,
indexers,
)
}
func (f *componentDefinitionInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredComponentDefinitionInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *componentDefinitionInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&rainbondv1alpha1.ComponentDefinition{}, f.defaultInformer)
}
func (f *componentDefinitionInformer) Lister() v1alpha1.ComponentDefinitionLister {
return v1alpha1.NewComponentDefinitionLister(f.Informer().GetIndexer())
}

View File

@ -0,0 +1,92 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by informer-gen. DO NOT EDIT.
package v1alpha1
import (
"context"
time "time"
rainbondv1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
versioned "github.com/goodrain/rainbond/pkg/generated/clientset/versioned"
internalinterfaces "github.com/goodrain/rainbond/pkg/generated/informers/externalversions/internalinterfaces"
v1alpha1 "github.com/goodrain/rainbond/pkg/generated/listers/rainbond/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
)
// HelmAppInformer provides access to a shared informer and lister for
// HelmApps.
type HelmAppInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1alpha1.HelmAppLister
}
type helmAppInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewHelmAppInformer constructs a new informer for HelmApp type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewHelmAppInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredHelmAppInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredHelmAppInformer constructs a new informer for HelmApp type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredHelmAppInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.RainbondV1alpha1().HelmApps(namespace).List(context.TODO(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.RainbondV1alpha1().HelmApps(namespace).Watch(context.TODO(), options)
},
},
&rainbondv1alpha1.HelmApp{},
resyncPeriod,
indexers,
)
}
func (f *helmAppInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredHelmAppInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *helmAppInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&rainbondv1alpha1.HelmApp{}, f.defaultInformer)
}
func (f *helmAppInformer) Lister() v1alpha1.HelmAppLister {
return v1alpha1.NewHelmAppLister(f.Informer().GetIndexer())
}

View File

@ -0,0 +1,61 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by informer-gen. DO NOT EDIT.
package v1alpha1
import (
internalinterfaces "github.com/goodrain/rainbond/pkg/generated/informers/externalversions/internalinterfaces"
)
// Interface provides access to all the informers in this group version.
type Interface interface {
// ComponentDefinitions returns a ComponentDefinitionInformer.
ComponentDefinitions() ComponentDefinitionInformer
// HelmApps returns a HelmAppInformer.
HelmApps() HelmAppInformer
// ThirdComponents returns a ThirdComponentInformer.
ThirdComponents() ThirdComponentInformer
}
type version struct {
factory internalinterfaces.SharedInformerFactory
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
}
// ComponentDefinitions returns a ComponentDefinitionInformer.
func (v *version) ComponentDefinitions() ComponentDefinitionInformer {
return &componentDefinitionInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
// HelmApps returns a HelmAppInformer.
func (v *version) HelmApps() HelmAppInformer {
return &helmAppInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
// ThirdComponents returns a ThirdComponentInformer.
func (v *version) ThirdComponents() ThirdComponentInformer {
return &thirdComponentInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}

View File

@ -0,0 +1,92 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by informer-gen. DO NOT EDIT.
package v1alpha1
import (
"context"
time "time"
rainbondv1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
versioned "github.com/goodrain/rainbond/pkg/generated/clientset/versioned"
internalinterfaces "github.com/goodrain/rainbond/pkg/generated/informers/externalversions/internalinterfaces"
v1alpha1 "github.com/goodrain/rainbond/pkg/generated/listers/rainbond/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
)
// ThirdComponentInformer provides access to a shared informer and lister for
// ThirdComponents.
type ThirdComponentInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1alpha1.ThirdComponentLister
}
type thirdComponentInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewThirdComponentInformer constructs a new informer for ThirdComponent type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewThirdComponentInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredThirdComponentInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredThirdComponentInformer constructs a new informer for ThirdComponent type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredThirdComponentInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.RainbondV1alpha1().ThirdComponents(namespace).List(context.TODO(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.RainbondV1alpha1().ThirdComponents(namespace).Watch(context.TODO(), options)
},
},
&rainbondv1alpha1.ThirdComponent{},
resyncPeriod,
indexers,
)
}
func (f *thirdComponentInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredThirdComponentInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *thirdComponentInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&rainbondv1alpha1.ThirdComponent{}, f.defaultInformer)
}
func (f *thirdComponentInformer) Lister() v1alpha1.ThirdComponentLister {
return v1alpha1.NewThirdComponentLister(f.Informer().GetIndexer())
}

View File

@ -0,0 +1,101 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by lister-gen. DO NOT EDIT.
package v1alpha1
import (
v1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// ComponentDefinitionLister helps list ComponentDefinitions.
// All objects returned here must be treated as read-only.
type ComponentDefinitionLister interface {
// List lists all ComponentDefinitions in the indexer.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v1alpha1.ComponentDefinition, err error)
// ComponentDefinitions returns an object that can list and get ComponentDefinitions.
ComponentDefinitions(namespace string) ComponentDefinitionNamespaceLister
ComponentDefinitionListerExpansion
}
// componentDefinitionLister implements the ComponentDefinitionLister interface.
type componentDefinitionLister struct {
indexer cache.Indexer
}
// NewComponentDefinitionLister returns a new ComponentDefinitionLister.
func NewComponentDefinitionLister(indexer cache.Indexer) ComponentDefinitionLister {
return &componentDefinitionLister{indexer: indexer}
}
// List lists all ComponentDefinitions in the indexer.
func (s *componentDefinitionLister) List(selector labels.Selector) (ret []*v1alpha1.ComponentDefinition, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.ComponentDefinition))
})
return ret, err
}
// ComponentDefinitions returns an object that can list and get ComponentDefinitions.
func (s *componentDefinitionLister) ComponentDefinitions(namespace string) ComponentDefinitionNamespaceLister {
return componentDefinitionNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// ComponentDefinitionNamespaceLister helps list and get ComponentDefinitions.
// All objects returned here must be treated as read-only.
type ComponentDefinitionNamespaceLister interface {
// List lists all ComponentDefinitions in the indexer for a given namespace.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v1alpha1.ComponentDefinition, err error)
// Get retrieves the ComponentDefinition from the indexer for a given namespace and name.
// Objects returned here must be treated as read-only.
Get(name string) (*v1alpha1.ComponentDefinition, error)
ComponentDefinitionNamespaceListerExpansion
}
// componentDefinitionNamespaceLister implements the ComponentDefinitionNamespaceLister
// interface.
type componentDefinitionNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all ComponentDefinitions in the indexer for a given namespace.
func (s componentDefinitionNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.ComponentDefinition, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.ComponentDefinition))
})
return ret, err
}
// Get retrieves the ComponentDefinition from the indexer for a given namespace and name.
func (s componentDefinitionNamespaceLister) Get(name string) (*v1alpha1.ComponentDefinition, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1alpha1.Resource("componentdefinition"), name)
}
return obj.(*v1alpha1.ComponentDefinition), nil
}

View File

@ -0,0 +1,45 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by lister-gen. DO NOT EDIT.
package v1alpha1
// ComponentDefinitionListerExpansion allows custom methods to be added to
// ComponentDefinitionLister.
type ComponentDefinitionListerExpansion interface{}
// ComponentDefinitionNamespaceListerExpansion allows custom methods to be added to
// ComponentDefinitionNamespaceLister.
type ComponentDefinitionNamespaceListerExpansion interface{}
// HelmAppListerExpansion allows custom methods to be added to
// HelmAppLister.
type HelmAppListerExpansion interface{}
// HelmAppNamespaceListerExpansion allows custom methods to be added to
// HelmAppNamespaceLister.
type HelmAppNamespaceListerExpansion interface{}
// ThirdComponentListerExpansion allows custom methods to be added to
// ThirdComponentLister.
type ThirdComponentListerExpansion interface{}
// ThirdComponentNamespaceListerExpansion allows custom methods to be added to
// ThirdComponentNamespaceLister.
type ThirdComponentNamespaceListerExpansion interface{}

View File

@ -0,0 +1,101 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by lister-gen. DO NOT EDIT.
package v1alpha1
import (
v1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// HelmAppLister helps list HelmApps.
// All objects returned here must be treated as read-only.
type HelmAppLister interface {
// List lists all HelmApps in the indexer.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v1alpha1.HelmApp, err error)
// HelmApps returns an object that can list and get HelmApps.
HelmApps(namespace string) HelmAppNamespaceLister
HelmAppListerExpansion
}
// helmAppLister implements the HelmAppLister interface.
type helmAppLister struct {
indexer cache.Indexer
}
// NewHelmAppLister returns a new HelmAppLister.
func NewHelmAppLister(indexer cache.Indexer) HelmAppLister {
return &helmAppLister{indexer: indexer}
}
// List lists all HelmApps in the indexer.
func (s *helmAppLister) List(selector labels.Selector) (ret []*v1alpha1.HelmApp, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.HelmApp))
})
return ret, err
}
// HelmApps returns an object that can list and get HelmApps.
func (s *helmAppLister) HelmApps(namespace string) HelmAppNamespaceLister {
return helmAppNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// HelmAppNamespaceLister helps list and get HelmApps.
// All objects returned here must be treated as read-only.
type HelmAppNamespaceLister interface {
// List lists all HelmApps in the indexer for a given namespace.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v1alpha1.HelmApp, err error)
// Get retrieves the HelmApp from the indexer for a given namespace and name.
// Objects returned here must be treated as read-only.
Get(name string) (*v1alpha1.HelmApp, error)
HelmAppNamespaceListerExpansion
}
// helmAppNamespaceLister implements the HelmAppNamespaceLister
// interface.
type helmAppNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all HelmApps in the indexer for a given namespace.
func (s helmAppNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.HelmApp, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.HelmApp))
})
return ret, err
}
// Get retrieves the HelmApp from the indexer for a given namespace and name.
func (s helmAppNamespaceLister) Get(name string) (*v1alpha1.HelmApp, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1alpha1.Resource("helmapp"), name)
}
return obj.(*v1alpha1.HelmApp), nil
}

View File

@ -0,0 +1,101 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by lister-gen. DO NOT EDIT.
package v1alpha1
import (
v1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// ThirdComponentLister helps list ThirdComponents.
// All objects returned here must be treated as read-only.
type ThirdComponentLister interface {
// List lists all ThirdComponents in the indexer.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v1alpha1.ThirdComponent, err error)
// ThirdComponents returns an object that can list and get ThirdComponents.
ThirdComponents(namespace string) ThirdComponentNamespaceLister
ThirdComponentListerExpansion
}
// thirdComponentLister implements the ThirdComponentLister interface.
type thirdComponentLister struct {
indexer cache.Indexer
}
// NewThirdComponentLister returns a new ThirdComponentLister.
func NewThirdComponentLister(indexer cache.Indexer) ThirdComponentLister {
return &thirdComponentLister{indexer: indexer}
}
// List lists all ThirdComponents in the indexer.
func (s *thirdComponentLister) List(selector labels.Selector) (ret []*v1alpha1.ThirdComponent, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.ThirdComponent))
})
return ret, err
}
// ThirdComponents returns an object that can list and get ThirdComponents.
func (s *thirdComponentLister) ThirdComponents(namespace string) ThirdComponentNamespaceLister {
return thirdComponentNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// ThirdComponentNamespaceLister helps list and get ThirdComponents.
// All objects returned here must be treated as read-only.
type ThirdComponentNamespaceLister interface {
// List lists all ThirdComponents in the indexer for a given namespace.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v1alpha1.ThirdComponent, err error)
// Get retrieves the ThirdComponent from the indexer for a given namespace and name.
// Objects returned here must be treated as read-only.
Get(name string) (*v1alpha1.ThirdComponent, error)
ThirdComponentNamespaceListerExpansion
}
// thirdComponentNamespaceLister implements the ThirdComponentNamespaceLister
// interface.
type thirdComponentNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all ThirdComponents in the indexer for a given namespace.
func (s thirdComponentNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.ThirdComponent, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.ThirdComponent))
})
return ret, err
}
// Get retrieves the ThirdComponent from the indexer for a given namespace and name.
func (s thirdComponentNamespaceLister) Get(name string) (*v1alpha1.ThirdComponent, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1alpha1.Resource("thirdcomponent"), name)
}
return obj.(*v1alpha1.ThirdComponent), nil
}

Some files were not shown because too many files have changed in this diff Show More