Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
post plugin fixes, remove flattening until I can Phone a Friend
Browse files Browse the repository at this point in the history
  • Loading branch information
bketelsen authored and rawkode committed Sep 7, 2021
1 parent 48e0a8f commit a9322ab
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd/images/images_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (g *ImageScanner) processImages(staticDir string) error {
return err
}

g.logger.Debug("Processing", "path", path)
g.logger.Info("Processing", "path", path)
if !info.IsDir() {
buf, err := ioutil.ReadFile(path)
if err != nil {
Expand Down
7 changes: 6 additions & 1 deletion content/postplugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (s *Service) runPostPlugins() error {
if err != nil {
return err
}
prePluginMap[n] = &plugins.PostbuildPlugin{}
postPluginMap[n] = &plugins.PostbuildPlugin{}
pterm.Info.Println("Calling Plugin", n, e)
err = s.callPostPlugin(n, e)
if err != nil {
Expand All @@ -69,6 +69,7 @@ func (s *Service) callPostPlugin(name, executable string) error {
pterm.Error.Println("plugin not found in path", executable)
log.Fatal(err)
}
pterm.Info.Println("found plugin at path", executable, executablePath)
// We're a host! Start by launching the plugin process.
client := plugin.NewClient(&plugin.ClientConfig{
HandshakeConfig: shared.PostbuildHandshakeConfig,
Expand All @@ -79,12 +80,14 @@ func (s *Service) callPostPlugin(name, executable string) error {
defer client.Kill()

// Connect via RPC
log.Println("Connecting to client")
rpcClient, err := client.Client()
if err != nil {
log.Fatal(err)
}

// Request the plugin
log.Println("Getting Plugin")
raw, err := rpcClient.Dispense(name)
if err != nil {
log.Fatal(err)
Expand All @@ -93,5 +96,7 @@ func (s *Service) callPostPlugin(name, executable string) error {
// We should have a Postbuild plugin now! This feels like a normal interface
// implementation but is in fact over an RPC connection.
postplug := raw.(plugins.Postbuild)
log.Println("Making the call")
log.Println(s.rawConfig)
return postplug.Process(s.rawConfig)
}
6 changes: 6 additions & 0 deletions content/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,11 @@ func (s *Service) RenderAndSave() error {
}

pterm.Success.Printf("Data blox written to '%s'\n", filePath)

pterm.Info.Println("Running Postbuild Plugins")
err = s.runPostPlugins()
if err != nil {
return err
}
return nil
}
5 changes: 1 addition & 4 deletions content/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func (s *Service) build() error {
return err
}

pterm.Info.Println("Running Prebuild Plugins")
err = s.runPrePlugins()
if err != nil {
return err
Expand Down Expand Up @@ -210,10 +211,6 @@ func (s *Service) build() error {

pterm.Success.Println("Validation Complete")
s.built = true
err = s.runPostPlugins()
if err != nil {
return err
}
return nil
}

Expand Down
15 changes: 9 additions & 6 deletions internal/cuedb/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,17 +431,19 @@ func (r *Engine) GetOutput() (cue.Value, error) {
r.Database = r.Database.FillPath(cue.Path{}, inst.Value())

// begin flattening
if true { // TODO: flag later
err := r.flatten(dataSet)
if err != nil {
fmt.Println(err)
/* if true { // TODO: flag later
err := r.flatten(dataSet)
if err != nil {
fmt.Println(err)
}
}
}
// end flattening
// end flattening
*/
}
return r.Database.LookupPath(cue.ParsePath("output")), nil
}

/*
func (r *Engine) flatten(d DataSet) error {
for _, rel := range d.relationships {
Expand All @@ -468,3 +470,4 @@ func (r *Engine) flatten(d DataSet) error {
}
return nil
}
*/

0 comments on commit a9322ab

Please sign in to comment.