Documentation
¶
Overview ¶
Package core contains every logic for working cli.
Index ¶
- Variables
- func CheckIsIgnored(comments []*parser.Comment, ruleName string) bool
- func GetRuleName(rule Rule) string
- func SetAllowCommentIgnores(val bool)
- type BUFConfig
- type Breaking
- type BreakingCheckConfig
- type BreakingChecker
- type Build
- type Collection
- type Config
- type Console
- type Core
- func (c *Core) BreakingCheck(ctx context.Context, workingDir, path string) ([]IssueInfo, error)
- func (c *Core) Download(ctx context.Context, dependencies []string) error
- func (c *Core) Generate(ctx context.Context, root, directory string) error
- func (c *Core) Get(ctx context.Context, requestedModule models.Module) error
- func (i *Core) Initialize(ctx context.Context, disk DirWalker, defaultLinters []string) error
- func (c *Core) Lint(ctx context.Context, fsWalker DirWalker) ([]IssueInfo, error)
- func (c *Core) Update(ctx context.Context, dependencies []string) error
- func (c *Core) Vendor(ctx context.Context) error
- type CurrentProjectGitWalker
- type DirWalker
- type Enum
- type FS
- type GitRefNotFoundError
- type Import
- type ImportPath
- type InputGitRepo
- type Inputs
- type InstructionInfo
- type InstructionParser
- type Issue
- type IssueInfo
- type Lint
- type LockFile
- type Message
- type Migrate
- type ModuleConfig
- type OneOf
- type OpenImportFileError
- type PackageName
- type Plugin
- type ProtoData
- type ProtoInfo
- type Query
- type Repo
- type Rule
- type Service
- type Storage
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidRule = errors.New("invalid rule") ErrRepositoryDoesNotExist = errors.New("repository does not exist") )
Functions ¶
func CheckIsIgnored ¶
CheckIsIgnored check if passed breakingCheckRuleName has to be ignored due to ignore command in comments
func SetAllowCommentIgnores ¶
func SetAllowCommentIgnores(val bool)
Types ¶
type BUFConfig ¶
type BUFConfig struct { Version string `yaml:"version"` Deps []string `yaml:"deps"` Build Build `yaml:"build"` Lint Lint `yaml:"lint"` Breaking Breaking `yaml:"breaking"` }
BUFConfig is the configuration for the buf tool.
type Breaking ¶
type Breaking struct { Use []string `yaml:"use"` Except []string `yaml:"except"` Ignore []string `yaml:"ignore"` IgnoreOnly map[string][]string `yaml:"ignore_only"` IgnoreUnstablePackages bool `yaml:"ignore_unstable_packages"` }
Breaking is the configuration for the breaking section of the buf tool.
type BreakingCheckConfig ¶
type BreakingChecker ¶
type BreakingChecker struct {
// contains filtered or unexported fields
}
func (*BreakingChecker) Check ¶
func (b *BreakingChecker) Check() ([]IssueInfo, error)
type Build ¶
type Build struct {
Excludes []string `yaml:"excludes"`
}
Build is the configuration for the build section of the buf tool.
type Collection ¶
type Collection struct { Imports map[ImportPath]Import Services map[string]Service // key message path - for supporting nested messages: // message MainMessage { // message NestedMessage{}; // }; // will be: MainMessage.NestedMessage Messages map[string]Message OneOfs map[string]OneOf Enums map[string]Enum }
type Console ¶
type Console interface {
RunCmd(ctx context.Context, dir string, command string, commandParams ...string) (string, error)
}
Console is provide to terminal command in console.
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core provide to business logic of EasyP.
func New ¶
func New( rules []Rule, ignore []string, deps []string, ignoreOnly map[string][]string, logger *slog.Logger, plugins []Plugin, inputs Inputs, console Console, storage Storage, moduleConfig ModuleConfig, lockFile LockFile, currentProjectGitWalker CurrentProjectGitWalker, breakingCheckConfig BreakingCheckConfig, ) *Core
func (*Core) BreakingCheck ¶
func (*Core) Download ¶
Download all packages from config dependencies slice of strings format: origin@version: github.com/company/repository@v1.2.3 if version is absent use the latest commit
func (*Core) Initialize ¶
Initialize initializes the EasyP configuration.
type CurrentProjectGitWalker ¶
type CurrentProjectGitWalker interface {
GetDirWalker(workingDir, gitRef, path string) (DirWalker, error)
}
CurrentProjectGitWalker is provider for fs walking for current project
type Enum ¶
type Enum struct { EnumPath string ProtoFilePath string PackageName PackageName *unordered.Enum }
type FS ¶
type FS interface { Open(name string) (io.ReadCloser, error) Create(name string) (io.WriteCloser, error) }
FS an interface for reading from some FS (os disk, git repo etc) and for writing to some FS
type GitRefNotFoundError ¶
type GitRefNotFoundError struct {
GitRef string
}
func (*GitRefNotFoundError) Error ¶
func (e *GitRefNotFoundError) Error() string
type ImportPath ¶
type ImportPath string
ImportPath type alias for path import in proto file
func ConvertImportPath ¶
func ConvertImportPath(source string) ImportPath
type InputGitRepo ¶
InputGitRepo is the configuration of the git repository.
type Inputs ¶
type Inputs struct { Dirs []string InputGitRepos []InputGitRepo }
Inputs is the source for generating code.
type InstructionInfo ¶
type InstructionInfo struct { PkgName PackageName Instruction string }
instructionInfo collects info about instruction in proto file e.g `google.api.http`:
`google.api` - package name 'http' - instruction name
func (InstructionInfo) GetFullName ¶
func (i InstructionInfo) GetFullName() string
type InstructionParser ¶
type InstructionParser struct {
SourcePkgName PackageName
}
parseInstruction parse input string and return its package name if passed input does not have package -> return pkgName as package name source proto file
func (InstructionParser) Parse ¶
func (p InstructionParser) Parse(input string) InstructionInfo
type Lint ¶
type Lint struct { Use []string `yaml:"use"` Except []string `yaml:"except"` Ignore []string `yaml:"ignore"` IgnoreOnly map[string][]string `yaml:"ignore_only"` AllowCommentIgnores bool `yaml:"allow_comment_ignores"` EnumZeroValueSuffix string `yaml:"enum_zero_value_suffix"` RPCAllowSameRequestResponse bool `yaml:"rpc_allow_same_request_response"` RPCAllowGoogleProtobufEmptyRequests bool `yaml:"rpc_allow_google_protobuf_empty_requests"` RPCAllowGoogleProtobufEmptyResponses bool `yaml:"rpc_allow_google_protobuf_empty_responses"` ServiceSuffix string `yaml:"service_suffix"` }
Lint is the configuration for the lint section of the buf tool.
type LockFile ¶
type LockFile interface { Read(moduleName string) (models.LockFileInfo, error) Write( moduleName string, revisionVersion string, installedPackageHash models.ModuleHash, ) error IsEmpty() bool DepsIter() iter.Seq[models.LockFileInfo] }
LockFile should implement adapter for lock file workflow
type Message ¶
type Message struct { MessagePath string ProtoFilePath string PackageName PackageName *unordered.Message }
type Migrate ¶
type Migrate struct {
BUF *BUFConfig
}
Migrate contains original configuration for the migration.
type ModuleConfig ¶
type ModuleConfig interface {
ReadFromRepo(ctx context.Context, repo repository.Repo, revision models.Revision) (models.ModuleConfig, error)
}
ModuleConfig should implement adapter for reading module configs
type OneOf ¶
type OneOf struct { OneOfPath string ProtoFilePath string PackageName PackageName *parser.Oneof }
type OpenImportFileError ¶
type OpenImportFileError struct {
FileName string
}
func (*OpenImportFileError) Error ¶
func (e *OpenImportFileError) Error() string
type PackageName ¶
type PackageName string
PackageName type alias for package name `package` section in protofile.
func GetPackageName ¶
func GetPackageName(protoFile *unordered.Proto) PackageName
type ProtoData ¶
type ProtoData map[PackageName]*Collection
collects proto data collections packageName -> services,messages etc
type ProtoInfo ¶
type ProtoInfo struct { Path string Info *unordered.Proto ProtoFilesFromImport map[ImportPath]*unordered.Proto }
ProtoInfo is the information of a proto file.
type Repo ¶
type Repo interface { // GetFiles returns list of all files in repository GetFiles(ctx context.Context, revision models.Revision, dirs ...string) ([]string, error) // ReadFile returns file's content from repository ReadFile(ctx context.Context, revision models.Revision, fileName string) (string, error) // Archive passed storage to archive and return full path to archive Archive( ctx context.Context, revision models.Revision, cacheDownloadPaths models.CacheDownloadPaths, ) error // ReadRevision reads commit's revision by passed version // or return the latest commit if version is empty ReadRevision(ctx context.Context, requestedVersion models.RequestedVersion) (models.Revision, error) // Fetch from remote repository specified version Fetch(ctx context.Context, revision models.Revision) error }
type Rule ¶
type Rule interface { // Message returns the message of the rule. Message() string // Validate validates the proto rule. Validate(ProtoInfo) ([]Issue, error) }
Rule is an interface for a rule checking.
type Service ¶
type Service struct { ProtoFilePath string PackageName PackageName *unordered.Service }
type Storage ¶
type Storage interface { CreateCacheRepositoryDir(name string) (string, error) CreateCacheDownloadDir(models.CacheDownloadPaths) error GetCacheDownloadPaths(module models.Module, revision models.Revision) models.CacheDownloadPaths Install( cacheDownloadPaths models.CacheDownloadPaths, module models.Module, revision models.Revision, moduleConfig models.ModuleConfig, ) (models.ModuleHash, error) GetInstalledModuleHash(moduleName string, revisionVersion string) (models.ModuleHash, error) IsModuleInstalled(module models.Module) (bool, error) GetInstallDir(moduleName string, revisionVersion string) string }
Storage should implement workflow with storage adapter