diff --git a/src/properties/map.go b/src/properties/map.go index 07632c7a..58b1dc51 100644 --- a/src/properties/map.go +++ b/src/properties/map.go @@ -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 diff --git a/src/segments/cf_target.go b/src/segments/cf_target.go index 32bb942b..adb695a2 100644 --- a/src/segments/cf_target.go +++ b/src/segments/cf_target.go @@ -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 { diff --git a/website/docs/segments/cloud/cftarget.mdx b/website/docs/segments/cloud/cftarget.mdx index 58da8934..faa11c5f 100644 --- a/website/docs/segments/cloud/cftarget.mdx +++ b/website/docs/segments/cloud/cftarget.mdx @@ -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"; - + ## Properties -| Name | Type | Default | Description | -| -------------- | :------: | :------: | ------------------------------------------------------------------------------------------------------------------------------------------------- | -| `display_mode` | `string` | `always` | | +| Name | Type | Default | Description | +| -------------- | :--------: | :----------------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `display_mode` | `string` | `always` | | +| `files` | `[]string` | `["manifest.yml"]` | on which files to display the segment on. Will look in parent folders as well | ## Template ([info][templates])