Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

kubernetes/Controller: Fix return type during initialization #1705

Merged
merged 1 commit into from
Sep 16, 2020

Conversation

shashankram
Copy link
Member

Fixes the return value and signature when a new Kubernetes
Controller is being initialized by returning the interface
and an error.

  • New Functionality [ ]
  • Documentation [ ]
  • Install [ ]
  • Control Plane [ ]
  • CLI Tool [ ]
  • Certificate Management [ ]
  • Networking [ ]
  • Metrics [ ]
  • SMI Policy [ ]
  • Security [ ]
  • Tests / CI System [ ]
  • Other [X]

Please answer the following questions with yes/no.

  • Does this change contain code from or inspired by another project? If so, did you notify the maintainers and provide attribution?
    No

Fixes the return value and signature when a new Kubernetes
Controller is being initialized by returning the interface
and an error.
@shashankram shashankram marked this pull request as ready for review September 16, 2020 16:19
@shashankram shashankram requested a review from a team as a code owner September 16, 2020 16:19
kubernetesClient := k8s.NewKubernetesClient(kubeClient, meshName, stop)
kubernetesClient, err := k8s.NewKubernetesClient(kubeClient, meshName, stop)
if err != nil {
log.Fatal().Err(err).Msg("Error initializing kubernetes controller")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of log.Fatal which calls os.Exit(1), could we use GinkgoT().Fatal() or something similar so the failure is registered by the testing framework?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not familiar with Ginko's fatal, but seems like we should leverage this across the test code. Would you mind creating an issue to handle this repo wide?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I understand is GinkgoT() is just a way to get a handle to the current *testing.T, so it's basically the equivalent of t.Fatal(). Yes, will open an issue.

// NewKubernetesClient returns a new Client which means to provide access to locally-cached k8s resources
func NewKubernetesClient(kubeClient kubernetes.Interface, meshName string, stop chan struct{}) Client {
// NewKubernetesClient returns a new kubernetes.Controller which means to provide access to locally-cached k8s resources
func NewKubernetesClient(kubeClient kubernetes.Interface, meshName string, stop chan struct{}) (Controller, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does changing the name of this function to NewKubernetesController make it any more clear?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this, but kept it as is since a few other interfaces are instantiated using NewXXXClient. How about I handle these renames generically in a follow-up?

@shashankram shashankram merged commit 1ba2735 into openservicemesh:main Sep 16, 2020
@shashankram shashankram deleted the fatal-event branch September 16, 2020 16:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants