Skip to content

Commit

Permalink
Merge pull request #136 from kaasops/validate-label
Browse files Browse the repository at this point in the history
Validate label
  • Loading branch information
dkhachyan committed Dec 13, 2023
2 parents 765a7fd + 9b0e8df commit 67fd30d
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 33 deletions.
2 changes: 1 addition & 1 deletion controllers/pipeline_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (r *PipelineReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
vaCtrl := vectoragent.NewController(vector, r.Client, r.Clientset)
vaCtrl.SetDefault()
// Get Vector Config file
byteConfig, _ := config.BuildByteConfig(vaCtrl, pipelineCR)
byteConfig, err := config.BuildByteConfig(vaCtrl, pipelineCR)
if err != nil {
if err := pipeline.SetFailedStatus(ctx, r.Client, pipelineCR, err.Error()); err != nil {
return ctrl.Result{}, err
Expand Down
4 changes: 2 additions & 2 deletions helm/charts/vector-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.33
version: 0.0.34

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v0.0.33"
appVersion: "v0.0.34"

home: https://github.com/kaasops/vector-operator
sources:
Expand Down
73 changes: 43 additions & 30 deletions helm/index.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
apiVersion: v1
entries:
vector-operator:
- apiVersion: v2
appVersion: v0.0.34
created: "2023-12-13T15:05:48.993680741+02:00"
description: A Helm chart to install Vector Operator
digest: 7f7909d3e2d092967ab8fa9ba191bca3684d19806908a4d54512f7d1836c1e3e
home: https://github.com/kaasops/vector-operator
name: vector-operator
sources:
- https://github.com/kaasops/vector-operator
type: application
urls:
- https://kaasops.github.io/vector-operator/helm/packages/vector-operator-0.0.34.tgz
version: 0.0.34
- apiVersion: v2
appVersion: v0.0.33
created: "2023-12-05T11:28:06.125648974+02:00"
created: "2023-12-13T15:05:48.992781703+02:00"
description: A Helm chart to install Vector Operator
digest: fcde3c94a0fa6caa5f3d333226c95b7c85ede8489d46277e1222a868ed4ec8c3
home: https://github.com/kaasops/vector-operator
Expand All @@ -16,7 +29,7 @@ entries:
version: 0.0.33
- apiVersion: v2
appVersion: v0.0.32
created: "2023-12-05T11:28:06.124757003+02:00"
created: "2023-12-13T15:05:48.991736673+02:00"
description: A Helm chart to install Vector Operator
digest: 26323037ec47f1703ea930a99ab4ec8fb93b44975ce969514ea68d4130017015
home: https://github.com/kaasops/vector-operator
Expand All @@ -29,7 +42,7 @@ entries:
version: 0.0.32
- apiVersion: v2
appVersion: v0.0.31
created: "2023-12-05T11:28:06.123447797+02:00"
created: "2023-12-13T15:05:48.99071941+02:00"
description: A Helm chart to install Vector Operator
digest: 45b924c07a825e0f7cd3fb534a6ffd16604790d13be1aff59150c045474754e3
home: https://github.com/kaasops/vector-operator
Expand All @@ -42,7 +55,7 @@ entries:
version: 0.0.31
- apiVersion: v2
appVersion: v0.0.30
created: "2023-12-05T11:28:06.122609568+02:00"
created: "2023-12-13T15:05:48.989433472+02:00"
description: A Helm chart to install Vector Operator
digest: 03beda549d15f50325028ea29af5f2065ac0b8adf3078bf7dc1312981aa5e7db
home: https://github.com/kaasops/vector-operator
Expand All @@ -55,7 +68,7 @@ entries:
version: 0.0.30
- apiVersion: v2
appVersion: v0.0.29
created: "2023-12-05T11:28:06.121744431+02:00"
created: "2023-12-13T15:05:48.988508317+02:00"
description: A Helm chart to install Vector Operator
digest: 0f025fc3a924b37b8c4131c4d8cfa437d2d4e557ab9476ed3e69a00232c7dca6
home: https://github.com/kaasops/vector-operator
Expand All @@ -68,7 +81,7 @@ entries:
version: 0.0.29
- apiVersion: v2
appVersion: v0.0.28
created: "2023-12-05T11:28:06.12089191+02:00"
created: "2023-12-13T15:05:48.987576519+02:00"
description: A Helm chart to install Vector Operator
digest: af856d41314313e04f15e7143409a9c564c6ca610b0d2eaec3112add8573e668
home: https://github.com/kaasops/vector-operator
Expand All @@ -81,7 +94,7 @@ entries:
version: 0.0.28
- apiVersion: v2
appVersion: v0.0.27
created: "2023-12-05T11:28:06.119473271+02:00"
created: "2023-12-13T15:05:48.986655288+02:00"
description: A Helm chart to install Vector Operator
digest: 631e2ff02bbd7f247cb486494fd2af60c57cc551066a6a3858226551bc1745a4
home: https://github.com/kaasops/vector-operator
Expand All @@ -94,7 +107,7 @@ entries:
version: 0.0.27
- apiVersion: v2
appVersion: v0.0.26
created: "2023-12-05T11:28:06.118512664+02:00"
created: "2023-12-13T15:05:48.98531776+02:00"
description: A Helm chart to install Vector Operator
digest: 760a2833f4c1a33466982419b079ff18d996331ebacc40cf93b0f55229cdb7db
home: https://github.com/kaasops/vector-operator
Expand All @@ -107,7 +120,7 @@ entries:
version: 0.0.26
- apiVersion: v2
appVersion: v0.0.25
created: "2023-12-05T11:28:06.117653997+02:00"
created: "2023-12-13T15:05:48.984428155+02:00"
description: A Helm chart to install Vector Operator
digest: fd22b996b071b6d85740ccf76e85cb640fa717c2620748d206d3f4fdd44cbcc2
home: https://github.com/kaasops/vector-operator
Expand All @@ -120,7 +133,7 @@ entries:
version: 0.0.25
- apiVersion: v2
appVersion: v0.0.24
created: "2023-12-05T11:28:06.116783358+02:00"
created: "2023-12-13T15:05:48.983490221+02:00"
description: A Helm chart to install Vector Operator
digest: ea257e60ecde063a0d1ed52ce5e3283245b8f0e2daba58ea3a5adb0ba82d7799
home: https://github.com/kaasops/vector-operator
Expand All @@ -133,7 +146,7 @@ entries:
version: 0.0.24
- apiVersion: v2
appVersion: v0.0.23
created: "2023-12-05T11:28:06.115233362+02:00"
created: "2023-12-13T15:05:48.982580785+02:00"
description: A Helm chart to install Vector Operator
digest: 546d202b3b9263f789b88335263191098dfcabd5d8698105f37cad24d56a8ed0
home: https://github.com/kaasops/vector-operator
Expand All @@ -146,7 +159,7 @@ entries:
version: 0.0.23
- apiVersion: v2
appVersion: v0.0.22
created: "2023-12-05T11:28:06.1138291+02:00"
created: "2023-12-13T15:05:48.981135766+02:00"
description: A Helm chart to install Vector Operator
digest: bf96ddc8ac61e9d6beb8bc763fbf3fa6025d950b29d70d80de6e8a0ea45e0411
home: https://github.com/kaasops/vector-operator
Expand All @@ -159,7 +172,7 @@ entries:
version: 0.0.22
- apiVersion: v2
appVersion: v0.0.21
created: "2023-12-05T11:28:06.112300943+02:00"
created: "2023-12-13T15:05:48.980181049+02:00"
description: A Helm chart to install Vector Operator
digest: d37b3064c0374d71e06c0131bcac2bf9e60ec4d62fcbbb20704c5277eabd899d
home: https://github.com/kaasops/vector-operator
Expand All @@ -172,7 +185,7 @@ entries:
version: 0.0.21
- apiVersion: v2
appVersion: v0.0.20
created: "2023-12-05T11:28:06.110444277+02:00"
created: "2023-12-13T15:05:48.97926056+02:00"
description: A Helm chart to install Vector Operator
digest: b95cd9ea8b74fde85175411129f77bf7a7afb4e9324ba2d02d489d0d6ef42d6d
home: https://github.com/kaasops/vector-operator
Expand All @@ -185,7 +198,7 @@ entries:
version: 0.0.20
- apiVersion: v2
appVersion: v0.0.19
created: "2023-12-05T11:28:06.109527429+02:00"
created: "2023-12-13T15:05:48.978669192+02:00"
description: A Helm chart to install Vector Operator
digest: bc1acd8b21a95e373702daa9c4ce4226b28f56b9c9299482d47b200baddbec14
home: https://github.com/kaasops/vector-operator
Expand All @@ -198,7 +211,7 @@ entries:
version: 0.0.19
- apiVersion: v2
appVersion: v0.0.18
created: "2023-12-05T11:28:06.108649646+02:00"
created: "2023-12-13T15:05:48.97772768+02:00"
description: A Helm chart to install Vector Operator
digest: 2bf9cde6eec7b00bfc70d7ac79b1e9d4bf3a406749c6b2bd816f20efd0cb44c3
home: https://github.com/kaasops/vector-operator
Expand All @@ -211,7 +224,7 @@ entries:
version: 0.0.18
- apiVersion: v2
appVersion: v0.0.17
created: "2023-12-05T11:28:06.107668183+02:00"
created: "2023-12-13T15:05:48.977081183+02:00"
description: A Helm chart to install Vector Operator
digest: edb51a059b9231f9bc2e2e0dd82c432d0e799a6767a7829ee113054478e098ed
home: https://github.com/kaasops/vector-operator
Expand All @@ -224,7 +237,7 @@ entries:
version: 0.0.17
- apiVersion: v2
appVersion: v0.0.16
created: "2023-12-05T11:28:06.106785725+02:00"
created: "2023-12-13T15:05:48.97650951+02:00"
description: A Helm chart to install Vector Operator
digest: 06e33602d72c44cf6779152df4936133ed87e228dd71cbb6615aa4c2666a1ee1
home: https://github.com/kaasops/vector-operator
Expand All @@ -237,7 +250,7 @@ entries:
version: 0.0.16
- apiVersion: v2
appVersion: v0.0.15
created: "2023-12-05T11:28:06.10594046+02:00"
created: "2023-12-13T15:05:48.975919778+02:00"
description: A Helm chart to install Vector Operator
digest: 6c9f5ba7a914329caa4f93342d3415fcf4e5fe39f5b7db69173896ea13a47c5b
home: https://github.com/kaasops/vector-operator
Expand All @@ -250,7 +263,7 @@ entries:
version: 0.0.15
- apiVersion: v2
appVersion: v0.0.14
created: "2023-12-05T11:28:06.104960994+02:00"
created: "2023-12-13T15:05:48.975143364+02:00"
description: A Helm chart to install Vector Operator
digest: 9f7a3b66247dea7f826b2b38202b0ddfa72b30ecc0954d75be36e066deda9df9
home: https://github.com/kaasops/vector-operator
Expand All @@ -263,7 +276,7 @@ entries:
version: 0.0.14
- apiVersion: v2
appVersion: v0.0.13
created: "2023-12-05T11:28:06.104063052+02:00"
created: "2023-12-13T15:05:48.974474092+02:00"
description: A Helm chart to install Vector Operator
digest: c88a1866a20fb2aea4a23886e6e60080eba9ae7ef2706f492d9b329dc9ddf49b
home: https://github.com/kaasops/vector-operator
Expand All @@ -276,7 +289,7 @@ entries:
version: 0.0.13
- apiVersion: v2
appVersion: v0.0.12
created: "2023-12-05T11:28:06.103442551+02:00"
created: "2023-12-13T15:05:48.973325008+02:00"
description: A Helm chart to install Vector Operator
digest: 384e8fd8f8f743036eaf1415d893158256a2ad9daddcb17a3d0701a528d9f0df
home: https://github.com/kaasops/vector-operator
Expand All @@ -289,7 +302,7 @@ entries:
version: 0.0.12
- apiVersion: v2
appVersion: v0.0.11
created: "2023-12-05T11:28:06.102826936+02:00"
created: "2023-12-13T15:05:48.972638831+02:00"
description: A Helm chart to install Vector Operator
digest: 29e1e04c1706b88ef61ed6c91a45847e6069843419515a33046c5929b179e273
home: https://github.com/kaasops/vector-operator
Expand All @@ -302,7 +315,7 @@ entries:
version: 0.0.11
- apiVersion: v2
appVersion: v0.0.10
created: "2023-12-05T11:28:06.10231291+02:00"
created: "2023-12-13T15:05:48.972061782+02:00"
description: A Helm chart to install Vector Operator
digest: f4398224ce88b852b319c950d0f39bfd5e6181801c1fac1b42b069dd2d358078
home: https://github.com/kaasops/vector-operator
Expand All @@ -315,7 +328,7 @@ entries:
version: 0.0.10
- apiVersion: v2
appVersion: v0.0.9
created: "2023-12-05T11:28:06.127665753+02:00"
created: "2023-12-13T15:05:48.996018778+02:00"
description: A Helm chart to install Vector Operator
digest: 66c528b6daa9f6fb9a8dd91895b69151f3f0183f4685ba4a2bc026fac27f25a7
home: https://github.com/kaasops/vector-operator
Expand All @@ -328,7 +341,7 @@ entries:
version: 0.0.9
- apiVersion: v2
appVersion: v0.0.8
created: "2023-12-05T11:28:06.12720499+02:00"
created: "2023-12-13T15:05:48.995505199+02:00"
description: A Helm chart to install Vector Operator
digest: 21c4c214cd0206abb743e82ac757804d644de08d80eb5f2edbb82ff9668cfed3
home: https://github.com/kaasops/vector-operator
Expand All @@ -341,7 +354,7 @@ entries:
version: 0.0.8
- apiVersion: v2
appVersion: v0.0.7
created: "2023-12-05T11:28:06.126655608+02:00"
created: "2023-12-13T15:05:48.994760335+02:00"
description: A Helm chart to install Vector Operator
digest: 27915a2bf70da3f66d08cf4a1f6c41ad38937759ad52eaf8b19f5a3e348e2f2e
home: https://github.com/kaasops/vector-operator
Expand All @@ -354,7 +367,7 @@ entries:
version: 0.0.7
- apiVersion: v2
appVersion: v0.0.6
created: "2023-12-05T11:28:06.126089492+02:00"
created: "2023-12-13T15:05:48.994174418+02:00"
description: A Helm chart to install Vector Operator
digest: 26760fbc2018336c12e8726307a624970ee994c4ffa021cc216c13669bd82f09
home: https://github.com/kaasops/vector-operator
Expand All @@ -367,7 +380,7 @@ entries:
version: 0.0.6
- apiVersion: v2
appVersion: v0.0.5
created: "2023-12-05T11:28:06.101782713+02:00"
created: "2023-12-13T15:05:48.971446797+02:00"
description: A Helm chart to install Vector Operator
digest: 1d6034027ae2f08a9dbea4d6ee9a1604117ae44d9daceb3f654b87a99175251f
home: https://github.com/kaasops/vector-operator
Expand All @@ -378,4 +391,4 @@ entries:
urls:
- https://kaasops.github.io/vector-operator/helm/packages/vector-operator-0.0.1.tgz
version: 0.0.1
generated: "2023-12-05T11:28:06.101170623+02:00"
generated: "2023-12-13T15:05:48.964762256+02:00"
Binary file added helm/packages/vector-operator-0.0.34.tgz
Binary file not shown.
10 changes: 10 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ import (
"github.com/kaasops/vector-operator/pkg/vector/vectoragent"
"github.com/mitchellh/mapstructure"
"gopkg.in/yaml.v2"
"k8s.io/apimachinery/pkg/labels"
goyaml "sigs.k8s.io/yaml"
)

var (
ErrNotAllowedSourceType error = errors.New("type kubernetes_logs only allowed")
ErrClusterScopeNotAllowed error = errors.New("logs from external namespace not allowed")
ErrInvalidSelector error = errors.New("invalid selector")
)

func New(vector *vectorv1alpha1.Vector) *VectorConfig {
Expand Down Expand Up @@ -88,6 +90,14 @@ func BuildConfig(vaCtrl *vectoragent.Controller, pipelines ...pipeline.Pipeline)
if v.Type != KubernetesSourceType {
return nil, ErrNotAllowedSourceType
}
_, err := labels.Parse(v.ExtraLabelSelector)
if err != nil {
return nil, ErrInvalidSelector
}
_, err = labels.Parse(v.ExtraNamespaceLabelSelector)
if err != nil {
return nil, ErrInvalidSelector
}
if v.ExtraNamespaceLabelSelector == "" {
v.ExtraNamespaceLabelSelector = k8s.NamespaceNameToLabel(pipeline.GetNamespace())
}
Expand Down

0 comments on commit 67fd30d

Please sign in to comment.