Skip to content

Commit

Permalink
Merge branch 'master' into vsphere
Browse files Browse the repository at this point in the history
  • Loading branch information
rawmind0 authored Dec 4, 2019
2 parents cefaccc + cfc6d45 commit 951be94
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
27 changes: 27 additions & 0 deletions rancher2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,31 @@ type Config struct {
Bootstrap bool `json:"bootstrap"`
ClusterID string `json:"clusterId"`
ProjectID string `json:"projectId"`
Version string
Sync sync.Mutex
Client Client
}

// GetRancherVersion get Rancher server version
func (c *Config) GetRancherVersion() (string, error) {
if len(c.Version) > 0 {
return c.Version, nil
}

client, err := c.ManagementClient()
if err != nil {
return "", fmt.Errorf("[ERROR] Getting Rancher version: %s", err)
}

version, err := client.Setting.ByID("server-version")
if err != nil {
return "", fmt.Errorf("[ERROR] Getting Rancher version: %s", err)
}
c.Version = version.Value

return c.Version, nil
}

// UpdateToken update tokenkey and restart client connections
func (c *Config) UpdateToken(token string) error {
if len(token) == 0 {
Expand Down Expand Up @@ -85,6 +106,12 @@ func (c *Config) ManagementClient() (*managementClient.Client, error) {
}
c.Client.Management = mClient

version, err := mClient.Setting.ByID("server-version")
if err != nil {
return nil, err
}
c.Version = version.Value

return c.Client.Management, nil
}

Expand Down
2 changes: 2 additions & 0 deletions rancher2/schema_alert_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const (
metricRuleComparisonLessOrEqual = "less-or-equal"
metricRuleComparisonLessThan = "less-than"
metricRuleComparisonNotEqual = "not-equal"
metricRuleComparisonNotNull = "has-value"
nodeRuleConditionCPU = "cpu"
nodeRuleConditionMem = "mem"
nodeRuleConditionNotReady = "notready"
Expand Down Expand Up @@ -50,6 +51,7 @@ var (
metricRuleComparisonLessOrEqual,
metricRuleComparisonLessThan,
metricRuleComparisonNotEqual,
metricRuleComparisonNotNull,
}
nodeRuleConditions = []string{
nodeRuleConditionCPU,
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/clusterAlertRule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ The following attributes are exported:
* `duration` - (Required) Metric rule duration (string)
* `expression` - (Required) Metric rule expression (string)
* `threshold_value` - (Required) Metric rule threshold value (float64)
* `comparison` - (Optional) Metric rule comparison. Supported values : `"equal" | "greater-or-equal" | "greater-than" | "less-or-equal" | "less-than" | "not-equal"`. Default: `equal` (string)
* `comparison` - (Optional) Metric rule comparison. Supported values : `"equal" | "greater-or-equal" | "greater-than" | "less-or-equal" | "less-than" | "not-equal" | "has-value"`. Default: `equal` (string)
* `description` - (Optional) Metric rule description (string)

### `node_rule`
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/projectAlertRule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ The following attributes are exported:
* `duration` - (Required) Metric rule duration (string)
* `expression` - (Required) Metric rule expression (string)
* `threshold_value` - (Required) Metric rule threshold value (float64)
* `comparison` - (Optional) Metric rule comparison. Supported values : `"equal" | "greater-or-equal" | "greater-than" | "less-or-equal" | "less-than" | "not-equal"`. Default: `equal` (string)
* `comparison` - (Optional) Metric rule comparison. Supported values : `"equal" | "greater-or-equal" | "greater-than" | "less-or-equal" | "less-than" | "not-equal" | "has-value"`. Default: `equal` (string)
* `description` - (Optional) Metric rule description (string)

### `pod_rule`
Expand Down

0 comments on commit 951be94

Please sign in to comment.