pkgs

package
v0.0.0-...-83043b2 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: GPL-2.0 Imports: 22 Imported by: 0

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

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

func (*Indexes) List

func (c *Indexes) List(context.Context) ([]string, error)

List reads from the Indexes Folder and returns the indexes that have been downloaded

func (*Indexes) Remove

func (c *Indexes) Remove(ctx context.Context, payload *indexes.IndexPayload) (*indexes.Operation, error)

Remove deletes the index file from the Indexes Folder

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.

func (*Tools) Installed

func (c *Tools) Installed(ctx context.Context) (tools.ToolCollection, error)

Installed crawles the Tools Folder and finds the installed tools.

func (*Tools) Remove

func (c *Tools) Remove(ctx context.Context, payload *tools.ToolPayload) (*tools.Operation, error)

Remove deletes the tool folder from Tools Folder

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