feat(cftarget): allow files override

resolves #5526
This commit is contained in:
Jan De Dobbeleer 2024-09-02 12:01:36 +02:00 committed by Jan De Dobbeleer
parent b67756001f
commit 0700dfa594
3 changed files with 26 additions and 16 deletions

View file

@ -53,6 +53,8 @@ const (
DefaultCacheTimeout = 10
// CacheTimeout cache timeout
CacheTimeout Property = "cache_timeout"
// Files to trigger the segment on
Files Property = "files"
)
type Map map[Property]any

View file

@ -41,12 +41,17 @@ func (c *CfTarget) Enabled() bool {
return c.setCFTargetStatus()
}
manifest, err := c.env.HasParentFilePath("manifest.yml", false)
if err != nil || manifest.IsDir {
return false
files := c.props.GetStringArray(properties.Files, []string{"manifest.yml"})
for _, file := range files {
manifest, err := c.env.HasParentFilePath(file, false)
if err != nil || manifest.IsDir {
continue
}
return c.setCFTargetStatus()
}
return c.setCFTargetStatus()
return false
}
func (c *CfTarget) setCFTargetStatus() bool {

View file

@ -10,22 +10,25 @@ Display the details of the logged [Cloud Foundry endpoint][cf-target] (`cf targe
## Sample Configuration
import Config from '@site/src/components/Config.js';
import Config from "@site/src/components/Config.js";
<Config data={{
"background": "#a7cae1",
"foreground": "#100e23",
"powerline_symbol": "\ue0b0",
"template": " \uf40a {{ .Org }}/{{ .Space }} ",
"style": "powerline",
"type": "cftarget"
}}/>
<Config
data={{
background: "#a7cae1",
foreground: "#100e23",
powerline_symbol: "\ue0b0",
template: " \uf40a {{ .Org }}/{{ .Space }} ",
style: "powerline",
type: "cftarget",
}}
/>
## Properties
| Name | Type | Default | Description |
| -------------- | :------: | :------: | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `display_mode` | `string` | `always` | <ul><li>`always`: the segment is always displayed</li><li>`files`: the segment is only displayed when a `manifest.yml` file is present </li></ul> |
| Name | Type | Default | Description |
| -------------- | :--------: | :----------------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `display_mode` | `string` | `always` | <ul><li>`always`: the segment is always displayed</li><li>`files`: the segment is only displayed when a `manifest.yml` file is present (or defined otherwise using `files`) </li></ul> |
| `files` | `[]string` | `["manifest.yml"]` | on which files to display the segment on. Will look in parent folders as well |
## Template ([info][templates])