projectstack

package
v0.8.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	StackFile                      = "stack.yaml"
	ProjectFile                    = "project.yaml"
	CiTestDir                      = "ci-test"
	SettingsFile                   = "settings.yaml"
	StdoutGoldenFile               = "stdout.golden.yaml"
	KclFile                        = "kcl.yaml"
	KCLGenerator     GeneratorType = "KCL"
)

Variables

View Source
var (
	ErrNotStackDirectory   = errors.New("path must be a stack directory")
	ErrNotProjectDirectory = errors.New("path must be a project directory")
	ErrProjectNotUnique    = errors.New("the project obtained is not unique")
	ErrStackNotUnique      = errors.New("the stack obtained is not unique")
)

Functions

func DetectProjectAndStack

func DetectProjectAndStack(stackDir string) (project *Project, stack *Stack, err error)

DetectProjectAndStack try to get stack and project from given path

func FindProjectPath

func FindProjectPath() (string, error)

FindProjectPath locates the closest project from the current working directory, or an error if not found.

func FindProjectPathFrom

func FindProjectPathFrom(path string) (string, error)

FindProjectPathFrom locates the closest project from the given path, searching "upwards" in the directory hierarchy. If no project is found, an empty path is returned.

func FindStackPath

func FindStackPath() (string, error)

FindStackPath locates the closest stack from the current working directory, or an error if not found.

func FindStackPathFrom

func FindStackPathFrom(path string) (string, error)

FindStackPathFrom locates the closest stack from the given path, searching "upwards" in the directory hierarchy. If no stack is found, an empty path is returned.

func IsProject

func IsProject(path string) bool

IsProject determine whether the given path is Project directory

func IsProjectFile

func IsProjectFile(path string) bool

IsProjectFile determine whether the given path is Project file

func IsStack

func IsStack(path string) bool

IsStack determine whether the given path is Stack directory

func IsStackFile

func IsStackFile(path string) bool

IsStackFile determine whether the given path is Stack file

Types

type GeneratorConfig added in v0.7.4

type GeneratorConfig struct {
	Type    GeneratorType          `json:"type"`
	Configs map[string]interface{} `json:"configs,omitempty"`
}

GeneratorConfig represent Generator configs saved in project.yaml

type GeneratorType added in v0.7.4

type GeneratorType string

type Project

type Project struct {
	ProjectConfiguration `json:",inline" yaml:",inline"`
	Path                 string   `json:"path,omitempty" yaml:"path,omitempty"`     // Absolute path to the project directory
	Stacks               []*Stack `json:"stacks,omitempty" yaml:"stacks,omitempty"` // Stacks
}

func FindAllProjects

func FindAllProjects() ([]*Project, error)

FindAllProjects find all projects from the current working directory

func FindAllProjectsFrom

func FindAllProjectsFrom(path string) ([]*Project, error)

FindAllProjectsFrom find all project from the given path

func GetProject

func GetProject() (*Project, error)

GetProject get project from the current working directory

func GetProjectFrom

func GetProjectFrom(path string) (*Project, error)

GetProjectFrom get project from the given path

func NewProject

func NewProject(config *ProjectConfiguration, path string, stacks []*Stack) *Project

NewProject creates a new project

func (*Project) GetName

func (p *Project) GetName() string

GetName returns the name of the project

func (*Project) GetPath

func (p *Project) GetPath() string

GetName returns the path of the project

func (*Project) TableReport

func (p *Project) TableReport() string

TableReport returns the report string of table format

type ProjectConfiguration

type ProjectConfiguration struct {
	// Project name
	Name string `json:"name" yaml:"name"`

	// Tenant name
	Tenant string `json:"tenant,omitempty" yaml:"tenant,omitempty"`

	// Backend storage config
	Backend *backend.Storage `json:"backend,omitempty" yaml:"backend,omitempty"`

	// SpecGenerator configs
	Generator *GeneratorConfig `json:"generator,omitempty" yaml:"generator,omitempty"`

	// Secret stores
	SecretStores *vals.SecretStores `json:"secret_stores,omitempty" yaml:"secret_stores,omitempty"`
}

ProjectConfiguration is the project configuration

func ParseProjectConfiguration

func ParseProjectConfiguration(path string) (*ProjectConfiguration, error)

ParseProjectConfiguration parse the project configuration by the given directory

type Stack

type Stack struct {
	StackConfiguration `json:",inline" yaml:",inline"`
	Path               string `json:"path,omitempty" yaml:"path,omitempty"` // Absolute path to the stack directory
}

func FindAllStacks

func FindAllStacks() ([]*Stack, error)

FindAllStacks find all stacks from the current working directory

func FindAllStacksFrom

func FindAllStacksFrom(path string) ([]*Stack, error)

FindAllStacksFrom find all stacks from the given path

func GetStack

func GetStack() (*Stack, error)

GetStack get stack from the current working directory

func GetStackFrom

func GetStackFrom(path string) (*Stack, error)

GetStackFrom get stack from the given path

func NewStack

func NewStack(config *StackConfiguration, path string) *Stack

NewStack creates a new stack

func (*Stack) GetName

func (s *Stack) GetName() string

GetName returns the name of the stack

func (*Stack) GetPath

func (s *Stack) GetPath() string

GetName returns the path of the stack

func (*Stack) TableReport

func (s *Stack) TableReport() string

TableReport returns the report string of table format

type StackConfiguration

type StackConfiguration struct {
	Name string `json:"name" yaml:"name"` // Stack name
}

StackConfiguration is the stack configuration

func ParseStackConfiguration

func ParseStackConfiguration(path string) (*StackConfiguration, error)

ParseStackConfiguration parse the stack configuration by the given directory

Jump to

Keyboard shortcuts

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