Skip to content

Commit

Permalink
fix tests & misc + deprecate v1alpha1
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinsonneau committed Oct 5, 2023
1 parent c2d87fb commit 282b28f
Show file tree
Hide file tree
Showing 11 changed files with 7,617 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ doc: crdoc ## Generate markdown documentation
$(CRDOC) --resources config/crd/bases/flows.netobserv.io_flowcollectors.yaml --output docs/FlowCollector.md

generate-go-conversions: $(CONVERSION_GEN) ## Run all generate-go-conversions
$(MAKE) clean-generated-conversions SRC_DIRS="./api/v1alpha1 ./api/v1beta1"
$(MAKE) clean-generated-conversions SRC_DIRS="./api/v1alpha1,./api/v1beta1"
$(CONVERSION_GEN) \
--input-dirs=./api/v1alpha1 \
--input-dirs=./api/v1beta1 \
Expand Down
2 changes: 2 additions & 0 deletions api/v1alpha1/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ limitations under the License.

// Package v1aplha1 contains the v1alpha1 API implementation.
// +k8s:conversion-gen=github.com/netobserv/network-observability-operator/api/v1beta2
//
// Deprecated: This package will be removed in one of the next releases.
package v1alpha1
6 changes: 5 additions & 1 deletion api/v1alpha1/flowcollector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,8 @@ type FlowCollectorStatus struct {
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[*].reason"

// FlowCollector is the Schema for the flowcollectors API, which pilots and configures netflow collection.
//
// Deprecated: This package will be removed in one of the next releases.
type FlowCollector struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -680,9 +682,11 @@ type FlowCollector struct {
Status FlowCollectorStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true
// +kubebuilder:object:root=true

// FlowCollectorList contains a list of FlowCollector
//
// Deprecated: This package will be removed in one of the next releases.
type FlowCollectorList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand Down
5 changes: 3 additions & 2 deletions bundle/manifests/flows.netobserv.io_flowcollectors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ spec:
name: v1alpha1
schema:
openAPIV3Schema:
description: FlowCollector is the Schema for the flowcollectors API, which
pilots and configures netflow collection.
description: "FlowCollector is the Schema for the flowcollectors API, which
pilots and configures netflow collection. \n Deprecated: This package will
be removed in one of the next releases."
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand Down
5 changes: 3 additions & 2 deletions config/crd/bases/flows.netobserv.io_flowcollectors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ spec:
name: v1alpha1
schema:
openAPIV3Schema:
description: FlowCollector is the Schema for the flowcollectors API, which
pilots and configures netflow collection.
description: "FlowCollector is the Schema for the flowcollectors API, which
pilots and configures netflow collection. \n Deprecated: This package will
be removed in one of the next releases."
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand Down
7,582 changes: 7,582 additions & 0 deletions config/crd/hack/flows.netobserv.io_flowcollectors.yaml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions controllers/flowcollector_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ func flowCollectorControllerSpecs() {
Name: "loki-ca",
Namespace: operatorNamespace,
},
Data: map[string]string{"ca.crt": "certificate data"},
})).Should(Succeed())
UpdateCR(crKey, func(fc *flowslatest.FlowCollector) {
fc.Spec.Loki.Manual.TLS = flowslatest.ClientTLS{
Expand Down Expand Up @@ -701,6 +702,7 @@ func flowCollectorControllerSpecs() {
}
})
})

