pkgs

package
v0.0.0-...-b2b9887 Latest Latest
Warning

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

Go to latest
Published: May 15, 2025 License: AGPL-3.0 Imports: 21 Imported by: 2

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

View Source
var (
	OS   = runtime.GOOS
	Arch = runtime.GOARCH
)

public vars to allow override in the tests

Functions

func FindTool

func FindTool(pack, name, version string, data Index) (Tool, System, bool)

FindTool searches the index for the correct tool and system that match the specified tool name and version

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 System

type System struct {
	Host     string `json:"host"`
	URL      string `json:"url"`
	Name     string `json:"archiveFileName"`
	Checksum string `json:"checksum"`
}

System is the go representation of the info needed to download a tool for a specific OS/Arch

type Tool

type Tool struct {
	Name    string   `json:"name"`
	Version string   `json:"version"`
	Systems []System `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.

func (*Tool) GetFlavourCompatibleWith

func (t *Tool) GetFlavourCompatibleWith(osName, osArch string) System

GetFlavourCompatibleWith returns the downloadable resource (System) compatible with the specified OS/Arch Source: https://github.com/arduino/arduino-cli/blob/master/internal/arduino/cores/tools.go#L206-L216

type Tools

type Tools struct {
	// contains filtered or unexported fields
}

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 Index Resource to search for tools

func New

func New(index *index.Resource, folder, behaviour string, verifySignaturePubKey *rsa.PublicKey) *Tools

New will return a Tool object, allowing the caller to execute operations on it. The New function will accept an index as parameter (used to download the indexes) and a folder used to download the indexes

func (*Tools) Available

func (t *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 (t *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 (t *Tools) Installed(ctx context.Context) (tools.ToolCollection, error)

Installed crawles the Tools Folder and finds the installed tools.

func (*Tools) Installedhead

func (t *Tools) Installedhead(ctx context.Context) (err error)

Installedhead is here only because it was required by the front-end. Probably when we bumped GOA something changed: Before that the frontend was able to perform the HEAD request to `v2/pkgs/tools/installed`. After the bump we have to implement it explicitly. Currently I do not know a better way in achieving the same result.

func (*Tools) Remove

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

Remove deletes the tool folder from Tools Folder

func (*Tools) SetBehaviour

func (t *Tools) SetBehaviour(behaviour string)

SetBehaviour sets the download behaviour to either keep or replace

Jump to

Keyboard shortcuts

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