Files
my-rook-config/pkg/operator/k8sutil/service_test.go
T
Alexander Trost 430e4dc0f4 k8sutil: set ResourceVersion for PrometheusRule
This change sets the ResourceVersion on the PrometheusRule object before
it is updated in Kubernetes.
This change fixes the following error
```
is invalid: metadata.resourceVersion: Invalid value: 0x0: must be specified for an update
```
which can occur during update when no ResourceVersion is set.

Resolves #4528

Signed-off-by: Alexander Trost <galexrt@googlemail.com>
2020-02-10 13:36:46 +01:00

38 lines
1.2 KiB
Go

/*
Copyright 2020 The Rook Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package k8sutil for Kubernetes helpers.
package k8sutil
import (
"testing"
"github.com/stretchr/testify/assert"
v1 "k8s.io/api/core/v1"
)
func TestParseServiceType(t *testing.T) {
validServiceTypes := []string{"ClusterIP", "NodePort", "LoadBalancer", "ExternalName"}
for _, serviceType := range validServiceTypes {
assert.Equal(t, v1.ServiceType(serviceType), ParseServiceType(serviceType))
}
invalidServiceTypes := []string{"", "nodeport", "notarealservice"}
for _, serviceType := range invalidServiceTypes {
assert.Equal(t, v1.ServiceType(""), ParseServiceType(serviceType))
}
}