Skip to content

Commit

Permalink
Feature/newdata (#31)
Browse files Browse the repository at this point in the history
* Adds lagoon version

* Adds drush no core gatherer

* fixes noCoreGatherer init

---------

Co-authored-by: Blaize Kaye <blaize.kaye@amazee.io>
bomoko and Blaize Kaye authored Jun 6, 2024
1 parent 53fb28f commit e32c663
Showing 3 changed files with 62 additions and 1 deletion.
55 changes: 55 additions & 0 deletions gatherers/DrushNoCorePMLGatherer.go
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{})
}
2 changes: 1 addition & 1 deletion gatherers/DrushPMLGatherer.go
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ type drushPmlEntry struct {

func (p *drushPmlGatherer) AppliesToEnvironment() bool {

err, stdOut, stdErr := utils.Shellout("drush pml --format=json 2> /dev/null")
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
6 changes: 6 additions & 0 deletions gatherers/EnvVarGatherer.go
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ func (p *envVarGatherer) AppliesToEnvironment() bool {
var lagoonDomain = os.Getenv("LAGOON_DOMAIN")
var lagoonEnvType = os.Getenv("LAGOON_ENVIRONMENT_TYPE")
var composerVersion = os.Getenv("COMPOSER_VERSION")
var lagoonVersion = os.Getenv("LAGOON_VERSION")

envVars := map[string]envVar{
"LAGOON_DOMAIN": {
@@ -39,6 +40,11 @@ func (p *envVarGatherer) AppliesToEnvironment() bool {
Value: composerVersion,
Description: "Composer version '" + composerVersion + "' was found",
},
"LAGOON_VERSION": {
Key: "LAGOON_VERSION",
Value: lagoonVersion,
Description: "Lagoon version '" + composerVersion + "' found",
},
}

for key, element := range envVars {

0 comments on commit e32c663

Please sign in to comment.