libpvr

package
Version: v0.0.0-...-489e375 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: Apache-2.0 Imports: 57 Imported by: 0

Documentation

Overview

Copyright 2019 Pantacor Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2018 Pantacor Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2019 Pantacor Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2018 Pantacor Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2019 Pantacor Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2020 Pantacor Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2018 Pantacor Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2021 Pantacor Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2020 Pantacor Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2017-2021 Pantacor Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2019 Pantacor Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2018 Pantacor Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2017-2020 Pantacor Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Index

Constants

View Source
const (
	SRC_FILE                    = "src.json"
	SRC_SPEC                    = "service-manifest-src@1"
	TEMPLATE_BUILTIN_LXC_DOCKER = "builtin-lxc-docker"
)
View Source
const (
	MKDIR_CMD                      = "mkdir"
	RM_CMD                         = "rm"
	TAR_CMD                        = "tar"
	TOUCH_CMD                      = "touch"
	MAKE_SQUASHFS_CMD              = "mksquashfs"
	SQUASH_FILE                    = "root.squashfs"
	DOCKER_DIGEST_FILE             = "root.squashfs.docker-digest"
	DOCKER_DOMAIN                  = "docker.io"
	DOCKER_DOMAIN_URL              = "https://" + DOCKER_DOMAIN
	DOCKER_REGISTRY                = "https://index.docker.io/v1/"
	DOCKER_REGISTRY_SERVER_ADDRESS = "https://registry-1.docker.io"
)
View Source
const (
	// PhTrailsEp constant defining pantahub /trails
	PhTrailsEp = "/trails"

	// PhTrailsSummaryEp constant defines pantahub /trails/summary EP
	PhTrailsSummaryEp = PhTrailsEp + "/summary"

	// PhAccountsEp constant defines pantahub /accounts endpoint
	PhAccountsEp = "/auth/accounts"

	// PhLogsEp constant defining pantahub /logs/
	PhLogsEp = "/logs/"

	// PhLogsEpCursor constant defines path to /logs/cursor
	PhLogsEpCursor = PhLogsEp + "cursor"
)
View Source
const (
	ConfigurationFile = "config.json"
)
View Source
const (
	PoolSize = 5
)
View Source
const PvrCheckpointFilename = "checkpoint.json"

Variables

View Source
var (
	ErrInvalidVolumeFormat = errors.New("Invalid volume format")
	ErrEmptyAppName        = errors.New("Empty app name")
	ErrEmptyFrom           = errors.New("Empty from")
	ErrNeedBeRoot          = errors.New("Please run this command as root or use fakeroot utility")
)
View Source
var (
	ErrMakeSquashFSNotFound    = errors.New("mksquashfs not found in your PATH, please install before continue")
	ErrTarNotFound             = errors.New("tar not found in your PATH, please install before continue")
	ErrImageNotFound           = errors.New("image not found or you do not have access")
	ErrDownloadedLayerDiffSize = errors.New("size of downloaded layer is different from expected")
)
View Source
var IsDebugEnabled bool

Variable set in main() to enable/disable debug

View Source
var (
	RuntimeDefaultMetadata = map[string]interface{}{
		"PVR_BASEURL":      "https://api.pantahub.com",
		"PVR_REPO_BASEURL": "https://pvr.pantahub.com",
		"PVR_AUTH":         "",
	}
)

Functions

func AskForConfirmation

func AskForConfirmation(question string) bool

AskForConfirmation ask the user for confirmation action

func Copy

func Copy(dst, src string) error

func Create

func Create(path string) error

func CreateFolder

func CreateFolder(path string) error

func CreateTrail

func CreateTrail(baseURL string,
	deviceAccessToken string,
	state map[string]interface{},
) (
	*resty.Response,
	error,
)

CreateTrail : Create Trail

func DownloadLayersFromLocalDocker

func DownloadLayersFromLocalDocker(digest string) (io.ReadCloser, error)

DownloadLayersFromLocalDocker : Download Layers From Local Docker

func ExtractFiles

func ExtractFiles(files []string, extractPath string) error

func FileHasSameSha

func FileHasSameSha(path, sha string) (bool, error)

func FiletoSha

func FiletoSha(path string) (string, error)

func FindWhiteoutsFromLayer

func FindWhiteoutsFromLayer(layerPath string) ([]string, error)

FindWhiteoutsFromLayer : Find Whiteout Files From a Layer

func FixupRepoRef

func FixupRepoRef(repoUri string) (string, error)

func FormatJson

func FormatJson(data []byte) ([]byte, error)

func FormatJsonC

func FormatJsonC(data []byte) ([]byte, error)

func GetFileContentType

func GetFileContentType(src string) (string, error)

GetFileContentType : Get File Content Type of a file

func GetPhAuthHeaderTokenKey

func GetPhAuthHeaderTokenKey(authHeader string) (string, error)

func GetPlatform

func GetPlatform() string

GetPlatform get string with the full platform name

func Hardlink(dst, src string) error

func IsFileExists

func IsFileExists(filePath string) (bool, error)

IsFileExists : Check if File Exists or not

func IsValidUrl

func IsValidUrl(value string) bool

IsValidUrl tests a string to determine if it is a well-structured url or not.

func LoadLocalImage

func LoadLocalImage(app *AppData) error

LoadLocalImage : To check whether Image Exist In Local Docker Or Not

func LogPrettyJSON

func LogPrettyJSON(content []byte) error

LogPrettyJSON : Pretty print Json content

func LoginDevice

func LoginDevice(
	baseURL string,
	prn string,
	secret string,
) (
	string,
	error,
)

LoginDevice : Login Device

func Max

func Max(x, y int) int

func Min

func Min(x, y int) int

func Mkdir

func Mkdir(path string, perm os.FileMode) error

func MkdirAll

func MkdirAll(path string, perm os.FileMode) error

func ParseRFC3339

func ParseRFC3339(date string) (time.Time, error)

ParseRFC3339 : Parse RFC3339 string : 2006-01-02T15:04:05+07:00

func PrintDebugf

func PrintDebugf(format string, a ...interface{}) (n int, err error)

PrintDebugf forwards to Printfs if IsDebugEnabled

func PrintDebugln

func PrintDebugln(a ...interface{}) (n int, err error)

PrintDebugln forwards to Printfs if IsDebugEnabled

func ProcessWhiteouts

func ProcessWhiteouts(extractPath string, layerPath string, layerNumber int) error

ProcessWhiteouts : FInd Whiteouts from a layer and process it in a given extract path

func ReadOrCreateFile

func ReadOrCreateFile(filePath string) (*[]byte, error)

ReadOrCreateFile read a file from file system if is not avaible creates the file

func Remove

func Remove(path string) error

Remove remove a path, a file

func RemoveAll

func RemoveAll(path string) error

RemoveAll remove a path, could be a file or a folder

func RemoveDirContents

func RemoveDirContents(dir string) error

func RenameFile

func RenameFile(src string, dst string) (err error)

func ReportDockerManifestError

func ReportDockerManifestError(err error, image string) error

func ReportError

func ReportError(err error, knowSolutions ...string) error

func Scan

func Scan()

func SetTempFilesInterrupHandler

func SetTempFilesInterrupHandler(tempdir string)

SetTempFilesInterrupHandler : Set Temp Files Interrup Handler

This function will capture Interrupt signals and delete all temp files

func ShowOrOpenRegisterLink(baseAPIURL, email, username, password string) error

ShowOrOpenRegisterLink show or open the user the registration link

func SliceContainsItem

func SliceContainsItem(slice []string, item string) bool

SliceContainsItem : checks if an item exists in a string array or not

func SprintTmpl

func SprintTmpl(format string, obj interface{}) (string, error)

func StructToMap

func StructToMap(s interface{}) (map[string]interface{}, error)

func Untar

func Untar(dst string, src string) error

Untar : Untar a file or folder

func UpdateIfNecessary

func UpdateIfNecessary(c *cli.Context) error

UpdateIfNecessary update pvr if is necesary but only check on time at the day

func ValidateSourceFlag

func ValidateSourceFlag(source string) error

ValidateSourceFlag : Validate Source Flag

func WriteConfiguration

func WriteConfiguration(filePath string, config *PvrGlobalConfig) error

WriteConfiguration write ~/.pvr/config.json with new data

func WriteTxtFile

func WriteTxtFile(filePath string, content string) error

Types

type Account

type Account struct {
	Email    string `json:"email" bson:"email"`
	Nick     string `json:"nick" bson:"nick"`
	Password string `json:"password,omitempty" bson:"password"`
}

Account data model

type AppData

type AppData struct {
	Appname         string
	DockerURL       string
	Username        string
	Password        string
	Appmanifest     *Source
	TemplateArgs    map[string]interface{}
	DestinationPath string
	LocalImage      DockerImage
	RemoteImage     DockerImage
	From            string
	Source          string
	Platform        string
	ConfigFile      string
	Volumes         []string
	FormatOptions   string
}

AppData : To hold all required App Information

type AsyncBody

type AsyncBody struct {
	Delegate io.ReadCloser
	// contains filtered or unexported fields
}

func (*AsyncBody) Read

func (a *AsyncBody) Read(p []byte) (n int, err error)

type DockerImage

type DockerImage struct {
	Exists         bool
	DockerDigest   string
	DockerConfig   map[string]interface{}
	DockerManifest *schema2.Manifest
	DockerRegistry *registry.Registry
	ImagePath      string
	DockerPlatform string
}

DockerImage : return type of ImageExistsInLocalDocker()

type DockerManifest

type DockerManifest map[string]interface{}

type DockerSource

type DockerSource struct {
	DockerName     string `json:"docker_name"`
	DockerTag      string `json:"docker_tag"`
	DockerDigest   string `json:"docker_digest"`
	DockerSource   string `json:"docker_source"`
	DockerPlatform string `json:"docker_platform,omitempty"`
	FormatOptions  string `json:"format_options,omitempty"`
}

type EncryptedAccountData

type EncryptedAccountData struct {
	Token       string `json:"token"`
	RedirectURI string `json:"redirect-uri"`
}

EncryptedAccountData Encrypted account response

func GetEncryptedAccount

func GetEncryptedAccount(authEp, email, username, password string) (*EncryptedAccountData, error)

GetEncryptedAccount encrypt account data in order to open the browser to finish the registration process

type FilePut

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

type JwsVerifySummary

type JwsVerifySummary struct {
	Protected []string `json:"protected,omitempty"`
	Excluded  []string `json:"excluded,omitempty"`
	NotSeen   []string `json:"notseen,omitempty"`
}

type LogFilter

type LogFilter struct {
	Devices   string
	Sources   string
	Levels    string
	Platforms string
}

LogFilter : Log Filter

type LogFormatter

type LogFormatter interface {
	Init(template string) error
	DoLog(m *logs.Entry) error
}

type LogFormatterJson

type LogFormatterJson struct{}

func (*LogFormatterJson) DoLog

func (s *LogFormatterJson) DoLog(m *logs.Entry) error

func (*LogFormatterJson) Init

func (s *LogFormatterJson) Init(format string) error

type LogFormatterTemplate

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

func (*LogFormatterTemplate) DoLog

func (s *LogFormatterTemplate) DoLog(v *logs.Entry) error

func (*LogFormatterTemplate) Init

func (s *LogFormatterTemplate) Init(template string) error

type Object

type Object struct {
	Id         string `json:"id" bson:"id"`
	StorageId  string `json:"storage-id" bson:"_id"`
	Owner      string `json:"owner"`
	ObjectName string `json:"objectname"`
	Sha        string `json:"sha256sum"`
	Size       string `json:"size"`
	MimeType   string `json:"mime-type"`
}

type ObjectWithAccess

type ObjectWithAccess struct {
	Object       `bson:",inline"`
	SignedPutUrl string `json:"signed-puturl"`
	SignedGetUrl string `json:"signed-geturl"`
	Now          string `json:"now"`
	ExpireTime   string `json:"expire-time"`
}

type PVZeroConf

type PVZeroConf struct {
	Hostname string
	AddrIPv4 []net.IP
	AddrIPv6 []net.IP
	Port     int

	Pantahub  string
	DeviceId  string
	Challenge string
}

func (PVZeroConf) ClaimCmd

func (p PVZeroConf) ClaimCmd() string

func (PVZeroConf) String

func (p PVZeroConf) String() string

type PantahubDevice

type PantahubDevice struct {
	Id               string    `json:"deviceid"`
	Prn              string    `json:"device"`
	Nick             string    `json:"device-nick"`
	Revision         int       `json:"revision"`
	ProgressRevision int       `json:"progress-revision"`
	RealIP           string    `json:"real-ip"`
	Timestamp        time.Time `json:"timestamp"`
	StateSha         string    `json:"state-sha"`
	Status           string    `json:"status"`
	StatusMsg        string    `json:"status-msg"`
}

type Pvr

type Pvr struct {
	Initialized     bool
	Dir             string
	Pvrdir          string
	Pvdir           string
	Objdir          string
	Pvrconfig       PvrConfig
	PristineJson    []byte
	PristineJsonMap PvrMap
	NewFiles        PvrIndex
	Session         *Session
}

func NewPvr

func NewPvr(s *Session, dir string) (*Pvr, error)

func NewPvrInit

func NewPvrInit(s *Session, dir string) (*Pvr, error)

func (*Pvr) AddApplication

func (p *Pvr) AddApplication(app AppData) error

func (*Pvr) AddFile

func (p *Pvr) AddFile(globs []string) error

XXX: make this git style

func (*Pvr) AuthConfig

func (p *Pvr) AuthConfig(username, password, registry string) (types.AuthConfig, error)

func (*Pvr) CheckIfIsRunningAsRoot

func (p *Pvr) CheckIfIsRunningAsRoot() error

func (*Pvr) Commit

func (p *Pvr) Commit(msg string, isCheckpoint bool) (err error)
func (p *Pvr) DeployPvLinks() error

DeployPvLinks sets up the hardlinks for the .pv/ files

func (*Pvr) Diff

func (p *Pvr) Diff() (*[]byte, error)

func (*Pvr) DoClaim

func (p *Pvr) DoClaim(deviceEp, challenge string) error

func (*Pvr) Export

func (p *Pvr) Export(parts []string, dst string) error

Export will put the 'json' file first into the archive to allow for stream parsing and validation of json before processing objects

func (*Pvr) FindDockerImage

func (p *Pvr) FindDockerImage(app *AppData) error

FindDockerImage : Find Docker Image

func (*Pvr) GenerateApplicationSquashFS

func (p *Pvr) GenerateApplicationSquashFS(app AppData) error

func (*Pvr) GenerateApplicationTemplateFiles

func (p *Pvr) GenerateApplicationTemplateFiles(appname string, dockerConfig map[string]interface{}, appManifest *Source) error

func (*Pvr) GetAppDockerDigest

func (p *Pvr) GetAppDockerDigest(appname string) (string, error)

GetAppDockerDigest : Get App Docker Digest

func (*Pvr) GetAppDockerName

func (p *Pvr) GetAppDockerName(appname string) (string, error)

GetAppDockerName : Get App Docker Name

func (*Pvr) GetApplicationInfo

func (p *Pvr) GetApplicationInfo(appname string) error

GetApplicationInfo : Get Application Info

func (*Pvr) GetApplicationManifest

func (p *Pvr) GetApplicationManifest(appname string) (*Source, error)

func (*Pvr) GetDockerConfig

func (p *Pvr) GetDockerConfig(manifestV2 *schema2.Manifest, image registry.Image, auth types.AuthConfig) (map[string]interface{}, error)

func (*Pvr) GetDockerImageRepoDigest

func (p *Pvr) GetDockerImageRepoDigest(image registry.Image, auth types.AuthConfig) (string, error)

GetDockerImageRepoDigest : Get Docker Image Repo Digest

func (*Pvr) GetDockerManifest

func (p *Pvr) GetDockerManifest(image registry.Image, auth types.AuthConfig) (*schema2.Manifest, error)

func (*Pvr) GetDockerRegistry

func (p *Pvr) GetDockerRegistry(image registry.Image, auth types.AuthConfig) (*registry.Registry, error)

func (*Pvr) GetRepo

func (p *Pvr) GetRepo(uri string, merge bool, showFilenames bool) (
	objectsCount int,
	err error,
)

func (*Pvr) GetRepoLocal

func (p *Pvr) GetRepoLocal(getPath string, merge bool, showFilenames bool) (
	objectsCount int,
	err error)

func (*Pvr) GetRepoRemote

func (p *Pvr) GetRepoRemote(url *url.URL, merge bool, showFilenames bool) (
	objectsCount int,
	err error,
)

func (*Pvr) GetSquashFSDigest

func (p *Pvr) GetSquashFSDigest(appName string) (string, error)

func (*Pvr) GetStateJson

func (p *Pvr) GetStateJson(uri string) (
	state map[string]interface{},
	err error,
)

func (*Pvr) GetTrackURL

func (p *Pvr) GetTrackURL(appname string) (string, error)

GetTrackURL : Get Track URL

func (*Pvr) GetWorkingJson

func (p *Pvr) GetWorkingJson() ([]byte, []string, error)

create the canonical json for the working directory

func (*Pvr) Import

func (p *Pvr) Import(src string) error

func (*Pvr) Init

func (p *Pvr) Init(objectsDir string) error

func (*Pvr) InitCustom

func (p *Pvr) InitCustom(customInitJson string, objectsDir string) error

func (*Pvr) InstallApplication

func (p *Pvr) InstallApplication(app AppData) error

InstallApplication : Install Application

func (*Pvr) JwsSign

func (p *Pvr) JwsSign(name string,
	privKeyPath string,
	match *PvsMatch,
	options *PvsOptions) error

JwsSign will add or update a signature based using a private key provided.

The payload will be assembled from the prinstine system state JSON using the match rule provided in PvsMatch struct.

PvsOptions allow to pass additional JoseHeader options to include in the Signature.

func (*Pvr) JwsSignAuto

func (p *Pvr) JwsSignAuto(keyPath string, part string, options *PvsOptions) error

func (*Pvr) JwsSignPvs

func (p *Pvr) JwsSignPvs(privKeyPath string,
	pvsPath string,
	options *PvsOptions) error

JwsSignPvs will parse a pvs@s json provided as argument and use the included PvsMatch section to invoke JwsSign

func (*Pvr) JwsVerifyPvs

func (p *Pvr) JwsVerifyPvs(keyPath string, pvsPath string) (*JwsVerifySummary, error)

JwsVerify will add or update a signature based using a private key provided.

The payload will be assembled from the prinstine system state JSON using the match rule provided in PvsMatch struct included in the pvs.

func (*Pvr) ListApplications

func (p *Pvr) ListApplications() error

ListApplications : List Applications

func (*Pvr) LoadRemoteImage

func (p *Pvr) LoadRemoteImage(app *AppData) error

LoadRemoteImage : To check whether Image Exist In Remote Docker Or Not

func (*Pvr) Post

func (p *Pvr) Post(uri string, envelope string, commitMsg string, rev int, force bool) error

make a json post to a REST endpoint. You can provide metainfo etc. in post argument as json. postKey if set will be used as key that refers to the posted json. Example usage: json blog post, json revision repo with commit message etc

func (*Pvr) Put

func (p *Pvr) Put(uri string, force bool) error

func (*Pvr) PutLocal

func (p *Pvr) PutLocal(repoPath string) error

func (*Pvr) PutObjects

func (p *Pvr) PutObjects(uri string, force bool) error

func (*Pvr) PutRemote

func (p *Pvr) PutRemote(repoPath *url.URL, force bool) error

func (*Pvr) RemoteCopy

func (p *Pvr) RemoteCopy(pvrSrc string, pvrDest string, merge bool,
	envelope string, commitMsg string, rev int, force bool) error

RemoteCopy will perform a remote only copy by taking the json, select elements that have the #fragement of a provided url as Prefix of their key and replace all elements in pvrDest that match that prefix. The target prefix can be overloaded through providing a #fragment in destination URL as well. It is an illegal input if pvrSrc has no fragement, but pvrDest has one. It is however legal input if pvrSrc has a fragement, but pvrDest does not have one. In that case the same fragement is implicitely appended to pvrDest

