artifactory

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AQLQueryTemplate = template.Must(template.New("aql_query").Parse(`items.find({
  {{ if .Repo -}}
  "repo": { "$match": "{{ .Repo }}" }{{ if or .Path .Name .Properties -}},{{ end }}
  {{ end -}}
  {{ if .Path -}}
  "path": { "$match": "{{ .Path }}" }{{ if or .Name .Properties -}},{{ end }}
  {{ end -}}
  {{ if .Name -}}
  "name": { "$match": "{{ .Name }}" }{{ if .Properties -}},{{ end }}
  {{ end -}}
  {{ if .Properties -}}
  {{ $first := true -}}
  {{ range $k, $v := .Properties -}}
  {{ if $first -}}
	{{ $first = false -}}
  {{ else -}},{{ end -}}
  "@{{ $k }}": { "$match": "{{ $v }}" }
  {{ end -}}
  {{ end -}}
}) .include("*", "property.*") .sort({"$desc": ["modified"]}) {{ if .Limit -}}.limit({{ .Limit -}}){{ end -}}
`))

AQLQueryTemplate is our default query template. The syntax for AQL, combined a go template might make this hard to read, but most of what we're doing is dealing with trailing commas. The rendered query will look something like the following:

items.find({
  "repo": { "$match": "hashicorp-packagespec-buildcache-local*" },
  "path": { "$match": "cache-v1/vault-enterprise/*" },
  "name": { "$match": "*.zip" },
  "@EDITION": { "$match": "ent" },
  "@GOARCH": { "$match": "amd64" },
  "@GOOS": { "$match": "linux" },
  "@artifactType": { "$match": "package" },
  "@productRevision": { "$match": "f45845666b4e552bfc8ca775834a3ef6fc097fe0" },
  "@productVersion": { "$match": "1.7.0" }
}) .include("*", "property.*") .sort({"$desc": ["modified"]}) .limit(1)

Functions

func SupportedVaultArch

func SupportedVaultArch(platform, arch string) bool

SupportedVaultArch validates that the given platform and arch are supported.

func SupportedVaultEdition

func SupportedVaultEdition(ed string) bool

SupportedVaultEdition validates that the given edition is a valid for Vault.

func SupportedVaultPlatform

func SupportedVaultPlatform(platform string) bool

SupportedVaultPlatform validates that the given platform is supported.

Types

type Client

type Client struct {
	Host     string
	Username string
	Token    string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opts ...Opt) *Client

func (*Client) SearchAQL

func (c *Client) SearchAQL(ctx context.Context, req *SearchAQLRequest) (*SearchAQLResponse, error)

type Opt

type Opt func(*Client) *Client

func WithHost

func WithHost(domain string) Opt

func WithToken

func WithToken(token string) Opt

func WithUsername

func WithUsername(username string) Opt

type SearchAQLOpt

type SearchAQLOpt func(*SearchAQLRequest) *SearchAQLRequest

func WithLimit

func WithLimit(limit string) SearchAQLOpt

func WithName

func WithName(name string) SearchAQLOpt

func WithPath

func WithPath(path string) SearchAQLOpt

func WithProperties

func WithProperties(props map[string]string) SearchAQLOpt

func WithProperty

func WithProperty(key, value string) SearchAQLOpt

func WithQueryTemplate

func WithQueryTemplate(temp *template.Template) SearchAQLOpt

func WithRepo

func WithRepo(repo string) SearchAQLOpt

type SearchAQLRequest

type SearchAQLRequest struct {
	Repo          string
	Path          string
	Name          string
	Properties    map[string]string
	QueryTemplate *template.Template
	Limit         string
}

func NewSearchAQLRequest

func NewSearchAQLRequest(opts ...SearchAQLOpt) *SearchAQLRequest

type SearchAQLResponse

type SearchAQLResponse struct {
	Results []struct {
		Repo       string      `json:"repo"`
		Path       string      `json:"path"`
		Name       string      `json:"name"`
		Type       string      `json:"type"`
		Size       json.Number `json:"size"`
		SHA256     string      `json:"sha256"`
		Properties []struct {
			Key   string `json:"key"`
			Value string `json:"value"`
		} `json:"properties"`
	} `json:"results"`
}

Jump to

Keyboard shortcuts

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