fakedevops.go 17.9 KB
Newer Older
Z
zryfish 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
Copyright 2020 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 已提交
17 18 19
package fake

import (
R
runzexia 已提交
20 21
	"fmt"
	"github.com/emicklei/go-restful"
R
runzexia 已提交
22
	"io/ioutil"
R
runzexia 已提交
23
	v1 "k8s.io/api/core/v1"
R
runzexia 已提交
24
	devopsv1alpha3 "kubesphere.io/kubesphere/pkg/apis/devops/v1alpha3"
R
runzexia 已提交
25 26
	"kubesphere.io/kubesphere/pkg/simple/client/devops"
	"net/http"
R
runzexia 已提交
27
	"net/url"
R
runzexia 已提交
28 29 30
	"strings"
)

R
runzexia 已提交
31
type Devops struct {
R
runzexia 已提交
32
	Data map[string]interface{}
R
runzexia 已提交
33 34

	Projects map[string]interface{}
R
runzexia 已提交
35 36

	Pipelines map[string]map[string]*devopsv1alpha3.Pipeline
R
runzexia 已提交
37 38

	Credentials map[string]map[string]*v1.Secret
R
runzexia 已提交
39 40 41 42
}

func New(projects ...string) *Devops {
	d := &Devops{
R
refmt  
runzexia 已提交
43 44 45
		Data:        nil,
		Projects:    map[string]interface{}{},
		Pipelines:   map[string]map[string]*devopsv1alpha3.Pipeline{},
R
runzexia 已提交
46
		Credentials: map[string]map[string]*v1.Secret{},
R
runzexia 已提交
47 48 49 50 51 52
	}
	for _, p := range projects {
		d.Projects[p] = true
	}
	return d
}
R
runzexia 已提交
53 54
func NewWithPipelines(project string, pipelines ...*devopsv1alpha3.Pipeline) *Devops {
	d := &Devops{
R
refmt  
runzexia 已提交
55 56 57
		Data:        nil,
		Projects:    map[string]interface{}{},
		Pipelines:   map[string]map[string]*devopsv1alpha3.Pipeline{},
R
runzexia 已提交
58
		Credentials: map[string]map[string]*v1.Secret{},
R
runzexia 已提交
59 60 61 62 63 64 65 66 67
	}

	d.Projects[project] = true
	d.Pipelines[project] = map[string]*devopsv1alpha3.Pipeline{}
	for _, f := range pipelines {
		d.Pipelines[project][f.Name] = f
	}
	return d
}
R
runzexia 已提交
68

R
runzexia 已提交
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
func NewWithCredentials(project string, credentials ...*v1.Secret) *Devops {
	d := &Devops{
		Data:        nil,
		Projects:    map[string]interface{}{},
		Credentials: map[string]map[string]*v1.Secret{},
	}

	d.Projects[project] = true
	d.Credentials[project] = map[string]*v1.Secret{}
	for _, f := range credentials {
		d.Credentials[project][f.Name] = f
	}
	return d
}

R
runzexia 已提交
84 85 86 87 88
func (d *Devops) CreateDevOpsProject(projectId string) (string, error) {
	if _, ok := d.Projects[projectId]; ok {
		return projectId, nil
	}
	d.Projects[projectId] = true
R
runzexia 已提交
89
	d.Pipelines[projectId] = map[string]*devopsv1alpha3.Pipeline{}
R
runzexia 已提交
90
	d.Credentials[projectId] = map[string]*v1.Secret{}
R
runzexia 已提交
91 92 93 94 95 96
	return projectId, nil
}

func (d *Devops) DeleteDevOpsProject(projectId string) error {
	if _, ok := d.Projects[projectId]; ok {
		delete(d.Projects, projectId)
R
runzexia 已提交
97
		delete(d.Pipelines, projectId)
R
runzexia 已提交
98
		delete(d.Credentials, projectId)
R
runzexia 已提交
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
		return nil
	} else {
		return &devops.ErrorResponse{
			Body: []byte{},
			Response: &http.Response{
				Status:        "404 Not Found",
				StatusCode:    404,
				Proto:         "HTTP/1.1",
				ProtoMajor:    1,
				ProtoMinor:    1,
				ContentLength: 50,
				Header: http.Header{
					"Foo": []string{"Bar"},
				},
				Body: ioutil.NopCloser(strings.NewReader("foo")), // shouldn't be used
			},
			Message: "",
		}
	}
}

