Debian Codegraph @

config.go

raw symbols SCIP
1 /*
2 Copyright The containerd Authors.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 package mainscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/
18
19 import (
20 "fmtscip-go gomod github.com/golang/go/src go1.13 fmt/"
21 "io/ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/"
22 "logscip-go gomod github.com/golang/go/src go1.13 log/"
23
24 "github.com/pelletier/go-tomlscip-go gomod github.com/pelletier/go-toml v1.8.1 `github.com/pelletier/go-toml`/"
25 )
26
27 type configscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config# struct {
28 Versionscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Version. string
29 Generatorsscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Generators. []string
30
31 // Generator is a code generator which is used from protoc.
32 // Deprecated: Use Generators instead.
33 Generatorscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Generator. string
34
35 // Parameters are custom parameters to be passed to the generators.
36 // The parameter key must be the generator name with a table value
37 // of keys and string values to be passed.
38 // Example:
39 // [parameters.go-ttrpc]
40 // customkey = "somevalue"
41 Parametersscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Parameters. map[string]map[string]string
42
43 // Plugins will be deprecated. It has to be per-Generator setting,
44 // but neither protoc-gen-go nor protoc-gen-go-grpc support plugins.
45 // So the refactoring is not worth to do.
46 Pluginsscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Plugins. []string
47
48 Includesscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Includes. struct {
49 Beforescip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#$anon_48fb85662828483f#Before. []string
50 Vendoredscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#$anon_48fb85662828483f#Vendored. []string
51 Packagesscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#$anon_48fb85662828483f#Packages. []string
52 Afterscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#$anon_48fb85662828483f#After. []string
53 }
54
55 Packagesscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Packages. map[string]string
56
57 Overridesscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Overrides. []struct {
58 Prefixesscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#$anon_31981d51bf45d911#Prefixes. []string
59 // Generator is a code generator which is used from protoc.
60 // Deprecated: Use Generators instead.
61 Generatorscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#$anon_31981d51bf45d911#Generator. string
62 Generatorsscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#$anon_31981d51bf45d911#Generators. []string
63 Parametersscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#$anon_31981d51bf45d911#Parameters. map[string]map[string]string
64 Pluginsscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#$anon_31981d51bf45d911#Plugins. *[]string
65
66 // TODO(stevvooe): We could probably support overriding of includes and
67 // package maps, but they don't seem to be as useful. Likely,
68 // overriding the package map is more useful but includes happen
69 // project-wide.
70 }
71
72 Descriptorsscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Descriptors. []struct {
73 Prefixscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#$anon_5dab7c5967f5797b#Prefix. string
74 Targetscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#$anon_5dab7c5967f5797b#Target. string
75 IgnoreFilesscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#$anon_5dab7c5967f5797b#IgnoreFiles. []string `toml:"ignore_files"`
76 }
77 }
78
79 func newDefaultConfigscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/newDefaultConfig().() configscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config# {
80 return configscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#{
81 Includesscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Includes.: struct {
82 Before []string
83 Vendored []string
84 Packages []string
85 After []string
86 }{
87 Before: []string{"."},
88 After: []string{"/usr/local/include", "/usr/include"},
89 },
90 }
91 }
92
93 func readConfigscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/readConfig().(path string) (configscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#, error) {
94 p, err := ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/.ReadFilescip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/ReadFile().(path)
95 if err != nil {
96 logscip-go gomod github.com/golang/go/src go1.13 log/.Fatallnscip-go gomod github.com/golang/go/src go1.13 log/Fatalln().(err)
97 }
98 return readConfigFromscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/readConfigFrom().(p)
99 }
100
101 func readConfigFromscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/readConfigFrom().(p []byte) (configscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#, error) {
102 c := newDefaultConfigscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/newDefaultConfig().()
103 if err := tomlscip-go gomod github.com/pelletier/go-toml v1.8.1 `github.com/pelletier/go-toml`/.Unmarshalscip-go gomod github.com/pelletier/go-toml v1.8.1 `github.com/pelletier/go-toml`/Unmarshal().(p, &c); err != nil {
104 logscip-go gomod github.com/golang/go/src go1.13 log/.Fatallnscip-go gomod github.com/golang/go/src go1.13 log/Fatalln().(err)
105 }
106
107 if c.Generatorscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Generator. != "" {
108 if len(c.Generatorsscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Generators.) > 0 {
109 return configscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#{}, fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.13 fmt/Errorf().(
110 `specify either "generators = %v" or "generator = %v", not both`,
111 c.Generatorsscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Generators., c.Generatorscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Generator.,
112 )
113 }
114 c.Generatorsscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Generators. = []string{c.Generatorscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Generator.}
115 c.Generatorscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Generator. = ""
116 }
117
118 for i, o := range c.Overridesscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Overrides. {
119 if o.Generatorscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#$anon_31981d51bf45d911#Generator. != "" {
120 if len(o.Generatorsscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#$anon_31981d51bf45d911#Generators.) > 0 {
121 return configscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#{}, fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.13 fmt/Errorf().(
122 `specify either "overrides[%d].generators" or "overrides[%d].generator", not both`,
123 i, i,
124 )
125 }
126 c.Overridesscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Overrides.[i].Generatorsscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#$anon_31981d51bf45d911#Generators. = []string{o.Generatorscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#$anon_31981d51bf45d911#Generator.}
127 c.Overridesscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Overrides.[i].Generatorscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#$anon_31981d51bf45d911#Generator. = ""
128 }
129 }
130
131 if len(c.Generatorsscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Generators.) == 0 {
132 c.Generatorsscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/config#Generators. = []string{"go"}
133 }
134
135 return c, nil
136 }