mirror of
https://github.com/foomo/posh-providers.git
synced 2025-10-16 12:35:41 +00:00
31 lines
691 B
Go
31 lines
691 B
Go
package stackit
|
|
|
|
import (
|
|
"sort"
|
|
|
|
"github.com/pkg/errors"
|
|
"github.com/samber/lo"
|
|
)
|
|
|
|
type Config struct {
|
|
Projects map[string]Project `json:"projects" yaml:"projects"`
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ~ Public methods
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
func (c Config) ProjectNames() []string {
|
|
ret := lo.Keys(c.Projects)
|
|
sort.Strings(ret)
|
|
return ret
|
|
}
|
|
|
|
func (c Config) Project(name string) (Project, error) {
|
|
value, ok := c.Projects[name]
|
|
if !ok {
|
|
return Project{}, errors.Errorf("given project not found: %s", name)
|
|
}
|
|
return value, nil
|
|
}
|