opslevel_jq_parser

package module
v2024.4.26 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 8 Imported by: 1

README

License Made With Go Release Issues Contributors Activity CodeCov Dependabot Go Reference

Overall

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/v2024

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 = "v2024.4.26"

Variables

This section is empty.

Functions

func NewJQDictParser added in v2024.2.26

func NewJQDictParser(dict map[string]string) map[string]JQFieldParser

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 JQDictParser added in v2024.2.26

type JQDictParser map[string]JQFieldParser

func (JQDictParser) Run added in v2024.2.26

func (p JQDictParser) Run(data string) ([]opslevel.PropertyInput, 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 {
	Aliases      []string                                `json:"aliases,omitempty"`
	Description  string                                  `json:"description,omitempty"`
	Framework    string                                  `json:"framework,omitempty"`
	Language     string                                  `json:"language,omitempty"`
	Lifecycle    string                                  `json:"lifecycle,omitempty"`
	Name         string                                  `json:"name,omitempty"`
	Owner        string                                  `json:"owner,omitempty"`
	Product      string                                  `json:"product,omitempty"`
	Properties   []opslevel.PropertyInput                `json:"properties,omitempty"`
	Repositories []opslevel.ServiceRepositoryCreateInput `json:"repositories,omitempty"` // This is a concrete class so fields are validated during `service preview`
	System       string                                  `json:"system,omitempty"`
	TagAssigns   []opslevel.TagInput                     `json:"tagAssigns,omitempty"`
	TagCreates   []opslevel.TagInput                     `json:"tagCreates,omitempty"`
	Tier         string                                  `json:"tier,omitempty"`
	Tools        []opslevel.ToolCreateInput              `json:"tools,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 {
	Aliases      []string              `json:"aliases" yaml:"aliases"` // JQ expressions that return a single string or a []string
	Description  string                `json:"description" yaml:"description"`
	Framework    string                `json:"framework" yaml:"framework"`
	Language     string                `json:"language" yaml:"language"`
	Lifecycle    string                `json:"lifecycle" yaml:"lifecycle"`
	Name         string                `json:"name" yaml:"name"`
	Owner        string                `json:"owner" yaml:"owner"`
	Product      string                `json:"product" yaml:"product"`
	Properties   map[string]string     `json:"properties" yaml:"properties"`
	Repositories []string              `json:"repositories" yaml:"repositories"` // JQ expressions that return a single string or []string or map[string]string or a []map[string]string
	System       string                `json:"system" yaml:"system"`
	Tags         TagRegistrationConfig `json:"tags" yaml:"tags"`
	Tier         string                `json:"tier" yaml:"tier"`
	Tools        []string              `json:"tools" yaml:"tools"` // JQ expressions that return a single 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
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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