| 3699 | |
| 3700 | |
| 3701 | Future<Option<Secret>> Slave::generateSecret( |
| 3702 | const FrameworkID& frameworkId, |
| 3703 | const ExecutorID& executorId, |
| 3704 | const ContainerID& containerId) |
| 3705 | { |
| 3706 | if (!secretGenerator) { |
| 3707 | return None(); |
| 3708 | } |
| 3709 | |
| 3710 | Principal principal( |
| 3711 | Option<string>::none(), |
| 3712 | { |
| 3713 | {"fid", frameworkId.value()}, |
| 3714 | {"eid", executorId.value()}, |
| 3715 | {"cid", containerId.value()} |
| 3716 | }); |
| 3717 | |
| 3718 | return secretGenerator->generate(principal) |
| 3719 | .then([](const Secret& secret) -> Future<Option<Secret>> { |
| 3720 | Option<Error> error = common::validation::validateSecret(secret); |
| 3721 | |
| 3722 | if (error.isSome()) { |
| 3723 | return Failure( |
| 3724 | "Failed to validate generated secret: " + error->message); |
| 3725 | } else if (secret.type() != Secret::VALUE) { |
| 3726 | return Failure( |
| 3727 | "Expecting generated secret to be of VALUE type instead of " + |
| 3728 | stringify(secret.type()) + " type; " + |
| 3729 | "only VALUE type secrets are supported at this time"); |
| 3730 | } |
| 3731 | |
| 3732 | return secret; |
| 3733 | }); |
| 3734 | } |
| 3735 | |
| 3736 | |
| 3737 | // Launches an executor which was previously created. |