opslevel_jq_parser

package module
v2023.12.11 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: MIT Imports: 8 Imported by: 1

README

opslevel-jq-parser

A jq wrapper which aids in converting data to opslevel-go input structures

This library leverages https://github.com/flant/libjq-go which are CGO bindings to the JQ library which provide C native speed

Installation

go get github.com/opslevel/opslevel-jq-parser/v2023

Then wherever you compile or test that project you'll need to add

docker run --name "libjq" -d flant/jq:b6be13d5-glibc
docker cp libjq:/libjq ./libjq 
docker rm libjq
export CGO_ENABLED=1
export CGO_CFLAGS="-I$(pwd)/libjq/include"
export CGO_LDFLAGS="-L$(pwd)/libjq/lib"

Here is a nice stanza you can put into your github actions workflow files

NOTE: the version is important - please see https://github.com/flant/libjq-go#notes

      - name: Setup LibJQ
        run: |-
          docker run --name "libjq" -d flant/jq:b6be13d5-glibc
          docker cp libjq:/libjq ./libjq 
          docker rm libjq
          echo CGO_ENABLED=1 >> $GITHUB_ENV
          echo CGO_CFLAGS="-I$(pwd)/libjq/include" >> $GITHUB_ENV
          echo CGO_LDFLAGS="-L$(pwd)/libjq/lib" >> $GITHUB_ENV

Documentation

Index

Constants

View Source
const ReleaseVersion = "v2023.12.11"

Variables

View Source
var SampleConfig = `` /* 2714-byte string literal not displayed */
View Source
var SimpleConfig = `` /* 548-byte string literal not displayed */

Functions

This section is empty.

Types

type JQArrayParser

type JQArrayParser struct {
	// contains filtered or unexported fields
}

func NewJQArrayParser

func NewJQArrayParser(expressions []string) *JQArrayParser

func (*JQArrayParser) Run

func (p *JQArrayParser) Run(data string) ([]string, error)

type JQFieldParser

type JQFieldParser struct {
	// contains filtered or unexported fields
}

func NewJQFieldParser

func NewJQFieldParser(expression string) *JQFieldParser

func (*JQFieldParser) Run

func (p *JQFieldParser) Run(data string) (string, error)

type JQRepositoryParser

type JQRepositoryParser struct {
	// contains filtered or unexported fields
}

func NewJQRepositoryParser

func NewJQRepositoryParser(expressions []string) *JQRepositoryParser

func (*JQRepositoryParser) Run

func (p *JQRepositoryParser) Run(data string) ([]opslevel.ServiceRepositoryCreateInput, error)

type JQServiceParser

type JQServiceParser struct {
	// contains filtered or unexported fields
}

func NewJQServiceParser

func NewJQServiceParser(cfg ServiceRegistrationConfig) *JQServiceParser

func (*JQServiceParser) Run

type JQTagsParser

type JQTagsParser struct {
	// contains filtered or unexported fields
}

func NewJQTagsParser

func NewJQTagsParser(cfg TagRegistrationConfig) *JQTagsParser

func (*JQTagsParser) Run

func (p *JQTagsParser) Run(data string) ([]opslevel.TagInput, []opslevel.TagInput, error)

type JQToolsParser

type JQToolsParser struct {
	// contains filtered or unexported fields
}

func NewJQToolsParser

func NewJQToolsParser(expressions []string) *JQToolsParser

func (*JQToolsParser) Run

func (p *JQToolsParser) Run(data string) ([]opslevel.ToolCreateInput, error)

type RepositoryDTO

type RepositoryDTO struct {
	Name      string
	Directory string
	Repo      string
}

func (*RepositoryDTO) Convert

func (r *RepositoryDTO) Convert() opslevel.ServiceRepositoryCreateInput

type ServiceRegistration

type ServiceRegistration struct {
	Name         string                                  `json:",omitempty"`
	Description  string                                  `json:",omitempty"`
	Owner        string                                  `json:",omitempty"`
	Lifecycle    string                                  `json:",omitempty"`
	Tier         string                                  `json:",omitempty"`
	Product      string                                  `json:",omitempty"`
	Language     string                                  `json:",omitempty"`
	Framework    string                                  `json:",omitempty"`
	System       string                                  `json:",omitempty"`
	Aliases      []string                                `json:",omitempty"`
	TagAssigns   []opslevel.TagInput                     `json:",omitempty"`
	TagCreates   []opslevel.TagInput                     `json:",omitempty"`
	Tools        []opslevel.ToolCreateInput              `json:",omitempty"` // This is a concrete class so fields are validated during `service preview`
	Repositories []opslevel.ServiceRepositoryCreateInput `json:",omitempty"` // This is a concrete class so fields are validated during `service preview`
}

ServiceRegistration represents the parsed json data from a ServiceRegistrationConfig

type ServiceRegistrationConfig

type ServiceRegistrationConfig struct {
	Name         string                `json:"name" yaml:"name"`
	Description  string                `json:"description" yaml:"description"`
	Owner        string                `json:"owner" yaml:"owner"`
	Lifecycle    string                `json:"lifecycle" yaml:"lifecycle"`
	Tier         string                `json:"tier" yaml:"tier"`
	Product      string                `json:"product" yaml:"product"`
	Language     string                `json:"language" yaml:"language"`
	Framework    string                `json:"framework" yaml:"framework"`
	System       string                `json:"system" yaml:"system"`
	Aliases      []string              `json:"aliases" yaml:"aliases"` // JQ expressions that return a single string or a []string
	Tags         TagRegistrationConfig `json:"tags" yaml:"tags"`
	Tools        []string              `json:"tools" yaml:"tools"`               // JQ expressions that return a single map[string]string or a []map[string]string
	Repositories []string              `json:"repositories" yaml:"repositories"` // JQ expressions that return a single string or []string or map[string]string or a []map[string]string
}

ServiceRegistrationConfig represents the jq expressions configuration that can turn json data into a ServiceRegistration

func NewServiceRegistrationConfig

func NewServiceRegistrationConfig(data string) (*ServiceRegistrationConfig, error)

type TagRegistrationConfig

type TagRegistrationConfig struct {
	Assign []string `json:"assign" yaml:"assign"` // JQ expressions that return a single string or a map[string]string
	Create []string `json:"create" yaml:"create"` // JQ expressions that return a single string or a map[string]string
}

Jump to

Keyboard shortcuts

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