Assemble the scope from the flags.
(&self, server_url: Option<&str>)
| 232 | |
| 233 | /// Assemble the scope from the flags. |
| 234 | fn build_scope(&self, server_url: Option<&str>) -> CliResult<DelegationScope> { |
| 235 | let mut builder = DelegationScope::builder().permissions(parse_permissions(&self.can)?); |
| 236 | |
| 237 | // Bind to the server unless this is a local-only certificate. A |
| 238 | // certificate with no server is valid everywhere, which is exactly what |
| 239 | // we do not want once one is in play. |
| 240 | if let Some(url) = server_url { |
| 241 | builder = builder.server(url); |
| 242 | } |
| 243 | for pattern in self |
| 244 | .projects |
| 245 | .as_deref() |
| 246 | .map(parse_patterns) |
| 247 | .unwrap_or_default() |
| 248 | { |
| 249 | builder = builder.project(pattern); |
| 250 | } |
| 251 | for pattern in self |
| 252 | .workspaces |
| 253 | .as_deref() |
| 254 | .map(parse_patterns) |
| 255 | .unwrap_or_default() |
| 256 | { |
| 257 | builder = builder.workspace(pattern); |
| 258 | } |
| 259 | for pattern in self |
| 260 | .views |
| 261 | .as_deref() |
| 262 | .map(parse_patterns) |
| 263 | .unwrap_or_default() |
| 264 | { |
| 265 | builder = builder.view(pattern); |
| 266 | } |
| 267 | if let Some(max) = self.max_changes { |
| 268 | builder = builder.max_changes(max); |
| 269 | } |
| 270 | Ok(builder.build()) |
| 271 | } |
| 272 | |
| 273 | /// Enroll the agent key and certificate with the server. |
| 274 | /// |
no test coverage detected