-
Notifications
You must be signed in to change notification settings - Fork 9
Conversation
Create a POC API to ease authoring invoker buildpacks.
detect/main.go
Outdated
detected = append(detected, "java") | ||
for name := range detect.BuildPlan { | ||
if strings.HasPrefix(name, "riff-invoker-") { | ||
detected = append(detected, name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we strip the prefix here?
invoker/buildpack.go
Outdated
} | ||
|
||
if code, err := bc.detect(detect); err != nil { | ||
detect.Logger.Info(err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use something else than Info (or at least use visual cue that we're dealing with an error)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logger only exposes Debug and Info levels. It appears the newer version of libcfbuildpack support more logging levels.
invoker/buildpack.go
Outdated
build, err := build.DefaultBuild() | ||
if err != nil { | ||
_, _ = fmt.Fprintf(os.Stderr, "Failed to initialize Build: %s\n", err) | ||
os.Exit(101) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os.Exit(101) | |
os.Exit(Error_Initialize) |
invoker/buildpack.go
Outdated
} | ||
|
||
build.Logger.Info("Buildpack passed detection but did not know how to actually build. Should never happen.") | ||
return build.Failure(104), nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return build.Failure(104), nil | |
return build.Failure(Error_DetectInternalError), nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a var named Error_BuildInternalError
since this is not part of the detect phase.
invoker/buildpack.go
Outdated
build.Logger.FirstLine(build.Logger.PrettyIdentity(build.Buildpack)) | ||
|
||
if invoker, ok, err := bc.buildpack.Invoker(build); err != nil { | ||
return build.Failure(105), err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error code should be internal error I think
invoker/buildpack.go
Outdated
return build.Failure(105), err | ||
} else if ok { | ||
if err = invoker.Contribute(); err != nil { | ||
return build.Failure(106), err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem, internal error here
invoker/buildpack.go
Outdated
) | ||
|
||
type Buildpack interface { | ||
Name() string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename (or add) to Key
or something, as this is something that is tested for strict equality with ==
and is not meant to be pretty displayable (like a product name)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to Id()
Refs projectriff/riff#1093