func (d *Devops) GetDevOpsProject(projectId string) (string, error) {
	if _, ok := d.Projects[projectId]; ok {
		return projectId, nil
	} else {
		return "", &devops.ErrorResponse{
			Body: []byte{},
			Response: &http.Response{
				Status:        "404 Not Found",
				StatusCode:    404,
				Proto:         "HTTP/1.1",
				ProtoMajor:    1,
				ProtoMinor:    1,
				ContentLength: 50,
				Header: http.Header{
					"Foo": []string{"Bar"},
				},
				Body: ioutil.NopCloser(strings.NewReader("foo")), // shouldn't be used
				Request: &http.Request{
					Method: "",
					URL: &url.URL{
						Scheme:     "",
						Opaque:     "",
						User:       nil,
						Host:       "",
						Path:       "",
						RawPath:    "",
						ForceQuery: false,
						RawQuery:   "",
						Fragment:   "",
					},
				},
			},
			Message: "",
		}
	}
R
runzexia 已提交
155 156
}

R
runzexia 已提交
157 158
func NewFakeDevops(data map[string]interface{}) *Devops {
	var fakeData Devops
R
runzexia 已提交
159 160 161 162 163
	fakeData.Data = data
	return &fakeData
}

// Pipelinne operator interface
R
runzexia 已提交
164
func (d *Devops) GetPipeline(projectName, pipelineName string, httpParameters *devops.HttpParameters) (*devops.Pipeline, error) {
R
runzexia 已提交
165 166 167
	return nil, nil
}

R
runzexia 已提交
168
func (d *Devops) ListPipelines(httpParameters *devops.HttpParameters) (*devops.PipelineList, error) {
R
runzexia 已提交
169 170
	return nil, nil
}
R
runzexia 已提交
171
func (d *Devops) GetPipelineRun(projectName, pipelineName, runId string, httpParameters *devops.HttpParameters) (*devops.PipelineRun, error) {
R
runzexia 已提交
172 173
	return nil, nil
}
R
runzexia 已提交
174
func (d *Devops) ListPipelineRuns(projectName, pipelineName string, httpParameters *devops.HttpParameters) (*devops.PipelineRunList, error) {
R
runzexia 已提交
175 176
	return nil, nil
}
R
runzexia 已提交
177
func (d *Devops) StopPipeline(projectName, pipelineName, runId string, httpParameters *devops.HttpParameters) (*devops.StopPipeline, error) {
R
runzexia 已提交
178 179
	return nil, nil
}
R
runzexia 已提交
180
func (d *Devops) ReplayPipeline(projectName, pipelineName, runId string, httpParameters *devops.HttpParameters) (*devops.ReplayPipeline, error) {
R
runzexia 已提交
181 182
	return nil, nil
}
R
runzexia 已提交
183
func (d *Devops) RunPipeline(projectName, pipelineName string, httpParameters *devops.HttpParameters) (*devops.RunPipeline, error) {
R
runzexia 已提交
184 185
	return nil, nil
}
R
runzexia 已提交
186
func (d *Devops) GetArtifacts(projectName, pipelineName, runId string, httpParameters *devops.HttpParameters) ([]devops.Artifacts, error) {
R
runzexia 已提交
187 188
	return nil, nil
}
R
runzexia 已提交
189
func (d *Devops) GetRunLog(projectName, pipelineName, runId string, httpParameters *devops.HttpParameters) ([]byte, error) {
R
runzexia 已提交
190 191
	return nil, nil
}
R
runzexia 已提交
192
func (d *Devops) GetStepLog(projectName, pipelineName, runId, nodeId, stepId string, httpParameters *devops.HttpParameters) ([]byte, http.Header, error) {
R
runzexia 已提交
193 194
	return nil, nil, nil
}
R
runzexia 已提交
195
func (d *Devops) GetNodeSteps(projectName, pipelineName, runId, nodeId string, httpParameters *devops.HttpParameters) ([]devops.NodeSteps, error) {
R
runzexia 已提交
196 197 198 199 200
	s := []string{projectName, pipelineName, runId, nodeId}
	key := strings.Join(s, "-")
	res := d.Data[key].([]devops.NodeSteps)
	return res, nil
}
R
runzexia 已提交
201
func (d *Devops) GetPipelineRunNodes(projectName, pipelineName, runId string, httpParameters *devops.HttpParameters) ([]devops.PipelineRunNodes, error) {
R
runzexia 已提交
202 203 204 205 206
	s := []string{projectName, pipelineName, runId}
	key := strings.Join(s, "-")
	res := d.Data[key].([]devops.PipelineRunNodes)
	return res, nil
}
R
runzexia 已提交
207
func (d *Devops) SubmitInputStep(projectName, pipelineName, runId, nodeId, stepId string, httpParameters *devops.HttpParameters) ([]byte, error) {
R
runzexia 已提交
208 209 210 211
	return nil, nil
}

