mirror of
https://github.com/rancher/types.git
synced 2025-09-12 13:03:45 +00:00
Add ObjClusterName to objects
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package v3
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/rancher/norman/condition"
|
||||
"github.com/rancher/norman/types"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
@@ -31,6 +33,13 @@ type AppSpec struct {
|
||||
ValuesYaml string `json:"valuesYaml,omitempty"`
|
||||
}
|
||||
|
||||
func (a *AppSpec) ObjClusterName() string {
|
||||
if parts := strings.SplitN(a.ProjectName, ":", 2); len(parts) == 2 {
|
||||
return parts[0]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var (
|
||||
AppConditionInstalled condition.Cond = "Installed"
|
||||
AppConditionMigrated condition.Cond = "Migrated"
|
||||
@@ -76,6 +85,13 @@ type AppRevisionSpec struct {
|
||||
ProjectName string `json:"projectName,omitempty" norman:"type=reference[/v3/schemas/project]"`
|
||||
}
|
||||
|
||||
func (a *AppRevisionSpec) ObjClusterName() string {
|
||||
if parts := strings.SplitN(a.ProjectName, ":", 2); len(parts) == 2 {
|
||||
return parts[0]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type AppRevisionStatus struct {
|
||||
ProjectName string `json:"projectName,omitempty" norman:"type=reference[/v3/schemas/project]"`
|
||||
ExternalID string `json:"externalId"`
|
||||
@@ -85,6 +101,13 @@ type AppRevisionStatus struct {
|
||||
Files map[string]string `json:"files,omitempty"`
|
||||
}
|
||||
|
||||
func (a *AppRevisionStatus) ObjClusterName() string {
|
||||
if parts := strings.SplitN(a.ProjectName, ":", 2); len(parts) == 2 {
|
||||
return parts[0]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type AppUpgradeConfig struct {
|
||||
ExternalID string `json:"externalId,omitempty"`
|
||||
Answers map[string]string `json:"answers,omitempty"`
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package v3
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rancher/norman/condition"
|
||||
"github.com/rancher/norman/types"
|
||||
@@ -26,6 +28,13 @@ type SourceCodeProvider struct {
|
||||
Type string `json:"type" norman:"options=github|gitlab|bitbucketcloud|bitbucketserver"`
|
||||
}
|
||||
|
||||
func (s *SourceCodeProvider) ObjClusterName() string {
|
||||
if parts := strings.SplitN(s.ProjectName, ":", 2); len(parts) == 2 {
|
||||
return parts[0]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type OauthProvider struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
@@ -61,6 +70,13 @@ type SourceCodeProviderConfig struct {
|
||||
Enabled bool `json:"enabled,omitempty"`
|
||||
}
|
||||
|
||||
func (s *SourceCodeProviderConfig) ObjClusterName() string {
|
||||
if parts := strings.SplitN(s.ProjectName, ":", 2); len(parts) == 2 {
|
||||
return parts[0]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GithubPipelineConfig struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
@@ -118,6 +134,10 @@ type Pipeline struct {
|
||||
Status PipelineStatus `json:"status"`
|
||||
}
|
||||
|
||||
func (p *Pipeline) ObjClusterName() string {
|
||||
return p.Spec.ObjClusterName()
|
||||
}
|
||||
|
||||
type PipelineExecution struct {
|
||||
types.Namespaced
|
||||
|
||||
@@ -128,6 +148,10 @@ type PipelineExecution struct {
|
||||
Status PipelineExecutionStatus `json:"status"`
|
||||
}
|
||||
|
||||
func (p *PipelineExecution) ObjClusterName() string {
|
||||
return p.Spec.ObjClusterName()
|
||||
}
|
||||
|
||||
type PipelineSetting struct {
|
||||
types.Namespaced
|
||||
|
||||
@@ -140,6 +164,13 @@ type PipelineSetting struct {
|
||||
Customized bool `json:"customized" norman:"nocreate,noupdate"`
|
||||
}
|
||||
|
||||
func (p *PipelineSetting) ObjClusterName() string {
|
||||
if parts := strings.SplitN(p.ProjectName, ":", 2); len(parts) == 2 {
|
||||
return parts[0]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type SourceCodeCredential struct {
|
||||
types.Namespaced
|
||||
|
||||
@@ -150,6 +181,10 @@ type SourceCodeCredential struct {
|
||||
Status SourceCodeCredentialStatus `json:"status"`
|
||||
}
|
||||
|
||||
func (s *SourceCodeCredential) ObjClusterName() string {
|
||||
return s.Spec.ObjClusterName()
|
||||
}
|
||||
|
||||
type SourceCodeRepository struct {
|
||||
types.Namespaced
|
||||
|
||||
@@ -160,6 +195,10 @@ type SourceCodeRepository struct {
|
||||
Status SourceCodeRepositoryStatus `json:"status"`
|
||||
}
|
||||
|
||||
func (s *SourceCodeRepository) ObjClusterName() string {
|
||||
return s.Spec.ObjClusterName()
|
||||
}
|
||||
|
||||
type PipelineStatus struct {
|
||||
PipelineState string `json:"pipelineState,omitempty" norman:"required,options=active|inactive,default=active"`
|
||||
NextRun int `json:"nextRun" yaml:"nextRun,omitempty" norman:"default=1,min=1"`
|
||||
@@ -184,6 +223,13 @@ type PipelineSpec struct {
|
||||
SourceCodeCredentialName string `json:"sourceCodeCredentialName,omitempty" yaml:"sourceCodeCredentialName,omitempty" norman:"type=reference[sourceCodeCredential],noupdate"`
|
||||
}
|
||||
|
||||
func (p *PipelineSpec) ObjClusterName() string {
|
||||
if parts := strings.SplitN(p.ProjectName, ":", 2); len(parts) == 2 {
|
||||
return parts[0]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type PipelineConfig struct {
|
||||
Stages []Stage `json:"stages,omitempty" yaml:"stages,omitempty"`
|
||||
|
||||
@@ -314,6 +360,13 @@ type PipelineExecutionSpec struct {
|
||||
Email string `json:"email,omitempty"`
|
||||
}
|
||||
|
||||
func (p *PipelineExecutionSpec) ObjClusterName() string {
|
||||
if parts := strings.SplitN(p.ProjectName, ":", 2); len(parts) == 2 {
|
||||
return parts[0]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type PipelineExecutionStatus struct {
|
||||
Conditions []PipelineCondition `json:"conditions,omitempty"`
|
||||
|
||||
@@ -351,6 +404,13 @@ type SourceCodeCredentialSpec struct {
|
||||
Expiry string `json:"expiry,omitempty"`
|
||||
}
|
||||
|
||||
func (s *SourceCodeCredentialSpec) ObjClusterName() string {
|
||||
if parts := strings.SplitN(s.ProjectName, ":", 2); len(parts) == 2 {
|
||||
return parts[0]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type SourceCodeCredentialStatus struct {
|
||||
Logout bool `json:"logout,omitempty"`
|
||||
}
|
||||
@@ -366,6 +426,13 @@ type SourceCodeRepositorySpec struct {
|
||||
DefaultBranch string `json:"defaultBranch,omitempty"`
|
||||
}
|
||||
|
||||
func (s *SourceCodeRepositorySpec) ObjClusterName() string {
|
||||
if parts := strings.SplitN(s.ProjectName, ":", 2); len(parts) == 2 {
|
||||
return parts[0]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type SourceCodeRepositoryStatus struct {
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user