mirror of
https://github.com/prometheus-operator/prometheus-operator.git
synced 2025-04-21 03:38:43 +00:00
chore: Refactor OpenStackSDConfig (#7244)
Co-authored-by: Jayapriya Pai <slashpai9@gmail.com>
This commit is contained in:
parent
8c196e77f5
commit
6f3c19ae6d
10 changed files with 576 additions and 9 deletions
Documentation/api-reference
bundle.yamlexample
prometheus-operator-crd-full
prometheus-operator-crd
jsonnet/prometheus-operator
pkg
apis/monitoring/v1alpha1
client/applyconfiguration/monitoring/v1alpha1
prometheus
test/e2e
|
@ -25985,7 +25985,7 @@ Duration
|
|||
<td>
|
||||
<code>port</code><br/>
|
||||
<em>
|
||||
int
|
||||
int32
|
||||
</em>
|
||||
</td>
|
||||
<td>
|
||||
|
|
11
bundle.yaml
generated
11
bundle.yaml
generated
|
@ -55587,6 +55587,7 @@ spec:
|
|||
required if using an application credential to authenticate. Some providers
|
||||
allow you to create an application credential to authenticate rather than a
|
||||
password.
|
||||
minLength: 1
|
||||
type: string
|
||||
applicationCredentialSecret:
|
||||
description: |-
|
||||
|
@ -55626,16 +55627,19 @@ spec:
|
|||
type: string
|
||||
domainID:
|
||||
description: DomainID
|
||||
minLength: 1
|
||||
type: string
|
||||
domainName:
|
||||
description: |-
|
||||
At most one of domainId and domainName must be provided if using username
|
||||
with Identity V3. Otherwise, either are optional.
|
||||
minLength: 1
|
||||
type: string
|
||||
identityEndpoint:
|
||||
description: |-
|
||||
IdentityEndpoint specifies the HTTP endpoint that is required to work with
|
||||
the Identity API of the appropriate version.
|
||||
pattern: ^http(s)?:\/\/.+$
|
||||
type: string
|
||||
password:
|
||||
description: |-
|
||||
|
@ -55667,9 +55671,13 @@ spec:
|
|||
description: |-
|
||||
The port to scrape metrics from. If using the public IP address, this must
|
||||
instead be specified in the relabeling rule.
|
||||
format: int32
|
||||
maximum: 65535
|
||||
minimum: 0
|
||||
type: integer
|
||||
projectID:
|
||||
description: ' ProjectID'
|
||||
minLength: 1
|
||||
type: string
|
||||
projectName:
|
||||
description: |-
|
||||
|
@ -55677,6 +55685,7 @@ spec:
|
|||
Some providers allow you to specify a ProjectName instead of the ProjectId.
|
||||
Some require both. Your provider's authentication policies will determine
|
||||
how these fields influence authentication.
|
||||
minLength: 1
|
||||
type: string
|
||||
refreshInterval:
|
||||
description: Refresh interval to re-read the instance list.
|
||||
|
@ -55858,6 +55867,7 @@ spec:
|
|||
type: object
|
||||
userid:
|
||||
description: UserID
|
||||
minLength: 1
|
||||
type: string
|
||||
username:
|
||||
description: |-
|
||||
|
@ -55865,6 +55875,7 @@ spec:
|
|||
control panel to discover your account's username.
|
||||
In Identity V3, either userid or a combination of username
|
||||
and domainId or domainName are needed
|
||||
minLength: 1
|
||||
type: string
|
||||
required:
|
||||
- region
|
||||
|
|
|
@ -10399,6 +10399,7 @@ spec:
|
|||
required if using an application credential to authenticate. Some providers
|
||||
allow you to create an application credential to authenticate rather than a
|
||||
password.
|
||||
minLength: 1
|
||||
type: string
|
||||
applicationCredentialSecret:
|
||||
description: |-
|
||||
|
@ -10438,16 +10439,19 @@ spec:
|
|||
type: string
|
||||
domainID:
|
||||
description: DomainID
|
||||
minLength: 1
|
||||
type: string
|
||||
domainName:
|
||||
description: |-
|
||||
At most one of domainId and domainName must be provided if using username
|
||||
with Identity V3. Otherwise, either are optional.
|
||||
minLength: 1
|
||||
type: string
|
||||
identityEndpoint:
|
||||
description: |-
|
||||
IdentityEndpoint specifies the HTTP endpoint that is required to work with
|
||||
the Identity API of the appropriate version.
|
||||
pattern: ^http(s)?:\/\/.+$
|
||||
type: string
|
||||
password:
|
||||
description: |-
|
||||
|
@ -10479,9 +10483,13 @@ spec:
|
|||
description: |-
|
||||
The port to scrape metrics from. If using the public IP address, this must
|
||||
instead be specified in the relabeling rule.
|
||||
format: int32
|
||||
maximum: 65535
|
||||
minimum: 0
|
||||
type: integer
|
||||
projectID:
|
||||
description: ' ProjectID'
|
||||
minLength: 1
|
||||
type: string
|
||||
projectName:
|
||||
description: |-
|
||||
|
@ -10489,6 +10497,7 @@ spec:
|
|||
Some providers allow you to specify a ProjectName instead of the ProjectId.
|
||||
Some require both. Your provider's authentication policies will determine
|
||||
how these fields influence authentication.
|
||||
minLength: 1
|
||||
type: string
|
||||
refreshInterval:
|
||||
description: Refresh interval to re-read the instance list.
|
||||
|
@ -10670,6 +10679,7 @@ spec:
|
|||
type: object
|
||||
userid:
|
||||
description: UserID
|
||||
minLength: 1
|
||||
type: string
|
||||
username:
|
||||
description: |-
|
||||
|
@ -10677,6 +10687,7 @@ spec:
|
|||
control panel to discover your account's username.
|
||||
In Identity V3, either userid or a combination of username
|
||||
and domainId or domainName are needed
|
||||
minLength: 1
|
||||
type: string
|
||||
required:
|
||||
- region
|
||||
|
|
|
@ -10400,6 +10400,7 @@ spec:
|
|||
required if using an application credential to authenticate. Some providers
|
||||
allow you to create an application credential to authenticate rather than a
|
||||
password.
|
||||
minLength: 1
|
||||
type: string
|
||||
applicationCredentialSecret:
|
||||
description: |-
|
||||
|
@ -10439,16 +10440,19 @@ spec:
|
|||
type: string
|
||||
domainID:
|
||||
description: DomainID
|
||||
minLength: 1
|
||||
type: string
|
||||
domainName:
|
||||
description: |-
|
||||
At most one of domainId and domainName must be provided if using username
|
||||
with Identity V3. Otherwise, either are optional.
|
||||
minLength: 1
|
||||
type: string
|
||||
identityEndpoint:
|
||||
description: |-
|
||||
IdentityEndpoint specifies the HTTP endpoint that is required to work with
|
||||
the Identity API of the appropriate version.
|
||||
pattern: ^http(s)?:\/\/.+$
|
||||
type: string
|
||||
password:
|
||||
description: |-
|
||||
|
@ -10480,9 +10484,13 @@ spec:
|
|||
description: |-
|
||||
The port to scrape metrics from. If using the public IP address, this must
|
||||
instead be specified in the relabeling rule.
|
||||
format: int32
|
||||
maximum: 65535
|
||||
minimum: 0
|
||||
type: integer
|
||||
projectID:
|
||||
description: ' ProjectID'
|
||||
minLength: 1
|
||||
type: string
|
||||
projectName:
|
||||
description: |-
|
||||
|
@ -10490,6 +10498,7 @@ spec:
|
|||
Some providers allow you to specify a ProjectName instead of the ProjectId.
|
||||
Some require both. Your provider's authentication policies will determine
|
||||
how these fields influence authentication.
|
||||
minLength: 1
|
||||
type: string
|
||||
refreshInterval:
|
||||
description: Refresh interval to re-read the instance list.
|
||||
|
@ -10671,6 +10680,7 @@ spec:
|
|||
type: object
|
||||
userid:
|
||||
description: UserID
|
||||
minLength: 1
|
||||
type: string
|
||||
username:
|
||||
description: |-
|
||||
|
@ -10678,6 +10688,7 @@ spec:
|
|||
control panel to discover your account's username.
|
||||
In Identity V3, either userid or a combination of username
|
||||
and domainId or domainName are needed
|
||||
minLength: 1
|
||||
type: string
|
||||
required:
|
||||
- region
|
||||
|
|
|
@ -9835,6 +9835,7 @@
|
|||
},
|
||||
"applicationCredentialName": {
|
||||
"description": "The ApplicationCredentialID or ApplicationCredentialName fields are\nrequired if using an application credential to authenticate. Some providers\nallow you to create an application credential to authenticate rather than a\npassword.",
|
||||
"minLength": 1,
|
||||
"type": "string"
|
||||
},
|
||||
"applicationCredentialSecret": {
|
||||
|
@ -9874,14 +9875,17 @@
|
|||
},
|
||||
"domainID": {
|
||||
"description": "DomainID",
|
||||
"minLength": 1,
|
||||
"type": "string"
|
||||
},
|
||||
"domainName": {
|
||||
"description": "At most one of domainId and domainName must be provided if using username\nwith Identity V3. Otherwise, either are optional.",
|
||||
"minLength": 1,
|
||||
"type": "string"
|
||||
},
|
||||
"identityEndpoint": {
|
||||
"description": "IdentityEndpoint specifies the HTTP endpoint that is required to work with\nthe Identity API of the appropriate version.",
|
||||
"pattern": "^http(s)?:\\/\\/.+$",
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
|
@ -9909,14 +9913,19 @@
|
|||
},
|
||||
"port": {
|
||||
"description": "The port to scrape metrics from. If using the public IP address, this must\ninstead be specified in the relabeling rule.",
|
||||
"format": "int32",
|
||||
"maximum": 65535,
|
||||
"minimum": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
"projectID": {
|
||||
"description": " ProjectID",
|
||||
"minLength": 1,
|
||||
"type": "string"
|
||||
},
|
||||
"projectName": {
|
||||
"description": "The ProjectId and ProjectName fields are optional for the Identity V2 API.\nSome providers allow you to specify a ProjectName instead of the ProjectId.\nSome require both. Your provider's authentication policies will determine\nhow these fields influence authentication.",
|
||||
"minLength": 1,
|
||||
"type": "string"
|
||||
},
|
||||
"refreshInterval": {
|
||||
|
@ -10102,10 +10111,12 @@
|
|||
},
|
||||
"userid": {
|
||||
"description": "UserID",
|
||||
"minLength": 1,
|
||||
"type": "string"
|
||||
},
|
||||
"username": {
|
||||
"description": "Username is required if using Identity V2 API. Consult with your provider's\ncontrol panel to discover your account's username.\nIn Identity V3, either userid or a combination of username\nand domainId or domainName are needed",
|
||||
"minLength": 1,
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -794,15 +794,18 @@ type OpenStackSDConfig struct {
|
|||
Region string `json:"region"`
|
||||
// IdentityEndpoint specifies the HTTP endpoint that is required to work with
|
||||
// the Identity API of the appropriate version.
|
||||
// +kubebuilder:validation:Pattern:=`^http(s)?:\/\/.+$`
|
||||
// +optional
|
||||
IdentityEndpoint *string `json:"identityEndpoint,omitempty"`
|
||||
// Username is required if using Identity V2 API. Consult with your provider's
|
||||
// control panel to discover your account's username.
|
||||
// In Identity V3, either userid or a combination of username
|
||||
// and domainId or domainName are needed
|
||||
// +kubebuilder:validation:MinLength:=1
|
||||
// +optional
|
||||
Username *string `json:"username,omitempty"`
|
||||
// UserID
|
||||
// +kubebuilder:validation:MinLength:=1
|
||||
// +optional
|
||||
UserID *string `json:"userid,omitempty"`
|
||||
// Password for the Identity V2 and V3 APIs. Consult with your provider's
|
||||
|
@ -811,24 +814,29 @@ type OpenStackSDConfig struct {
|
|||
Password *corev1.SecretKeySelector `json:"password,omitempty"`
|
||||
// At most one of domainId and domainName must be provided if using username
|
||||
// with Identity V3. Otherwise, either are optional.
|
||||
// +kubebuilder:validation:MinLength:=1
|
||||
// +optional
|
||||
DomainName *string `json:"domainName,omitempty"`
|
||||
// DomainID
|
||||
// +kubebuilder:validation:MinLength:=1
|
||||
// +optional
|
||||
DomainID *string `json:"domainID,omitempty"`
|
||||
// The ProjectId and ProjectName fields are optional for the Identity V2 API.
|
||||
// Some providers allow you to specify a ProjectName instead of the ProjectId.
|
||||
// Some require both. Your provider's authentication policies will determine
|
||||
// how these fields influence authentication.
|
||||
// +kubebuilder:validation:MinLength:=1
|
||||
// +optional
|
||||
ProjectName *string `json:"projectName,omitempty"`
|
||||
// ProjectID
|
||||
// +kubebuilder:validation:MinLength:=1
|
||||
// +optional
|
||||
ProjectID *string `json:"projectID,omitempty"`
|
||||
// The ApplicationCredentialID or ApplicationCredentialName fields are
|
||||
// required if using an application credential to authenticate. Some providers
|
||||
// allow you to create an application credential to authenticate rather than a
|
||||
// password.
|
||||
// +kubebuilder:validation:MinLength:=1
|
||||
// +optional
|
||||
ApplicationCredentialName *string `json:"applicationCredentialName,omitempty"`
|
||||
// ApplicationCredentialID
|
||||
|
@ -847,8 +855,10 @@ type OpenStackSDConfig struct {
|
|||
RefreshInterval *v1.Duration `json:"refreshInterval,omitempty"`
|
||||
// The port to scrape metrics from. If using the public IP address, this must
|
||||
// instead be specified in the relabeling rule.
|
||||
// +kubebuilder:validation:Minimum=0
|
||||
// +kubebuilder:validation:Maximum=65535
|
||||
// +optional
|
||||
Port *int `json:"port"`
|
||||
Port *int32 `json:"port,omitempty"`
|
||||
// Availability of the endpoint to connect to.
|
||||
// +kubebuilder:validation:Enum=Public;public;Admin;admin;Internal;internal
|
||||
// +optional
|
||||
|
|
|
@ -1686,7 +1686,7 @@ func (in *OpenStackSDConfig) DeepCopyInto(out *OpenStackSDConfig) {
|
|||
}
|
||||
if in.Port != nil {
|
||||
in, out := &in.Port, &out.Port
|
||||
*out = new(int)
|
||||
*out = new(int32)
|
||||
**out = **in
|
||||
}
|
||||
if in.Availability != nil {
|
||||
|
|
|
@ -40,7 +40,7 @@ type OpenStackSDConfigApplyConfiguration struct {
|
|||
ApplicationCredentialSecret *v1.SecretKeySelector `json:"applicationCredentialSecret,omitempty"`
|
||||
AllTenants *bool `json:"allTenants,omitempty"`
|
||||
RefreshInterval *monitoringv1.Duration `json:"refreshInterval,omitempty"`
|
||||
Port *int `json:"port,omitempty"`
|
||||
Port *int32 `json:"port,omitempty"`
|
||||
Availability *string `json:"availability,omitempty"`
|
||||
TLSConfig *applyconfigurationmonitoringv1.SafeTLSConfigApplyConfiguration `json:"tlsConfig,omitempty"`
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ func (b *OpenStackSDConfigApplyConfiguration) WithRefreshInterval(value monitori
|
|||
// WithPort sets the Port field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the Port field is set to the value of the last call.
|
||||
func (b *OpenStackSDConfigApplyConfiguration) WithPort(value int) *OpenStackSDConfigApplyConfiguration {
|
||||
func (b *OpenStackSDConfigApplyConfiguration) WithPort(value int32) *OpenStackSDConfigApplyConfiguration {
|
||||
b.Port = &value
|
||||
return b
|
||||
}
|
||||
|
|
|
@ -8114,7 +8114,7 @@ func TestScrapeConfigSpecConfigWithOpenStackSD(t *testing.T) {
|
|||
},
|
||||
DomainName: ptr.To("devops-project-1"),
|
||||
RefreshInterval: ptr.To(monitoringv1.Duration("30s")),
|
||||
Port: ptr.To(9100),
|
||||
Port: ptr.To(int32(9100)),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -613,15 +613,18 @@ func testScrapeConfigCRDValidations(t *testing.T) {
|
|||
t.Run("LightSailSD", func(t *testing.T) {
|
||||
runScrapeConfigCRDValidation(t, LightSailSDTestCases)
|
||||
})
|
||||
t.Run("GCESD", func(t *testing.T) {
|
||||
runScrapeConfigCRDValidation(t, GCESDTestCases)
|
||||
})
|
||||
t.Run("AzureSD", func(t *testing.T) {
|
||||
runScrapeConfigCRDValidation(t, AzureSDTestCases)
|
||||
})
|
||||
t.Run("OVHCloudSD", func(t *testing.T) {
|
||||
runScrapeConfigCRDValidation(t, OVHCloudSDTestCases)
|
||||
})
|
||||
t.Run("GCESD", func(t *testing.T) {
|
||||
runScrapeConfigCRDValidation(t, GCESDTestCases)
|
||||
})
|
||||
t.Run("OpenStackSD", func(t *testing.T) {
|
||||
runScrapeConfigCRDValidation(t, OpenStackSDTestCases)
|
||||
})
|
||||
}
|
||||
|
||||
func runScrapeConfigCRDValidation(t *testing.T, testCases []scrapeCRDTestCase) {
|
||||
|
@ -2670,3 +2673,513 @@ var OVHCloudSDTestCases = []scrapeCRDTestCase{
|
|||
expectedError: false,
|
||||
},
|
||||
}
|
||||
|
||||
var OpenStackSDTestCases = []scrapeCRDTestCase{
|
||||
{
|
||||
name: "Bareconfig",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Missing Role",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Region: "default",
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Missing Region",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Valid Role Hypervisor",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "Valid Role Instance",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "instance",
|
||||
Region: "default",
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid Role",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "default",
|
||||
Region: "default",
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Invalid Role Empty",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "",
|
||||
Region: "default",
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Invalid Region Empty",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Valid Endpoint HTTP",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
IdentityEndpoint: ptr.To("http://example.com"),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "Valid Endpoint HTTPS",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
IdentityEndpoint: ptr.To("https://example.com"),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid Endpoint",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
IdentityEndpoint: ptr.To("ftp://example.com"),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Invalid Endpoint Empty",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
IdentityEndpoint: ptr.To(""),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Valid Username",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
Username: ptr.To("admin"),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid Username",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
Username: ptr.To(""),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Valid User ID",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
UserID: ptr.To("ac3377633149401296f6c0d92d79dc16"),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid User ID",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
UserID: ptr.To(""),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Valid Domain ID",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
DomainID: ptr.To("e0353a670a9e496da891347c589539e9"),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid Domain ID",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
DomainID: ptr.To(""),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Valid Domain Name",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
DomainName: ptr.To("default"),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid Domain Name",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
DomainName: ptr.To(""),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Valid Project Name",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
ProjectName: ptr.To("default"),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid Project Name",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
ProjectName: ptr.To(""),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Valid Project ID",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
ProjectID: ptr.To("343d245e850143a096806dfaefa9afdc"),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid Project ID",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
ProjectID: ptr.To(""),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Valid Application Credential Name",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
ApplicationCredentialName: ptr.To("monitoring"),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid Application Credential Name",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
ApplicationCredentialName: ptr.To(""),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Valid Application Credential ID",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
ApplicationCredentialID: ptr.To("aa809205ed614a0e854bac92c0768bb9"),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid Application Credential ID",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
ApplicationCredentialID: ptr.To(""),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "All Tenants True",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
AllTenants: ptr.To(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "All Tenants False",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
AllTenants: ptr.To(false),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "Valid Refresh Interval",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
RefreshInterval: ptr.To(monitoringv1.Duration("30s")),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid Refresh Interval",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
RefreshInterval: ptr.To(monitoringv1.Duration("30g")),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Valid Port 8080",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
Port: ptr.To(int32(8080)),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid Port -1",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
Port: ptr.To(int32(-1)),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Invalid Port 65537",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
Port: ptr.To(int32(65537)),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Valid Availability Public",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
Availability: ptr.To("public"),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "Valid Availability Admin",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
Availability: ptr.To("admin"),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "Valid Availability Internal",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
Availability: ptr.To("internal"),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid Availability",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
Availability: ptr.To("private"),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Invalid Availability Empty Value",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
OpenStackSDConfigs: []monitoringv1alpha1.OpenStackSDConfig{
|
||||
{
|
||||
Role: "hypervisor",
|
||||
Region: "default",
|
||||
Availability: ptr.To(""),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue