Skip to content

Commit

Permalink
Modifying imports for grafana-operator to include v3
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkirwan committed Jan 3, 2020
1 parent 03d7fa8 commit 5a373c0
Show file tree
Hide file tree
Showing 26 changed files with 80 additions and 80 deletions.
12 changes: 6 additions & 6 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"context"
"flag"
"fmt"
"github.com/integr8ly/grafana-operator/pkg/apis"
"github.com/integr8ly/grafana-operator/pkg/controller"
"github.com/integr8ly/grafana-operator/pkg/controller/common"
config2 "github.com/integr8ly/grafana-operator/pkg/controller/config"
"github.com/integr8ly/grafana-operator/pkg/controller/grafanadashboard"
"github.com/integr8ly/grafana-operator/version"
"github.com/integr8ly/grafana-operator/v3/pkg/apis"
"github.com/integr8ly/grafana-operator/v3/pkg/controller"
"github.com/integr8ly/grafana-operator/v3/pkg/controller/common"
config2 "github.com/integr8ly/grafana-operator/v3/pkg/controller/config"
"github.com/integr8ly/grafana-operator/v3/pkg/controller/grafanadashboard"
"github.com/integr8ly/grafana-operator/v3/version"
routev1 "github.com/openshift/api/route/v1"
"github.com/operator-framework/operator-sdk/pkg/k8sutil"
"github.com/operator-framework/operator-sdk/pkg/leader"
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/addtoscheme_integreatly_v1alpha1.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package apis

