org.kiwiproject.ansible.vault.VaultViewCommand Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kiwi Show documentation
Show all versions of kiwi Show documentation
Kiwi is a utility library. We really like Google's Guava, and also use Apache Commons.
But if they don't have something we need, and we think it is useful, this is where we put it.
package org.kiwiproject.ansible.vault;
import static org.kiwiproject.base.KiwiPreconditions.checkArgumentNotBlank;
import static org.kiwiproject.base.KiwiPreconditions.checkArgumentNotNull;
import lombok.Builder;
import java.nio.file.Paths;
import java.util.List;
/**
* Generates {@code ansible-vault view} commands.
*/
@Builder
public class VaultViewCommand implements OsCommand {
private final String ansibleVaultPath;
private final String vaultPasswordFilePath;
private final String encryptedFilePath;
/**
* Create an instance.
*
* @param configuration the {@link VaultConfiguration} to use
* @param encryptedFilePath path to the encrypted file to view
* @return the command
*/
public static VaultViewCommand from(VaultConfiguration configuration, String encryptedFilePath) {
checkArgumentNotNull(configuration, "configuration cannot be null");
checkArgumentNotBlank(encryptedFilePath, "encryptedFilePath cannot be blank");
return VaultViewCommand.builder()
.ansibleVaultPath(configuration.getAnsibleVaultPath())
.vaultPasswordFilePath(configuration.getVaultPasswordFilePath())
.encryptedFilePath(encryptedFilePath)
.build();
}
@Override
public List getCommandParts() {
return List.of(
ansibleVaultPath,
"view",
"--vault-password-file", vaultPasswordFilePath,
Paths.get(encryptedFilePath).toString()
);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy