Skip to content

Commit d2d39a3

Browse files
authored
Allow to create an SSL certificate with a specific key type (#4)
* Allow to create an SSL certificate with a specific key type
1 parent c5cc601 commit d2d39a3

File tree

1,208 files changed

+252346
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,208 files changed

+252346
-5
lines changed

go.mod

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
module github.com/swisscom/appcloud-cf-cli-plugin
2+
3+
go 1.17
4+
5+
require (
6+
code.cloudfoundry.org/cli v7.1.0+incompatible
7+
github.com/pkg/errors v0.9.1
8+
)
9+
10+
require (
11+
code.cloudfoundry.org/bytefmt v0.0.0-20211005130812-5bb3c17173e5 // indirect
12+
code.cloudfoundry.org/cli-plugin-repo v0.0.0-20211108170549-31c720a1b03c // indirect
13+
code.cloudfoundry.org/go-log-cache v1.0.0 // indirect
14+
code.cloudfoundry.org/go-loggregator v7.4.0+incompatible // indirect
15+
code.cloudfoundry.org/gofileutils v0.0.0-20170111115228-4d0c80011a0f // indirect
16+
code.cloudfoundry.org/jsonry v1.1.3 // indirect
17+
code.cloudfoundry.org/rfc5424 v0.0.0-20201103192249-000122071b78 // indirect
18+
code.cloudfoundry.org/tlsconfig v0.0.0-20211123175040-23cc9f05b6b3 // indirect
19+
code.cloudfoundry.org/ykk v0.0.0-20170424192843-e4df4ce2fd4d // indirect
20+
github.com/SermoDigital/jose v0.9.1 // indirect
21+
github.com/blang/semver v3.5.1+incompatible // indirect
22+
github.com/bmatcuk/doublestar v1.3.4 // indirect
23+
github.com/bmizerany/pat v0.0.0-20210406213842-e4b6760bdd6f // indirect
24+
github.com/charlievieth/fs v0.0.2 // indirect
25+
github.com/cloudfoundry/bosh-cli v6.4.1+incompatible // indirect
26+
github.com/cloudfoundry/bosh-utils v0.0.291 // indirect
27+
github.com/cppforlife/go-patch v0.2.0 // indirect
28+
github.com/creack/pty v1.1.11 // indirect
29+
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
30+
github.com/fatih/color v1.13.0 // indirect
31+
github.com/google/go-querystring v1.1.0 // indirect
32+
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
33+
github.com/jessevdk/go-flags v1.5.0 // indirect
34+
github.com/kr/pty v1.1.8 // indirect
35+
github.com/kr/text v0.1.0 // indirect
36+
github.com/lunixbochs/vtclean v1.0.0 // indirect
37+
github.com/mattn/go-colorable v0.1.9 // indirect
38+
github.com/mattn/go-isatty v0.0.14 // indirect
39+
github.com/mattn/go-runewidth v0.0.13 // indirect
40+
github.com/moby/moby v20.10.11+incompatible // indirect
41+
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
42+
github.com/rivo/uniseg v0.2.0 // indirect
43+
github.com/rogpeppe/go-internal v1.8.0 // indirect
44+
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect
45+
github.com/sirupsen/logrus v1.8.1 // indirect
46+
github.com/tedsuo/rata v1.0.0 // indirect
47+
github.com/vito/go-interact v1.0.0 // indirect
48+
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 // indirect
49+
golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1 // indirect
50+
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
51+
golang.org/x/text v0.3.7 // indirect
52+
google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1 // indirect
53+
google.golang.org/grpc v1.42.0 // indirect
54+
google.golang.org/protobuf v1.27.1 // indirect
55+
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
56+
gopkg.in/cheggaaa/pb.v1 v1.0.28 // indirect
57+
gopkg.in/yaml.v2 v2.4.0 // indirect
58+
)

go.sum

Lines changed: 319 additions & 0 deletions
Large diffs are not rendered by default.

internal/appcloud/appcloud.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,10 @@ func (p *Plugin) GetMetadata() plugin.PluginMetadata {
155155
Name: "create-ssl-certificate",
156156
HelpText: "Create and enable an SSL certificate for a route",
157157
UsageDetails: plugin.Usage{
158-
Usage: "create-ssl-certificate DOMAIN [--hostname HOSTNAME]",
158+
Usage: "create-ssl-certificate DOMAIN [--hostname HOSTNAME] [--key-type KEY_TYPE]",
159159
Options: map[string]string{
160160
"-hostname, -n": "Hostname for the HTTP route",
161+
"-key-type, -kt": "Key type for the certificate (e.g. RSA, ECDSA)",
161162
},
162163
},
163164
},
@@ -357,11 +358,11 @@ func (p *Plugin) Run(cliConnection plugin.CliConnection, args []string) {
357358
var fc flags.FlagContext
358359
fc, err = parseSSLCertificateArgs(args)
359360
if err != nil {
360-
p.ui.Say("Incorrect Usage: Organization option must be a string")
361+
p.ui.Say(err.Error())
361362
return
362363
}
363364

364-
err = p.CreateSSLCertificate(cliConnection, args[1], fc.String("hostname"))
365+
err = p.CreateSSLCertificate(cliConnection, args[1], fc.String("hostname"), fc.String("key-type"))
365366
case "revoke-ssl-certificate":
366367
if len(args) < 2 {
367368
p.ui.Say("Incorrect Usage: the required argument DOMAIN was not provided")
@@ -447,10 +448,11 @@ func (p *Plugin) Run(cliConnection plugin.CliConnection, args []string) {
447448
}
448449
}
449450

450-
// parseSSLCertificateArgs parses the arguments passed to a ssl certificate command.
451+
// parseSSLCertificateArgs parses the arguments passed to an ssl certificate command.
451452
func parseSSLCertificateArgs(args []string) (flags.FlagContext, error) {
452453
fc := flags.New()
453454
fc.NewStringFlag("hostname", "n", "Hostname for the HTTP route")
455+
fc.NewStringFlag("key-type", "kt", "Key type for the certificate")
454456
err := fc.Parse(args...)
455457
if err != nil {
456458
return nil, err

internal/appcloud/create_ssl_certificate.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
// CreateSSLCertificate creates a new SSL certificate for an FQDN.
14-
func (p *Plugin) CreateSSLCertificate(c plugin.CliConnection, domain string, hostname string) error {
14+
func (p *Plugin) CreateSSLCertificate(c plugin.CliConnection, domain string, hostname string, keyType string) error {
1515
un, err := c.Username()
1616
if err != nil {
1717
return errors.Wrap(err, "Couldn't get your username")
@@ -32,6 +32,7 @@ func (p *Plugin) CreateSSLCertificate(c plugin.CliConnection, domain string, hos
3232
req := SSLCertificateRequest{
3333
SpaceID: s.Guid,
3434
FullDomainName: fullDomain,
35+
KeyType: keyType,
3536
}
3637
reqData, err := json.Marshal(req)
3738
if err != nil {

internal/appcloud/ssl_certificate.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type SSLCertificate struct {
1313
type SSLCertificateRequest struct {
1414
SpaceID string `json:"space_id"`
1515
FullDomainName string `json:"full_domain_name"`
16+
KeyType string `json:"key_type,omitempty"`
1617
}
1718

1819
// SSLCertificateResponse is the response from the server from a create certificate call

vendor/code.cloudfoundry.org/bytefmt/LICENSE

Lines changed: 201 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/code.cloudfoundry.org/bytefmt/NOTICE

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/code.cloudfoundry.org/bytefmt/README.md

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)