Skip to content

Commit

Permalink
fix gofmt formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Courtney Pacheco <cpacheco@redhat.com>
  • Loading branch information
courtneypacheco committed May 14, 2021
1 parent 7f03dc5 commit 59e1f02
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 24 deletions.
9 changes: 4 additions & 5 deletions controllers/nodefeaturediscovery_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ type NodeFeatureDiscoveryReconciler struct {
client.Client

// Log is used to log the reconciliation. Every controllers needs this.
Log logr.Logger
Log logr.Logger

// Scheme is used by the kubebuilder library to set OwnerReferences. Every
// controller needs this.
Scheme *runtime.Scheme
Scheme *runtime.Scheme

// Recorder defines interfaces for working with OCP event recorders. This
// field is needed by NFD in order for NFD to write events.
Recorder record.EventRecorder
Recorder record.EventRecorder

// AssetsDir defines the directory with assets under the operator image
AssetsDir string
Expand All @@ -74,7 +74,7 @@ type NodeFeatureDiscoveryReconciler struct {
// struct.
func (r *NodeFeatureDiscoveryReconciler) SetupWithManager(mgr ctrl.Manager) error {

// The predicate package is used by the controller to filter events before
// The predicate package is used by the controller to filter events before
// they are sent to event handlers. When "UpdateFunc" is used, it will
// return "true" if a given update event should be processed. In this case,
// the "validateUpdateEvent" function is used with UpdateFunc to initate the
Expand Down Expand Up @@ -163,7 +163,6 @@ func (r *NodeFeatureDiscoveryReconciler) Reconcile(ctx context.Context, req ctrl
instance := &nfdv1.NodeFeatureDiscovery{}
err := r.Get(ctx, req.NamespacedName, instance)


// If an error occurs because "r.Get" cannot get the NFD instance
// (e.g., due to timeouts, aborts, etc. defined by ctx), the
// request likely needs to be requeued.
Expand Down
12 changes: 5 additions & 7 deletions controllers/nodefeaturediscovery_controls.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (s ResourceStatus) String() string {
"Ready",
"NotReady"}

// Ideally, 's' should be either Ready (=0) or NotReady (=1), but
// Ideally, 's' should be either Ready (=0) or NotReady (=1), but
// we may run into a case where we get an unknown status, so return
// information stating that the resource status is unknown
if s < Ready || s > NotReady {
Expand All @@ -75,7 +75,7 @@ func Namespace(n NFD) (ResourceStatus, error) {
logger := log.WithValues("Namespace", obj.Name, "Namespace", "Cluster")

// Look for the Namespace to see if it exists, and if so, check if
// it's Ready/NotReady. If the Namespace does not exist, then
// it's Ready/NotReady. If the Namespace does not exist, then
// attempt to create it
logger.Info("Looking for")
err := n.rec.Client.Get(context.TODO(), types.NamespacedName{Namespace: obj.Namespace, Name: obj.Name}, found)
Expand Down Expand Up @@ -126,7 +126,7 @@ func ServiceAccount(n NFD) (ResourceStatus, error) {
}

// Look for the ServiceAccount to see if it exists, and if so, check if
// it's Ready/NotReady. If the ServiceAccount does not exist, then
// it's Ready/NotReady. If the ServiceAccount does not exist, then
// attempt to create it
err := n.rec.Client.Get(context.TODO(), types.NamespacedName{Namespace: obj.Namespace, Name: obj.Name}, found)
if err != nil && errors.IsNotFound(err) {
Expand Down Expand Up @@ -165,7 +165,7 @@ func ClusterRole(n NFD) (ResourceStatus, error) {
logger.Info("Looking for")

// Look for the ClusterRole to see if it exists, and if so, check
// if it's Ready/NotReady. If the ClusterRole does not exist, then
// if it's Ready/NotReady. If the ClusterRole does not exist, then
// attempt to create it
err := n.rec.Client.Get(context.TODO(), types.NamespacedName{Namespace: "", Name: obj.Name}, found)
if err != nil && errors.IsNotFound(err) {
Expand Down Expand Up @@ -306,7 +306,7 @@ func RoleBinding(n NFD) (ResourceStatus, error) {
obj := n.resources[state].RoleBinding

// The Namespace should already be defined, so let's set the
// namespace to the namespace defined in the
// namespace to the namespace defined in the
obj.SetNamespace(n.ins.GetNamespace())

// found states if the RoleBinding was found
Expand Down Expand Up @@ -558,7 +558,6 @@ func Service(n NFD) (ResourceStatus, error) {

logger.Info("Found, updating")


// Copy the Service object
required := obj.DeepCopy()

Expand All @@ -567,7 +566,6 @@ func Service(n NFD) (ResourceStatus, error) {
required.ResourceVersion = found.ResourceVersion
required.Spec.ClusterIP = found.Spec.ClusterIP


// If we found the Service, let's attempt to update it with the
// resource version and cluster IP that was just found
err = n.rec.Client.Update(context.TODO(), required)
Expand Down
1 change: 0 additions & 1 deletion controllers/nodefeaturediscovery_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ func getAssetsFrom(path string) []assetsFromFile {
return manifests
}


func addResourcesControls(path string) (Resources, controlFunc) {

// res is a Resources object that contains information about
Expand Down
8 changes: 4 additions & 4 deletions controllers/nodefeaturediscovery_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ type NFD struct {

// controls is a list that contains the status of an NFD resource
// as being Ready (=0) or NotReady (=1)
controls []controlFunc
controls []controlFunc

// rec represents the NFD reconciler struct used for reconciliation
rec *NodeFeatureDiscoveryReconciler
rec *NodeFeatureDiscoveryReconciler

// ins is the NodeFeatureDiscovery struct that contains the Schema
// for the nodefeaturediscoveries API
ins *nfdv1.NodeFeatureDiscovery
ins *nfdv1.NodeFeatureDiscovery

// idx is the index that is used to step through the 'controls' list
// and is set to 0 upon calling 'init()'
idx int
idx int
}

// addState takes a given path and finds resources in that path, then
Expand Down
14 changes: 7 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (

var (
// scheme holds a new scheme for the operator
scheme = runtime.NewScheme()
scheme = runtime.NewScheme()

// setupLog will be used for logging the operator "setup" process so that users know
// what parts of the logging are associated with the setup of the manager and
Expand All @@ -59,14 +59,14 @@ func main() {
// The bind address tells Prometheus which port to scrape this data's metrics from.
var metricsAddr string

// enableLeaderElection should be set to 'disable' by default If we enable leader
// election, then only one node can run the controller manager and we will not
// have NFD Operator running on all nodes.
// enableLeaderElection should be set to 'disable' by default If we enable leader
// election, then only one node can run the controller manager and we will not
// have NFD Operator running on all nodes.
var enableLeaderElection bool

// probeAddr is responsible for the health probe bind address, where the health
// probe is responsible for determining liveness, readiness, and configuration
// of the operator pods.
// probeAddr is responsible for the health probe bind address, where the health
// probe is responsible for determining liveness, readiness, and configuration
// of the operator pods.
var probeAddr string

// The following 3 lines setup the CLI arguments that are used upon initilization of
Expand Down

0 comments on commit 59e1f02

Please sign in to comment.