-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathimage.rs
More file actions
111 lines (94 loc) · 2.96 KB
/
Copy pathimage.rs
File metadata and controls
111 lines (94 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
use clap::{Args, Subcommand, ValueEnum};
use crate::{
cli::Cli,
core::{
image::ImageSelector,
platform::{Architecture, TargetPlatform},
},
};
#[derive(Debug, Args)]
pub struct ImageArguments {
#[command(subcommand)]
pub command: ImageCommand,
}
#[derive(Debug, Subcommand)]
pub enum ImageCommand {
/// Lists images known by boil with all available versions.
List(ImageListArguments),
/// Checks if all images known by boil are available in the specified registries.
///
/// Access tokens must be provided with the following name: `BOIL_REGISTRY_TOKEN_<REGISTRY_URI>`.
Check(ImageCheckArguments),
/// Calculates the size of images known by boil.
Size(ImageSizeArguments),
}
#[derive(Debug, Args)]
pub struct ImageListArguments {
/// Optionally specify one or more images to display.
pub image: Vec<ImageSelector>,
/// Pretty print the structured output.
#[arg(long, value_enum, default_value_t = Pretty::default())]
pub pretty: Pretty,
}
#[derive(Debug, Args)]
pub struct ImageCheckArguments {
/// Optionally specify one or more images to check. Checks all images by default.
pub image: Vec<ImageSelector>,
// NOTE (@Techassi): Should this maybe be renamed to vendor_version?
/// The image version to check.
#[arg(
short, long,
value_parser = Cli::parse_vendor_version,
default_value_t = Cli::default_vendor_version(),
help_heading = "Image Options"
)]
pub image_version: String,
}
#[derive(Debug, Args)]
pub struct ImageSizeArguments {
/// Optionally specify one or more images to check. Checks all images by default.
pub image: Vec<ImageSelector>,
/// The vendor version to use.
#[arg(
short, long,
// TODO (@Techassi): Eventually remove these aliases
short_alias = 'i',
alias = "image-version",
value_parser = Cli::parse_vendor_version,
default_value_t = Cli::default_vendor_version(),
help_heading = "Image Options"
)]
pub vendor_version: String,
/// Target platform of the image.
#[arg(
short, long,
short_alias = 'a', alias = "architecture",
default_value_t = Self::default_architecture(),
help_heading = "Image Options"
)]
pub target_platform: TargetPlatform,
/// Pretty print the structured output.
#[arg(long, value_enum, default_value_t = Pretty::default(), help_heading = "Output Options")]
pub pretty: Pretty,
#[arg(short, long, value_enum, default_value_t = Format::default(), help_heading = "Output Options")]
pub format: Format,
}
impl ImageSizeArguments {
// TODO: Auto-detect this
fn default_architecture() -> TargetPlatform {
TargetPlatform::Linux(Architecture::Amd64)
}
}
#[derive(Clone, Debug, Default, ValueEnum)]
pub enum Pretty {
#[default]
Auto,
Always,
Never,
}
#[derive(Clone, Debug, Default, ValueEnum)]
pub enum Format {
#[default]
Plain,
Json,
}