It("Should have certificate mounted", func() {
By("Expecting certificate mounted")
Eventually(func() interface{} {
Expand Down
25 changes: 14 additions & 11 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/manager"

flowsv1alpha1 "github.com/netobserv/network-observability-operator/api/v1alpha1"
flowsv1beta1 "github.com/netobserv/network-observability-operator/api/v1beta1"
flowsv1beta2 "github.com/netobserv/network-observability-operator/api/v1beta2"
"github.com/netobserv/network-observability-operator/controllers/operator"
Expand Down Expand Up @@ -88,13 +87,20 @@ var _ = BeforeSuite(func() {

By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{
filepath.Join("..", "config", "crd", "bases"),
// We need to install the ConsolePlugin CRD to test setup of our Network Console Plugin
filepath.Join("..", "vendor", "github.com", "openshift", "api", "console", "v1alpha1"),
filepath.Join("..", "vendor", "github.com", "openshift", "api", "config", "v1"),
filepath.Join("..", "vendor", "github.com", "openshift", "api", "operator", "v1"),
filepath.Join("..", "test-assets"),
Scheme: scheme.Scheme,
CRDInstallOptions: envtest.CRDInstallOptions{
Paths: []string{
// FIXME: till v1beta2 becomes the new storage version we will point to hack folder
// where v1beta2 is marked as the storage version
// filepath.Join("..", "config", "crd", "bases"),
filepath.Join("..", "config", "crd", "hack"),
// We need to install the ConsolePlugin CRD to test setup of our Network Console Plugin
filepath.Join("..", "vendor", "github.com", "openshift", "api", "console", "v1alpha1"),
filepath.Join("..", "vendor", "github.com", "openshift", "api", "config", "v1"),
filepath.Join("..", "vendor", "github.com", "openshift", "api", "operator", "v1"),
filepath.Join("..", "test-assets"),
},
CleanUpAfterUse: true,
},
ErrorIfCRDPathMissing: true,
}
Expand All @@ -103,9 +109,6 @@ var _ = BeforeSuite(func() {
Expect(err).NotTo(HaveOccurred())
Expect(cfg).NotTo(BeNil())

err = flowsv1alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())

err = flowsv1beta1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())

Expand Down
3 changes: 2 additions & 1 deletion docs/FlowCollector.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ Resource Types:



FlowCollector is the Schema for the flowcollectors API, which pilots and configures netflow collection.
FlowCollector is the Schema for the flowcollectors API, which pilots and configures netflow collection.
Deprecated: This package will be removed in one of the next releases.

<table>
<thead>
Expand Down
4 changes: 1 addition & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"

flowsv1alpha1 "github.com/netobserv/network-observability-operator/api/v1alpha1"
flowsv1beta1 "github.com/netobserv/network-observability-operator/api/v1beta1"
flowsv1beta2 "github.com/netobserv/network-observability-operator/api/v1beta2"
"github.com/netobserv/network-observability-operator/controllers"
Expand All @@ -65,7 +64,6 @@ var (

func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(flowsv1alpha1.AddToScheme(scheme))
utilruntime.Must(flowsv1beta1.AddToScheme(scheme))
utilruntime.Must(flowsv1beta2.AddToScheme(scheme))
utilruntime.Must(corev1.AddToScheme(scheme))
Expand Down Expand Up @@ -143,7 +141,7 @@ func main() {
os.Exit(1)
}
if err = (&flowsv1beta2.FlowCollector{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create v1beta1 webhook", "webhook", "FlowCollector")
setupLog.Error(err, "unable to create v1beta2 webhook", "webhook", "FlowCollector")
os.Exit(1)
}
//+kubebuilder:scaffold:builder
Expand Down
4 changes: 2 additions & 2 deletions pkg/cleanup/cleanup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var oldDashboard = corev1.ConfigMap{
Name: "grafana-dashboard-netobserv",
Namespace: "openshift-config-managed",
OwnerReferences: []v1.OwnerReference{{
APIVersion: "flows.netobserv.io/v1beta1",
APIVersion: "flows.netobserv.io/v1beta2",
Kind: "FlowCollector",
Name: "cluster",
Controller: pointer.Bool(true),
Expand Down Expand Up @@ -74,7 +74,7 @@ func TestCleanPastReferences_DifferentOwner(t *testing.T) {
clientMock := test.ClientMock{}
unmanaged := oldDashboard
unmanaged.OwnerReferences = []v1.OwnerReference{{
APIVersion: "something/v1beta1",
APIVersion: "something/v1beta2",
Kind: "SomethingElse",
Name: "SomethingElse",
}}
Expand Down

0 comments on commit 282b28f

Please sign in to comment.