kitops icon indicating copy to clipboard operation
kitops copied to clipboard

Expose core Kit CLI functionality as a reusable Go library

Open gorkem opened this issue 6 months ago • 2 comments

Describe the problem you're trying to solve All Kit CLI commands currently live under cmd/*, with business logic and flag parsing tightly coupled to Cobra. This makes it difficult for other Go programs to import and invoke Kit functionality without shelling out.

Describe the solution you'd like

  1. Create a new package pkg/kit exposing public APIs like:
    func List(ctx context.Context, opts ListOptions) ([]ModelInfo, error)
    func Push(ctx context.Context, opts PushOptions) error
    // …etc…
    
  2. Refactor each command to delegate to these package functions
  3. Move data types, validation routines, output-format helpers, and error definitions into pkg/kit.
  4. Update tests to separate unit tests against pkg/kit APIs in and retain or convert integration tests under cmd/ to ensure the CLI remains unchanged.
  5. Add documentation with examples for library usage

gorkem avatar Jun 21 '25 22:06 gorkem

Perhaps something similar to https://github.com/kitops-ml/pykitops?

bmicklea avatar Jul 16 '25 14:07 bmicklea

I have taken up this issue and raised a pr #1005 @gorkem

arnab2001 avatar Nov 03 '25 19:11 arnab2001