github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/internal/operator/boom/api/v1beta1/grafana/grafana.go (about)

     1  package grafana
     2  
     3  import (
     4  	"github.com/caos/orbos/internal/operator/boom/api/v1beta1/grafana/admin"
     5  	"github.com/caos/orbos/internal/operator/boom/api/v1beta1/grafana/auth"
     6  	"github.com/caos/orbos/internal/operator/boom/api/v1beta1/network"
     7  	"github.com/caos/orbos/internal/operator/boom/api/v1beta1/storage"
     8  )
     9  
    10  type Grafana struct {
    11  	//Flag if tool should be deployed
    12  	//@default: false
    13  	Deploy bool `json:"deploy" yaml:"deploy"`
    14  	//Spec for the definition of the admin account
    15  	Admin *admin.Admin `json:"admin,omitempty" yaml:"admin,omitempty"`
    16  	//Spec for additional datasources
    17  	Datasources []*Datasource `json:"datasources,omitempty" yaml:"datasources,omitempty"`
    18  	//Spec for additional Dashboardproviders
    19  	DashboardProviders []*Provider `json:"dashboardproviders,omitempty" yaml:"dashboardproviders,omitempty"`
    20  	//Spec to define how the persistence should be handled
    21  	Storage *storage.Spec `json:"storage,omitempty" yaml:"storage,omitempty"`
    22  	//Network configuration, used for SSO and external access
    23  	Network *network.Network `json:"network,omitempty" yaml:"network,omitempty"`
    24  	//Authorization and Authentication configuration for SSO
    25  	Auth *auth.Auth `json:"auth,omitempty" yaml:"auth,omitempty"`
    26  	//List of plugins which get added to the grafana instance
    27  	Plugins []string `json:"plugins,omitempty" yaml:"plugins,omitempty"`
    28  	//NodeSelector for deployment
    29  	NodeSelector map[string]string `json:"nodeSelector,omitempty" yaml:"nodeSelector,omitempty"`
    30  }
    31  
    32  func (g *Grafana) InitSecrets() {
    33  	if g.Admin == nil {
    34  		g.Admin = &admin.Admin{}
    35  	}
    36  	g.Admin.InitSecrets()
    37  	if g.Auth == nil {
    38  		g.Auth = &auth.Auth{}
    39  	}
    40  	g.Auth.InitSecrets()
    41  }
    42  
    43  func (m *Grafana) IsZero() bool {
    44  	if !m.Deploy &&
    45  		(m.Admin == nil || m.Admin.IsZero()) &&
    46  		(m.Auth == nil || m.Auth.IsZero()) &&
    47  		m.Datasources == nil &&
    48  		m.DashboardProviders == nil &&
    49  		m.Storage == nil &&
    50  		m.Network == nil &&
    51  		m.Plugins == nil &&
    52  		m.NodeSelector == nil {
    53  		return true
    54  	}
    55  
    56  	return false
    57  }
    58  
    59  type Datasource struct {
    60  	//Name of the datasource
    61  	Name string `json:"name,omitempty" yaml:"name,omitempty"`
    62  	//Type of the datasource (for example prometheus)
    63  	Type string `json:"type,omitempty" yaml:"type,omitempty"`
    64  	//URL to the datasource
    65  	Url string `json:"url,omitempty" yaml:"url,omitempty"`
    66  	//Access defintion of the datasource
    67  	Access string `json:"access,omitempty" yaml:"access,omitempty"`
    68  	//Boolean if datasource should be used as default
    69  	IsDefault bool `json:"isDefault,omitempty" yaml:"isDefault,omitempty"`
    70  }
    71  
    72  type Provider struct {
    73  	//ConfigMaps in which the dashboards are stored
    74  	ConfigMaps []string `json:"configMaps,omitempty" yaml:"configMaps,omitempty"`
    75  	//Local folder in which the dashboards are mounted
    76  	Folder string `json:"folder,omitempty" yaml:"folder,omitempty"`
    77  }