-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into misc-updates
- Loading branch information
Showing
30 changed files
with
442 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,31 @@ | ||
domain: integreatly.org | ||
layout: go.kubebuilder.io/v3 | ||
layout: | ||
- go.kubebuilder.io/v3 | ||
projectName: grafana-operator | ||
repo: github.com/integr8ly/grafana-operator | ||
resources: | ||
- crdVersion: v1 | ||
- api: | ||
crdVersion: v1 | ||
namespaced: true | ||
group: integreatly.org | ||
kind: Grafana | ||
version: v1alpha1 | ||
- crdVersion: v1 | ||
controller: true | ||
- api: | ||
crdVersion: v1 | ||
namespaced: true | ||
group: integreatly.org | ||
kind: GrafanaDashboard | ||
version: v1alpha1 | ||
- crdVersion: v1 | ||
controller: true | ||
- api: | ||
crdVersion: v1 | ||
namespaced: true | ||
group: integreatly.org | ||
kind: GrafanaDatasource | ||
version: v1alpha1 | ||
version: 3-alpha | ||
controller: true | ||
version: "3" | ||
plugins: | ||
manifests.sdk.operatorframework.io/v2: {} | ||
scorecard.sdk.operatorframework.io/v2: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
var labelSelector = &metav1.LabelSelector{ | ||
MatchExpressions: []metav1.LabelSelectorRequirement{ | ||
{ | ||
Key: "app", | ||
Operator: "In", | ||
Values: []string{"grafana"}, | ||
}, | ||
}, | ||
} | ||
|
||
var listLabelSelector = []*metav1.LabelSelector{ | ||
{ | ||
MatchExpressions: []metav1.LabelSelectorRequirement{ | ||
{ | ||
Key: "ham", | ||
Operator: "In", | ||
Values: []string{"eggs"}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
MatchExpressions: []metav1.LabelSelectorRequirement{ | ||
{ | ||
Key: "app", | ||
Operator: "NotIn", | ||
Values: []string{"grafana"}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
func TestDashboardMatchesSelectorFalse(t *testing.T) { | ||
i := &GrafanaDashboard{ | ||
TypeMeta: metav1.TypeMeta{}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "dashboard", | ||
Namespace: "grafana", | ||
Labels: map[string]string{ | ||
"foo": "bar", | ||
}, | ||
}, | ||
Spec: GrafanaDashboardSpec{}, | ||
} | ||
output, err := i.matchesSelector(labelSelector) | ||
require.NoError(t, err) | ||
require.Equal(t, output, false) | ||
} | ||
|
||
func TestDashboardMatchesSelectorTrue(t *testing.T) { | ||
i := &GrafanaDashboard{ | ||
TypeMeta: metav1.TypeMeta{}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "dashboard", | ||
Namespace: "grafana", | ||
Labels: map[string]string{ | ||
"app": "grafana", | ||
}, | ||
}, | ||
Spec: GrafanaDashboardSpec{}, | ||
} | ||
output, err := i.matchesSelector(labelSelector) | ||
require.NoError(t, err) | ||
require.Equal(t, output, true) | ||
} | ||
|
||
func TestDashboardMatchesSelectorsMultipleNotIn(t *testing.T) { | ||
i := &GrafanaDashboard{ | ||
TypeMeta: metav1.TypeMeta{}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "dashboard", | ||
Namespace: "grafana", | ||
Labels: map[string]string{ | ||
"foo": "bar", | ||
"app": "grafana", | ||
}, | ||
}, | ||
Spec: GrafanaDashboardSpec{}, | ||
} | ||
output, err := i.MatchesSelectors(listLabelSelector) | ||
require.NoError(t, err) | ||
require.Equal(t, output, false) | ||
} | ||
|
||
func TestMatchesDashboardSelectorsMultipleTrue(t *testing.T) { | ||
i := &GrafanaDashboard{ | ||
TypeMeta: metav1.TypeMeta{}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "dashboard", | ||
Namespace: "grafana", | ||
Labels: map[string]string{ | ||
"foo": "bar", | ||
}, | ||
}, | ||
Spec: GrafanaDashboardSpec{}, | ||
} | ||
output, err := i.MatchesSelectors(listLabelSelector) | ||
require.NoError(t, err) | ||
require.Equal(t, output, true) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.