diff --git a/CHANGELOG.md b/CHANGELOG.md index e31d4d4c..ac940752 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +# 2.9.1 +* Policy Reporter + * Name Configuration for Target (Channels) to customize UI Labels +* Policy Reporter UI + * Fix table on chip selection + * Order labels + * Return 404 Status Code for non existing URL paths + # 2.9.0 * Policy Reporter * New configuration to use Redis as external result caching store diff --git a/charts/policy-reporter/Chart.lock b/charts/policy-reporter/Chart.lock index 9ae96fac..994678cc 100644 --- a/charts/policy-reporter/Chart.lock +++ b/charts/policy-reporter/Chart.lock @@ -4,9 +4,9 @@ dependencies: version: 2.3.0 - name: ui repository: "" - version: 2.4.0 + version: 2.4.2 - name: kyvernoPlugin repository: "" version: 1.3.1 -digest: sha256:7a734be2c2f509c2e8424949509f176278a279d75600f89ec81c0b41ac27041f -generated: "2022-05-23T16:49:26.121035+02:00" +digest: sha256:f1686cfbc5de749d82c2020a8c546e70534e4d7cd154d74cf1380a5fc3dc91ee +generated: "2022-06-09T23:43:09.479977+02:00" diff --git a/charts/policy-reporter/Chart.yaml b/charts/policy-reporter/Chart.yaml index 8a695a53..3ac87808 100644 --- a/charts/policy-reporter/Chart.yaml +++ b/charts/policy-reporter/Chart.yaml @@ -5,8 +5,8 @@ description: | It creates Prometheus Metrics and can send rule validation events to different targets like Loki, Elasticsearch, Slack or Discord type: application -version: 2.9.0 -appVersion: 2.6.0 +version: 2.9.1 +appVersion: 2.6.1 icon: https://github.com/kyverno/kyverno/raw/main/img/logo.png home: https://kyverno.github.io/policy-reporter @@ -21,7 +21,7 @@ dependencies: version: "2.3.0" - name: ui condition: ui.enabled - version: "2.4.0" + version: "2.4.2" - name: kyvernoPlugin condition: kyvernoPlugin.enabled version: "1.3.1" diff --git a/charts/policy-reporter/charts/ui/Chart.yaml b/charts/policy-reporter/charts/ui/Chart.yaml index 02965685..54adf7ec 100644 --- a/charts/policy-reporter/charts/ui/Chart.yaml +++ b/charts/policy-reporter/charts/ui/Chart.yaml @@ -3,5 +3,5 @@ name: ui description: Policy Reporter UI type: application -version: 2.4.0 -appVersion: 1.4.0 +version: 2.4.2 +appVersion: 1.4.2 diff --git a/charts/policy-reporter/charts/ui/values.yaml b/charts/policy-reporter/charts/ui/values.yaml index 29754b93..18db0565 100644 --- a/charts/policy-reporter/charts/ui/values.yaml +++ b/charts/policy-reporter/charts/ui/values.yaml @@ -29,7 +29,7 @@ image: registry: ghcr.io repository: kyverno/policy-reporter-ui pullPolicy: IfNotPresent - tag: 1.4.0 + tag: 1.4.2 # configurations related to the PolicyReporter API policyReporter: diff --git a/charts/policy-reporter/values.yaml b/charts/policy-reporter/values.yaml index 6ea9416a..00d93851 100644 --- a/charts/policy-reporter/values.yaml +++ b/charts/policy-reporter/values.yaml @@ -2,7 +2,7 @@ image: registry: ghcr.io repository: kyverno/policy-reporter pullPolicy: IfNotPresent - tag: 2.6.0 + tag: 2.6.1 imagePullSecrets: [] diff --git a/manifest/default-policy-reporter-ui/install.yaml b/manifest/default-policy-reporter-ui/install.yaml index a8b1aad0..4b1d498b 100644 --- a/manifest/default-policy-reporter-ui/install.yaml +++ b/manifest/default-policy-reporter-ui/install.yaml @@ -93,7 +93,7 @@ spec: automountServiceAccountToken: false containers: - name: ui - image: "ghcr.io/kyverno/policy-reporter-ui:1.4.0" + image: "ghcr.io/kyverno/policy-reporter-ui:1.4.2" imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false @@ -145,7 +145,7 @@ spec: fsGroup: 1234 containers: - name: policy-reporter - image: "ghcr.io/kyverno/policy-reporter:2.6.0" + image: "ghcr.io/kyverno/policy-reporter:2.6.1" imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false diff --git a/manifest/kyverno-policy-reporter-ui/install.yaml b/manifest/kyverno-policy-reporter-ui/install.yaml index 918f11f4..b9926bfc 100644 --- a/manifest/kyverno-policy-reporter-ui/install.yaml +++ b/manifest/kyverno-policy-reporter-ui/install.yaml @@ -204,7 +204,7 @@ spec: spec: containers: - name: ui - image: "ghcr.io/kyverno/policy-reporter-ui:1.4.0" + image: "ghcr.io/kyverno/policy-reporter-ui:1.4.2" imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false @@ -256,7 +256,7 @@ spec: fsGroup: 1234 containers: - name: policy-reporter - image: "ghcr.io/kyverno/policy-reporter:2.6.0" + image: "ghcr.io/kyverno/policy-reporter:2.6.1" imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false diff --git a/manifest/policy-reporter/install.yaml b/manifest/policy-reporter/install.yaml index 3560039e..16c50fcc 100644 --- a/manifest/policy-reporter/install.yaml +++ b/manifest/policy-reporter/install.yaml @@ -84,7 +84,7 @@ spec: automountServiceAccountToken: true containers: - name: policy-reporter - image: "ghcr.io/kyverno/policy-reporter:2.6.0" + image: "ghcr.io/kyverno/policy-reporter:2.6.1" imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false diff --git a/pkg/config/config.go b/pkg/config/config.go index 975248c3..d34f6b1d 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -21,6 +21,7 @@ type MetricsFilter struct { // Loki configuration type Loki struct { + Name string `mapstructure:"name"` Host string `mapstructure:"host"` CustomLabels map[string]string `mapstructure:"customLabels"` SkipExisting bool `mapstructure:"skipExistingOnStartup"` @@ -32,6 +33,7 @@ type Loki struct { // Elasticsearch configuration type Elasticsearch struct { + Name string `mapstructure:"name"` Host string `mapstructure:"host"` Index string `mapstructure:"index"` Rotation string `mapstructure:"rotation"` @@ -44,6 +46,7 @@ type Elasticsearch struct { // Slack configuration type Slack struct { + Name string `mapstructure:"name"` Webhook string `mapstructure:"webhook"` SkipExisting bool `mapstructure:"skipExistingOnStartup"` MinimumPriority string `mapstructure:"minimumPriority"` @@ -54,6 +57,7 @@ type Slack struct { // Discord configuration type Discord struct { + Name string `mapstructure:"name"` Webhook string `mapstructure:"webhook"` SkipExisting bool `mapstructure:"skipExistingOnStartup"` MinimumPriority string `mapstructure:"minimumPriority"` @@ -64,6 +68,7 @@ type Discord struct { // Teams configuration type Teams struct { + Name string `mapstructure:"name"` Webhook string `mapstructure:"webhook"` SkipExisting bool `mapstructure:"skipExistingOnStartup"` MinimumPriority string `mapstructure:"minimumPriority"` @@ -82,6 +87,7 @@ type UI struct { // Webhook configuration type Webhook struct { + Name string `mapstructure:"name"` Host string `mapstructure:"host"` Headers map[string]string `mapstructure:"headers"` SkipExisting bool `mapstructure:"skipExistingOnStartup"` @@ -92,6 +98,7 @@ type Webhook struct { } type S3 struct { + Name string `mapstructure:"name"` AccessKeyID string `mapstructure:"accessKeyID"` SecretAccessKey string `mapstructure:"secretAccessKey"` Region string `mapstructure:"region"` diff --git a/pkg/config/resolver.go b/pkg/config/resolver.go index eb918eb0..d40a867c 100644 --- a/pkg/config/resolver.go +++ b/pkg/config/resolver.go @@ -140,12 +140,19 @@ func (r *Resolver) Mapper() kubernetes.Mapper { // LokiClients resolver method func (r *Resolver) LokiClients() []target.Client { clients := make([]target.Client, 0) + if r.config.Loki.Name == "" { + r.config.Loki.Name = "Loki" + } - if loki := createLokiClient(r.config.Loki, Loki{}, "Loki"); loki != nil { + if loki := createLokiClient(r.config.Loki, Loki{}); loki != nil { clients = append(clients, loki) } for i, channel := range r.config.Loki.Channels { - if loki := createLokiClient(channel, r.config.Loki, fmt.Sprintf("Loki Channel %d", i+1)); loki != nil { + if channel.Name == "" { + channel.Name = fmt.Sprintf("Loki Channel %d", i+1) + } + + if loki := createLokiClient(channel, r.config.Loki); loki != nil { clients = append(clients, loki) } } @@ -156,12 +163,19 @@ func (r *Resolver) LokiClients() []target.Client { // ElasticsearchClients resolver method func (r *Resolver) ElasticsearchClients() []target.Client { clients := make([]target.Client, 0) + if r.config.Elasticsearch.Name == "" { + r.config.Elasticsearch.Name = "Elasticsearch" + } - if es := createElasticsearchClient(r.config.Elasticsearch, Elasticsearch{}, "Elasticsearch"); es != nil { + if es := createElasticsearchClient(r.config.Elasticsearch, Elasticsearch{}); es != nil { clients = append(clients, es) } for i, channel := range r.config.Elasticsearch.Channels { - if es := createElasticsearchClient(channel, r.config.Elasticsearch, fmt.Sprintf("Elasticsearch Channel %d", i+1)); es != nil { + if channel.Name == "" { + channel.Name = fmt.Sprintf("Elasticsearch Channel %d", i+1) + } + + if es := createElasticsearchClient(channel, r.config.Elasticsearch); es != nil { clients = append(clients, es) } } @@ -172,12 +186,19 @@ func (r *Resolver) ElasticsearchClients() []target.Client { // SlackClients resolver method func (r *Resolver) SlackClients() []target.Client { clients := make([]target.Client, 0) + if r.config.Slack.Name == "" { + r.config.Slack.Name = "Slack" + } - if es := createSlackClient(r.config.Slack, Slack{}, "Slack"); es != nil { + if es := createSlackClient(r.config.Slack, Slack{}); es != nil { clients = append(clients, es) } for i, channel := range r.config.Slack.Channels { - if es := createSlackClient(channel, r.config.Slack, fmt.Sprintf("Slack Channel %d", i+1)); es != nil { + if channel.Name == "" { + channel.Name = fmt.Sprintf("Slack Channel %d", i+1) + } + + if es := createSlackClient(channel, r.config.Slack); es != nil { clients = append(clients, es) } } @@ -188,12 +209,19 @@ func (r *Resolver) SlackClients() []target.Client { // DiscordClients resolver method func (r *Resolver) DiscordClients() []target.Client { clients := make([]target.Client, 0) + if r.config.Discord.Name == "" { + r.config.Discord.Name = "Discord" + } - if es := createDiscordClient(r.config.Discord, Discord{}, "Discord"); es != nil { + if es := createDiscordClient(r.config.Discord, Discord{}); es != nil { clients = append(clients, es) } for i, channel := range r.config.Discord.Channels { - if es := createDiscordClient(channel, r.config.Discord, fmt.Sprintf("Discord Channel %d", i+1)); es != nil { + if channel.Name == "" { + channel.Name = fmt.Sprintf("Discord Channel %d", i+1) + } + + if es := createDiscordClient(channel, r.config.Discord); es != nil { clients = append(clients, es) } } @@ -204,12 +232,19 @@ func (r *Resolver) DiscordClients() []target.Client { // TeamsClients resolver method func (r *Resolver) TeamsClients() []target.Client { clients := make([]target.Client, 0) + if r.config.Teams.Name == "" { + r.config.Teams.Name = "Teams" + } - if es := createTeamsClient(r.config.Teams, Teams{}, "Teams"); es != nil { + if es := createTeamsClient(r.config.Teams, Teams{}); es != nil { clients = append(clients, es) } for i, channel := range r.config.Teams.Channels { - if es := createTeamsClient(channel, r.config.Teams, fmt.Sprintf("Teams Channel %d", i+1)); es != nil { + if channel.Name == "" { + channel.Name = fmt.Sprintf("Teams Channel %d", i+1) + } + + if es := createTeamsClient(channel, r.config.Teams); es != nil { clients = append(clients, es) } } @@ -220,12 +255,19 @@ func (r *Resolver) TeamsClients() []target.Client { // WebhookClients resolver method func (r *Resolver) WebhookClients() []target.Client { clients := make([]target.Client, 0) + if r.config.Webhook.Name == "" { + r.config.Webhook.Name = "Webhook" + } - if es := createWebhookClient(r.config.Webhook, Webhook{}, "Webhook"); es != nil { + if es := createWebhookClient(r.config.Webhook, Webhook{}); es != nil { clients = append(clients, es) } for i, channel := range r.config.Webhook.Channels { - if es := createWebhookClient(channel, r.config.Webhook, fmt.Sprintf("Webhook Channel %d", i+1)); es != nil { + if channel.Name == "" { + channel.Name = fmt.Sprintf("Webhook Channel %d", i+1) + } + + if es := createWebhookClient(channel, r.config.Webhook); es != nil { clients = append(clients, es) } } @@ -253,12 +295,19 @@ func (r *Resolver) UIClient() target.Client { // TeamsClients resolver method func (r *Resolver) S3Clients() []target.Client { clients := make([]target.Client, 0) + if r.config.S3.Name == "" { + r.config.S3.Name = "S3" + } - if es := createS3Client(r.config.S3, S3{}, "S3"); es != nil { + if es := createS3Client(r.config.S3, S3{}); es != nil { clients = append(clients, es) } for i, channel := range r.config.S3.Channels { - if es := createS3Client(channel, r.config.S3, fmt.Sprintf("S3 Channel %d", i+1)); es != nil { + if channel.Name == "" { + channel.Name = fmt.Sprintf("S3 Channel %d", i+1) + } + + if es := createS3Client(channel, r.config.S3); es != nil { clients = append(clients, es) } } @@ -357,7 +406,7 @@ func NewResolver(config *Config, k8sConfig *rest.Config) Resolver { } } -func createSlackClient(config Slack, parent Slack, name string) target.Client { +func createSlackClient(config Slack, parent Slack) target.Client { if config.Webhook == "" { return nil } @@ -370,10 +419,10 @@ func createSlackClient(config Slack, parent Slack, name string) target.Client { config.SkipExisting = parent.SkipExisting } - log.Printf("[INFO] %s configured", name) + log.Printf("[INFO] %s configured", config.Name) return slack.NewClient( - name, + config.Name, config.Webhook, config.SkipExisting, createTargetFilter(config.Filter, config.MinimumPriority, config.Sources), @@ -381,7 +430,7 @@ func createSlackClient(config Slack, parent Slack, name string) target.Client { ) } -func createLokiClient(config Loki, parent Loki, name string) target.Client { +func createLokiClient(config Loki, parent Loki) target.Client { if config.Host == "" && parent.Host == "" { return nil } else if config.Host == "" { @@ -396,10 +445,10 @@ func createLokiClient(config Loki, parent Loki, name string) target.Client { config.MinimumPriority = parent.MinimumPriority } - log.Printf("[INFO] %s configured", name) + log.Printf("[INFO] %s configured", config.Name) return loki.NewClient( - name, + config.Name, config.Host, config.SkipExisting, createTargetFilter(config.Filter, config.MinimumPriority, config.Sources), @@ -408,7 +457,7 @@ func createLokiClient(config Loki, parent Loki, name string) target.Client { ) } -func createElasticsearchClient(config Elasticsearch, parent Elasticsearch, name string) target.Client { +func createElasticsearchClient(config Elasticsearch, parent Elasticsearch) target.Client { if config.Host == "" && parent.Host == "" { return nil } else if config.Host == "" { @@ -435,10 +484,10 @@ func createElasticsearchClient(config Elasticsearch, parent Elasticsearch, name config.SkipExisting = parent.SkipExisting } - log.Printf("[INFO] %s configured", name) + log.Printf("[INFO] %s configured", config.Name) return elasticsearch.NewClient( - name, + config.Name, config.Host, config.Index, config.Rotation, @@ -448,7 +497,7 @@ func createElasticsearchClient(config Elasticsearch, parent Elasticsearch, name ) } -func createDiscordClient(config Discord, parent Discord, name string) target.Client { +func createDiscordClient(config Discord, parent Discord) target.Client { if config.Webhook == "" { return nil } @@ -461,10 +510,10 @@ func createDiscordClient(config Discord, parent Discord, name string) target.Cli config.SkipExisting = parent.SkipExisting } - log.Printf("[INFO] %s configured", name) + log.Printf("[INFO] %s configured", config.Name) return discord.NewClient( - name, + config.Name, config.Webhook, config.SkipExisting, createTargetFilter(config.Filter, config.MinimumPriority, config.Sources), @@ -472,7 +521,7 @@ func createDiscordClient(config Discord, parent Discord, name string) target.Cli ) } -func createTeamsClient(config Teams, parent Teams, name string) target.Client { +func createTeamsClient(config Teams, parent Teams) target.Client { if config.Webhook == "" { return nil } @@ -485,10 +534,10 @@ func createTeamsClient(config Teams, parent Teams, name string) target.Client { config.SkipExisting = parent.SkipExisting } - log.Printf("[INFO] %s configured", name) + log.Printf("[INFO] %s configured", config.Name) return teams.NewClient( - name, + config.Name, config.Webhook, config.SkipExisting, createTargetFilter(config.Filter, config.MinimumPriority, config.Sources), @@ -496,7 +545,7 @@ func createTeamsClient(config Teams, parent Teams, name string) target.Client { ) } -func createWebhookClient(config Webhook, parent Webhook, name string) target.Client { +func createWebhookClient(config Webhook, parent Webhook) target.Client { if config.Host == "" { return nil } @@ -521,10 +570,10 @@ func createWebhookClient(config Webhook, parent Webhook, name string) target.Cli config.Headers = headers } - log.Printf("[INFO] %s configured", name) + log.Printf("[INFO] %s configured", config.Name) return webhook.NewClient( - name, + config.Name, config.Host, config.Headers, config.SkipExisting, @@ -533,7 +582,7 @@ func createWebhookClient(config Webhook, parent Webhook, name string) target.Cli ) } -func createS3Client(config S3, parent S3, name string) target.Client { +func createS3Client(config S3, parent S3) target.Client { if config.Endpoint == "" && parent.Endpoint == "" { return nil } else if config.Endpoint == "" { @@ -541,28 +590,28 @@ func createS3Client(config S3, parent S3, name string) target.Client { } if config.AccessKeyID == "" && parent.AccessKeyID == "" { - log.Printf("[ERROR] %s.AccessKeyID has not been declared", name) + log.Printf("[ERROR] %s.AccessKeyID has not been declared", config.Name) return nil } else if config.AccessKeyID == "" { config.AccessKeyID = parent.AccessKeyID } if config.SecretAccessKey == "" && parent.SecretAccessKey == "" { - log.Printf("[ERROR] %s.SecretAccessKey has not been declared", name) + log.Printf("[ERROR] %s.SecretAccessKey has not been declared", config.Name) return nil } else if config.SecretAccessKey == "" { config.SecretAccessKey = parent.SecretAccessKey } if config.Region == "" && parent.Region == "" { - log.Printf("[ERROR] %s.Region has not been declared", name) + log.Printf("[ERROR] %s.Region has not been declared", config.Name) return nil } else if config.Region == "" { config.Region = parent.Region } if config.Bucket == "" && parent.Bucket == "" { - log.Printf("[ERROR] %s.Bucket has not been declared", name) + log.Printf("[ERROR] %s.Bucket has not been declared", config.Name) return nil } else if config.Bucket == "" { config.Bucket = parent.Bucket @@ -590,10 +639,10 @@ func createS3Client(config S3, parent S3, name string) target.Client { config.Bucket, ) - log.Printf("[INFO] %s configured", name) + log.Printf("[INFO] %s configured", config.Name) return s3.NewClient( - name, + config.Name, s3Client, config.Prefix, config.SkipExisting, diff --git a/pkg/config/resolver_test.go b/pkg/config/resolver_test.go index 7049237b..7ee0331e 100644 --- a/pkg/config/resolver_test.go +++ b/pkg/config/resolver_test.go @@ -81,6 +81,7 @@ var testConfig = &config.Config{ MinimumPriority: "debug", Endpoint: "https://storage.yandexcloud.net", Region: "ru-central1", + Prefix: "prefix", Channels: []config.S3{{}}, }, }