commons

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EXECUTABLE, _  = os.Executable()
	WORKING_DIR, _ = os.Getwd()
	HOME_DIR, _    = os.UserHomeDir()

	//	Nhost Variables
	NHOST_AUTH_URL string
)

Functions

This section is empty.

Types

type Account

type Account struct {
	AccessToken  string           `json:"access_token" yaml:"accessToken"`
	RefreshToken string           `json:"refresh_token" yaml:"refreshToken"`
	User         userCommons.User `json:"user" yaml:"user"`
}

type ConfigType

type ConfigType string
const (
	ProjectConfig     ConfigType = "ProjectConfig"
	AccountConfig     ConfigType = "AccountConfig"
	KeysConfig        ConfigType = "KeysConfig"
	ContingencyConfig ConfigType = "ContingencyConfig"

	CONFIG_FOLDER_NAME = ".envs"
)

type Keys

type Keys struct {
	Public  []byte `json:"public_key" yaml:"public_key"`
	Private []byte `json:"private_key" yaml:"private_key"`
}
 func (p *ProjectStringified) Unstringify() (*Project, error) {

	key, err := base64.StdEncoding.DecodeString(p.Key)
	if err != nil {
		return nil, err
	}

	return &Project{
		Organisation:   p.Organisation,
		Project:        p.Project,
		Key:         key,
		AutoCapitalize: p.AutoCapitalize,
	}, nil
}
func (p *Project) Stringify() *ProjectStringified {
	return &ProjectStringified{
		Organisation:   p.Organisation,
		Project:        p.Project,
		Key:         base64.StdEncoding.EncodeToString(p.Key),
		AutoCapitalize: p.AutoCapitalize,
	}
}

func (*Keys) Stringify

func (k *Keys) Stringify() *KeysStringified

type KeysStringified

type KeysStringified struct {
	Public  string `json:"public_key" yaml:"public_key"`
	Private string `json:"private_key" yaml:"private_key"`
}

func (*KeysStringified) Unstringify

func (k *KeysStringified) Unstringify() (*Keys, error)

type Project

type Project struct {
	//OrgID     string `json:"org_id" yaml:"org_id"`
	ProjectID string `json:"project_id" yaml:"project_id"`
	Key       []byte `json:"key" yaml:"key"`
}

func (*Project) MarshalJSON

func (p *Project) MarshalJSON() ([]byte, error)

Custom json marshalling. We need to do this because we want to store the org key as a base64 encoded string in the config file. We can't store it as a byte array because yaml marshalling will convert it to a string.

func (*Project) UnmarshalJSON

func (p *Project) UnmarshalJSON(data []byte) error

Custom json unmarshalling. We need to do this because we want to store the org key as a base64 encoded string in the config file.

Jump to

Keyboard shortcuts

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