Skip to content

Commit

Permalink
Update all the references of NC v1beta2 to v1beta3
Browse files Browse the repository at this point in the history
Signed-off-by: Sunny <darkowlzz@protonmail.com>
  • Loading branch information
darkowlzz committed Nov 28, 2023
1 parent c004099 commit 1d9feae
Show file tree
Hide file tree
Showing 35 changed files with 133 additions and 132 deletions.
2 changes: 1 addition & 1 deletion cmd/flux/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package main
import (
"sigs.k8s.io/controller-runtime/pkg/client"

notificationv1 "github.com/fluxcd/notification-controller/api/v1beta2"
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta3"
)

// notificationv1.Alert
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/alert_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package main
import (
"sigs.k8s.io/controller-runtime/pkg/client"

notificationv1 "github.com/fluxcd/notification-controller/api/v1beta2"
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta3"
)

// notificationv1.Provider
Expand Down
10 changes: 5 additions & 5 deletions cmd/flux/create_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"

notificationv1 "github.com/fluxcd/notification-controller/api/v1"
notificationv1b2 "github.com/fluxcd/notification-controller/api/v1beta2"
notificationv1b3 "github.com/fluxcd/notification-controller/api/v1beta3"
"github.com/fluxcd/pkg/apis/meta"

"github.com/fluxcd/flux2/v2/internal/utils"
Expand Down Expand Up @@ -96,13 +96,13 @@ func createAlertCmdRun(cmd *cobra.Command, args []string) error {
logger.Generatef("generating Alert")
}

alert := notificationv1b2.Alert{
alert := notificationv1b3.Alert{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: *kubeconfigArgs.Namespace,
Labels: sourceLabels,
},
Spec: notificationv1b2.AlertSpec{
Spec: notificationv1b3.AlertSpec{
ProviderRef: meta.LocalObjectReference{
Name: alertArgs.providerRef,
},
Expand Down Expand Up @@ -140,13 +140,13 @@ func createAlertCmdRun(cmd *cobra.Command, args []string) error {
}

func upsertAlert(ctx context.Context, kubeClient client.Client,
alert *notificationv1b2.Alert) (types.NamespacedName, error) {
alert *notificationv1b3.Alert) (types.NamespacedName, error) {
namespacedName := types.NamespacedName{
Namespace: alert.GetNamespace(),
Name: alert.GetName(),
}

var existing notificationv1b2.Alert
var existing notificationv1b3.Alert
err := kubeClient.Get(ctx, namespacedName, &existing)
if err != nil {
if errors.IsNotFound(err) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/create_alertprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"sigs.k8s.io/controller-runtime/pkg/client"

notificationv1 "github.com/fluxcd/notification-controller/api/v1beta2"
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta3"
"github.com/fluxcd/pkg/apis/meta"

"github.com/fluxcd/flux2/v2/internal/utils"
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/delete_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package main
import (
"github.com/spf13/cobra"

notificationv1 "github.com/fluxcd/notification-controller/api/v1beta2"
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta3"
)

var deleteAlertCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/delete_alertprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package main
import (
"github.com/spf13/cobra"

notificationv1 "github.com/fluxcd/notification-controller/api/v1beta2"
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta3"
)

var deleteAlertProviderCmd = &cobra.Command{
Expand Down
10 changes: 5 additions & 5 deletions cmd/flux/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import (
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1beta2"
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1"
notificationv1 "github.com/fluxcd/notification-controller/api/v1"
notificationv1b2 "github.com/fluxcd/notification-controller/api/v1beta2"
notificationv1b3 "github.com/fluxcd/notification-controller/api/v1beta3"
sourcev1 "github.com/fluxcd/source-controller/api/v1"
sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2"

Expand Down Expand Up @@ -426,14 +426,14 @@ var fluxKindMap = refMap{
},
field: []string{"spec", "chart", "spec", "sourceRef"},
},
notificationv1b2.AlertKind: {
gvk: notificationv1b2.GroupVersion.WithKind(notificationv1b2.AlertKind),
kind: notificationv1b2.ProviderKind,
notificationv1b3.AlertKind: {
gvk: notificationv1b3.GroupVersion.WithKind(notificationv1b3.AlertKind),
kind: notificationv1b3.ProviderKind,
crossNamespaced: false,
field: []string{"spec", "providerRef"},
},
notificationv1.ReceiverKind: {gvk: notificationv1.GroupVersion.WithKind(notificationv1.ReceiverKind)},
notificationv1b2.ProviderKind: {gvk: notificationv1b2.GroupVersion.WithKind(notificationv1b2.ProviderKind)},
notificationv1b3.ProviderKind: {gvk: notificationv1b3.GroupVersion.WithKind(notificationv1b3.ProviderKind)},
imagev1.ImagePolicyKind: {
gvk: imagev1.GroupVersion.WithKind(imagev1.ImagePolicyKind),
kind: imagev1.ImageRepositoryKind,
Expand Down
8 changes: 4 additions & 4 deletions cmd/flux/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1beta2"
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1"
notificationv1 "github.com/fluxcd/notification-controller/api/v1"
notificationv1b2 "github.com/fluxcd/notification-controller/api/v1beta2"
notificationv1b3 "github.com/fluxcd/notification-controller/api/v1beta3"
eventv1 "github.com/fluxcd/pkg/apis/event/v1beta1"
"github.com/fluxcd/pkg/ssa"
sourcev1 "github.com/fluxcd/source-controller/api/v1"
Expand Down Expand Up @@ -127,7 +127,7 @@ spec:
name: podinfo-chart
version: '*'
---
apiVersion: notification.toolkit.fluxcd.io/v1beta2
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Alert
metadata:
name: webapp
Expand All @@ -140,7 +140,7 @@ spec:
providerRef:
name: slack
---
apiVersion: notification.toolkit.fluxcd.io/v1beta2
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Provider
metadata:
name: slack
Expand Down Expand Up @@ -416,7 +416,7 @@ func getScheme() *runtime.Scheme {
kustomizev1.AddToScheme(newscheme)
helmv2beta1.AddToScheme(newscheme)
notificationv1.AddToScheme(newscheme)
notificationv1b2.AddToScheme(newscheme)
notificationv1b3.AddToScheme(newscheme)
imagev1.AddToScheme(newscheme)
autov1.AddToScheme(newscheme)
sourcev1.AddToScheme(newscheme)
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/export_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

notificationv1 "github.com/fluxcd/notification-controller/api/v1beta2"
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta3"
)

var exportAlertCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/export_alertprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

notificationv1 "github.com/fluxcd/notification-controller/api/v1beta2"
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta3"
)

var exportAlertProviderCmd = &cobra.Command{
Expand Down
5 changes: 2 additions & 3 deletions cmd/flux/get_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"

notificationv1 "github.com/fluxcd/notification-controller/api/v1beta2"
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta3"
)

var getAlertCmd = &cobra.Command{
Expand Down Expand Up @@ -92,6 +92,5 @@ func (s alertListAdapter) headers(includeNamespace bool) []string {
}

func (s alertListAdapter) statusSelectorMatches(i int, conditionType, conditionStatus string) bool {
item := s.Items[i]
return statusMatches(conditionType, conditionStatus, item.Status.Conditions)
return false
}
5 changes: 2 additions & 3 deletions cmd/flux/get_alertprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"

notificationv1 "github.com/fluxcd/notification-controller/api/v1beta2"
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta3"
)

var getAlertProviderCmd = &cobra.Command{
Expand Down Expand Up @@ -88,6 +88,5 @@ func (s alertProviderListAdapter) headers(includeNamespace bool) []string {
}

func (s alertProviderListAdapter) statusSelectorMatches(i int, conditionType, conditionStatus string) bool {
item := s.Items[i]
return statusMatches(conditionType, conditionStatus, item.Status.Conditions)
return false
}
6 changes: 3 additions & 3 deletions cmd/flux/get_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
helmv2 "github.com/fluxcd/helm-controller/api/v2beta1"
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1"
notificationv1 "github.com/fluxcd/notification-controller/api/v1"
notificationv1b2 "github.com/fluxcd/notification-controller/api/v1beta2"
notificationv1b3 "github.com/fluxcd/notification-controller/api/v1beta3"
)

var getAllCmd = &cobra.Command{
Expand Down Expand Up @@ -63,11 +63,11 @@ var getAllCmd = &cobra.Command{
},
{
apiType: alertProviderType,
list: alertProviderListAdapter{&notificationv1b2.ProviderList{}},
list: alertProviderListAdapter{&notificationv1b3.ProviderList{}},
},
{
apiType: alertType,
list: &alertListAdapter{&notificationv1b2.AlertList{}},
list: &alertListAdapter{&notificationv1b3.AlertList{}},
},
}

Expand Down
4 changes: 3 additions & 1 deletion cmd/flux/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/fluxcd/flux2/v2/internal/utils"
"github.com/google/go-cmp/cmp"
"github.com/mattn/go-shellwords"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
k8syaml "k8s.io/apimachinery/pkg/util/yaml"
"k8s.io/client-go/tools/clientcmd"
Expand Down Expand Up @@ -112,7 +113,8 @@ func (m *testEnvKubeManager) CreateObjects(clientObjects []*unstructured.Unstruc
}
obj.SetResourceVersion(createObj.GetResourceVersion())
err = m.client.Status().Update(context.Background(), obj)
if err != nil {
// Updating status of static objects results in not found error.
if err != nil && !errors.IsNotFound(err) {
return err
}
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/flux/resume_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package main
import (
"github.com/spf13/cobra"

notificationv1 "github.com/fluxcd/notification-controller/api/v1beta2"
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta3"
)

var resumeAlertCmd = &cobra.Command{
Expand All @@ -44,7 +44,7 @@ func init() {
}

func (obj alertAdapter) getObservedGeneration() int64 {
return obj.Alert.Status.ObservedGeneration
return 0
}

func (obj alertAdapter) setUnsuspended() {
Expand Down
4 changes: 2 additions & 2 deletions cmd/flux/resume_alertprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package main
import (
"github.com/spf13/cobra"

notificationv1 "github.com/fluxcd/notification-controller/api/v1beta2"
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta3"
)

var resumeAlertProviderCmd = &cobra.Command{
Expand All @@ -44,7 +44,7 @@ func init() {
}

func (obj alertProviderAdapter) getObservedGeneration() int64 {
return obj.Provider.Status.ObservedGeneration
return 0
}

func (obj alertProviderAdapter) setUnsuspended() {
Expand Down
14 changes: 7 additions & 7 deletions cmd/flux/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1beta2"
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1"
notificationv1 "github.com/fluxcd/notification-controller/api/v1"
notificationv1b2 "github.com/fluxcd/notification-controller/api/v1beta2"
notificationv1b3 "github.com/fluxcd/notification-controller/api/v1beta3"
sourcev1 "github.com/fluxcd/source-controller/api/v1"
sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2"

Expand Down Expand Up @@ -111,14 +111,14 @@ func runStatsCmd(cmd *cobra.Command, args []string) error {
Group: helmv2.GroupVersion.Group,
},
{
Kind: notificationv1b2.AlertKind,
Version: notificationv1b2.GroupVersion.Version,
Group: notificationv1b2.GroupVersion.Group,
Kind: notificationv1b3.AlertKind,
Version: notificationv1b3.GroupVersion.Version,
Group: notificationv1b3.GroupVersion.Group,
},
{
Kind: notificationv1b2.ProviderKind,
Version: notificationv1b2.GroupVersion.Version,
Group: notificationv1b2.GroupVersion.Group,
Kind: notificationv1b3.ProviderKind,
Version: notificationv1b3.GroupVersion.Version,
Group: notificationv1b3.GroupVersion.Group,
},
{
Kind: notificationv1.ReceiverKind,
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/suspend_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package main
import (
"github.com/spf13/cobra"

notificationv1 "github.com/fluxcd/notification-controller/api/v1beta2"
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta3"
)

var suspendAlertCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/suspend_alertprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package main
import (
"github.com/spf13/cobra"

notificationv1 "github.com/fluxcd/notification-controller/api/v1beta2"
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta3"
)

var suspendAlertProviderCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/testdata/export/alert.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: notification.toolkit.fluxcd.io/v1beta2
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Alert
metadata:
name: flux-system
Expand Down
4 changes: 2 additions & 2 deletions cmd/flux/testdata/export/objects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: Namespace
metadata:
name: {{ .fluxns }}
---
apiVersion: notification.toolkit.fluxcd.io/v1beta2
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Provider
metadata:
name: slack
Expand All @@ -14,7 +14,7 @@ spec:
channel: 'A channel with spacess'
address: https://hooks.slack.com/services/mock
---
apiVersion: notification.toolkit.fluxcd.io/v1beta2
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Alert
metadata:
name: flux-system
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/testdata/export/provider.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: notification.toolkit.fluxcd.io/v1beta2
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Provider
metadata:
name: slack
Expand Down
Loading

0 comments on commit 1d9feae

Please sign in to comment.