MCPcopy Create free account
hub / github.com/apache/mesos / foreach

Function foreach

src/common/validation.cpp:146–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144Option<Error> validateEnvironment(const Environment& environment)
145{
146 foreach (const Environment::Variable& variable, environment.variables()) {
147 switch (variable.type()) {
148 case Environment::Variable::SECRET: {
149 if (!variable.has_secret()) {
150 return Error(
151 "Environment variable '" + variable.name() +
152 "' of type 'SECRET' must have a secret set");
153 }
154
155 if (variable.has_value()) {
156 return Error(
157 "Environment variable '" + variable.name() +
158 "' of type 'SECRET' must not have a value set");
159 }
160
161 Option<Error> error = validateSecret(variable.secret());
162 if (error.isSome()) {
163 return Error(
164 "Environment variable '" + variable.name() + "' specifies an "
165 "invalid secret: " + error->message);
166 }
167
168 if (variable.secret().value().data().find('\0') != string::npos) {
169 return Error(
170 "Environment variable '" + variable.name() + "' specifies a "
171 "secret containing null bytes, which is not allowed in the "
172 "environment");
173 }
174 break;
175 }
176
177 // NOTE: If new variable types are added in the future and an upgraded
178 // client/master sends a new type to an older master/agent, the older
179 // master/agent will see VALUE instead of the new type, since VALUE is set
180 // as the default type in the protobuf definition.
181 case Environment::Variable::VALUE:
182 if (!variable.has_value()) {
183 return Error(
184 "Environment variable '" + variable.name() +
185 "' of type 'VALUE' must have a value set");
186 }
187
188 if (variable.has_secret()) {
189 return Error(
190 "Environment variable '" + variable.name() +
191 "' of type 'VALUE' must not have a secret set");
192 }
193 break;
194
195 case Environment::Variable::UNKNOWN:
196 return Error("Environment variable of type 'UNKNOWN' is not allowed");
197
198 UNREACHABLE();
199 }
200 }
201
202 return None();
203}

Callers

nothing calls this directly

Calls 12

validateSecretFunction · 0.85
validateVolumeFunction · 0.85
validateInputScalarValueFunction · 0.85
typeMethod · 0.80
dataMethod · 0.80
quantitiesMethod · 0.80
ErrorFunction · 0.50
nameMethod · 0.45
isSomeMethod · 0.45
findMethod · 0.45
valueMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected