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 DefaultCacheTimeout = 10
// CacheTimeout cache timeout // CacheTimeout cache timeout
CacheTimeout Property = "cache_timeout" CacheTimeout Property = "cache_timeout"
// Files to trigger the segment on
Files Property = "files"
) )
type Map map[Property]any type Map map[Property]any

View file

@ -41,12 +41,17 @@ func (c *CfTarget) Enabled() bool {
return c.setCFTargetStatus() return c.setCFTargetStatus()
} }
manifest, err := c.env.HasParentFilePath("manifest.yml", 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 { if err != nil || manifest.IsDir {
return false continue
} }
return c.setCFTargetStatus() return c.setCFTargetStatus()
}
return false
} }
func (c *CfTarget) setCFTargetStatus() bool { 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 ## Sample Configuration
import Config from '@site/src/components/Config.js'; import Config from "@site/src/components/Config.js";
<Config data={{ <Config
"background": "#a7cae1", data={{
"foreground": "#100e23", background: "#a7cae1",
"powerline_symbol": "\ue0b0", foreground: "#100e23",
"template": " \uf40a {{ .Org }}/{{ .Space }} ", powerline_symbol: "\ue0b0",
"style": "powerline", template: " \uf40a {{ .Org }}/{{ .Space }} ",
"type": "cftarget" style: "powerline",
}}/> type: "cftarget",
}}
/>
## Properties ## Properties
| Name | Type | Default | Description | | 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> | | `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]) ## Template ([info][templates])