Implement blackbox in Golang (#250)

* Initial release
This commit is contained in:
Tom Limoncelli
2020-07-24 14:21:33 -04:00
committed by GitHub
parent e049c02655
commit 1c77c87555
86 changed files with 6074 additions and 22 deletions

15
models/crypters.go Normal file
View File

@@ -0,0 +1,15 @@
package models
// Crypter is gpg binaries, go-opengpg, etc.
type Crypter interface {
// Name returns the plug-in's canonical name.
Name() string
// Decrypt name+".gpg", possibly overwriting name.
Decrypt(filename string, umask int, overwrite bool) error
// Encrypt name, overwriting name+".gpg"
Encrypt(filename string, umask int, receivers []string) (string, error)
// Cat outputs a file, unencrypting if needed.
Cat(filename string) ([]byte, error)
// AddNewKey extracts keyname from sourcedir's GnuPG chain to destdir keychain.
AddNewKey(keyname, repobasename, sourcedir, destdir string) ([]string, error)
}

30
models/vcs.go Normal file
View File

@@ -0,0 +1,30 @@
package models
import "github.com/StackExchange/blackbox/v2/pkg/commitlater"
// Vcs is git/hg/etc.
type Vcs interface {
// Name returns the plug-in's canonical name.
Name() string
// Discover returns true if we are a repo of this type; along with the Abs path to the repo root (or "" if we don't know).
Discover() (bool, string)
// SetFileTypeUnix informs the VCS that files should maintain unix-style line endings.
SetFileTypeUnix(repobasedir string, files ...string) error
// IgnoreAnywhere tells the VCS to ignore these files anywhere in the repo.
IgnoreAnywhere(repobasedir string, files []string) error
// IgnoreAnywhere tells the VCS to ignore these files, rooted in the base of the repo.
IgnoreFiles(repobasedir string, files []string) error
// CommitTitle sets the title of the next commit.
CommitTitle(title string)
// NeedsCommit queues up commits for later execution.
NeedsCommit(message string, repobasedir string, names []string)
// DebugCommits dumps a list of future commits.
DebugCommits() commitlater.List
// FlushCommits informs the VCS to do queued up commits.
FlushCommits() error
// TestingInitRepo initializes a repo of this type (for use by integration tests)
TestingInitRepo() error
}