Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

porch: Added renderstatus to packagerevisionresources update api #3522

Merged
merged 6 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ kpt/kpt
*.exe
*.gif
bin/
**/__debug_bin

# Emacs temp files
*~
Expand Down
2 changes: 1 addition & 1 deletion commands/fn/render/cmdrender.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (r *Runner) runE(c *cobra.Command, _ []string) error {
RunnerOptions: r.RunnerOptions,
FileSystem: filesys.FileSystemOrOnDisk{},
}
if err := executor.Execute(r.ctx); err != nil {
if _, err := executor.Execute(r.ctx); err != nil {
return err
}

Expand Down
18 changes: 9 additions & 9 deletions internal/util/render/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ type Renderer struct {
}

// Execute runs a pipeline.
func (e *Renderer) Execute(ctx context.Context) error {
func (e *Renderer) Execute(ctx context.Context) (*fnresult.ResultList, error) {
const op errors.Op = "fn.render"

pr := printer.FromContextOrDie(ctx)

root, err := newPkgNode(e.FileSystem, e.PkgPath, nil)
if err != nil {
return errors.E(op, types.UniquePath(e.PkgPath), err)
return nil, errors.E(op, types.UniquePath(e.PkgPath), err)
}

// initialize hydration context
Expand All @@ -91,17 +91,17 @@ func (e *Renderer) Execute(ctx context.Context) error {
// to avoid masking the hydration error.
// don't disable the CLI output in case of error
_ = e.saveFnResults(ctx, hctx.fnResults)
return errors.E(op, root.pkg.UniquePath, err)
return hctx.fnResults, errors.E(op, root.pkg.UniquePath, err)
}

// adjust the relative paths of the resources.
err = adjustRelPath(hctx)
if err != nil {
return err
return nil, err
}

if err = trackOutputFiles(hctx); err != nil {
return err
return nil, err
}

// add metrics annotation to output resources to track the usage as the resources
Expand All @@ -122,11 +122,11 @@ func (e *Renderer) Execute(ctx context.Context) error {
}
err = pkgWriter.Write(hctx.root.resources)
if err != nil {
return fmt.Errorf("failed to save resources: %w", err)
return nil, fmt.Errorf("failed to save resources: %w", err)
}

if err = pruneResources(e.FileSystem, hctx); err != nil {
return err
return nil, err
}
pr.Printf("Successfully executed %d function(s) in %d package(s).\n", hctx.executedFunctionCnt, len(hctx.pkgs))
} else {
Expand All @@ -140,11 +140,11 @@ func (e *Renderer) Execute(ctx context.Context) error {
}
err = writer.Write(hctx.root.resources)
if err != nil {
return fmt.Errorf("failed to write resources: %w", err)
return nil, fmt.Errorf("failed to write resources: %w", err)
}
}

return e.saveFnResults(ctx, hctx.fnResults)
return hctx.fnResults, e.saveFnResults(ctx, hctx.fnResults)
}

func (e *Renderer) saveFnResults(ctx context.Context, fnResults *fnresult.ResultList) error {
Expand Down
3 changes: 2 additions & 1 deletion pkg/fn/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package fn
import (
"context"

fnresult "github.com/GoogleContainerTools/kpt/pkg/api/fnresult/v1"
"sigs.k8s.io/kustomize/kyaml/filesys"
)

Expand All @@ -26,5 +27,5 @@ type RenderOptions struct {
}

type Renderer interface {
Render(ctx context.Context, pkg filesys.FileSystem, opts RenderOptions) error
Render(ctx context.Context, pkg filesys.FileSystem, opts RenderOptions) (*fnresult.ResultList, error)
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading