mirror of
https://github.com/starship/starship.git
synced 2026-06-24 02:01:36 +07:00
fix(docker_context): add compose.yml and compose.yaml to files (#6625)
This commit is contained in:
@@ -430,6 +430,8 @@
|
||||
"default": {
|
||||
"detect_extensions": [],
|
||||
"detect_files": [
|
||||
"compose.yml",
|
||||
"compose.yaml",
|
||||
"docker-compose.yml",
|
||||
"docker-compose.yaml",
|
||||
"Dockerfile"
|
||||
@@ -3163,6 +3165,8 @@
|
||||
},
|
||||
"detect_files": {
|
||||
"default": [
|
||||
"compose.yml",
|
||||
"compose.yaml",
|
||||
"docker-compose.yml",
|
||||
"docker-compose.yaml",
|
||||
"Dockerfile"
|
||||
|
||||
+10
-10
@@ -1317,16 +1317,16 @@ the context in use).
|
||||
|
||||
### Options
|
||||
|
||||
| Option | Default | Description |
|
||||
| ------------------- | ------------------------------------------------------------- | --------------------------------------------------------------------------------- |
|
||||
| `format` | `'via [$symbol$context]($style) '` | The format for the module. |
|
||||
| `symbol` | `'🐳 '` | The symbol used before displaying the Docker context. |
|
||||
| `only_with_files` | `true` | Only show when there's a match |
|
||||
| `detect_extensions` | `[]` | Which extensions should trigger this module (needs `only_with_files` to be true). |
|
||||
| `detect_files` | `['docker-compose.yml', 'docker-compose.yaml', 'Dockerfile']` | Which filenames should trigger this module (needs `only_with_files` to be true). |
|
||||
| `detect_folders` | `[]` | Which folders should trigger this module (needs `only_with_files` to be true). |
|
||||
| `style` | `'blue bold'` | The style for the module. |
|
||||
| `disabled` | `false` | Disables the `docker_context` module. |
|
||||
| Option | Default | Description |
|
||||
| ------------------- | -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
|
||||
| `format` | `'via [$symbol$context]($style) '` | The format for the module. |
|
||||
| `symbol` | `'🐳 '` | The symbol used before displaying the Docker context. |
|
||||
| `only_with_files` | `true` | Only show when there's a match |
|
||||
| `detect_extensions` | `[]` | Which extensions should trigger this module (needs `only_with_files` to be true). |
|
||||
| `detect_files` | `['compose.yml', 'compose.yaml', 'docker-compose.yml', 'docker-compose.yaml', 'Dockerfile']` | Which filenames should trigger this module (needs `only_with_files` to be true). |
|
||||
| `detect_folders` | `[]` | Which folders should trigger this module (needs `only_with_files` to be true). |
|
||||
| `style` | `'blue bold'` | The style for the module. |
|
||||
| `disabled` | `false` | Disables the `docker_context` module. |
|
||||
|
||||
### Variables
|
||||
|
||||
|
||||
@@ -27,7 +27,13 @@ impl Default for DockerContextConfig<'_> {
|
||||
only_with_files: true,
|
||||
disabled: false,
|
||||
detect_extensions: vec![],
|
||||
detect_files: vec!["docker-compose.yml", "docker-compose.yaml", "Dockerfile"],
|
||||
detect_files: vec![
|
||||
"compose.yml",
|
||||
"compose.yaml",
|
||||
"docker-compose.yml",
|
||||
"docker-compose.yaml",
|
||||
"Dockerfile",
|
||||
],
|
||||
detect_folders: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,6 +108,64 @@ mod tests {
|
||||
cfg_dir.close()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_with_compose_yml() -> io::Result<()> {
|
||||
let cfg_dir = tempfile::tempdir()?;
|
||||
let cfg_file = cfg_dir.path().join("config.json");
|
||||
|
||||
let pwd = tempfile::tempdir()?;
|
||||
File::create(pwd.path().join("compose.yml"))?.sync_all()?;
|
||||
|
||||
let config_content = serde_json::json!({
|
||||
"currentContext": "starship"
|
||||
});
|
||||
|
||||
let mut docker_config = File::create(cfg_file)?;
|
||||
docker_config.write_all(config_content.to_string().as_bytes())?;
|
||||
docker_config.sync_all()?;
|
||||
|
||||
let actual = ModuleRenderer::new("docker_context")
|
||||
.env("DOCKER_CONFIG", cfg_dir.path().to_string_lossy())
|
||||
.path(pwd.path())
|
||||
.collect();
|
||||
|
||||
let expected = Some(format!("via {} ", Color::Blue.bold().paint("🐳 starship")));
|
||||
|
||||
assert_eq!(expected, actual);
|
||||
|
||||
cfg_dir.close()?;
|
||||
pwd.close()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_with_compose_yaml() -> io::Result<()> {
|
||||
let cfg_dir = tempfile::tempdir()?;
|
||||
let cfg_file = cfg_dir.path().join("config.json");
|
||||
|
||||
let pwd = tempfile::tempdir()?;
|
||||
File::create(pwd.path().join("compose.yaml"))?.sync_all()?;
|
||||
|
||||
let config_content = serde_json::json!({
|
||||
"currentContext": "starship"
|
||||
});
|
||||
|
||||
let mut docker_config = File::create(cfg_file)?;
|
||||
docker_config.write_all(config_content.to_string().as_bytes())?;
|
||||
docker_config.sync_all()?;
|
||||
|
||||
let actual = ModuleRenderer::new("docker_context")
|
||||
.env("DOCKER_CONFIG", cfg_dir.path().to_string_lossy())
|
||||
.path(pwd.path())
|
||||
.collect();
|
||||
|
||||
let expected = Some(format!("via {} ", Color::Blue.bold().paint("🐳 starship")));
|
||||
|
||||
assert_eq!(expected, actual);
|
||||
|
||||
cfg_dir.close()?;
|
||||
pwd.close()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_with_docker_compose_yml() -> io::Result<()> {
|
||||
let cfg_dir = tempfile::tempdir()?;
|
||||
|
||||
Reference in New Issue
Block a user