Documentation
¶
Overview ¶
Package pkgs implements the functions from github.com/arduino-create-agent/gen/indexes and github.com/arduino-create-agent/gen/tools.
It allows to manage package indexes from arduino cores, and to download tools used for upload.
Index ¶
- type Index
- type Indexes
- func (c *Indexes) Add(ctx context.Context, payload *indexes.IndexPayload) (*indexes.Operation, error)
- func (c *Indexes) Get(ctx context.Context, uri string) (index Index, err error)
- func (c *Indexes) List(context.Context) ([]string, error)
- func (c *Indexes) Remove(ctx context.Context, payload *indexes.IndexPayload) (*indexes.Operation, error)
- type Tool
- type Tools
- func (c *Tools) Available(ctx context.Context) (res tools.ToolCollection, err error)
- func (c *Tools) Install(ctx context.Context, payload *tools.ToolPayload) (*tools.Operation, error)
- func (c *Tools) Installed(ctx context.Context) (tools.ToolCollection, error)
- func (c *Tools) Remove(ctx context.Context, payload *tools.ToolPayload) (*tools.Operation, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Index ¶
type Index struct {
Packages []struct {
Name string `json:"name"`
Tools []Tool `json:"tools"`
} `json:"packages"`
}
Index is the go representation of a typical package-index file, stripped from every non-used field.
type Indexes ¶
type Indexes struct {
Log *logrus.Logger
Folder string
}
Indexes is a client that implements github.com/arduino/arduino-create-agent/gen/indexes.Service interface
func (*Indexes) Add ¶
func (c *Indexes) Add(ctx context.Context, payload *indexes.IndexPayload) (*indexes.Operation, error)
Add downloads the index file found at the url contained in the payload, and saves it in the Indexes Folder. If called with an already existing index, it overwrites the file. It can fail if the payload is not defined, if it contains an invalid url.
func (*Indexes) Get ¶
func (c *Indexes) Get(ctx context.Context, uri string) (index Index, err error)
Get reads the index file from the Indexes Folder, unmarshaling it
type Tool ¶
type Tool struct {
Name string `json:"name"`
Version string `json:"version"`
Systems []struct {
Host string `json:"host"`
URL string `json:"url"`
Checksum string `json:"checksum"`
} `json:"systems"`
}
Tool is the go representation of the info about a tool contained in a package-index file, stripped from every non-used field.
type Tools ¶
type Tools struct {
Indexes interface {
List(context.Context) ([]string, error)
Get(context.Context, string) (Index, error)
}
Folder string
}
Tools is a client that implements github.com/arduino/arduino-create-agent/gen/tools.Service interface. It saves tools in a specified folder with this structure: packager/name/version For example:
folder
└── arduino
└── bossac
├── 1.6.1-arduino
│ └── bossac
└── 1.7.0
└── bossac
It requires an Indexes client to list and read package index files: use the Indexes struct
func (*Tools) Available ¶
func (c *Tools) Available(ctx context.Context) (res tools.ToolCollection, err error)
Available crawles the downloaded package index files and returns a list of tools that can be installed.
func (*Tools) Install ¶
func (c *Tools) Install(ctx context.Context, payload *tools.ToolPayload) (*tools.Operation, error)
Install crawles the Index folder, downloads the specified tool, extracts the archive in the Tools Folder. It checks for the Signature specified in the package index.