-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'pre/v1' into v1/archive
- Loading branch information
Showing
7 changed files
with
99 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package lambroll | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
) | ||
|
||
type RenderOption struct { | ||
Jsonnet bool `default:"false" help:"render function.json as jsonnet"` | ||
} | ||
|
||
// Invoke invokes function | ||
func (app *App) Render(ctx context.Context, opt RenderOption) error { | ||
fn, err := app.loadFunction(app.functionFilePath) | ||
if err != nil { | ||
return fmt.Errorf("failed to load function: %w", err) | ||
} | ||
b, err := marshalJSON(fn) | ||
if err != nil { | ||
return fmt.Errorf("failed to marshal function: %w", err) | ||
} | ||
if opt.Jsonnet { | ||
b, err = jsonToJsonnet(b, app.functionFilePath) | ||
if err != nil { | ||
return fmt.Errorf("failed to render function.json as jsonnet: %w", err) | ||
} | ||
} | ||
if _, err := os.Stdout.Write(b); err != nil { | ||
return fmt.Errorf("failed to write function.json: %w", err) | ||
} | ||
return nil | ||
} |
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