Skip to content

Commit

Permalink
Fix linters
Browse files Browse the repository at this point in the history
  • Loading branch information
VaishnaviHire committed Oct 16, 2024
1 parent 8578f8f commit 22e94b9
Show file tree
Hide file tree
Showing 17 changed files with 121 additions and 179 deletions.
22 changes: 11 additions & 11 deletions components/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package dashboard

//
//import (
// import (
// "context"
// "errors"
// "fmt"
Expand All @@ -24,7 +24,7 @@ package dashboard
// "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy"
//)
//
//var (
// var (
// ComponentNameUpstream = "dashboard"
// PathUpstream = deploy.DefaultManifestPath + "/" + ComponentNameUpstream + "/odh"
//
Expand All @@ -37,15 +37,15 @@ package dashboard
//)
//
//// Verifies that Dashboard implements ComponentInterface.
//var _ components.ComponentInterface = (*Dashboard)(nil)
// var _ components.ComponentInterface = (*Dashboard)(nil)
//
//// Dashboard struct holds the configuration for the Dashboard component.
//// +kubebuilder:object:generate=true
//type Dashboard struct {
// type Dashboard struct {
// components.Component `json:""`
//}
//
//func (d *Dashboard) Init(ctx context.Context, platform cluster.Platform) error {
// func (d *Dashboard) Init(ctx context.Context, platform cluster.Platform) error {
// log := logf.FromContext(ctx).WithName(ComponentNameUpstream)
//
// imageParamMap := map[string]string{
Expand All @@ -65,7 +65,7 @@ package dashboard
// return nil
//}
//
//func (d *Dashboard) OverrideManifests(ctx context.Context, platform cluster.Platform) error {
// func (d *Dashboard) OverrideManifests(ctx context.Context, platform cluster.Platform) error {
// // If devflags are set, update default manifests path
// if len(d.DevFlags.Manifests) != 0 {
// manifestConfig := d.DevFlags.Manifests[0]
Expand All @@ -79,18 +79,18 @@ package dashboard
// return nil
//}
//
//func (d *Dashboard) GetComponentName() string {
// func (d *Dashboard) GetComponentName() string {
// return ComponentNameUpstream
//}
//
//func (d *Dashboard) ReconcileComponent(ctx context.Context,
// func (d *Dashboard) ReconcileComponent(ctx context.Context,
// cli client.Client,
// l logr.Logger,
// owner metav1.Object,
// dscispec *dsciv1.DSCInitializationSpec,
// platform cluster.Platform,
// currentComponentExist bool,
//) error {
// ) error {
// entryPath := DefaultPath
// enabled := d.GetManagementState() == operatorv1.Managed
// monitoringEnabled := dscispec.Monitoring.ManagementState == operatorv1.Managed
Expand Down Expand Up @@ -184,7 +184,7 @@ package dashboard
// }
//}
//
//func updateKustomizeVariable(ctx context.Context, cli client.Client, platform cluster.Platform, dscispec *dsciv1.DSCInitializationSpec) (map[string]string, error) {
// func updateKustomizeVariable(ctx context.Context, cli client.Client, platform cluster.Platform, dscispec *dsciv1.DSCInitializationSpec) (map[string]string, error) {
// adminGroups := map[cluster.Platform]string{
// cluster.SelfManagedRhods: "rhods-admins",
// cluster.ManagedRhods: "dedicated-admins",
Expand Down Expand Up @@ -217,7 +217,7 @@ package dashboard
// }, nil
//}
//
//func (d *Dashboard) cleanOauthClient(ctx context.Context, cli client.Client, dscispec *dsciv1.DSCInitializationSpec, currentComponentExist bool, l logr.Logger) error {
// func (d *Dashboard) cleanOauthClient(ctx context.Context, cli client.Client, dscispec *dsciv1.DSCInitializationSpec, currentComponentExist bool, l logr.Logger) error {
// // Remove previous oauth-client secrets
// // Check if component is going from state of `Not Installed --> Installed`
// // Assumption: Component is currently set to enabled
Expand Down
2 changes: 1 addition & 1 deletion controllers/components/codeflare_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
componentsv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1"
)