func (*Pvr) RemoveApplication

func (p *Pvr) RemoveApplication(appname string) error

RemoveApplication : Remove Application

func (*Pvr) Reset

func (p *Pvr) Reset(canonicalJson bool) error
func (p *Pvr) ResetWithHardlink() error

func (*Pvr) RunAsRoot

func (p *Pvr) RunAsRoot() error

func (*Pvr) SaveConfig

func (p *Pvr) SaveConfig() error

func (*Pvr) SetConfiguration

func (pvr *Pvr) SetConfiguration(arguments []string) (*PvrGlobalConfig, error)

SetConfiguration read arguments and write new configuration, merging with the previous configuration on the file

func (*Pvr) Status

func (p *Pvr) Status() (*PvrStatus, error)

func (*Pvr) String

func (p *Pvr) String() string

func (*Pvr) UnpackRepo

func (p *Pvr) UnpackRepo(repoPath string, outDir string) error

func (*Pvr) UpdateApplication

func (p *Pvr) UpdateApplication(app AppData) error

func (*Pvr) UpdatePvr

func (pvr *Pvr) UpdatePvr(username, password string, silent bool) error

UpdatePvr Take the username, password and configuration File (aka: ~/.pvr) and update the pvr binary

func (*Pvr) Verify

func (p *Pvr) Verify(keyPath string) error

type PvrAuthConfig

type PvrAuthConfig struct {
	Spec   string                   `json:"spec"`
	Tokens map[string]PvrAuthTokens `json:"tokens"`
	// contains filtered or unexported fields
}

func LoadConfig

func LoadConfig(filePath string) (*PvrAuthConfig, error)

func (*PvrAuthConfig) DoRefresh

func (p *PvrAuthConfig) DoRefresh(authEp, token string) (string, string, error)

func (*PvrAuthConfig) Save

func (p *PvrAuthConfig) Save() error

type PvrAuthTarget

type PvrAuthTarget struct {
	// Name is the name of the target; 'default' for api.pantahub.com
	Name     string
	TargetEp *url.URL
}

type PvrAuthTokens

type PvrAuthTokens struct {
	Name string
	// Name is the name of the target; 'default' for api.pantahub.com
	AccessToken  string `json:"access-token"`
	RefreshToken string `json:"refresh-token"`
}

type PvrConfig

type PvrConfig struct {
	DefaultGetUrl  string
	DefaultPutUrl  string
	DefaultPostUrl string
	ObjectsDir     string

	// tokens by realm
	AccessTokens  map[string]string
	RefreshTokens map[string]string
}

type PvrGlobalConfig

type PvrGlobalConfig struct {
	Spec            string `json:"Spec"`
	AutoUpgrade     bool   `json:"AutoUpgrade"`
	DistributionTag string `json:"DistributionTag"`
}

PvrGlobalConfig define all the posible general configuration for pvr

func LoadConfiguration

func LoadConfiguration(filePath string) (*PvrGlobalConfig, error)

LoadConfiguration read configuration from ~/.pvr/config.json or return default configuration

type PvrIndex

type PvrIndex map[string]string

type PvrMap

type PvrMap map[string]interface{}

type PvrSource

type PvrSource struct {
	PvrUrl   string `json:"pvr_url,omitempty"`
	PvrMerge bool   `json:"pvr_merge,omitempty"`
}

type PvrStatus

type PvrStatus struct {
	NewFiles       []string
	RemovedFiles   []string
	ChangedFiles   []string
	UntrackedFiles []string
	JsonDiff       *[]byte
}

func (*PvrStatus) String

func (p *PvrStatus) String() string

stringify of file status for "pvr status" list...

type PvsMatch

type PvsMatch struct {
	Include []string `json:"include"`
	Exclude []string `json:"exclude"`
}

type PvsOptions

type PvsOptions struct {
	Algorithm    gojose.SignatureAlgorithm
	ExtraHeaders map[string]interface{}
}

