Add app source and tests
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
56
lib/Peach/about/external/data/Docker.dart
vendored
Normal file
56
lib/Peach/about/external/data/Docker.dart
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
class DockerStatus {
|
||||
final bool installed;
|
||||
final bool running;
|
||||
final String version;
|
||||
DockerStatus(this.installed, this.running, this.version);
|
||||
}
|
||||
|
||||
class DockerContainer {
|
||||
final String id;
|
||||
final String name;
|
||||
final String image;
|
||||
final String state; // running | exited | created | paused | restarting | dead
|
||||
final String status; // e.g. "Up 2 hours" / "Exited (0) 3 min ago"
|
||||
final String ports;
|
||||
|
||||
DockerContainer({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.image,
|
||||
required this.state,
|
||||
required this.status,
|
||||
required this.ports,
|
||||
});
|
||||
|
||||
bool get up => state.toLowerCase() == 'running';
|
||||
}
|
||||
|
||||
/// Everything needed to `docker run` a new container.
|
||||
class DockerRunSpec {
|
||||
String image;
|
||||
String name;
|
||||
String ports; // "host:container" per line
|
||||
String env; // "KEY=VALUE" per line
|
||||
String volumes; // "host:container" per line
|
||||
String restart; // no | on-failure | always | unless-stopped
|
||||
bool detached;
|
||||
String command;
|
||||
|
||||
DockerRunSpec({
|
||||
this.image = '',
|
||||
this.name = '',
|
||||
this.ports = '',
|
||||
this.env = '',
|
||||
this.volumes = '',
|
||||
this.restart = 'unless-stopped',
|
||||
this.detached = true,
|
||||
this.command = '',
|
||||
});
|
||||
|
||||
List<String> _lines(String s) =>
|
||||
s.split('\n').map((e) => e.trim()).where((e) => e.isNotEmpty).toList();
|
||||
|
||||
List<String> get portList => _lines(ports);
|
||||
List<String> get envList => _lines(env);
|
||||
List<String> get volumeList => _lines(volumes);
|
||||
}
|
||||
Reference in New Issue
Block a user