validate method

void validate(
  1. void showUsage()
)

Implementation

void validate(void Function() showUsage) {
  if (!isConfigured) {
    printerr(
        red("A saved configuration doesn't exist. You must use first run "
            "'nginx-le config."));
    showUsage();
  }

  if (image == null) {
    printerr(red(
        'Your configuration is in an inconsistent state. (image is null). '
        "Run 'nginx-le config'."));
    showUsage();
  }

  if (containerid == null) {
    printerr(red('Your configuration is in an inconsistent state. '
        "(containerid is null). Run 'nginx-le config'."));
    showUsage();
  }

  if (!Containers().existsByContainerId(containerid!)) {
    printerr(red('The ngnix-le container $containerid no longer exists.'));
    printerr(red('  Run nginx-le config to change the container.'));
    exit(1);
  }
  if (!Images().existsByImageId(imageid: image!.imageid!)) {
    printerr(red('The ngnix-le image ${image!.imageid} no longer exists.'));
    printerr(red('  Run nginx-le config to change the image.'));
    exit(1);
  }
}