type PvsPartSelection

type PvsPartSelection struct {
	Selected    map[string]interface{}
	NotSelected map[string]interface{}
	NotSeen     map[string]interface{}
}

type Session

type Session struct {
	Configuration *PvrGlobalConfig
	// contains filtered or unexported fields
}

func DefaultSession

func DefaultSession() *Session

func NewSession

func NewSession(app *cli.App) (*Session, error)

func (*Session) CreateDevice

func (s *Session) CreateDevice(baseURL string, deviceNick string) (
	*resty.Response,
	error,
)

CreateDevice : Create Device

func (*Session) DoAuthCall

func (s *Session) DoAuthCall(withAnon bool, fn WrappableRestyCallFunc) (*resty.Response, error)

func (*Session) DoLogs

func (p *Session) DoLogs(
	baseurl string,
	deviceIds []string,
	rev int,
	startTime *time.Time,
	endTime *time.Time,
	cursor bool,
	logFilter LogFilter,
) (logEntries []*logs.Entry, cursorID string, err error)

func (*Session) DoLogsCursor

func (p *Session) DoLogsCursor(baseurl string, cursor string) (logEntries []*logs.Entry, cursorID string, err error)

func (*Session) DoPs

func (p *Session) DoPs(baseurl string) ([]PantahubDevice, error)

func (*Session) GetApp

func (s *Session) GetApp() *cli.App

func (*Session) GetAuthStatus

func (s *Session) GetAuthStatus(baseURL string) (
	*resty.Response,
	error,
)

GetAuthStatus : Get Auth Status, GET /auth/auth_status

func (*Session) GetConfigDir

func (s *Session) GetConfigDir() string

func (*Session) GetDevice

func (s *Session) GetDevice(baseURL string,
	deviceNick string,
	ownerNick string,
) (
	*resty.Response,
	error,
)

GetDevice : Get Device

func (*Session) GetDevices

func (s *Session) GetDevices(baseURL string,
	ownerNick string,
	deviceNick string,
) (
	*resty.Response,
	error,
)

GetDevices : Get Devices

func (*Session) GetUserProfiles

func (s *Session) GetUserProfiles(baseURL string,
	userNick string,
) (
	*resty.Response,
	error,
)

GetUserProfiles : Get User Profiles

func (*Session) IsUserLoggedIn

func (session *Session) IsUserLoggedIn(baseURL string) (bool, error)

IsUserLoggedIn : To check if a user is logged in or not

func (*Session) Login

func (s *Session) Login(APIURL string, withAnon bool) (*resty.Response, error)

Login : Login to a given URL

func (*Session) SuggestDeviceNicks

func (s *Session) SuggestDeviceNicks(userNick, searchTerm string, baseURL string)

SuggestDeviceNicks : Suggest Device Nicks

func (*Session) SuggestNicks

func (s *Session) SuggestNicks(searchTerm string, baseURL string)

SuggestNicks : Suggest Nicks (Either user nicks or device nicks)

func (*Session) SuggestUserNicks

func (s *Session) SuggestUserNicks(searchTerm string, baseURL string)

SuggestUserNicks : Suggest User Nicks

func (*Session) UpdateDevice

func (s *Session) UpdateDevice(
	baseURL string,
	deviceNick string,
	data map[string]interface{},
	updateField string,
) (
	*resty.Response,
	error,
)

UpdateDevice : Update user-meta or device-meta field of a device

func (*Session) Whoami

func (s *Session) Whoami() error

Whoami : List all loggedin nick names

type Source

type Source struct {
	Name         string                   `json:"name,omitempty"`
	Spec         string                   `json:"#spec"`
	Template     string                   `json:"template"`
	TemplateArgs map[string]interface{}   `json:"args"`
	Logs         []map[string]interface{} `json:"logs,omitempty"`
	Exports      []string                 `json:"exports,omitempty"`
	Config       map[string]interface{}   `json:"config"`
	DockerSource
	PvrSource
	Persistence map[string]string `json:"persistence"`
}

type WrappableRestyCallFunc

type WrappableRestyCallFunc func(req *resty.Request) (*resty.Response, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL