From c80eabee8e8b21b5145b3a96c4b368dac7811c80 Mon Sep 17 00:00:00 2001 From: gitlawr Date: Tue, 6 Mar 2018 11:21:43 +0800 Subject: [PATCH] change sourcecode cred/repo to user scope --- .../management.cattle.io/v3/pipeline_types.go | 21 ++++++++++++------- apis/management.cattle.io/v3/schema/schema.go | 19 ++++++++++------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/apis/management.cattle.io/v3/pipeline_types.go b/apis/management.cattle.io/v3/pipeline_types.go index ae0edeac..67f2c4d9 100644 --- a/apis/management.cattle.io/v3/pipeline_types.go +++ b/apis/management.cattle.io/v3/pipeline_types.go @@ -51,6 +51,8 @@ type PipelineExecutionLog struct { } type SourceCodeCredential struct { + types.Namespaced + metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -59,6 +61,8 @@ type SourceCodeCredential struct { } type SourceCodeRepository struct { + types.Namespaced + metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -84,14 +88,15 @@ type GithubClusterConfig struct { } 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"` - LastExecutionID string `json:"lastExecutionId,omitempty" yaml:"lastExecutionId,omitempty"` - LastRunState string `json:"lastRunState,omitempty" yaml:"lastRunState,omitempty"` - LastStarted string `json:"lastStarted,omitempty" yaml:"lastStarted,omitempty"` - NextStart string `json:"nextStart,omitempty" yaml:"nextStart,omitempty"` - WebHookID string `json:"webhookId,omitempty" yaml:"webhookId,omitempty"` - Token string `json:"token,omitempty" yaml:"token,omitempty" norman:"writeOnly,noupdate"` + PipelineState string `json:"pipelineState,omitempty" norman:"required,options=active|inactive,default=active"` + NextRun int `json:"nextRun" yaml:"nextRun,omitempty" norman:"default=1,min=1"` + LastExecutionID string `json:"lastExecutionId,omitempty" yaml:"lastExecutionId,omitempty"` + LastRunState string `json:"lastRunState,omitempty" yaml:"lastRunState,omitempty"` + LastStarted string `json:"lastStarted,omitempty" yaml:"lastStarted,omitempty"` + NextStart string `json:"nextStart,omitempty" yaml:"nextStart,omitempty"` + WebHookID string `json:"webhookId,omitempty" yaml:"webhookId,omitempty"` + Token string `json:"token,omitempty" yaml:"token,omitempty" norman:"writeOnly,noupdate"` + SourceCodeCredential *SourceCodeCredential `json:"sourceCodeCredential,omitempty" yaml:"sourceCodeCredential,omitempty"` } type PipelineSpec struct { diff --git a/apis/management.cattle.io/v3/schema/schema.go b/apis/management.cattle.io/v3/schema/schema.go index fb3fa128..f06de328 100644 --- a/apis/management.cattle.io/v3/schema/schema.go +++ b/apis/management.cattle.io/v3/schema/schema.go @@ -394,11 +394,6 @@ func pipelineTypes(schema *types.Schemas) *types.Schemas { MustImport(&Version, v3.AuthAppInput{}). MustImport(&Version, v3.AuthUserInput{}). MustImport(&Version, v3.RunPipelineInput{}). - MustImportAndCustomize(&Version, v3.SourceCodeCredential{}, func(schema *types.Schema) { - schema.ResourceActions = map[string]types.Action{ - "refreshrepos": {}, - } - }). MustImportAndCustomize(&Version, v3.ClusterPipeline{}, func(schema *types.Schema) { schema.ResourceActions = map[string]types.Action{ "deploy": {}, @@ -429,7 +424,17 @@ func pipelineTypes(schema *types.Schemas) *types.Schemas { "rerun": {}, } }). - MustImport(&Version, v3.SourceCodeRepository{}). - MustImport(&Version, v3.PipelineExecutionLog{}) + MustImport(&Version, v3.PipelineExecutionLog{}). + MustImportAndCustomize(&Version, v3.SourceCodeCredential{}, func(schema *types.Schema) { + delete(schema.ResourceFields, "namespaceId") + schema.ResourceMethods = []string{http.MethodGet, http.MethodDelete} + schema.ResourceActions = map[string]types.Action{ + "refreshrepos": {}, + } + }). + MustImportAndCustomize(&Version, v3.SourceCodeRepository{}, func(schema *types.Schema) { + schema.ResourceMethods = []string{http.MethodGet, http.MethodDelete} + delete(schema.ResourceFields, "namespaceId") + }) }