Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(745)

Side by Side Diff: deploytool/api/deploy/util.go

Issue 2584893004: luci_deploy: Enable loading "index.yaml" directly. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « deploytool/api/deploy/component.pb.go ('k') | deploytool/cmd/luci_deploy/appengine.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package deploy 5 package deploy
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9
10 "github.com/luci/luci-go/common/errors"
9 ) 11 )
10 12
11 // AppYAMLString returns the "app.yaml" string for this option. 13 // AppYAMLString returns the "app.yaml" string for this option.
12 func (v AppEngineModule_Handler_LoginOption) AppYAMLString() string { 14 func (v AppEngineModule_Handler_LoginOption) AppYAMLString() string {
13 switch v { 15 switch v {
14 case AppEngineModule_Handler_LOGIN_OPTIONAL: 16 case AppEngineModule_Handler_LOGIN_OPTIONAL:
15 return "optional" 17 return "optional"
16 case AppEngineModule_Handler_LOGIN_REQUIRED: 18 case AppEngineModule_Handler_LOGIN_REQUIRED:
17 return "required" 19 return "required"
18 case AppEngineModule_Handler_LOGIN_ADMIN: 20 case AppEngineModule_Handler_LOGIN_ADMIN:
(...skipping 10 matching lines...) Expand all
29 return "optional" 31 return "optional"
30 case AppEngineModule_Handler_SECURE_NEVER: 32 case AppEngineModule_Handler_SECURE_NEVER:
31 return "never" 33 return "never"
32 case AppEngineModule_Handler_SECURE_ALWAYS: 34 case AppEngineModule_Handler_SECURE_ALWAYS:
33 return "always" 35 return "always"
34 default: 36 default:
35 panic(fmt.Errorf("unknown handler secure option %q", v)) 37 panic(fmt.Errorf("unknown handler secure option %q", v))
36 } 38 }
37 } 39 }
38 40
39 // AppYAMLString returns the "app.yaml" string for this option. 41 // AppYAMLString returns the "index.yaml" string for this option.
40 func (v AppEngineResources_Index_Direction) AppYAMLString() string { 42 func (v AppEngineResources_Index_Direction) AppYAMLString() string {
41 switch v { 43 switch v {
42 case AppEngineResources_Index_ASCENDING: 44 case AppEngineResources_Index_ASCENDING:
43 return "asc" 45 return "asc"
44 case AppEngineResources_Index_DESCENDING: 46 case AppEngineResources_Index_DESCENDING:
45 return "desc" 47 return "desc"
46 default: 48 default:
47 panic(fmt.Errorf("unknown index direction %q", v)) 49 panic(fmt.Errorf("unknown index direction %q", v))
48 } 50 }
49 } 51 }
50 52
53 // IndexDirectionFromAppYAMLString returns the
54 // AppEngineResources_Index_Direction value associated with the given
55 // "index.yaml" strnig value.
56 //
57 // This is a reverse of the AppEngineResources_Index_Direction's AppYAMLString.
58 //
59 // If the direction value is not recognized, an error will be returned.
60 func IndexDirectionFromAppYAMLString(v string) (AppEngineResources_Index_Directi on, error) {
61 switch v {
62 case "asc", "":
63 return AppEngineResources_Index_ASCENDING, nil
64
65 case "desc":
66 return AppEngineResources_Index_DESCENDING, nil
67
68 default:
69 return 0, errors.Reason("invalid index direction %(value)q").D(" value", v).Err()
70 }
71 }
72
51 // KubeString returns the Kubernetes "restartPolicy" field string for the 73 // KubeString returns the Kubernetes "restartPolicy" field string for the
52 // enumeration value. 74 // enumeration value.
53 func (v KubernetesPod_RestartPolicy) KubeString() string { 75 func (v KubernetesPod_RestartPolicy) KubeString() string {
54 switch v { 76 switch v {
55 case KubernetesPod_RESTART_ALWAYS: 77 case KubernetesPod_RESTART_ALWAYS:
56 return "Always" 78 return "Always"
57 case KubernetesPod_RESTART_ON_FAILURE: 79 case KubernetesPod_RESTART_ON_FAILURE:
58 return "OnFailure" 80 return "OnFailure"
59 case KubernetesPod_RESTART_NEVER: 81 case KubernetesPod_RESTART_NEVER:
60 return "Never" 82 return "Never"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 return "Ti" 115 return "Ti"
94 case KubernetesPod_Container_Resources_PEBIBYTE: 116 case KubernetesPod_Container_Resources_PEBIBYTE:
95 return "Pi" 117 return "Pi"
96 case KubernetesPod_Container_Resources_EXBIBYTE: 118 case KubernetesPod_Container_Resources_EXBIBYTE:
97 return "Ei" 119 return "Ei"
98 120
99 default: 121 default:
100 panic(fmt.Errorf("unknown resource unit (%v)", v)) 122 panic(fmt.Errorf("unknown resource unit (%v)", v))
101 } 123 }
102 } 124 }
OLDNEW
« no previous file with comments | « deploytool/api/deploy/component.pb.go ('k') | deploytool/cmd/luci_deploy/appengine.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698