Class DiskMappingParser

java.lang.Object
com.google.jenkins.plugins.computeengine.util.DiskMappingParser

public class DiskMappingParser extends Object
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-disk semantics) — when the line contains source-snapshot, size, or type. A new disk is created and attached.
  • Attach existing disk (--disk semantics) — when the line contains only name (without any create-disk keys). An existing disk is attached by reference.
  • 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 of AttachedDisk objects. 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 AttachedDisk objects, empty if input is null/blank
      Throws:
      IllegalArgumentException - if a line fails validation
    • normalizeDiskType

      @Nullable public static String normalizeDiskType(@Nullable String diskType, String zone)
      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 null
      zone - 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 null
      project - 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 null
      project - the project ID (e.g. my-project)
      Returns:
      the qualified snapshot source, or null if input is null