github.com/criteo/command-launcher@v0.0.0-20230407142452-fb616f546e98/internal/repository/pkg-repository.go (about) 1 package repository 2 3 import "github.com/criteo/command-launcher/internal/command" 4 5 /* 6 PackageRepository is responsible for managing the local installed packages. 7 8 You can get the installed command from a package repository. 9 10 Note: package repository manages packages, a packages contains multiple commands. 11 */ 12 type PackageRepository interface { 13 Name() string 14 15 Install(pkg command.Package) error 16 17 Uninstall(name string) error 18 19 Update(pkg command.Package) error 20 21 InstalledPackages() []command.PackageManifest 22 23 InstalledCommands() []command.Command 24 25 InstalledGroupCommands() []command.Command 26 27 InstalledExecutableCommands() []command.Command 28 29 InstalledSystemCommands() SystemCommands 30 31 Package(name string) (command.PackageManifest, error) 32 33 // package repository doesn't resolve the the conflicts, to identify a command, we have to 34 // provide the full path of the command: repo > pkg > group > name 35 // Since we already know the repo, this Command function will take 3 parameters: 36 // pkg, group, and name 37 Command(pkg string, group string, name string) (command.Command, error) 38 39 RepositoryFolder() (string, error) 40 } 41 42 /* 43 System commands 44 */ 45 const ( 46 SYSTEM_LOGIN_COMMAND = "__login__" 47 SYSTEM_METRICS_COMMAND = "__metrics__" 48 ) 49 50 type SystemCommands struct { 51 /* 52 login hook to extend the login process 53 it is called during built-in "login" command execution 54 login command accepts two arguments 55 - arg1: username 56 - arg2: password 57 and it returns a json, contains all credentials, ex: 58 { 59 "username": "", 60 "password": "", 61 "login_token": "" 62 } 63 To reference these credentials, use environment variable: 64 COLA_LOGIN_[CREDENTIAL_NAME] 65 */ 66 Login command.Command 67 // send metrics hook 68 // it is called at the the end of the command execution 69 // the metrics command must provide following subcommands: 70 // - metrics send 71 Metrics command.Command 72 }