Skip to content

Instantly share code, notes, and snippets.

View brurucy's full-sized avatar
🎯
Focusing

Bruno Rucy Carneiro Alves de Lima brurucy

🎯
Focusing
View GitHub Profile
@brurucy
brurucy / example_8.go
Last active March 28, 2023 22:22
memoir
func TestGetSchema(t *testing.T) {
ctrl := gomock.NewController(t)
schemataRepositoryMock := NewMockSchemataRepository(ctrl)
gitRepositoryMock := NewMockGitRepository(ctrl)
somePath := "some-api.json"
actualSchema := []byte(`{...}`)
gitRepositoryMock.EXPECT().Clone(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(s storage.Storer, worktree billy.Filesystem, o *git.CloneOptions) (*git.Repository, error) {...})
someSchemaName := "some-api"
@brurucy
brurucy / example_7.go
Created February 9, 2023 21:25
memoir
package internal
import (
"github.com/go-git/go-billy/v5/memfs"
"github.com/pipedrive/pdfx/diplomat"
"github.com/pipedrive/pdfx/echo"
"github.com/pipedrive/pdfx/logger"
"github.com/pipedrive/pdfx/prometheus"
"github.com/pipedrive/pdfx/runmode"
"github.com/pipedrive/schemer/internal/repository"
@brurucy
brurucy / example_6.go
Last active February 9, 2023 21:24
memoir
func main() {
pdfx.Run(internal.Module())
}
@brurucy
brurucy / example_5.go
Last active February 9, 2023 21:31
memoir
func main() {
log := logger.New(verbose)
if err != nil { … }
rawSchemata, err := os.ReadFile(SCHEMATA_LOCATION)
if err != nil { … }
schemata := schema.Schemata{}
if err = yaml.Unmarshal(rawSchemata, &schemata); err != nil { … }
@brurucy
brurucy / example_4.go
Created February 9, 2023 21:21
memoir
fx.Run(
fx.Invoke(func(o *Obj) {
fmt.Println(“%s”, o.ToString())
}),
fx.Provide(Foo(2)),
fx.Provide(New),
fx.Provide(Bar(“two”)),
)
@brurucy
brurucy / example_3.go
Created February 9, 2023 21:21
memoir
func New(opts …Option) *Obj {
obj := new(Obj)
for _, opt := range opts {
opt(obj)
}
return obj
}
@brurucy
brurucy / example_2.go
Created February 9, 2023 21:20
memoir
type Option func(*Obj)
func Foo(foo int) Option {
return func(obj *Obj) {
obj.foo = foo
}
}
func Bar(bar string) Option {
return func(obj *Obj) {
@brurucy
brurucy / example_1.go
Created February 9, 2023 21:19
memoir
type Obj struct {
foo int
bar string
}
func (o *Obj) ToString() string {
return fmt.Sprintf(“obj: %d %s”, o.foo, o.bar)
}
@brurucy
brurucy / neodora-test.rego
Created June 30, 2022 11:06
neodora-test-snippet-example
test_deny_different_images {
imageDefinition[{
"ciImage": "node:14-alpine",
"normalImage": "php:16-alpine",
}] with input as [[{
"Cmd": "from",
"Flags": [],
"JSON": false,
"Stage": 0,
"SubCmd": "",
@brurucy
brurucy / neodora.rego
Created June 30, 2022 11:01
rego-snippet-example
imageDefinition[result] {
data.neodora.files["go.mod"] == null
ciImage := last_image_from_file(input)
normalImage := trim_suffix(last_image_from_file(data.neodora.files.Dockerfile), "-dev")
ciImage != normalImage
result = {
"ciImage": ciImage,
"normalImage": normalImage,
}
}