import (
"github.com/integr8ly/grafana-operator/pkg/apis/integreatly/v1alpha1"
"github.com/integr8ly/grafana-operator/v3/pkg/apis/integreatly/v1alpha1"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/add_datasource.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package controller

import (
"github.com/integr8ly/grafana-operator/pkg/controller/grafanadatasource"
"github.com/integr8ly/grafana-operator/v3/pkg/controller/grafanadatasource"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/add_grafana.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package controller

import (
"github.com/integr8ly/grafana-operator/pkg/controller/grafana"
"github.com/integr8ly/grafana-operator/v3/pkg/controller/grafana"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/common/auto_detect.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package common

import (
config2 "github.com/integr8ly/grafana-operator/pkg/controller/config"
config2 "github.com/integr8ly/grafana-operator/v3/pkg/controller/config"
"k8s.io/apimachinery/pkg/runtime/schema"

"time"
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/common/clusterState.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package common

import (
"context"
"github.com/integr8ly/grafana-operator/pkg/apis/integreatly/v1alpha1"
"github.com/integr8ly/grafana-operator/pkg/controller/config"
"github.com/integr8ly/grafana-operator/pkg/controller/model"
"github.com/integr8ly/grafana-operator/v3/pkg/apis/integreatly/v1alpha1"
"github.com/integr8ly/grafana-operator/v3/pkg/controller/config"
"github.com/integr8ly/grafana-operator/v3/pkg/controller/model"
v12 "github.com/openshift/api/route/v1"
v13 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/common/dataSourcesState.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package common

import (
"context"
"github.com/integr8ly/grafana-operator/pkg/apis/integreatly/v1alpha1"
"github.com/integr8ly/grafana-operator/pkg/controller/model"
"github.com/integr8ly/grafana-operator/v3/pkg/apis/integreatly/v1alpha1"
"github.com/integr8ly/grafana-operator/v3/pkg/controller/model"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/config/controller_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"sync"
"time"

"github.com/integr8ly/grafana-operator/pkg/apis/integreatly/v1alpha1"
"github.com/integr8ly/grafana-operator/v3/pkg/apis/integreatly/v1alpha1"
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/config/grafanaIni.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package config
import (
"crypto/md5"
"fmt"
"github.com/integr8ly/grafana-operator/pkg/apis/integreatly/v1alpha1"
"github.com/integr8ly/grafana-operator/v3/pkg/apis/integreatly/v1alpha1"
"io"
"sort"
"strings"
Expand Down
26 changes: 13 additions & 13 deletions pkg/controller/grafana/grafana_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"context"
stdErr "errors"
"fmt"
i8ly "github.com/integr8ly/grafana-operator/pkg/apis/integreatly/v1alpha1"
"github.com/integr8ly/grafana-operator/pkg/controller/common"
"github.com/integr8ly/grafana-operator/pkg/controller/config"
"github.com/integr8ly/grafana-operator/pkg/controller/model"
grafanav1alpha1 "github.com/integr8ly/grafana-operator/v3/pkg/apis/integreatly/v1alpha1"
"github.com/integr8ly/grafana-operator/v3/pkg/controller/common"
"github.com/integr8ly/grafana-operator/v3/pkg/controller/config"
"github.com/integr8ly/grafana-operator/v3/pkg/controller/model"
routev1 "github.com/openshift/api/route/v1"
v12 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -61,7 +61,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler, autodetectChannel chan sch
}

// Watch for changes to primary resource Grafana
err = c.Watch(&source.Kind{Type: &i8ly.Grafana{}}, &handler.EnqueueRequestForObject{})
err = c.Watch(&source.Kind{Type: &grafanav1alpha1.Grafana{}}, &handler.EnqueueRequestForObject{})
if err != nil {
return err
}
Expand Down Expand Up @@ -128,14 +128,14 @@ type ReconcileGrafana struct {
func watchSecondaryResource(c controller.Controller, resource runtime.Object) error {
return c.Watch(&source.Kind{Type: resource}, &handler.EnqueueRequestForOwner{
IsController: true,
OwnerType: &i8ly.Grafana{},
OwnerType: &grafanav1alpha1.Grafana{},
})
}

// Reconcile reads that state of the cluster for a Grafana object and makes changes based on the state read
// and what is in the Grafana.Spec
func (r *ReconcileGrafana) Reconcile(request reconcile.Request) (reconcile.Result, error) {
instance := &i8ly.Grafana{}
instance := &grafanav1alpha1.Grafana{}
err := r.client.Get(r.context, request.NamespacedName, instance)
if err != nil {
if errors.IsNotFound(err) {
Expand Down Expand Up @@ -176,9 +176,9 @@ func (r *ReconcileGrafana) Reconcile(request reconcile.Request) (reconcile.Resul
return r.manageSuccess(cr, currentState)
}

func (r *ReconcileGrafana) manageError(cr *i8ly.Grafana, issue error) (reconcile.Result, error) {
func (r *ReconcileGrafana) manageError(cr *grafanav1alpha1.Grafana, issue error) (reconcile.Result, error) {
r.recorder.Event(cr, "Warning", "ProcessingError", issue.Error())
cr.Status.Phase = i8ly.PhaseFailing
cr.Status.Phase = grafanav1alpha1.PhaseFailing
cr.Status.Message = issue.Error()

err := r.client.Status().Update(r.context, cr)
Expand All @@ -200,7 +200,7 @@ func (r *ReconcileGrafana) manageError(cr *i8ly.Grafana, issue error) (reconcile
}

// Try to find a suitable url to grafana
func (r *ReconcileGrafana) getGrafanaAdminUrl(cr *i8ly.Grafana, state *common.ClusterState) (string, error) {
func (r *ReconcileGrafana) getGrafanaAdminUrl(cr *grafanav1alpha1.Grafana, state *common.ClusterState) (string, error) {
// If preferService is true, we skip the routes and try to access grafana
// by using the serivce.
preferService := false
Expand Down Expand Up @@ -238,8 +238,8 @@ func (r *ReconcileGrafana) getGrafanaAdminUrl(cr *i8ly.Grafana, state *common.Cl
return "", stdErr.New("failed to find admin url")
}

func (r *ReconcileGrafana) manageSuccess(cr *i8ly.Grafana, state *common.ClusterState) (reconcile.Result, error) {
cr.Status.Phase = i8ly.PhaseReconciling
func (r *ReconcileGrafana) manageSuccess(cr *grafanav1alpha1.Grafana, state *common.ClusterState) (reconcile.Result, error) {
cr.Status.Phase = grafanav1alpha1.PhaseReconciling
cr.Status.Message = "success"

// Only update the status if the dashboard controller had a chance to sync the cluster
Expand All @@ -249,7 +249,7 @@ func (r *ReconcileGrafana) manageSuccess(cr *i8ly.Grafana, state *common.Cluster
} else {
r.config.SetDashboards(cr.Status.InstalledDashboards)
if r.config.Dashboards == nil {
r.config.SetDashboards(make(map[string][]*i8ly.GrafanaDashboardRef))
r.config.SetDashboards(make(map[string][]*grafanav1alpha1.GrafanaDashboardRef))
}
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/grafana/grafana_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package grafana

import (
"fmt"
"github.com/integr8ly/grafana-operator/pkg/apis/integreatly/v1alpha1"
"github.com/integr8ly/grafana-operator/pkg/controller/common"
"github.com/integr8ly/grafana-operator/pkg/controller/config"
"github.com/integr8ly/grafana-operator/pkg/controller/model"
"github.com/integr8ly/grafana-operator/v3/pkg/apis/integreatly/v1alpha1"
"github.com/integr8ly/grafana-operator/v3/pkg/controller/common"
"github.com/integr8ly/grafana-operator/v3/pkg/controller/config"
"github.com/integr8ly/grafana-operator/v3/pkg/controller/model"
)

type GrafanaReconciler struct {
Expand Down
16 changes: 8 additions & 8 deletions pkg/controller/grafana/pluginsHelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package grafana
import (
"crypto/tls"
"fmt"
integreatly "github.com/integr8ly/grafana-operator/pkg/apis/integreatly/v1alpha1"
"github.com/integr8ly/grafana-operator/pkg/controller/config"
grafanav1alpha1 "github.com/integr8ly/grafana-operator/v3/pkg/apis/integreatly/v1alpha1"
"github.com/integr8ly/grafana-operator/v3/pkg/controller/config"
"net/http"
"strings"
)
Expand All @@ -28,7 +28,7 @@ func newPluginsHelper() *PluginsHelperImpl {

// Query the Grafana plugin database for the given plugin and version
// A 200 OK response indicates that the plugin exists and can be downloaded
func (h *PluginsHelperImpl) PluginExists(plugin integreatly.GrafanaPlugin) bool {
func (h *PluginsHelperImpl) PluginExists(plugin grafanav1alpha1.GrafanaPlugin) bool {
url := fmt.Sprintf(h.BaseUrl, plugin.Name, plugin.Version)
resp, err := h.HttpClient.Get(url)
if err != nil {
Expand All @@ -46,7 +46,7 @@ func (h *PluginsHelperImpl) PluginExists(plugin integreatly.GrafanaPlugin) bool
// Turns an array of plugins into a string representation of the form
// `<name>:<version>,...` that is used as the value for the GRAFANA_PLUGINS
// environment variable
func (h *PluginsHelperImpl) BuildEnv(cr *integreatly.Grafana) string {
func (h *PluginsHelperImpl) BuildEnv(cr *grafanav1alpha1.Grafana) string {
var env []string
for _, plugin := range cr.Status.InstalledPlugins {
env = append(env, fmt.Sprintf("%s:%s", plugin.Name, plugin.Version))
Expand All @@ -55,8 +55,8 @@ func (h *PluginsHelperImpl) BuildEnv(cr *integreatly.Grafana) string {
}

// Append a status message to the origin dashboard of a plugin
func (h *PluginsHelperImpl) pickLatestVersions(requested integreatly.PluginList) (integreatly.PluginList, error) {
var latestVersions integreatly.PluginList
func (h *PluginsHelperImpl) pickLatestVersions(requested grafanav1alpha1.PluginList) (grafanav1alpha1.PluginList, error) {
var latestVersions grafanav1alpha1.PluginList
for _, plugin := range requested {
result, err := requested.HasNewerVersionOf(&plugin)

Expand All @@ -78,8 +78,8 @@ func (h *PluginsHelperImpl) pickLatestVersions(requested integreatly.PluginList)
// Creates the list of plugins that can be added or updated
// Does not directly deal with removing plugins: if a plugin is not in the list and the env var is updated, it will
// automatically be removed
func (h *PluginsHelperImpl) FilterPlugins(cr *integreatly.Grafana, requested integreatly.PluginList) (integreatly.PluginList, bool) {
filteredPlugins := integreatly.PluginList{}
func (h *PluginsHelperImpl) FilterPlugins(cr *grafanav1alpha1.Grafana, requested grafanav1alpha1.PluginList) (grafanav1alpha1.PluginList, bool) {
filteredPlugins := grafanav1alpha1.PluginList{}
pluginsUpdated := false

// Try to pick the latest versions of all plugins
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/grafana/pluginsHelper_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package grafana

import (
testing2 "github.com/integr8ly/grafana-operator/pkg/controller/testing"
testing2 "github.com/integr8ly/grafana-operator/v3/pkg/controller/testing"
"testing"
)

Expand Down
26 changes: 13 additions & 13 deletions pkg/controller/grafanadashboard/dashboard_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
defaultErrors "errors"
"fmt"
i8ly "github.com/integr8ly/grafana-operator/pkg/apis/integreatly/v1alpha1"
"github.com/integr8ly/grafana-operator/pkg/controller/common"
"github.com/integr8ly/grafana-operator/pkg/controller/config"
grafanav1alpha1 "github.com/integr8ly/grafana-operator/v3/pkg/apis/integreatly/v1alpha1"
"github.com/integr8ly/grafana-operator/v3/pkg/controller/common"
"github.com/integr8ly/grafana-operator/v3/pkg/controller/config"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/record"
Expand Down Expand Up @@ -56,7 +56,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler, namespace string) error {
}

// Watch for changes to primary resource GrafanaDashboard
err = c.Watch(&source.Kind{Type: &i8ly.GrafanaDashboard{}}, &handler.EnqueueRequestForObject{})
err = c.Watch(&source.Kind{Type: &grafanav1alpha1.GrafanaDashboard{}}, &handler.EnqueueRequestForObject{})
if err == nil {
log.Info("Starting dashboard controller")
}
Expand Down Expand Up @@ -130,7 +130,7 @@ func (r *ReconcileGrafanaDashboard) Reconcile(request reconcile.Request) (reconc
}

// Fetch the GrafanaDashboard instance
instance := &i8ly.GrafanaDashboard{}
instance := &grafanav1alpha1.GrafanaDashboard{}
err = r.client.Get(r.context, request.NamespacedName, instance)
if err != nil {
if errors.IsNotFound(err) {
Expand All @@ -157,14 +157,14 @@ func (r *ReconcileGrafanaDashboard) Reconcile(request reconcile.Request) (reconc
func (r *ReconcileGrafanaDashboard) reconcileDashboards(request reconcile.Request, grafanaClient GrafanaClient) (reconcile.Result, error) {
// Collect known and namespace dashboards
knownDashboards := r.config.GetDashboards(request.Namespace)
namespaceDashboards := &i8ly.GrafanaDashboardList{}
namespaceDashboards := &grafanav1alpha1.GrafanaDashboardList{}
err := r.client.List(r.context, namespaceDashboards)
if err != nil {
return reconcile.Result{}, err
}

// Prepare lists
var dashboardsToDelete []*i8ly.GrafanaDashboardRef
var dashboardsToDelete []*grafanav1alpha1.GrafanaDashboardRef

// Check if a given dashboard (by name) is present in the list of
// dashboards in the namespace
Expand All @@ -178,7 +178,7 @@ func (r *ReconcileGrafanaDashboard) reconcileDashboards(request reconcile.Reques
}

// Returns the hash of a dashboard if it is known
findHash := func(item *i8ly.GrafanaDashboard) string {
findHash := func(item *grafanav1alpha1.GrafanaDashboard) string {
for _, d := range knownDashboards {
if item.Name == d.Name {
return d.Hash
Expand Down Expand Up @@ -255,7 +255,7 @@ func (r *ReconcileGrafanaDashboard) reconcileDashboards(request reconcile.Reques

// Handle success case: update dashboard metadata (id, uid) and update the list
// of plugins
func (r *ReconcileGrafanaDashboard) manageSuccess(dashboard *i8ly.GrafanaDashboard, status GrafanaResponse, hash string) error {
func (r *ReconcileGrafanaDashboard) manageSuccess(dashboard *grafanav1alpha1.GrafanaDashboard, status GrafanaResponse, hash string) error {
msg := fmt.Sprintf("dashboard %v/%v successfully submitted",
dashboard.Namespace,
dashboard.Name)
Expand All @@ -266,7 +266,7 @@ func (r *ReconcileGrafanaDashboard) manageSuccess(dashboard *i8ly.GrafanaDashboa
dashboard.Status.UID = *status.UID
dashboard.Status.ID = *status.ID
dashboard.Status.Slug = *status.Slug
dashboard.Status.Phase = i8ly.PhaseReconciling
dashboard.Status.Phase = grafanav1alpha1.PhaseReconciling
dashboard.Status.Hash = hash
dashboard.Status.Message = "success"

Expand All @@ -277,9 +277,9 @@ func (r *ReconcileGrafanaDashboard) manageSuccess(dashboard *i8ly.GrafanaDashboa
}

// Handle error case: update dashboard with error message and status
func (r *ReconcileGrafanaDashboard) manageError(dashboard *i8ly.GrafanaDashboard, issue error) {
func (r *ReconcileGrafanaDashboard) manageError(dashboard *grafanav1alpha1.GrafanaDashboard, issue error) {
r.recorder.Event(dashboard, "Warning", "ProcessingError", issue.Error())
dashboard.Status.Phase = i8ly.PhaseFailing
dashboard.Status.Phase = grafanav1alpha1.PhaseFailing
dashboard.Status.Message = issue.Error()

err := r.client.Status().Update(r.context, dashboard)
Expand Down Expand Up @@ -314,7 +314,7 @@ func (r *ReconcileGrafanaDashboard) getClient() (GrafanaClient, error) {
}

// Test if a given dashboard matches an array of label selectors
func (r *ReconcileGrafanaDashboard) isMatch(item *i8ly.GrafanaDashboard) bool {
func (r *ReconcileGrafanaDashboard) isMatch(item *grafanav1alpha1.GrafanaDashboard) bool {
if r.state.DashboardSelectors == nil {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/grafanadashboard/dashboard_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"errors"
"fmt"
"github.com/go-logr/logr"
"github.com/integr8ly/grafana-operator/pkg/apis/integreatly/v1alpha1"
"github.com/integr8ly/grafana-operator/v3/pkg/apis/integreatly/v1alpha1"
"io/ioutil"
"net/http"
"net/url"
Expand Down
Loading

0 comments on commit 5a373c0

Please sign in to comment.