Skip to content
This repository was archived by the owner on Oct 4, 2019. It is now read-only.

Conversation

@akashshinde
Copy link

@akashshinde akashshinde commented May 15, 2019

This PR adds clientset to devconsole apis.

Code is generated using code-generator(https://github.com/kubernetes/code-generator)

Following resources are supported by this clientset

  • GitSource
  • GitSourceAnanlysis
  • Component

Usage

Import

import (
     devconsoleclient "github.com/redhat-developer/devconsole-api/pkg/apis/client/clientset/versioned"
)

Initialise Client

client, _ := devconsoleclient.NewForConfig(config)

Get Resource

  • List Components
client.Components(namespace).List(options)
  • Get Component
client.Components(namespace).Get(name, options)

Why

This would helps us to have better code readability, we could refactor the code following way
Instead of (In controller)

 gitSource := &devconsoleapi.GitSource{}
 err := r.client.Get(context.TODO(), client.ObjectKey{
                         Namespace: cp.Namespace,
                         Name:      cp.Spec.GitSourceRef,
           }, gitSource)
  

we can have

gitSource, err := r.devconsoleClient.GitSources(cp.Namespace).Get(cp.Spec.GitSourceRef)

@sbose78
Copy link
Member

sbose78 commented May 15, 2019

Why are we adding it here, instead of using it directly at the controller repo - or whichever repo we need it in?

@akashshinde
Copy link
Author

akashshinde commented May 15, 2019

@sbose78 I feel clientset should get added to this repo, since clientset is tightly coupled with the crd apis, whereas there is not correlation between controller codebase and clientset

NOTE : If anyone wants to access clientset he should not require to import devconsole-operator

@sbose78
Copy link
Member

sbose78 commented May 15, 2019

Thanks, make sense. Could you add an example on how we should be consuming this ?

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbose78

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@akashshinde
Copy link
Author

@sbose78 I have added example under Why section

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants