mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
allow user to replace docker repo prefix from image names
Example usage:
```yaml
replacements:
imageNamePrefixes:
'123456789012.dkr.ecr.us-east-1.amazonaws.com': '<prod>'
'923456789999.dkr.ecr.us-east-1.amazonaws.com': '<dev>'
```
Closes #316
This commit is contained in:
parent
0b158dfabe
commit
d64a92227a
3 changed files with 30 additions and 0 deletions
|
|
@ -90,3 +90,14 @@ customCommands:
|
||||||
command: 'docker exec -it {{ .Container.ID }} bash'
|
command: 'docker exec -it {{ .Container.ID }} bash'
|
||||||
serviceNames: []
|
serviceNames: []
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Replacements
|
||||||
|
|
||||||
|
You can add replacements like so:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
replacements:
|
||||||
|
imageNamePrefixes:
|
||||||
|
'123456789012.dkr.ecr.us-east-1.amazonaws.com': '<prod>'
|
||||||
|
'923456789999.dkr.ecr.us-east-1.amazonaws.com': '<dev>'
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,13 @@ func (c *DockerCommand) RefreshImages() ([]*Image, error) {
|
||||||
if len(nameParts) > 1 {
|
if len(nameParts) > 1 {
|
||||||
tag = nameParts[len(nameParts)-1]
|
tag = nameParts[len(nameParts)-1]
|
||||||
name = strings.Join(nameParts[:len(nameParts)-1], ":")
|
name = strings.Join(nameParts[:len(nameParts)-1], ":")
|
||||||
|
|
||||||
|
for prefix, replacement := range c.Config.UserConfig.Replacements.ImageNamePrefixes {
|
||||||
|
if strings.HasPrefix(name, prefix) {
|
||||||
|
name = strings.Replace(name, prefix, replacement, 1)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ownImages[i] = &Image{
|
ownImages[i] = &Image{
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,9 @@ type UserConfig struct {
|
||||||
// Stats determines how long lazydocker will gather container stats for, and
|
// Stats determines how long lazydocker will gather container stats for, and
|
||||||
// what stat info to graph
|
// what stat info to graph
|
||||||
Stats StatsConfig `yaml:"stats,omitempty"`
|
Stats StatsConfig `yaml:"stats,omitempty"`
|
||||||
|
|
||||||
|
// Replacements determines how we render a container's info
|
||||||
|
Replacements Replacements `yaml:"replacements,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ThemeConfig is for setting the colors of panels and some text.
|
// ThemeConfig is for setting the colors of panels and some text.
|
||||||
|
|
@ -258,6 +261,12 @@ type CustomCommands struct {
|
||||||
Volumes []CustomCommand `yaml:"volumes,omitempty"`
|
Volumes []CustomCommand `yaml:"volumes,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Replacements contains the stuff relating to rendering a container's info
|
||||||
|
type Replacements struct {
|
||||||
|
// ImageNamePrefixes tells us how to replace a prefix in the Docker image name
|
||||||
|
ImageNamePrefixes map[string]string `yaml:"imageNamePrefixes,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// CustomCommand is a template for a command we want to run against a service or
|
// CustomCommand is a template for a command we want to run against a service or
|
||||||
// container
|
// container
|
||||||
type CustomCommand struct {
|
type CustomCommand struct {
|
||||||
|
|
@ -404,6 +413,9 @@ func GetDefaultConfig() UserConfig {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Replacements: Replacements{
|
||||||
|
ImageNamePrefixes: map[string]string{},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue