nhost

package
v0.6.13 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DB_USER     = "postgres"
	DB_PASSWORD = "postgres"

	MINIO_USER     = "minioaccesskey123123"
	MINIO_PASSWORD = "minioaccesskey123123"
)

Variables

View Source
var (
	DOMAIN string
	API    string

	//  fetch current working directory
	NHOST_DIR string
	DOT_NHOST string

	//  initialize the names of all Nhost services in the stack
	SERVICES []string

	//  find user's home directory
	HOME string

	//  Nhost root directory for HOME
	ROOT string

	//  authentication file location
	AUTH_PATH string

	//  path for migrations
	MIGRATIONS_DIR string

	//  path for metadata
	METADATA_DIR string

	//  default Nhost database
	DATABASE string

	//  path for seeds
	SEEDS_DIR string

	//  path for frontend
	WEB_DIR string

	//  path for API code
	API_DIR string

	//  path for email templates
	EMAILS_DIR string

	//  path for legacy migrations
	LEGACY_DIR string

	//  path for local git directory
	GIT_DIR string

	//  default git repository remote to watch for git ops
	REMOTE string

	//  path for .env.development
	ENV_FILE string

	//  path for config.yaml file
	CONFIG_PATH string

	//  path for .gitignore file
	GITIGNORE string

	//  path for .nhost/nhost.yaml file
	INFO_PATH string

	//  path for express NPM modules
	NODE_MODULES_PATH string

	//  package repository to download latest release from
	REPOSITORY string

	//  initialize the project prefix
	PREFIX string

	//	mandatorily required locations
	LOCATIONS Required
)

Functions

func Env

func Env() ([]string, error)

func Exists

func Exists() bool

func GetAddress added in v0.5.9

func GetAddress(s *Service) string

Generate service address based on assigned port

func GetContainerName

func GetContainerName(name string) string

func GetCurrentBranch

func GetCurrentBranch() string

func GetDotNhost

func GetDotNhost() (string, error)

Get the expected current DotNhost directory as per git branch head

func Init added in v0.5.9

func Init()

Initialize Nhost variables for runtime

func InitLocations added in v0.5.9

func InitLocations() error

func ParseEnvVarsFromConfig

func ParseEnvVarsFromConfig(payload map[interface{}]interface{}, prefix string) []string

func UpdateLocations added in v0.5.9

func UpdateLocations(old, new string)

Updates the directory paths in all variables

Types

type App

type App struct {
	ID                 string   `json:"id,omitempty"`
	Name               string   `json:"name,omitempty"`
	GraphQLAdminSecret string   `json:"hasuraGraphqlAdminSecret,omitempty"`
	Subdomain          string   `json:"subdomain,omitempty"`
	EnvVars            []EnvVar `json:"environmentVariables,omitempty"`
	Workspace          string   `json:"workspace,omitempty"`
}

func Info

func Info() (App, error)

type Asset

type Asset struct {
	URL                string `json:",omitempty"`
	Name               string `json:",omitempty"`
	ID                 string `json:",omitempty"`
	Label              string `json:",omitempty"`
	BrowserDownloadURL string `json:"browser_download_url,omitempty"`
	Size               int    `json:",omitempty"`
}

GitHub Release API Assets structure

type Authentication

type Authentication struct {
	Endpoints map[string]interface{} `yaml:",omitempty"`
	Providers map[string]interface{} `yaml:",omitempty"`
	Signin    map[string]interface{} `yaml:",omitempty"`
	Signup    map[string]interface{} `yaml:",omitempty"`
	Email     map[string]interface{} `yaml:",omitempty"`
	Tokens    map[string]interface{} `yaml:",omitempty"`
	Gravatar  map[string]interface{} `yaml:",omitempty"`
}

Nhost config.yaml authentication structure

type Configuration

type Configuration struct {
	MetadataDirectory string                      `yaml:"metadata_directory,omitempty"`
	Services          map[string]*Service         `yaml:",omitempty"`
	Auth              map[interface{}]interface{} `yaml:",omitempty"`
	Storage           map[interface{}]interface{} `yaml:",omitempty"`
	Version           int                         `yaml:",omitempty"`
	Sessions          map[string]Session          `yaml:",omitempty"`
}

Nhost config.yaml root structure

func GenerateConfig

func GenerateConfig(options App) Configuration

generates fresh config.yaml for /nhost dir

func (*Configuration) Init

func (config *Configuration) Init(port string) error

func (*Configuration) MarshalJSON

func (r *Configuration) MarshalJSON() ([]byte, error)

func (*Configuration) MarshalYAML

func (r *Configuration) MarshalYAML() ([]byte, error)

func (*Configuration) Save

func (config *Configuration) Save() error

func (*Configuration) Wrap

func (c *Configuration) Wrap() error

type Credentials

type Credentials struct {
	ID    string `json:"id,omitempty"`
	Token string `json:"token,omitempty"`
}

Authentication credentials structure

func LoadCredentials

func LoadCredentials() (Credentials, error)

fetches saved credentials from auth file

type Domains

type Domains struct {
	Hasura string `json:"hasura_domain,omitempty"`
}

Nhost project domains

type EnvVar

type EnvVar struct {
	ID    string `json:"id,omitempty"`
	Name  string `json:"name,omitempty"`
	Value string `json:"devValue,omitempty"`
}

type Error

type Error struct {
	Code  string
	Email string
}

Error structure

type Information

type Information struct {
	ProjectID string `yaml:"project_id,omitempty"`
	ID        string `yaml:",omitempty"`
	Name      string `yaml:",omitempty"`
}

.nhost/nhost.yaml information

type Project

type Project struct {
	ID                          string                   `json:"id" yaml:"project_id"`
	UserID                      string                   `json:"user_id"`
	Team                        Team                     `json:",omitempty"`
	TeamID                      string                   `json:"team_id,omitempty"`
	Type                        string                   `json:",omitempty"`
	Name                        string                   `json:"name"`
	HasuraGQEVersion            string                   `json:"hasura_gqe_version,omitempty"`
	BackendVersion              string                   `json:"backend_version,omitempty"`
	HasuraGQEAdminSecret        string                   `json:"hasura_gqe_admin_secret,omitempty"`
	PostgresVersion             string                   `json:"postgres_version,omitempty"`
	HasuraGQECustomEnvVariables map[string]string        `json:"hasura_gqe_custom_env_variables,omitempty"`
	BackendUserFields           string                   `json:"backend_user_fields,omitempty"`
	HBPDefaultAllowedUserRoles  string                   `json:"hbp_DEFAULT_ALLOWED_USER_ROLES,omitempty"`
	HBPRegistrationCustomFields string                   `json:"hbp_REGISTRATION_CUSTOM_FIELDS,omitempty"`
	HBPAllowedUserRoles         string                   `json:"hbp_allowed_user_roles,omitempty"`
	ProjectDomains              Domains                  `json:"project_domain"`
	ProjectEnvVars              []map[string]interface{} `json:"project_env_vars,omitempty"`
}

Nhost project structure

func (*Project) MarshalJSON

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

func (*Project) MarshalYAML

func (r *Project) MarshalYAML() ([]byte, error)

type Release

type Release struct {
	URL         string  `json:",omitempty"`
	Name        string  `json:",omitempty"`
	TagName     string  `json:"tag_name,omitempty"`
	Prerelease  bool    `json:",omitempty"`
	CreatedAt   string  `json:"created_at,omitempty"`
	PublishedAt string  `json:",omitempty"`
	Body        string  `json:",omitempty"`
	Assets      []Asset `json:",omitempty"`
}

GitHub Release API reponse structure

func GetReleases added in v0.5.7

func GetReleases() ([]Release, error)

Downloads the list of all releases from GitHub API

func SearchRelease added in v0.5.7

func SearchRelease(releases []Release, version string) (Release, error)

Seaches for required release from supplied list of releases, and returns it.

func (*Release) Asset

func (release *Release) Asset() Asset

fetches the required asset from release depending on OS and Architecture by matching download URL

func (*Release) Changes added in v0.5.7

func (r *Release) Changes(releases []Release) (string, error)

Compares and updates the changelog for specified release

func (*Release) MarshalJSON added in v0.5.7

func (r *Release) MarshalJSON() ([]byte, error)

type Required added in v0.5.9

type Required struct {
	Directories []*string
	Files       []*string
}

type Response

type Response struct {
	Project           Project `json:",omitempty"`
	User              User
	Error             Error
	Email             string `json:"email"`
	VerificationToken string `json:"verificationToken"`
	VerifiedToken     string `json:"token"`
}

Authentication validation response

type Server

type Server struct {
	ID          string
	Name        string
	CountryCode string
	City        string
}

Nhost servers structure

func Servers

func Servers() ([]Server, error)

fetches the list of Nhost production servers

type Service

type Service struct {
	Port    int         `yaml:",omitempty"`
	Version interface{} `yaml:",omitempty"`
	Image   string      `yaml:",omitempty"`
	//	AdminSecret    interface{}            `yaml:"admin_secret,omitempty"`
	Name           string                 `yaml:",omitempty"`
	Address        string                 `yaml:",omitempty"`
	ID             string                 `yaml:",omitempty"`
	Config         *container.Config      `yaml:",omitempty"`
	HostConfig     *container.HostConfig  `yaml:",omitempty"`
	HealthEndpoint string                 `yaml:"health_endpoint,omitempty"`
	Environment    map[string]interface{} `yaml:",omitempty"`

	//	If custom address is mentioned,
	//	do not launch the container
	NoContainer bool `yaml:",omitempty"`

	//  Channels are best thought of as queues (FIFO).
	//  Therefore you can't really skip around.
	//  We need a mutex to lock the service
	//  before updating it's channels.
	sync.Mutex `yaml:",omitempty"`
	Active     bool `yaml:",omitempty"`
}

Nhost config.yaml service structure

func (*Service) Activate

func (s *Service) Activate()

Sends out the activation signal to whoever is listening, or whichever resource is waiting for this signal

func (*Service) Deactivate

func (s *Service) Deactivate()

Sends out the de-activation signal to whoever is listening, or whichever resource is waiting for this signal

func (*Service) Exec

func (s *Service) Exec(docker *client.Client, ctx context.Context, command []string) (types.IDResponse, error)

func (*Service) Exists

func (s *Service) Exists(client *client.Client, ctx context.Context) string

Checks whether the service's container already exists. Returns container ID string if true.

func (*Service) Healthz

func (s *Service) Healthz() bool

func (*Service) InitConfig

func (s *Service) InitConfig()

func (*Service) Inspect

func (s *Service) Inspect(client *client.Client, ctx context.Context) error

Fetches container's configuration, mount points and host configuration, and validates them against configuration initialized by Nhost for it's respective service.

func (*Service) Logs

func (s *Service) Logs(cli *client.Client, ctx context.Context) ([]byte, error)

fetches the logs of a specific container and writes them to a log file

func (*Service) Remove

func (s *Service) Remove(client *client.Client, ctx context.Context) error

Removes given container

func (*Service) Reset

func (s *Service) Reset()

Reset the service ID, port, address and any other fields

func (*Service) Run

func (s *Service) Run(client *client.Client, ctx context.Context, networkID string) error

start a fresh container in background and connect it to specified network

func (*Service) Stop

func (s *Service) Stop(client *client.Client, ctx context.Context) error

Stops given container

type Session

type Session struct {
	Command string
	Dir     string
	Log     bool
	Browser string
}

Session struct

type Team

type Team struct {
	Name     string    `json:",omitempty"`
	ID       string    `json:",omitempty"`
	Projects []Project `json:",omitempty"`
}

type TeamData

type TeamData struct {
	Team Team `json:",omitempty"`
}

Nhost individual team structure

type User

type User struct {
	ID               string            `json:"id,omitempty"`
	Name             string            `json:"displayName,omitempty"`
	WorkspaceMembers []WorkspaceMember `json:"workspaceMembers,omitempty"`
}

Nhost user structure

type Workspace

type Workspace struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
	Apps []App  `json:"apps,omitempty"`
}

type WorkspaceMember

type WorkspaceMember struct {
	ID        string    `json:"id,omitempty"`
	Workspace Workspace `json:"workspace,omitempty"`
}

Jump to

Keyboard shortcuts

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