Documentation ¶
Overview ¶
Package vppapi parses VPP API files without any additional processing.
Index ¶
- Constants
- func FindFiles(dir string) (files []string, err error)
- func FindFilesRecursive(dir string, deep int) (files []string, err error)
- func GetVPPVersionInstalled() (string, error)
- func GetVPPVersionRepo(repoDir string) (string, error)
- func ResolveApiDir(dir string) string
- func ResolveVPPVersion(apidir string) string
- type AliasType
- type Counter
- type CounterPaths
- type Element
- type EnumEntry
- type EnumType
- type Field
- type File
- type InputFormat
- type InputRef
- type Message
- type RPC
- type Schema
- type Service
- type StructType
- type UnionType
- type VppInput
Constants ¶
const ( OptionFormat = "format" OptionGitBranch = "branch" OptionGitTag = "tag" OptionGitRef = "ref" OptionGitDepth = "depth" OptionGitSubdir = "subdir" OptionArchiveCompression = "compression" OptionArchiveSubdir = "subdir" OptionArchiveStrip = "strip" )
const ( VPPVersionEnvVar = "VPP_VERSION" VPPDirEnvVar = "VPP_DIR" )
const ( // DefaultDir is default location of API files. DefaultDir = "/usr/share/vpp/api" // APIFileExtension is a VPP API file extension suffix APIFileExtension = ".api.json" )
const (
OptFileVersion = "version"
)
Variables ¶
This section is empty.
Functions ¶
func FindFiles ¶
FindFiles searches for API files in given directory or in a nested directory that is at most one level deeper than dir. This effectively finds all API files under core & plugins directories inside API directory.
func FindFilesRecursive ¶
FindFilesRecursive searches for API files under dir or in a nested directory that is not nested deeper than deep.
func GetVPPVersionInstalled ¶
GetVPPVersionInstalled retrieves VPP version of installed package using dpkg-query.
func GetVPPVersionRepo ¶
GetVPPVersionRepo retrieves VPP version using script in repo directory.
func ResolveApiDir ¶
ResolveApiDir checks if parameter dir is a path to directory of local VPP repository and returns path to directory with VPP API JSON files under build-root. It will execute `make json-api-files` in case the folder with VPP API JSON files does not exist yet.
func ResolveVPPVersion ¶
ResolveVPPVersion resolves version of the VPP for target directory.
Version resolved here can be overriden by setting VPP_VERSION env var.
Types ¶
type CounterPaths ¶
type File ¶
type File struct { Name string // Name is the name of this API file (without any extension). Path string // Path is the location of thi API file relative to API directory. CRC string // CRC is a checksum for this API file. // Options is a map of string key-value pairs that provides additional options for this file. Options map[string]string `json:",omitempty"` // Imports is a list of strings representing the names of API files that are imported by this file. Imports []string `json:",omitempty"` AliasTypes []AliasType `json:",omitempty"` EnumTypes []EnumType `json:",omitempty"` EnumflagTypes []EnumType `json:",omitempty"` StructTypes []StructType `json:",omitempty"` UnionTypes []UnionType `json:",omitempty"` // Messages is a list of Message objects representing messages used in the API. Messages []Message `json:",omitempty"` // Service is an object representing the RPC services used in the API. // In case there is not any services defined for this File, the Service is nil. Service *Service `json:",omitempty"` Counters []Counter `json:",omitempty"` Paths []CounterPaths `json:",omitempty"` }
File is a single API file and its contents.
func Parse ¶
Parse parses API files in directory DefaultDir and returns collection of File or an error if any error occurs during parsing.
func ParseDir ¶
ParseDir searches for API files in apiDir, parses the found API files and returns collection of File.
API files must have suffix `.api.json` and must be formatted as JSON.
type InputFormat ¶
type InputFormat string
const ( FormatNone InputFormat = "" FormatDir InputFormat = "dir" FormatGit InputFormat = "git" FormatTar InputFormat = "tar" FormatZip InputFormat = "zip" )
type InputRef ¶
type InputRef struct { Path string Format InputFormat Options map[string]string }
InputRef is used to specify reference to VPP API input.
func ParseInputRef ¶
type Schema ¶
type Schema struct { // Files is a list of File objects that are part of this scheme. Files []File // Version is a VPP version of this schema. Version string }
Schema represents a collection of API files for a specific VPP version.
type StructType ¶
type VppInput ¶
VppInput defines VPP API input source.
func ResolveVppInput ¶
ResolveVppInput parses an input string and returns VppInput or an error if a problem occurs durig parsing. The input string consists of path, which can be followed by '#' and one or more options separated by comma. The actual format can be specified explicitely by an option 'format', if that is not the case then the format will be detected from path automatically if possible.
- `path` - `path#option1=val,option2=val`
Available formats:
* Directory: `dir`
- absolute: `/usr/share/vpp/api`
- relative: `path/to/apidir`
* Git repository: `git`
- local repository: `.git`
- remote repository: `https://github.com/FDio/vpp.git`
* Tarball/Zip Archive (`tar`/`zip`)
- local archive: `api.tar.gz`
- remote archive: `https://example.com/api.tar.gz`
- standard input: `-`
Format options:
* Git repository
- `branch`: name of branch
- `tag`: specific git tag
- `ref`: git reference
- `depth`: git depth
- `subdir`: subdirectory to use as base directory
* Tarball/ZIP Archive
- `compression`: compression to use (`gzip`)
- `subdir`: subdirectory to use as base directory
- 'strip': strip first N directories, applied before `subdir`