-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com>
- Loading branch information
Showing
11 changed files
with
333 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "hooks", | ||
srcs = ["hooks.go"], | ||
importpath = "aspect.build/cli/pkg/hooks", | ||
visibility = ["//visibility:public"], | ||
deps = ["//pkg/aspecterrors"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
Copyright © 2021 Aspect Build Systems Inc | ||
Not licensed for re-use. | ||
*/ | ||
|
||
package hooks | ||
|
||
import ( | ||
"context" | ||
|
||
"aspect.build/cli/pkg/aspecterrors" | ||
) | ||
|
||
type Hooks struct { | ||
postBuild *hookList | ||
} | ||
|
||
func New() *Hooks { | ||
return &Hooks{ | ||
postBuild: &hookList{}, | ||
} | ||
} | ||
|
||
func (hooks *Hooks) RegisterPostBuild(fn PostBuildFn) { | ||
hooks.postBuild.insert(fn) | ||
} | ||
|
||
func (hooks *Hooks) ExecutePostBuild(ctx context.Context) *aspecterrors.ErrorList { | ||
errors := &aspecterrors.ErrorList{} | ||
node := hooks.postBuild.head | ||
for node != nil { | ||
if err := node.fn.(PostBuildFn)(ctx); err != nil { | ||
errors.Insert(err) | ||
} | ||
node = node.next | ||
} | ||
return errors | ||
} | ||
|
||
type PostBuildFn func(ctx context.Context) error | ||
|
||
type hookList struct { | ||
head *hookNode | ||
tail *hookNode | ||
} | ||
|
||
func (l *hookList) insert(fn interface{}) { | ||
node := &hookNode{fn: fn} | ||
if l.head == nil { | ||
l.head = node | ||
} else { | ||
l.tail.next = node | ||
} | ||
l.tail = node | ||
} | ||
|
||
type hookNode struct { | ||
next *hookNode | ||
fn interface{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "fix_visibility", | ||
srcs = ["plugin.go"], | ||
importpath = "aspect.build/cli/pkg/plugins/fix_visibility", | ||
visibility = ["//pkg/aspect/build:__pkg__"], | ||
deps = [ | ||
"@bazel_gazelle//label:go_default_library", | ||
"@go_googleapis//google/devtools/build/v1:build_go_proto", | ||
], | ||
) |
Oops, something went wrong.