resolver

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package resolver contains the .proto resolver API and implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArtifactoryConfig

type ArtifactoryConfig struct {
	URL          string                        `hcl:"url" help:"Artifactory URL, eg. \"https://artifactory.mycompany.com/artifactory\""`
	DownloadURL  string                        `hcl:"download_url,optional" help:"Optional URL to download artifacts from. If not provided Artifactory itself will be used."`
	Repositories []ArtifactoryRepositoryConfig `hcl:"repository,block" help:"Artifactory repositories to download the latest JAR from."`
}

ArtifactoryConfig defines how to talk to Artifactory and where to download artifacts from.

type ArtifactoryRepositoryConfig

type ArtifactoryRepositoryConfig struct {
	Path    string `hcl:"name,label" help:"Artifact repository name."`
	Version string `hcl:"version,optional" help:"The artifact version to use."`
}

ArtifactoryRepositoryConfig is the config for a single repository within Artifactory.

type NamedReadCloser

type NamedReadCloser interface {
	Name() string
	io.ReadCloser
}

NamedReadCloser gives an io.ReadCloser an identity.

type RemoteConfig

type RemoteConfig struct {
	BitbucketServers []string `hcl:"bitbucket-servers,optional" help:"List of hostnames to treat as Bitbucket servers."`
}

RemoteConfig contains the configuration for Remote().

type Repo

type Repo struct {
	URL        string   `hcl:"url,label" help:"Git cloneable URL of repository."`
	Root       string   `hcl:"root,optional" help:"Root path in remote repository to search for protos."`
	Prefix     string   `hcl:"prefix,optional" help:"Prefix of proto path that will match this repository. eg. 'google'"`
	Protos     []string `hcl:"protos,optional" help:"A list of specific .proto files that this repository contains."`
	CommitHash string   `hcl:"commit,optional" help:"Specific commit to retrieve .proto files from."`
}

Repo defines a source repository and where to retrieve protos from it.

func (*Repo) Commit

func (r *Repo) Commit() string

Commit from which to retrieve protos.

func (*Repo) ParseURL

func (r *Repo) ParseURL() (*url.URL, error)

ParseURL with giturls library

type Resolver

type Resolver func(path string) (NamedReadCloser, error)

A Resolver can resolve proto imports to source.

Will return (nil, nil) if not found.

func ArtifactoryJAR

func ArtifactoryJAR(artifactoryURL, jarURL string, repository ArtifactoryRepositoryConfig) Resolver

ArtifactoryJAR resolves protobufs from JAR files in Artifactory.

This will sync metadata from Artifactory, download, cache, and unpack the latest JAR.

"artifactoryURL" should be the base Artifactory URL, eg. "https://artifactory.mycompany.com/artifactory". "jarURL" should have the same URL layout as Artifactory, but could be a JAR mirror, eg. "https://edge-cache.mycompany.com/artifactory". "repositoryPath" is the Artifactory repository path to the artifact we're retrieving, eg. "jar-releases/com/mycompany/external/protos/mycompany-protos" or "mycompany-public/com/mycompany/protos/all-protos"

func Combine

func Combine(resolvers ...Resolver) Resolver

Combine a set of resolvers, trying each in turn.

func Local

func Local(includes []string) Resolver

Local tries to resolve imports locally.

func Remote

func Remote(config RemoteConfig, repos []Repo) Resolver

Remote resolves imports from their source repositories.

Jump to

Keyboard shortcuts

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