//BranchPipelinne operator interface
R
runzexia 已提交
212
func (d *Devops) GetBranchPipeline(projectName, pipelineName, branchName string, httpParameters *devops.HttpParameters) (*devops.BranchPipeline, error) {
R
runzexia 已提交
213 214
	return nil, nil
}
R
runzexia 已提交
215
func (d *Devops) GetBranchPipelineRun(projectName, pipelineName, branchName, runId string, httpParameters *devops.HttpParameters) (*devops.PipelineRun, error) {
R
runzexia 已提交
216 217
	return nil, nil
}
R
runzexia 已提交
218
func (d *Devops) StopBranchPipeline(projectName, pipelineName, branchName, runId string, httpParameters *devops.HttpParameters) (*devops.StopPipeline, error) {
R
runzexia 已提交
219 220
	return nil, nil
}
R
runzexia 已提交
221
func (d *Devops) ReplayBranchPipeline(projectName, pipelineName, branchName, runId string, httpParameters *devops.HttpParameters) (*devops.ReplayPipeline, error) {
R
runzexia 已提交
222 223
	return nil, nil
}
R
runzexia 已提交
224
func (d *Devops) RunBranchPipeline(projectName, pipelineName, branchName string, httpParameters *devops.HttpParameters) (*devops.RunPipeline, error) {
R
runzexia 已提交
225 226
	return nil, nil
}
R
runzexia 已提交
227
func (d *Devops) GetBranchArtifacts(projectName, pipelineName, branchName, runId string, httpParameters *devops.HttpParameters) ([]devops.Artifacts, error) {
R
runzexia 已提交
228 229
	return nil, nil
}
R
runzexia 已提交
230
func (d *Devops) GetBranchRunLog(projectName, pipelineName, branchName, runId string, httpParameters *devops.HttpParameters) ([]byte, error) {
R
runzexia 已提交
231 232
	return nil, nil
}
R
runzexia 已提交
233
func (d *Devops) GetBranchStepLog(projectName, pipelineName, branchName, runId, nodeId, stepId string, httpParameters *devops.HttpParameters) ([]byte, http.Header, error) {
R
runzexia 已提交
234 235
	return nil, nil, nil
}
R
runzexia 已提交
236
func (d *Devops) GetBranchNodeSteps(projectName, pipelineName, branchName, runId, nodeId string, httpParameters *devops.HttpParameters) ([]devops.NodeSteps, error) {
R
runzexia 已提交
237 238 239 240 241
	s := []string{projectName, pipelineName, branchName, runId, nodeId}
	key := strings.Join(s, "-")
	res := d.Data[key].([]devops.NodeSteps)
	return res, nil
}
R
runzexia 已提交
242
func (d *Devops) GetBranchPipelineRunNodes(projectName, pipelineName, branchName, runId string, httpParameters *devops.HttpParameters) ([]devops.BranchPipelineRunNodes, error) {
R
runzexia 已提交
243 244 245 246 247
	s := []string{projectName, pipelineName, branchName, runId}
	key := strings.Join(s, "-")
	res := d.Data[key].([]devops.BranchPipelineRunNodes)
	return res, nil
}
R
runzexia 已提交
248
func (d *Devops) SubmitBranchInputStep(projectName, pipelineName, branchName, runId, nodeId, stepId string, httpParameters *devops.HttpParameters) ([]byte, error) {
R
runzexia 已提交
249 250
	return nil, nil
}
R
runzexia 已提交
251
func (d *Devops) GetPipelineBranch(projectName, pipelineName string, httpParameters *devops.HttpParameters) (*devops.PipelineBranch, error) {
R
runzexia 已提交
252 253
	return nil, nil
}
R
runzexia 已提交
254
func (d *Devops) ScanBranch(projectName, pipelineName string, httpParameters *devops.HttpParameters) ([]byte, error) {
R
runzexia 已提交
255 256 257 258
	return nil, nil
}

