Skip to content

Commit 1fdf171

Browse files
docs(config): add godoc for the config package (#25)
1 parent b269b5e commit 1fdf171

2 files changed

Lines changed: 44 additions & 14 deletions

File tree

api/config.go

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,32 @@ type ConfigUnset struct {
1818

1919
// Config is the structure of an app's config.
2020
type Config struct {
21-
Owner string `json:"owner,omitempty"`
22-
App string `json:"app,omitempty"`
23-
Values map[string]interface{} `json:"values,omitempty"`
24-
Memory map[string]interface{} `json:"memory,omitempty"`
25-
CPU map[string]interface{} `json:"cpu,omitempty"`
21+
// Owner is the app owner. It cannot be updated with config.Set(). See app.Transfer().
22+
Owner string `json:"owner,omitempty"`
23+
// App is the app name. It cannot be updated at all right now.
24+
App string `json:"app,omitempty"`
25+
// Values are exposed as environment variables to the app.
26+
Values map[string]interface{} `json:"values,omitempty"`
27+
// Memory is used to set process memory limits. The key is the process name
28+
// and the value is a number followed by a memory unit (G, M, K, or B). Ex: 200G
29+
Memory map[string]interface{} `json:"memory,omitempty"`
30+
// CPU is used to set process CPU limits. It can be set in terms of whole CPUs
31+
// (ex 1) or in milli units to reflect the number of CPU shares (ex 500m).
32+
CPU map[string]interface{} `json:"cpu,omitempty"`
33+
// Healthchecks are the healthchecks that the application uses.
2634
Healthcheck map[string]*Healthcheck `json:"healthcheck,omitempty"`
27-
Tags map[string]interface{} `json:"tags,omitempty"`
28-
Registry map[string]interface{} `json:"registry,omitempty"`
29-
Created string `json:"created,omitempty"`
30-
Updated string `json:"updated,omitempty"`
31-
UUID string `json:"uuid,omitempty"`
35+
// Tags restrict applications to run on k8s nodes with that label.
36+
Tags map[string]interface{} `json:"tags,omitempty"`
37+
// Registry is a key-value pair to provide authentication for docker registries.
38+
// The key is the username and the value is the password.
39+
Registry map[string]interface{} `json:"registry,omitempty"`
40+
// Created is the time that the application was created and cannot be updated.
41+
Created string `json:"created,omitempty"`
42+
// Updated is the last time the configuration was changed and cannot be updated.
43+
Updated string `json:"updated,omitempty"`
44+
// UUID is a unique string reflecting the configuration in its current state.
45+
// It changes every time the configuration is changed and cannot be updated.
46+
UUID string `json:"uuid,omitempty"`
3247
}
3348

3449
// Healthcheck is the structure for an application healthcheck.
@@ -56,9 +71,13 @@ Failure Threshold: {{.FailureThreshold}}
5671
Exec Probe: {{or .Exec "N/A"}}
5772
HTTP GET Probe: {{or .HTTPGet "N/A"}}
5873
TCP Socket Probe: {{or .TCPSocket "N/A"}}`)
59-
if err != nil { panic(err) }
74+
if err != nil {
75+
panic(err)
76+
}
6077
err = tmpl.Execute(&doc, h)
61-
if err != nil { panic(err) }
78+
if err != nil {
79+
panic(err)
80+
}
6281
return doc.String()
6382
}
6483

@@ -70,7 +89,7 @@ type KVPair struct {
7089
}
7190

7291
func (k KVPair) String() string {
73-
return k.Key+"="+k.Value
92+
return k.Key + "=" + k.Value
7493
}
7594

7695
// ExecProbe executes a command within a Pod.

config/config.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package config provides methods for managing configuration of apps.
12
package config
23

34
import (
@@ -32,7 +33,17 @@ func List(c *deis.Client, app string) (api.Config, error) {
3233
return config, nil
3334
}
3435

35-
// Set sets an app's config variables.
36+
// Set sets an app's config variables and creates a new release.
37+
// This is a patching operation, which means when you call Set() with an api.Config:
38+
//
39+
// - If the variable does not exist, it will be set.
40+
// - If the variable exists, it will be overwriten.
41+
// - If the variable is set to nil, it will be unset.
42+
// - If the variable was ignored in the api.Config, it will remain unchanged.
43+
//
44+
// Calling Set() with an empty api.Config will return a deis.ErrConflict.
45+
// Trying to unset a key that does not exist returns a deis.ErrUnprocessable.
46+
// Trying to set a tag that is not a label in the kubernetes cluster will return a deis.ErrTagNotFound.
3647
func Set(c *deis.Client, app string, config api.Config) (api.Config, error) {
3748
body, err := json.Marshal(config)
3849

0 commit comments

Comments
 (0)