Skip to content

Commit

Permalink
chore: update api version in code
Browse files Browse the repository at this point in the history
this commit updates paths of new api version in code
and removes deprecated node-labeller api fields

Signed-off-by: Karel Šimon <ksimon@redhat.com>
  • Loading branch information
ksimon1 committed Jun 14, 2023
1 parent 3ffa456 commit eb60b15
Show file tree
Hide file tree
Showing 52 changed files with 194 additions and 761 deletions.
4 changes: 2 additions & 2 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ resources:
domain: kubevirt.io
group: ssp
kind: SSP
path: kubevirt.io/ssp-operator/api/v1beta1
version: v1beta1
path: kubevirt.io/ssp-operator/api/v1beta2
version: v1beta2
webhooks:
# conversion: true
# defaulting: true
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ The following resource types and CRDs are needed by `ssp-operator` when deployed
| `datavolumes.cdi.kubevirt.io/v1beta1` | `data-sources` operand (Kind `DataVolume` and `DataVolumeSource`) |
| `datasources.cdi.kubevirt.io/v1beta1` | `data-sources` operand (Kind `DataSource`) |
| `prometheusrules.monitoring.coreos.com` | `metrics` operand (Kind `PrometheusRule`) |
| `securitycontextconstraints.security.openshift.io` | `node-labeller` operand (Kind `SecurityContextConstraints`) |
| `template.openshift.io/v1` | `common-templates` operand (Kind `Template`) |
| `virtualmachineclusterinstancetypes.instancetypes.kubevirt.io/v1alpha2` | `common-instancetypes` operand (Kind `VirtualMachineClusterInstancetype`) |
| `virtualmachineclusterpreferences.instancetypes.kubevirt.io/v1alpha2` | `common-instancetypes` operand (Kind `VirtualMachineClusterPreference`) |
Expand Down Expand Up @@ -61,7 +60,7 @@ oc apply -f https://github.com/kubevirt/ssp-operator/releases/download/${SSP_VER
```

To activate the operator, a CR needs to be created.
An example is in [config/samples/ssp_v1beta1_ssp.yaml](config/samples/ssp_v1beta1_ssp.yaml).
An example is in [config/samples/ssp_v1beta2_ssp.yaml](config/samples/ssp_v1beta2_ssp.yaml).

## Building

Expand Down
2 changes: 1 addition & 1 deletion automation/e2e-tekton/example-pipelines-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ make deploy
oc wait -n kubevirt deployment ssp-operator --for condition=Available --timeout 10m

# Deploy sample SSP CR
oc apply -f "config/samples/ssp_v1beta1_ssp.yaml"
oc apply -f "config/samples/ssp_v1beta2_ssp.yaml"
oc wait -n kubevirt ssp ssp-sample --for condition=Available --timeout 10m

wait_until_exists "pipeline windows-efi-installer -n kubevirt" wait_until_exists "pipeline windows-customize -n kubevirt"
Expand Down
2 changes: 0 additions & 2 deletions controllers/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
common_templates "kubevirt.io/ssp-operator/internal/operands/common-templates"
data_sources "kubevirt.io/ssp-operator/internal/operands/data-sources"
"kubevirt.io/ssp-operator/internal/operands/metrics"
node_labeller "kubevirt.io/ssp-operator/internal/operands/node-labeller"
tekton_pipelines "kubevirt.io/ssp-operator/internal/operands/tekton-pipelines"
tekton_tasks "kubevirt.io/ssp-operator/internal/operands/tekton-tasks"
template_validator "kubevirt.io/ssp-operator/internal/operands/template-validator"
Expand Down Expand Up @@ -94,7 +93,6 @@ func setupManager(ctx context.Context, cancel context.CancelFunc, mgr controller
metrics.New(),
template_validator.New(),
common_templates.New(templatesBundle.Templates),
node_labeller.New(),
vm_console_proxy.New(vmConsoleProxyBundle),
)
}
Expand Down
4 changes: 1 addition & 3 deletions controllers/ssp_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"

ssp "kubevirt.io/ssp-operator/api/v1beta1"
ssp "kubevirt.io/ssp-operator/api/v1beta2"
"kubevirt.io/ssp-operator/internal/common"
handler_hook "kubevirt.io/ssp-operator/internal/controller/handler-hook"
"kubevirt.io/ssp-operator/internal/controller/predicates"
Expand All @@ -65,7 +65,6 @@ var kvsspCRDs = map[string]string{
"kubevirtmetricsaggregations.ssp.kubevirt.io": "KubevirtMetricsAggregation",
"kubevirttemplatevalidators.ssp.kubevirt.io": "KubevirtTemplateValidator",
"kubevirtcommontemplatesbundles.ssp.kubevirt.io": "KubevirtCommonTemplatesBundle",
"kubevirtnodelabellerbundles.ssp.kubevirt.io": "KubevirtNodeLabellerBundle",
}

// sspReconciler reconciles a SSP object
Expand Down Expand Up @@ -102,7 +101,6 @@ var _ reconcile.Reconciler = &sspReconciler{}
// +kubebuilder:rbac:groups=apiextensions.k8s.io,resources=customresourcedefinitions,verbs=list
// +kubebuilder:rbac:groups=ssp.kubevirt.io,resources=kubevirtcommontemplatesbundles,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=ssp.kubevirt.io,resources=kubevirtmetricsaggregations,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=ssp.kubevirt.io,resources=kubevirtnodelabellerbundles,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=ssp.kubevirt.io,resources=kubevirttemplatevalidators,verbs=get;list;watch;create;update;patch;delete

func (r *sspReconciler) setupController(mgr ctrl.Manager) error {
Expand Down
6 changes: 0 additions & 6 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,6 @@ Installs prometheus monitoring rules for `ssp-operator` metrics. The available
metrics can be found in `docs/metrics.md`. The installed rules can be found in
`internal/operands/metrics/resources.go`.

#### `node-labeller` operand

Node labeling was moved to the [kubevirt](https://github.com/kubevirt/kubevirt)
core. The operand removes remaining resources created by older versions of
`ssp-operator`.

#### `template-validator` operand

The main `template-validator` runs in at least one separate container than the
Expand Down
2 changes: 1 addition & 1 deletion hack/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
source ./hack/common.sh

# Please note that the validation webhooks are not currently deployed so take care when using a custom SSP CR
export KUBEVIRT_SSP=${KUBEVIRT_SSP:-./config/samples/ssp_v1beta1_ssp.yaml}
export KUBEVIRT_SSP=${KUBEVIRT_SSP:-./config/samples/ssp_v1beta2_ssp.yaml}

if [ -z "${KUBECTL}" ] || [ -z "${KUBESSH}" ] || [ -z "${KUSTOMIZE}" ] || [ -z "${KUBEVIRTCI_REGISTERY}" ]; then
echo "${BASH_SOURCE[0]} expects the following env variables to be provided: KUBECTL, KUBESSH, KUSTOMIZE and KUBEVIRTCI_REGISTERY."
Expand Down
4 changes: 2 additions & 2 deletions internal/common/crypto_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/go-logr/logr"
ocpv1 "github.com/openshift/api/config/v1"
"github.com/openshift/library-go/pkg/crypto"
"kubevirt.io/ssp-operator/api/v1beta1"
ssp "kubevirt.io/ssp-operator/api/v1beta2"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down Expand Up @@ -86,7 +86,7 @@ func GetSspTlsOptions(ctx context.Context) (*SSPTLSOptions, error) {
return nil, err
}

var sspList v1beta1.SSPList
var sspList ssp.SSPList
if err := apiReader.List(ctx, &sspList, &client.ListOptions{}); err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions internal/common/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package common
import (
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/selection"
"kubevirt.io/ssp-operator/api/v1beta1"
ssp "kubevirt.io/ssp-operator/api/v1beta2"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down Expand Up @@ -36,7 +36,7 @@ const (
// Name will translate into the AppKubernetesNameLabel
// Component will translate into the AppKubernetesComponentLabel
// Instance wide labels will be taken from the request if available
func AddAppLabels(requestInstance *v1beta1.SSP, name string, component AppComponent, obj client.Object) client.Object {
func AddAppLabels(requestInstance *ssp.SSP, name string, component AppComponent, obj client.Object) client.Object {
labels := getOrCreateLabels(obj)
addInstanceLabels(requestInstance, labels)

Expand All @@ -56,7 +56,7 @@ func getOrCreateLabels(obj client.Object) map[string]string {
return labels
}

func addInstanceLabels(requestInstance *v1beta1.SSP, to map[string]string) {
func addInstanceLabels(requestInstance *ssp.SSP, to map[string]string) {
if requestInstance.Labels == nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion internal/common/labels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

ssp "kubevirt.io/ssp-operator/api/v1beta1"
ssp "kubevirt.io/ssp-operator/api/v1beta2"
)

var _ = Describe("AddAppLabels", func() {
Expand Down
2 changes: 1 addition & 1 deletion internal/common/owner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

ssp "kubevirt.io/ssp-operator/api/v1beta1"
ssp "kubevirt.io/ssp-operator/api/v1beta2"
)

var _ = Describe("Owner", func() {
Expand Down
2 changes: 1 addition & 1 deletion internal/common/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

ssp "kubevirt.io/ssp-operator/api/v1beta1"
ssp "kubevirt.io/ssp-operator/api/v1beta2"
crd_watch "kubevirt.io/ssp-operator/internal/crd-watch"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/common/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

ssp "kubevirt.io/ssp-operator/api/v1beta1"
ssp "kubevirt.io/ssp-operator/api/v1beta2"
)

var log = logf.Log.WithName("common_operand_package")
Expand Down
4 changes: 2 additions & 2 deletions internal/common/scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
instancetypev1alpha2 "kubevirt.io/api/instancetype/v1alpha2"
sspv1beta1 "kubevirt.io/ssp-operator/api/v1beta1"
ssp "kubevirt.io/ssp-operator/api/v1beta2"
)

var (
Expand All @@ -23,7 +23,7 @@ func init() {
utilruntime.Must(clientgoscheme.AddToScheme(Scheme))
utilruntime.Must(extv1.AddToScheme(Scheme))
utilruntime.Must(internalmeta.AddToScheme(Scheme))
utilruntime.Must(sspv1beta1.AddToScheme(Scheme))
utilruntime.Must(ssp.AddToScheme(Scheme))
utilruntime.Must(osconfv1.Install(Scheme))
utilruntime.Must(instancetypev1alpha2.AddToScheme(Scheme))
}
Expand Down
14 changes: 7 additions & 7 deletions internal/controller/predicates/predicates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import (
"k8s.io/utils/pointer"
"sigs.k8s.io/controller-runtime/pkg/event"

sspv1beta1 "kubevirt.io/ssp-operator/api/v1beta1"
ssp "kubevirt.io/ssp-operator/api/v1beta2"
)

var _ = Describe("SpecChangedPredicate", func() {
It("Should be false if spec is the same", func() {
obj := &sspv1beta1.SSP{
Spec: sspv1beta1.SSPSpec{
TemplateValidator: &sspv1beta1.TemplateValidator{
obj := &ssp.SSP{
Spec: ssp.SSPSpec{
TemplateValidator: &ssp.TemplateValidator{
Replicas: pointer.Int32(1),
},
},
Expand All @@ -32,9 +32,9 @@ var _ = Describe("SpecChangedPredicate", func() {
})

It("Shuld be true if spec is different", func() {
obj := &sspv1beta1.SSP{
Spec: sspv1beta1.SSPSpec{
TemplateValidator: &sspv1beta1.TemplateValidator{
obj := &ssp.SSP{
Spec: ssp.SSPSpec{
TemplateValidator: &ssp.TemplateValidator{
Replicas: pointer.Int32(1),
},
},
Expand Down
2 changes: 1 addition & 1 deletion internal/operands/common-instancetypes/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

instancetypeapi "kubevirt.io/api/instancetype"
instancetypev1alpha2 "kubevirt.io/api/instancetype/v1alpha2"
ssp "kubevirt.io/ssp-operator/api/v1beta1"
ssp "kubevirt.io/ssp-operator/api/v1beta2"
"kubevirt.io/ssp-operator/internal/common"
crd_watch "kubevirt.io/ssp-operator/internal/crd-watch"
. "kubevirt.io/ssp-operator/internal/test-utils"
Expand Down
2 changes: 1 addition & 1 deletion internal/operands/common-templates/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

ssp "kubevirt.io/ssp-operator/api/v1beta1"
ssp "kubevirt.io/ssp-operator/api/v1beta2"
"kubevirt.io/ssp-operator/internal/common"
"kubevirt.io/ssp-operator/internal/operands"
. "kubevirt.io/ssp-operator/internal/test-utils"
Expand Down
2 changes: 1 addition & 1 deletion internal/operands/data-sources/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
cdiv1beta1 "kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client"

ssp "kubevirt.io/ssp-operator/api/v1beta1"
ssp "kubevirt.io/ssp-operator/api/v1beta2"
"kubevirt.io/ssp-operator/internal"
"kubevirt.io/ssp-operator/internal/common"
"kubevirt.io/ssp-operator/internal/operands"
Expand Down
2 changes: 1 addition & 1 deletion internal/operands/data-sources/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

ssp "kubevirt.io/ssp-operator/api/v1beta1"
ssp "kubevirt.io/ssp-operator/api/v1beta2"
"kubevirt.io/ssp-operator/internal"
"kubevirt.io/ssp-operator/internal/common"
"kubevirt.io/ssp-operator/internal/operands"
Expand Down
2 changes: 1 addition & 1 deletion internal/operands/metrics/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

ssp "kubevirt.io/ssp-operator/api/v1beta1"
ssp "kubevirt.io/ssp-operator/api/v1beta2"
"kubevirt.io/ssp-operator/internal/common"
)

Expand Down
Loading

0 comments on commit eb60b15

Please sign in to comment.