// Common pipeline operator interface
R
runzexia 已提交
259
func (d *Devops) GetConsoleLog(projectName, pipelineName string, httpParameters *devops.HttpParameters) ([]byte, error) {
R
runzexia 已提交
260 261
	return nil, nil
}
R
runzexia 已提交
262
func (d *Devops) GetCrumb(httpParameters *devops.HttpParameters) (*devops.Crumb, error) {
R
runzexia 已提交
263 264 265 266
	return nil, nil
}

// SCM operator interface
R
runzexia 已提交
267
func (d *Devops) GetSCMServers(scmId string, httpParameters *devops.HttpParameters) ([]devops.SCMServer, error) {
R
runzexia 已提交
268 269
	return nil, nil
}
R
runzexia 已提交
270
func (d *Devops) GetSCMOrg(scmId string, httpParameters *devops.HttpParameters) ([]devops.SCMOrg, error) {
R
runzexia 已提交
271 272
	return nil, nil
}
S
shaowenchen 已提交
273 274
func (d *Devops) GetOrgRepo(scmId, organizationId string, httpParameters *devops.HttpParameters) (devops.OrgRepo, error) {
	return devops.OrgRepo{}, nil
R
runzexia 已提交
275
}
R
runzexia 已提交
276
func (d *Devops) CreateSCMServers(scmId string, httpParameters *devops.HttpParameters) (*devops.SCMServer, error) {
R
runzexia 已提交
277 278
	return nil, nil
}
R
runzexia 已提交
279
func (d *Devops) Validate(scmId string, httpParameters *devops.HttpParameters) (*devops.Validates, error) {
R
runzexia 已提交
280 281 282 283
	return nil, nil
}

//Webhook operator interface
R
runzexia 已提交
284
func (d *Devops) GetNotifyCommit(httpParameters *devops.HttpParameters) ([]byte, error) {
R
runzexia 已提交
285 286
	return nil, nil
}
R
runzexia 已提交
287
func (d *Devops) GithubWebhook(httpParameters *devops.HttpParameters) ([]byte, error) {
R
runzexia 已提交
288 289 290
	return nil, nil
}

R
runzexia 已提交
291
func (d *Devops) CheckScriptCompile(projectName, pipelineName string, httpParameters *devops.HttpParameters) (*devops.CheckScript, error) {
R
runzexia 已提交
292 293
	return nil, nil
}
R
runzexia 已提交
294
func (d *Devops) CheckCron(projectName string, httpParameters *devops.HttpParameters) (*devops.CheckCronRes, error) {
R
runzexia 已提交
295 296
	return nil, nil
}
R
runzexia 已提交
297
func (d *Devops) ToJenkinsfile(httpParameters *devops.HttpParameters) (*devops.ResJenkinsfile, error) {
R
runzexia 已提交
298 299
	return nil, nil
}
300
func (d *Devops) ToJson(httpParameters *devops.HttpParameters) (map[string]interface{}, error) {
R
runzexia 已提交
301 302 303 304
	return nil, nil
}

// CredentialOperator
R
runzexia 已提交
305 306 307 308 309 310 311
func (d *Devops) CreateCredentialInProject(projectId string, credential *v1.Secret) (string, error) {
	if _, ok := d.Credentials[projectId][credential.Name]; ok {
		err := fmt.Errorf("credential name [%s] has been used", credential.Name)
		return "", restful.NewError(http.StatusConflict, err.Error())
	}
	d.Credentials[projectId][credential.Name] = credential
	return credential.Name, nil
R
runzexia 已提交
312
}
R
runzexia 已提交
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
func (d *Devops) UpdateCredentialInProject(projectId string, credential *v1.Secret) (string, error) {
	if _, ok := d.Credentials[projectId][credential.Name]; !ok {
		err := &devops.ErrorResponse{
			Body: []byte{},
			Response: &http.Response{
				Status:        "404 Not Found",
				StatusCode:    404,
				Proto:         "HTTP/1.1",
				ProtoMajor:    1,
				ProtoMinor:    1,
				ContentLength: 50,
				Header: http.Header{
					"Foo": []string{"Bar"},
				},
				Body: ioutil.NopCloser(strings.NewReader("foo")), // shouldn't be used
				Request: &http.Request{
					Method: "",
					URL: &url.URL{
						Scheme:     "",
						Opaque:     "",
						User:       nil,
						Host:       "",
						Path:       "",
						RawPath:    "",
						ForceQuery: false,
						RawQuery:   "",
						Fragment:   "",
					},
				},
			},
			Message: "",
		}
		return "", err
	}
	d.Credentials[projectId][credential.Name] = credential
	return credential.Name, nil
R
runzexia 已提交
349
}
R
runzexia 已提交
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385

