Class DiskMappingParser
java.lang.Object
com.google.jenkins.plugins.computeengine.util.DiskMappingParser
Parses disk mapping strings in GCP key=value format into
AttachedDisk objects.
Supports two modes in the same textarea. Both modes support device-name,
mode, interface, and auto-delete.
- Create disk
(
--create-disksemantics) — when the line containssource-snapshot,size, ortype. A new disk is created and attached. - Attach existing disk
(
--disksemantics) — when the line contains onlyname(without any create-disk keys). An existing disk is attached by reference.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringnormalizeDiskSource(String diskSource, String project, String zone) Expands short disk names to project- and zone-qualified resource paths (projects/{project}/zones/{zone}/disks/{name}).static StringnormalizeDiskType(String diskType, String zone) Expands short disk type names (e.g.static StringnormalizeSnapshotSource(String snapshotSource, String project) Expands short snapshot names to project-qualified resource paths (projects/{project}/global/snapshots/{name}).static List<com.google.api.services.compute.model.AttachedDisk> Parses a multi-line disk mapping string into a list ofAttachedDiskobjects.
-
Method Details
-
parse
public static List<com.google.api.services.compute.model.AttachedDisk> parse(@Nullable String diskMapping) Parses a multi-line disk mapping string into a list ofAttachedDiskobjects. Each non-blank line is parsed as a separate disk specification.- Parameters:
diskMapping- the disk mapping string (one disk per line), or null/empty- Returns:
- a list of configured
AttachedDiskobjects, empty if input is null/blank - Throws:
IllegalArgumentException- if a line fails validation
-
normalizeDiskType
Expands short disk type names (e.g.pd-ssd) to zone-qualified resource paths (zones/{zone}/diskTypes/pd-ssd). Full URLs and relative paths that already contain a/are returned unchanged.- Parameters:
diskType- the disk type value from the mapping, or nullzone- the zone name (e.g.us-east1-b)- Returns:
- the qualified disk type, or null if input is null
-
normalizeDiskSource
@Nullable public static String normalizeDiskSource(@Nullable String diskSource, String project, String zone) Expands short disk names to project- and zone-qualified resource paths (projects/{project}/zones/{zone}/disks/{name}). Full URLs and relative paths that already contain a/are returned unchanged.- Parameters:
diskSource- the disk name or path from the mapping, or nullproject- the project ID (e.g.my-project)zone- the zone name (e.g.us-east1-b)- Returns:
- the qualified disk source, or null if input is null
-
normalizeSnapshotSource
@Nullable public static String normalizeSnapshotSource(@Nullable String snapshotSource, String project) Expands short snapshot names to project-qualified resource paths (projects/{project}/global/snapshots/{name}). Full URLs and relative paths that already contain a/are returned unchanged.- Parameters:
snapshotSource- the snapshot name or path from the mapping, or nullproject- the project ID (e.g.my-project)- Returns:
- the qualified snapshot source, or null if input is null
-