-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Community Integration Bugs (#595)
* fix: Resolve an issue with manifest file names. This commit resolves an issue where the manifest file was not being written to the correct location and was overwriting the starlark source, but only in the community repo. * fix: Make the manifest filename a constant. This commit removes the ability to have a .yml ending switches all uses to be a constant. This will significantly reduce headaches down the line given there is only one file name. * community: Add load app command. This commit adds a load app command so that we can ensure that an app can load, even if it cannot render. * fix: Update checks to match community. This commit makes some of the checks a bit less aggressive with a TODO on how to make it more agressive in the future. The reason being, I'd like to get this enabled today as a drop in replacement rather then be more strict.
- Loading branch information
1 parent
40c7664
commit dac3229
Showing
7 changed files
with
74 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package community | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"strings" | ||
|
||
"github.com/spf13/cobra" | ||
"tidbyt.dev/pixlet/runtime" | ||
) | ||
|
||
var LoadAppCmd = &cobra.Command{ | ||
Use: "load-app <filespec>", | ||
Short: "Validates an app can be successfully loaded in our runtime.", | ||
Example: ` pixlet community load-app app.star`, | ||
Long: `This command ensures an app can be loaded into our runtime successfully.`, | ||
Args: cobra.ExactArgs(1), | ||
RunE: LoadApp, | ||
} | ||
|
||
func LoadApp(cmd *cobra.Command, args []string) error { | ||
script := args[0] | ||
|
||
if !strings.HasSuffix(script, ".star") { | ||
return fmt.Errorf("script file must have suffix .star: %s", script) | ||
} | ||
|
||
src, err := ioutil.ReadFile(script) | ||
if err != nil { | ||
return fmt.Errorf("failed to read file %s: %w", script, err) | ||
} | ||
runtime.InitCache(runtime.NewInMemoryCache()) | ||
|
||
applet := runtime.Applet{} | ||
err = applet.Load(script, src, nil) | ||
if err != nil { | ||
return fmt.Errorf("failed to load applet: %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
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