project.go 2.0 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
Copyright 2019 The KubeSphere 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.
*/

R
runzexia 已提交
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
package devops

import (
	"kubesphere.io/kubesphere/pkg/utils/idutils"
	"time"
)

var DevOpsProjectColumns = GetColumnsFromStruct(&DevOpsProject{})

const (
	DevOpsProjectTableName         = "project"
	DevOpsProjectPrefix            = "project-"
	DevOpsProjectDescriptionColumn = "description"
	DevOpsProjectIdColumn          = "project.project_id"
	DevOpsProjectNameColumn        = "project.name"
	DevOpsProjectExtraColumn       = "project.extra"
	DevOpsProjectWorkSpaceColumn   = "project.workspace"
	DevOpsProjectCreateTimeColumn  = "project.create_time"
)

34 35 36 37 38
type PageableDevOpsProject struct {
	Items      []*DevOpsProject `json:"items"`
	TotalCount int              `json:"total_count"`
}

R
runzexia 已提交
39 40 41
type DevOpsProject struct {
	ProjectId   string    `json:"project_id" db:"project_id"`
	Name        string    `json:"name"`
R
runzexia 已提交
42
	Description string    `json:"description,omitempty"`
R
runzexia 已提交
43 44 45
	Creator     string    `json:"creator"`
	CreateTime  time.Time `json:"create_time"`
	Status      string    `json:"status"`
R
runzexia 已提交
46 47
	Visibility  string    `json:"visibility,omitempty"`
	Extra       string    `json:"extra,omitempty"`
R
runzexia 已提交
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
	Workspace   string    `json:"workspace"`
}

func NewDevOpsProject(name, description, creator, extra, workspace string) *DevOpsProject {
	return &DevOpsProject{
		ProjectId:   idutils.GetUuid(DevOpsProjectPrefix),
		Name:        name,
		Description: description,
		Creator:     creator,
		CreateTime:  time.Now(),
		Status:      StatusActive,
		Visibility:  VisibilityPrivate,
		Extra:       extra,
		Workspace:   workspace,
	}
}