// CodeFlareReconciler reconciles a CodeFlare object
// CodeFlareReconciler reconciles a CodeFlare object.
type CodeFlareReconciler struct {
client.Client
Scheme *runtime.Scheme
Expand Down
14 changes: 6 additions & 8 deletions controllers/components/dashboard_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"errors"
"fmt"
"k8s.io/utils/pointer"
"path/filepath"

appsv1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -177,11 +176,7 @@ func watchDashboardResources(_ context.Context, a client.Object) []reconcile.Req

var dashboardPredicates = predicate.Funcs{
CreateFunc: func(e event.CreateEvent) bool {
if e.Object.GetObjectKind().GroupVersionKind().Kind == gvk.Dashboard.Kind {
return true
}
// Reconcile not needed during creation
return false
return e.Object.GetObjectKind().GroupVersionKind().Kind == gvk.Dashboard.Kind
},
DeleteFunc: func(e event.DeleteEvent) bool {
if e.Object.GetObjectKind().GroupVersionKind().Kind == gvk.Dashboard.Kind {
Expand Down Expand Up @@ -368,6 +363,8 @@ func (a *DeployComponentAction) Execute(ctx context.Context, rr *odhtypes.Reconc
switch rr.Platform {
case cluster.SelfManagedRhods, cluster.ManagedRhods:
// anaconda
blckownerDel := true
ctrlr := true
err := cluster.CreateSecret(
ctx,
rr.Client,
Expand All @@ -379,8 +376,8 @@ func (a *DeployComponentAction) Execute(ctx context.Context, rr *odhtypes.Reconc
Kind: rr.Instance.GetObjectKind().GroupVersionKind().Kind,
Name: rr.Instance.GetName(),
UID: rr.Instance.GetUID(),
Controller: pointer.Bool(true),
BlockOwnerDeletion: pointer.Bool(true),
Controller: &ctrlr,
BlockOwnerDeletion: &blckownerDel,
}),
cluster.WithLabels(
labels.ComponentName, ComponentName,
Expand All @@ -394,6 +391,7 @@ func (a *DeployComponentAction) Execute(ctx context.Context, rr *odhtypes.Reconc
}

name = ComponentNameDownstream
default:
}

err = deploy.DeployManifestsFromPathWithLabels(ctx, rr.Client, rr.Instance, path, rr.DSCI.Spec.ApplicationsNamespace, name, true, map[string]string{
Expand Down
2 changes: 1 addition & 1 deletion controllers/components/datasciencepipelines_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
componentsv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1"
)

// DataSciencePipelinesReconciler reconciles a DataSciencePipelines object
// DataSciencePipelinesReconciler reconciles a DataSciencePipelines object.
type DataSciencePipelinesReconciler struct {
client.Client
Scheme *runtime.Scheme
Expand Down
2 changes: 1 addition & 1 deletion controllers/components/kserve_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
componentsv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1"
)

// KserveReconciler reconciles a Kserve object
// KserveReconciler reconciles a Kserve object.
type KserveReconciler struct {
client.Client
Scheme *runtime.Scheme
Expand Down
2 changes: 1 addition & 1 deletion controllers/components/kueue_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
componentsv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1"
)

// KueueReconciler reconciles a Kueue object
// KueueReconciler reconciles a Kueue object.
type KueueReconciler struct {
client.Client
Scheme *runtime.Scheme
Expand Down
2 changes: 1 addition & 1 deletion controllers/components/modelmeshserving_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
componentsv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1"
)

// ModelMeshServingReconciler reconciles a ModelMeshServing object
// ModelMeshServingReconciler reconciles a ModelMeshServing object.
type ModelMeshServingReconciler struct {
client.Client
Scheme *runtime.Scheme
Expand Down
2 changes: 1 addition & 1 deletion controllers/components/modelregistry_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
componentsv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1"
)

// ModelRegistryReconciler reconciles a ModelRegistry object
// ModelRegistryReconciler reconciles a ModelRegistry object.
type ModelRegistryReconciler struct {
client.Client
Scheme *runtime.Scheme
Expand Down
2 changes: 1 addition & 1 deletion controllers/components/ray_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
componentsv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1"
)

// RayReconciler reconciles a Ray object
// RayReconciler reconciles a Ray object.
type RayReconciler struct {
client.Client
Scheme *runtime.Scheme
Expand Down
3 changes: 2 additions & 1 deletion controllers/components/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package components
package components_test

//revive:disable:dot-imports
import (
"path/filepath"
"testing"
Expand Down
2 changes: 1 addition & 1 deletion controllers/components/trainingoperator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
componentsv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1"
)

// TrainingOperatorReconciler reconciles a TrainingOperator object
// TrainingOperatorReconciler reconciles a TrainingOperator object.
type TrainingOperatorReconciler struct {
client.Client
Scheme *runtime.Scheme
Expand Down
2 changes: 1 addition & 1 deletion controllers/components/trustyai_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
componentsv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1"
)

// TrustyAIReconciler reconciles a TrustyAI object
// TrustyAIReconciler reconciles a TrustyAI object.
type TrustyAIReconciler struct {
client.Client
Scheme *runtime.Scheme
Expand Down
2 changes: 1 addition & 1 deletion controllers/components/workbenches_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
componentsv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1"
)

// WorkbenchesReconciler reconciles a Workbenches object
// WorkbenchesReconciler reconciles a Workbenches object.
type WorkbenchesReconciler struct {
client.Client
Scheme *runtime.Scheme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const (

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
func (r *DataScienceClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { //nolint:maintidx,gocyclo
func (r *DataScienceClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { //nolint:maintidx
log := r.Log
log.Info("Reconciling DataScienceCluster resources", "Request.Name", req.Name)

Expand Down
18 changes: 0 additions & 18 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"flag"
"os"

"github.com/hashicorp/go-multierror"
addonv1alpha1 "github.com/openshift/addon-operator/apis/addons/v1alpha1"
ocappsv1 "github.com/openshift/api/apps/v1" //nolint:importas //reason: conflicts with appsv1 "k8s.io/api/apps/v1"
buildv1 "github.com/openshift/api/build/v1"
Expand Down Expand Up @@ -81,7 +80,6 @@ var (
)

func init() { //nolint:gochecknoinits

utilruntime.Must(componentsv1.AddToScheme(scheme))
// +kubebuilder:scaffold:scheme
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
Expand All @@ -108,22 +106,6 @@ func init() { //nolint:gochecknoinits
utilruntime.Must(operatorv1.Install(scheme))
}

func initComponents(ctx context.Context, p cluster.Platform) error {
var errs *multierror.Error
var dummyDSC = &dscv1.DataScienceCluster{}

components, err := dummyDSC.GetComponents()
if err != nil {
return err
}

for _, c := range components {
errs = multierror.Append(errs, c.Init(ctx, p))
}

return errs.ErrorOrNil()
}

func main() { //nolint:funlen,maintidx
var metricsAddr string
var enableLeaderElection bool
Expand Down
13 changes: 7 additions & 6 deletions pkg/controller/actions/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@ import (
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/types"
)

func NewFakeClient(objs ...ctrlClient.Object) ctrlClient.WithWatch {
func NewFakeClient(objs ...ctrlClient.Object) ctrlClient.WithWatch { //nolint:ireturn
scheme := runtime.NewScheme()
utilruntime.Must(corev1.AddToScheme(scheme))
utilruntime.Must(appsv1.AddToScheme(scheme))

fakeMapper := meta.NewDefaultRESTMapper(scheme.PreferredVersionAllGroups())
for gvk := range scheme.AllKnownTypes() {
switch {
// TODO: add cases for cluster scoped
default:
fakeMapper.Add(gvk, meta.RESTScopeNamespace)
}
fakeMapper.Add(gvk, meta.RESTScopeNamespace)
// switch {
//// TODO: add cases for cluster scoped
//default:
// fakeMapper.Add(gvk, meta.RESTScopeNamespace)
//}
}

return fake.NewClientBuilder().
Expand Down
Loading

0 comments on commit 22e94b9

Please sign in to comment.