getMinCLIVersion function

String getMinCLIVersion(
  1. Map agentJson
)

Implementation

String getMinCLIVersion(Map agentJson) {
  final versions = _findVersions(agentJson);

  if (versions.isEmpty) {
    throw Exception(
        'Agent Json don\'t contain versions and hence failed to determine the minimum cli version required for the agent. Please contact CommandDash team. \nTroubling json: $agentJson');
  }

  var minVersion = versions.first;
  var minVersionNumber = _versionToNumber(minVersion);

  for (final version in versions) {
    final versionNumber = _versionToNumber(version);

    if ((minVersionNumber == null) ||
        (versionNumber != null && versionNumber < minVersionNumber)) {
      minVersion = version;
      minVersionNumber = versionNumber;
    }
  }
  return minVersion;
}