mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 09:41:57 +00:00
Added container filters as CLI arguments
gofmt load_container_filters.go removed the environment variable for container label filters Added the --app.container-label-filter command line argument, and load_container_filters.go now uses the results from that Changed init() to InitializeTopologies() Changed init() to InitializeTopologies() so that it can be called after the container filters are loaded from the command line argument. init() executes before main() in prog/main.go, so the flag parsing isn't finished before init() is called Applied lint fixes fixed lint issues brought back the init function for api_topologies.go Addressed many of the PR comments, except escaping colons Renamed IsDesired to HasLabel in render/filters.go Allows for the user to escape colons added registry function for modifying the container filters created a separate function that parses the container filter flags simplified registry.addContainerFilters() addressed review comments switched API Topology Description IDs to constants addressed review comments joined constants added test functions addressed most of the review comments Changed containerLabelFilters to an array of APItopologyOptions, placing the parsing in the Set() function. Removed parsing from HasLabel in render/filters.go refactored code added test that applies to the container filtering by labels applied golint made Registry items private and added a MakeRegistry() function fixed usage of topologyRegistry.RendererForTopology Added container label filters by exclusion minor update to report_fixture Modified container labels test to use existing report I added labels to the existing containers in the fixed report for testing. refactored code refactored code further code refactoring addressed @ijsnellf's review comments unexported Registry, and reduced duplicate code addressed @ijsnellf's review comments Addressed review comments Addressed final review comments
This commit is contained in:
@@ -268,6 +268,22 @@ func IsApplication(n report.Node) bool {
|
||||
// IsSystem checks if the node is a "system" node
|
||||
var IsSystem = Complement(IsApplication)
|
||||
|
||||
// HasLabel checks if the node has the desired docker label
|
||||
func HasLabel(labelKey string, labelValue string) FilterFunc {
|
||||
return func(n report.Node) bool {
|
||||
value, _ := n.Latest.Lookup(docker.LabelPrefix + labelKey)
|
||||
if value == labelValue {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// DoesNotHaveLabel checks if the node does NOT have the specified docker label
|
||||
func DoesNotHaveLabel(labelKey string, labelValue string) FilterFunc {
|
||||
return Complement(HasLabel(labelKey, labelValue))
|
||||
}
|
||||
|
||||
// IsNotPseudo returns true if the node is not a pseudo node
|
||||
// or internet/service nodes.
|
||||
func IsNotPseudo(n report.Node) bool {
|
||||
|
||||
Reference in New Issue
Block a user