storage

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2022 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractZip

func ExtractZip(rawZip []byte, writer func(name string) (io.WriteCloser, error)) error

ExtractZip extracts a zip's files to the specified directory. The writer is expected to create any necessary directories and return a writer for writing a file.

func GetZipFileReader

func GetZipFileReader(rawZip []byte, filename string) (io.ReadCloser, error)

GetZipFileReader returns a reader for a single file in a zip.

func WalkZip

func WalkZip(rawZip []byte, fn func(*zip.File) (bool, error)) (io.ReadCloser, error)

WalkZip applies a function over every file in the zip. If the function returns true a reader for that file will be immediately returned. If it returns an error the error will immediately be returned. Otherwise `nil` will be returned once the archive's end is reached.

Types

type AssetType

type AssetType string
const (
	VSIXAssetType AssetType = "Microsoft.VisualStudio.Services.VSIXPackage"
)

type Extension

type Extension struct {
	ID           string
	Location     string
	Dependencies []string
	Pack         []string
}

type Local

type Local struct {
	ExtDir string
	Logger slog.Logger
}

Local implements Storage. It stores extensions locally on disk.

func (*Local) AddExtension

func (s *Local) AddExtension(ctx context.Context, source string) (*Extension, error)

func (*Local) FileServer

func (s *Local) FileServer() http.Handler

func (*Local) Manifest

func (s *Local) Manifest(ctx context.Context, publisher, extension, version string) (*VSIXManifest, error)

func (*Local) RemoveExtension

func (s *Local) RemoveExtension(ctx context.Context, id string, all bool) ([]string, error)

func (*Local) WalkExtensions

func (s *Local) WalkExtensions(ctx context.Context, fn func(manifest *VSIXManifest, versions []string) error) error

type PropertyType

type PropertyType string
const (
	DependencyPropertyType PropertyType = "Microsoft.VisualStudio.Code.ExtensionDependencies"
	PackPropertyType       PropertyType = "Microsoft.VisualStudio.Code.ExtensionPack"
)

type Storage

type Storage interface {
	// AddExtension adds the extension found at the specified source by copying it
	// into the extension storage directory and returns details about the added
	// extension.  The source may be an URI or a local file path.
	AddExtension(ctx context.Context, source string) (*Extension, error)
	// RemoveExtension removes the extension by id (publisher, name, and version)
	// or all versions if all is true (in which case the id should omit the
	// version) and returns the IDs removed.
	RemoveExtension(ctx context.Context, name string, all bool) ([]string, error)
	// FileServer provides a handler for fetching extension repository files from
	// a client.
	FileServer() http.Handler
	// Manifest returns the manifest for the provided extension version.
	Manifest(ctx context.Context, publisher, extension, version string) (*VSIXManifest, error)
	// WalkExtensions applies a function over every extension providing the
	// manifest for the latest version and a list of all available versions.  If
	// the function returns error the error is returned and the iteration aborted.
	WalkExtensions(ctx context.Context, fn func(manifest *VSIXManifest, versions []string) error) error
}

TODO: Add Artifactory implementation of Storage.

type VSIXAsset

type VSIXAsset struct {
	Type        AssetType `xml:",attr"`
	Path        string    `xml:",attr"`
	Addressable string    `xml:",attr"`
}

VSIXAsset implements XMLManifest.PackageManifest.Assets.Asset. https://github.com/microsoft/vscode-vsce/blob/main/src/xml.ts#L25

type VSIXAssets

type VSIXAssets struct {
	Asset []VSIXAsset
}

VSIXAssets implements XMLManifest.PackageManifest.Assets. https://github.com/microsoft/vscode-vsce/blob/main/src/xml.ts#L25

type VSIXIdentity

type VSIXIdentity struct {
	// ID correlates to ExtensionName, *not* ExtensionID.
	ID             string `xml:"Id,attr"`
	Version        string `xml:",attr"`
	Publisher      string `xml:",attr"`
	TargetPlatform string `xml:",attr"`
}

VSIXManifest implement XMLManifest.PackageManifest.Metadata.Identity. https://github.com/microsoft/vscode-vsce/blob/main/src/xml.ts#L14

type VSIXManifest

type VSIXManifest struct {
	Metadata     VSIXMetadata
	Installation struct {
		InstallationTarget struct {
			ID string `xml:"Id,attr"`
		}
	}
	Dependencies []string
	Assets       VSIXAssets
}

VSIXManifest implement XMLManifest.PackageManifest. https://github.com/microsoft/vscode-vsce/blob/main/src/xml.ts#L9-L26

type VSIXMetadata

type VSIXMetadata struct {
	Description  string
	DisplayName  string
	Identity     VSIXIdentity
	Tags         string
	GalleryFlags string
	License      string
	Icon         string
	Properties   VSIXProperties
	Categories   string
}

VSIXManifest implement XMLManifest.PackageManifest.Metadata. https://github.com/microsoft/vscode-vsce/blob/main/src/xml.ts#L11-L22

type VSIXProperties

type VSIXProperties struct {
	Property []VSIXProperty
}

VSIXProperties implements XMLManifest.PackageManifest.Metadata.Properties. https://github.com/microsoft/vscode-vsce/blob/main/src/xml.ts#L19

type VSIXProperty

type VSIXProperty struct {
	ID    PropertyType `xml:"Id,attr"`
	Value string       `xml:",attr"`
}

VSIXProperty implements XMLManifest.PackageManifest.Metadata.Properties.Property. https://github.com/microsoft/vscode-vsce/blob/main/src/xml.ts#L19

Jump to

Keyboard shortcuts

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