func (d *Devops) GetCredentialInProject(projectId, id string) (*devops.Credential, error) {
	if _, ok := d.Credentials[projectId][id]; !ok {
		err := &devops.ErrorResponse{
			Body: []byte{},
			Response: &http.Response{
				Status:        "404 Not Found",
				StatusCode:    404,
				Proto:         "HTTP/1.1",
				ProtoMajor:    1,
				ProtoMinor:    1,
				ContentLength: 50,
				Header: http.Header{
					"Foo": []string{"Bar"},
				},
				Body: ioutil.NopCloser(strings.NewReader("foo")), // shouldn't be used
				Request: &http.Request{
					Method: "",
					URL: &url.URL{
						Scheme:     "",
						Opaque:     "",
						User:       nil,
						Host:       "",
						Path:       "",
						RawPath:    "",
						ForceQuery: false,
						RawQuery:   "",
						Fragment:   "",
					},
				},
			},
			Message: "",
		}
		return nil, err
	}
	return &devops.Credential{Id: id}, nil
R
runzexia 已提交
386
}
R
runzexia 已提交
387
func (d *Devops) GetCredentialsInProject(projectId string) ([]*devops.Credential, error) {
R
runzexia 已提交
388 389
	return nil, nil
}
R
runzexia 已提交
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426
func (d *Devops) DeleteCredentialInProject(projectId, id string) (string, error) {
	if _, ok := d.Credentials[projectId][id]; !ok {
		err := &devops.ErrorResponse{
			Body: []byte{},
			Response: &http.Response{
				Status:        "404 Not Found",
				StatusCode:    404,
				Proto:         "HTTP/1.1",
				ProtoMajor:    1,
				ProtoMinor:    1,
				ContentLength: 50,
				Header: http.Header{
					"Foo": []string{"Bar"},
				},
				Body: ioutil.NopCloser(strings.NewReader("foo")), // shouldn't be used
				Request: &http.Request{
					Method: "",
					URL: &url.URL{
						Scheme:     "",
						Opaque:     "",
						User:       nil,
						Host:       "",
						Path:       "",
						RawPath:    "",
						ForceQuery: false,
						RawQuery:   "",
						Fragment:   "",
					},
				},
			},
			Message: "",
		}
		return "", err
	}
	delete(d.Credentials[projectId], id)
	return "", nil
}
R
runzexia 已提交
427 428

// BuildGetter
R
runzexia 已提交
429
func (d *Devops) GetProjectPipelineBuildByType(projectId, pipelineId string, status string) (*devops.Build, error) {
R
runzexia 已提交
430 431
	return nil, nil
}
R
runzexia 已提交
432
func (d *Devops) GetMultiBranchPipelineBuildByType(projectId, pipelineId, branch string, status string) (*devops.Build, error) {
R
runzexia 已提交
433 434 435 436
	return nil, nil
}

// ProjectPipelineOperator
R
runzexia 已提交
437 438 439 440 441 442
func (d *Devops) CreateProjectPipeline(projectId string, pipeline *devopsv1alpha3.Pipeline) (string, error) {
	if _, ok := d.Pipelines[projectId][pipeline.Name]; ok {
		err := fmt.Errorf("pipeline name [%s] has been used", pipeline.Name)
		return "", restful.NewError(http.StatusConflict, err.Error())
	}
	d.Pipelines[projectId][pipeline.Name] = pipeline
R
runzexia 已提交
443 444
	return "", nil
}
R
runzexia 已提交
445

