Search in sources :

Example 1 with PermissionConfiguration

use of com.google.cloud.tools.jib.maven.JibPluginConfiguration.PermissionConfiguration in project jib by GoogleContainerTools.

the class MojoCommon method convertPermissionsList.

/**
 * Converts a list of {@link PermissionConfiguration} to an equivalent {@code
 * String->FilePermission} map.
 *
 * @param permissionList the list to convert
 * @return the resulting map
 */
static Map<String, FilePermissions> convertPermissionsList(List<PermissionConfiguration> permissionList) {
    // Order is important, so use a LinkedHashMap
    Map<String, FilePermissions> permissionsMap = new LinkedHashMap<>();
    for (PermissionConfiguration permission : permissionList) {
        Optional<String> file = permission.getFile();
        Optional<String> mode = permission.getMode();
        if (!file.isPresent() || !mode.isPresent()) {
            throw new IllegalArgumentException("Incomplete <permission> configuration; requires <file> and <mode> fields to be set");
        }
        permissionsMap.put(file.get(), FilePermissions.fromOctalString(mode.get()));
    }
    return permissionsMap;
}
Also used : PermissionConfiguration(com.google.cloud.tools.jib.maven.JibPluginConfiguration.PermissionConfiguration) FilePermissions(com.google.cloud.tools.jib.api.buildplan.FilePermissions) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with PermissionConfiguration

use of com.google.cloud.tools.jib.maven.JibPluginConfiguration.PermissionConfiguration in project jib by google.

the class MojoCommon method convertPermissionsList.

/**
 * Converts a list of {@link PermissionConfiguration} to an equivalent {@code
 * String->FilePermission} map.
 *
 * @param permissionList the list to convert
 * @return the resulting map
 */
static Map<String, FilePermissions> convertPermissionsList(List<PermissionConfiguration> permissionList) {
    // Order is important, so use a LinkedHashMap
    Map<String, FilePermissions> permissionsMap = new LinkedHashMap<>();
    for (PermissionConfiguration permission : permissionList) {
        Optional<String> file = permission.getFile();
        Optional<String> mode = permission.getMode();
        if (!file.isPresent() || !mode.isPresent()) {
            throw new IllegalArgumentException("Incomplete <permission> configuration; requires <file> and <mode> fields to be set");
        }
        permissionsMap.put(file.get(), FilePermissions.fromOctalString(mode.get()));
    }
    return permissionsMap;
}
Also used : PermissionConfiguration(com.google.cloud.tools.jib.maven.JibPluginConfiguration.PermissionConfiguration) FilePermissions(com.google.cloud.tools.jib.api.buildplan.FilePermissions) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

FilePermissions (com.google.cloud.tools.jib.api.buildplan.FilePermissions)2 PermissionConfiguration (com.google.cloud.tools.jib.maven.JibPluginConfiguration.PermissionConfiguration)2 LinkedHashMap (java.util.LinkedHashMap)2