Container.fromJson constructor

Container.fromJson(
  1. Map<String, dynamic> json
)

Creates a Container from JSON data.

Implementation

factory Container.fromJson(Map<String, dynamic> json) {
  final tempArgsJson = json['args'];
  final tempCommandJson = json['command'];
  final tempEnvJson = json['env'];
  final tempEnvFromJson = json['envFrom'];
  final tempImageJson = json['image'];
  final tempImagePullPolicyJson = json['imagePullPolicy'];
  final tempLifecycleJson = json['lifecycle'];
  final tempLivenessProbeJson = json['livenessProbe'];
  final tempNameJson = json['name'];
  final tempPortsJson = json['ports'];
  final tempReadinessProbeJson = json['readinessProbe'];
  final tempResizePolicyJson = json['resizePolicy'];
  final tempResourcesJson = json['resources'];
  final tempSecurityContextJson = json['securityContext'];
  final tempStartupProbeJson = json['startupProbe'];
  final tempStdinJson = json['stdin'];
  final tempStdinOnceJson = json['stdinOnce'];
  final tempTerminationMessagePathJson = json['terminationMessagePath'];
  final tempTerminationMessagePolicyJson = json['terminationMessagePolicy'];
  final tempTtyJson = json['tty'];
  final tempVolumeDevicesJson = json['volumeDevices'];
  final tempVolumeMountsJson = json['volumeMounts'];
  final tempWorkingDirJson = json['workingDir'];

  final List<String>? tempArgs =
      tempArgsJson != null ? List<String>.from(tempArgsJson) : null;
  final List<String>? tempCommand =
      tempCommandJson != null ? List<String>.from(tempCommandJson) : null;

  final List<EnvVar>? tempEnv = tempEnvJson != null
      ? List<dynamic>.from(tempEnvJson)
          .map(
            (e) => EnvVar.fromJson(
              Map<String, dynamic>.from(e),
            ),
          )
          .toList()
      : null;

  final List<EnvFromSource>? tempEnvFrom = tempEnvFromJson != null
      ? List<dynamic>.from(tempEnvFromJson)
          .map(
            (e) => EnvFromSource.fromJson(
              Map<String, dynamic>.from(e),
            ),
          )
          .toList()
      : null;

  final String? tempImage = tempImageJson;
  final String? tempImagePullPolicy = tempImagePullPolicyJson;
  final Lifecycle? tempLifecycle = tempLifecycleJson != null
      ? Lifecycle.fromJson(tempLifecycleJson)
      : null;
  final Probe? tempLivenessProbe = tempLivenessProbeJson != null
      ? Probe.fromJson(tempLivenessProbeJson)
      : null;
  final String tempName = tempNameJson;

  final List<ContainerPort>? tempPorts = tempPortsJson != null
      ? List<dynamic>.from(tempPortsJson)
          .map(
            (e) => ContainerPort.fromJson(
              Map<String, dynamic>.from(e),
            ),
          )
          .toList()
      : null;

  final Probe? tempReadinessProbe = tempReadinessProbeJson != null
      ? Probe.fromJson(tempReadinessProbeJson)
      : null;

  final List<ContainerResizePolicy>? tempResizePolicy =
      tempResizePolicyJson != null
          ? List<dynamic>.from(tempResizePolicyJson)
              .map(
                (e) => ContainerResizePolicy.fromJson(
                  Map<String, dynamic>.from(e),
                ),
              )
              .toList()
          : null;

  final ResourceRequirements? tempResources = tempResourcesJson != null
      ? ResourceRequirements.fromJson(tempResourcesJson)
      : null;
  final SecurityContext? tempSecurityContext = tempSecurityContextJson != null
      ? SecurityContext.fromJson(tempSecurityContextJson)
      : null;
  final Probe? tempStartupProbe = tempStartupProbeJson != null
      ? Probe.fromJson(tempStartupProbeJson)
      : null;
  final bool? tempStdin = tempStdinJson;
  final bool? tempStdinOnce = tempStdinOnceJson;
  final String? tempTerminationMessagePath = tempTerminationMessagePathJson;
  final String? tempTerminationMessagePolicy =
      tempTerminationMessagePolicyJson;
  final bool? tempTty = tempTtyJson;

  final List<VolumeDevice>? tempVolumeDevices = tempVolumeDevicesJson != null
      ? List<dynamic>.from(tempVolumeDevicesJson)
          .map(
            (e) => VolumeDevice.fromJson(
              Map<String, dynamic>.from(e),
            ),
          )
          .toList()
      : null;

  final List<VolumeMount>? tempVolumeMounts = tempVolumeMountsJson != null
      ? List<dynamic>.from(tempVolumeMountsJson)
          .map(
            (e) => VolumeMount.fromJson(
              Map<String, dynamic>.from(e),
            ),
          )
          .toList()
      : null;

  final String? tempWorkingDir = tempWorkingDirJson;

  return Container(
    args: tempArgs,
    command: tempCommand,
    env: tempEnv,
    envFrom: tempEnvFrom,
    image: tempImage,
    imagePullPolicy: tempImagePullPolicy,
    lifecycle: tempLifecycle,
    livenessProbe: tempLivenessProbe,
    name: tempName,
    ports: tempPorts,
    readinessProbe: tempReadinessProbe,
    resizePolicy: tempResizePolicy,
    resources: tempResources,
    securityContext: tempSecurityContext,
    startupProbe: tempStartupProbe,
    stdin: tempStdin,
    stdinOnce: tempStdinOnce,
    terminationMessagePath: tempTerminationMessagePath,
    terminationMessagePolicy: tempTerminationMessagePolicy,
    tty: tempTty,
    volumeDevices: tempVolumeDevices,
    volumeMounts: tempVolumeMounts,
    workingDir: tempWorkingDir,
  );
}