R
runzexia 已提交
446
func (d *Devops) DeleteProjectPipeline(projectId string, pipelineId string) (string, error) {
R
runzexia 已提交
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480
	if _, ok := d.Pipelines[projectId][pipelineId]; !ok {
		err := &devops.ErrorResponse{
			Body: []byte{},
			Response: &http.Response{
				Status:        "404 Not Found",
				StatusCode:    404,
				Proto:         "HTTP/1.1",
				ProtoMajor:    1,
				ProtoMinor:    1,
				ContentLength: 50,
				Header: http.Header{
					"Foo": []string{"Bar"},
				},
				Body: ioutil.NopCloser(strings.NewReader("foo")), // shouldn't be used
				Request: &http.Request{
					Method: "",
					URL: &url.URL{
						Scheme:     "",
						Opaque:     "",
						User:       nil,
						Host:       "",
						Path:       "",
						RawPath:    "",
						ForceQuery: false,
						RawQuery:   "",
						Fragment:   "",
					},
				},
			},
			Message: "",
		}
		return "", err
	}
	delete(d.Pipelines[projectId], pipelineId)
R
runzexia 已提交
481 482
	return "", nil
}
R
runzexia 已提交
483

R
runzexia 已提交
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518
func (d *Devops) UpdateProjectPipeline(projectId string, pipeline *devopsv1alpha3.Pipeline) (string, error) {
	if _, ok := d.Pipelines[projectId][pipeline.Name]; !ok {
		err := &devops.ErrorResponse{
			Body: []byte{},
			Response: &http.Response{
				Status:        "404 Not Found",
				StatusCode:    404,
				Proto:         "HTTP/1.1",
				ProtoMajor:    1,
				ProtoMinor:    1,
				ContentLength: 50,
				Header: http.Header{
					"Foo": []string{"Bar"},
				},
				Body: ioutil.NopCloser(strings.NewReader("foo")), // shouldn't be used
				Request: &http.Request{
					Method: "",
					URL: &url.URL{
						Scheme:     "",
						Opaque:     "",
						User:       nil,
						Host:       "",
						Path:       "",
						RawPath:    "",
						ForceQuery: false,
						RawQuery:   "",
						Fragment:   "",
					},
				},
			},
			Message: "",
		}
		return "", err
	}
	d.Pipelines[projectId][pipeline.Name] = pipeline
R
runzexia 已提交
519 520
	return "", nil
}
R
runzexia 已提交
521

R
runzexia 已提交
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557
func (d *Devops) GetProjectPipelineConfig(projectId, pipelineId string) (*devopsv1alpha3.Pipeline, error) {
	if _, ok := d.Pipelines[projectId][pipelineId]; !ok {
		err := &devops.ErrorResponse{
			Body: []byte{},
			Response: &http.Response{
				Status:        "404 Not Found",
				StatusCode:    404,
				Proto:         "HTTP/1.1",
				ProtoMajor:    1,
				ProtoMinor:    1,
				ContentLength: 50,
				Header: http.Header{
					"Foo": []string{"Bar"},
				},
				Body: ioutil.NopCloser(strings.NewReader("foo")), // shouldn't be used
				Request: &http.Request{
					Method: "",
					URL: &url.URL{
						Scheme:     "",
						Opaque:     "",
						User:       nil,
						Host:       "",
						Path:       "",
						RawPath:    "",
						ForceQuery: false,
						RawQuery:   "",
						Fragment:   "",
					},
				},
			},
			Message: "",
		}
		return nil, err
	}

	return d.Pipelines[projectId][pipelineId], nil
R
runzexia 已提交
558
}
S
shaowenchen 已提交
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594

func (d *Devops) AddGlobalRole(roleName string, ids devops.GlobalPermissionIds, overwrite bool) error {
	return nil
}

func (d *Devops) AddProjectRole(roleName string, pattern string, ids devops.ProjectPermissionIds, overwrite bool) error {
	return nil
}

func (d *Devops) DeleteProjectRoles(roleName ...string) error {
	return nil
}

func (d *Devops) AssignProjectRole(roleName string, sid string) error {
	return nil
}

func (d *Devops) UnAssignProjectRole(roleName string, sid string) error {
	return nil
}

func (d *Devops) AssignGlobalRole(roleName string, sid string) error {
	return nil
}

func (d *Devops) UnAssignGlobalRole(roleName string, sid string) error {
	return nil
}

func (d *Devops) DeleteUserInProject(sid string) error {
	return nil
}

func (d *Devops) GetGlobalRole(roleName string) (string, error) {
	return "", nil
}