client

module
v0.0.0-...-93a508a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2023 License: Apache-2.0

README

Kubernetes Query Builder SDK

The discovery SDK provides means to prepare and query for the state of a clusters objects, schema and API resources to determine the details about a cluster and how best to interact with it.

The longer term goal is to also become the most query and resource efficient means of doing so, perhaps with some limited caching ability.

The Query Builder SDK can query for:

  • Objects
    • Annotation
    • Labels
    • Conditions
  • Resources
    • WithFields
  • OpenAPI Schema

Once created, these prepared queries can be exported and used whenever necessary .

Example

// Define some standard objects, GVRs or schema
var ns = corev1.ObjectReference{
    Kind:      "namespace",
    Name:      "ian",
    Namespace: "ian",
}

// Its important to our use case for this annotation to also match
var testAnnotations = map[string]string{
    "cluster.x-k8s.io/provider": "infrastructure-fake",
}

// We want to ensure this version of pipelines exists, perhaps with specific fields
var testGVR = schema.GroupVersionResource{
    Group:    "tekton.dev",
    Version:  "v1beta1",
    Resource: "pipelines",
}

// We will now generate a partial query to match our specific namespace
var testResource1 = Object(ns).WithAnnotations(testAnnotations).WithConditions([C])

// Our usecase requires us to match a specific GVR
var testGVR1 = GVR(testGVR).WithFields([field])

// This partial schema is importan to be available - it doesnt matter what GVR provides it, but the schema needs to be available.
var testSchema1 = PartialSchema(schema).NotExist()

c, err := NewClusterQueryClient()
if err != nil {
    return err
}

// Build your query and use it where its necessary
OurCoolQuery := c.Query(testResource1, testGVR1, testSchema1).Prepare()

ok, err := OurCoolQuery()
if err != nil {
    return err
}
if ok {
    log.Log("W00T")
}

Directories

Path Synopsis
pkg
discovery
Package discovery provides efficient means to query Kubernetes clusters for the state of its api surface and existing objects
Package discovery provides efficient means to query Kubernetes clusters for the state of its api surface and existing objects
discovery/tkg
Package tkg exports constants and functions to help evaluate the state of a TKG cluster.
Package tkg exports constants and functions to help evaluate the state of a TKG cluster.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL