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