-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds lagoon version * Adds drush no core gatherer * fixes noCoreGatherer init --------- Co-authored-by: Blaize Kaye <blaize.kaye@amazee.io>
Showing
3 changed files
with
62 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package gatherers | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"log" | ||
|
||
"github.com/uselagoon/lagoon-facts-app/utils" | ||
) | ||
|
||
type drushPmlNoCoreGatherer struct { | ||
GatheredFacts []GatheredFact | ||
} | ||
|
||
func (p *drushPmlNoCoreGatherer) GetGathererCmdType() string { | ||
return GATHERER_TYPE_STATIC | ||
} | ||
|
||
func (p *drushPmlNoCoreGatherer) AppliesToEnvironment() bool { | ||
|
||
err, stdOut, stdErr := utils.Shellout("drush pml --no-core --format=json 2> /dev/null") | ||
if err != nil { | ||
log.Printf("Drush pml gatherer cannot be applied: %v", stdErr) | ||
return false | ||
} | ||
|
||
var result map[string]drushPmlEntry | ||
|
||
if err = json.Unmarshal([]byte(stdOut), &result); err != nil { | ||
log.Println(err.Error()) | ||
return false | ||
} | ||
|
||
for key, element := range result { | ||
if element.Version != nil { | ||
p.GatheredFacts = append(p.GatheredFacts, GatheredFact{ | ||
Name: key, | ||
Value: fmt.Sprintf("%v", element.Version), | ||
Source: "drush_pml_nocore", | ||
Description: "Status: " + element.Status, | ||
Category: Drupal, | ||
}) | ||
} | ||
} | ||
|
||
return true | ||
} | ||
|
||
func (p *drushPmlNoCoreGatherer) GatherFacts() ([]GatheredFact, error) { | ||
return p.GatheredFacts, nil | ||
} | ||
|
||
func init() { | ||
RegisterGatherer("Drupal no-core Module List Gatherer", &drushPmlNoCoreGatherer{}) | ||
} |
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