1+ // Package certs manages SSL keys and certificates on the deis platform
12package certs
23
34import (
@@ -10,7 +11,7 @@ import (
1011 "github.com/deis/controller-sdk-go/api"
1112)
1213
13- // List certs registered with the controller .
14+ // List lists certificates added to deis .
1415func List (c * deis.Client , results int ) ([]api.Cert , int , error ) {
1516 body , count , err := c .LimitedRequest ("/v2/certs/" , results )
1617
@@ -26,7 +27,10 @@ func List(c *deis.Client, results int) ([]api.Cert, int, error) {
2627 return res , count , nil
2728}
2829
29- // New creates a cert.
30+ // New creates a new certificate.
31+ // Certificates are created independently from apps and are applied on a per domain basis.
32+ // So to enable SSL for an app with the domain test.com, you would first create the certificate,
33+ // then use the attach method to attach test.com to the certificate.
3034func New (c * deis.Client , cert string , key string , name string ) (api.Cert , error ) {
3135 req := api.CertCreateRequest {Certificate : cert , Key : key , Name : name }
3236 reqBody , err := json .Marshal (req )
@@ -52,7 +56,7 @@ func New(c *deis.Client, cert string, key string, name string) (api.Cert, error)
5256 return resCert , reqErr
5357}
5458
55- // Get information for a certificate
59+ // Get retrieves information about a certificate
5660func Get (c * deis.Client , name string ) (api.Cert , error ) {
5761 url := fmt .Sprintf ("/v2/certs/%s" , name )
5862 res , reqErr := c .Request ("GET" , url , nil )
@@ -73,7 +77,7 @@ func Get(c *deis.Client, name string) (api.Cert, error) {
7377 return resCert , reqErr
7478}
7579
76- // Delete removes a cert .
80+ // Delete removes a certificate .
7781func Delete (c * deis.Client , name string ) error {
7882 url := fmt .Sprintf ("/v2/certs/%s" , name )
7983 res , err := c .Request ("DELETE" , url , nil )
@@ -83,7 +87,7 @@ func Delete(c *deis.Client, name string) error {
8387 return err
8488}
8589
86- // Attach a certificate to a domain
90+ // Attach adds a domain to a certificate.
8791func Attach (c * deis.Client , name string , domain string ) error {
8892 req := api.CertAttachRequest {Domain : domain }
8993 reqBody , err := json .Marshal (req )
@@ -99,7 +103,7 @@ func Attach(c *deis.Client, name string, domain string) error {
99103 return err
100104}
101105
102- // Detach a certificate from a domain
106+ // Detach removes a domain from a certificate.
103107func Detach (c * deis.Client , name string , domain string ) error {
104108 url := fmt .Sprintf ("/v2/certs/%s/domain/%s" , name , domain )
105109 res , err := c .Request ("DELETE" , url , nil )
0 commit comments