Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow creating certificate authorities #2001

Merged
merged 1 commit into from
Jun 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tool/tctl/common/resource_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func (g *ResourceCommand) Initialize(app *kingpin.Application, config *service.C
services.KindUser: g.createUser,
services.KindTrustedCluster: g.createTrustedCluster,
services.KindGithubConnector: g.createGithubConnector,
services.KindCertAuthority: g.createCertAuthority,
}
g.config = config

Expand Down Expand Up @@ -213,6 +214,19 @@ func (u *ResourceCommand) createTrustedCluster(client auth.ClientI, raw services
return nil
}

// createCertAuthority creates certificate authority
func (u *ResourceCommand) createCertAuthority(client auth.ClientI, raw services.UnknownResource) error {
certAuthority, err := services.GetCertAuthorityMarshaler().UnmarshalCertAuthority(raw.Raw)
if err != nil {
return trace.Wrap(err)
}
if err := client.UpsertCertAuthority(certAuthority); err != nil {
Copy link
Contributor

@russjones russjones Jun 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this does a upsert and not create it's a pretty serious operation with which you can accidentally take down your entire cluster. We should probably prompt the user with something like before continuing.

Warning: Updating your certificate authorities can potentially put your
cluster in a unrecoverable state. Make sure you backup all Teleport state
and export your existing certificate authorities before you continue.

Are you sure you want to proceed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't have this flow anywhere, so I would let them do this on their own risk.

return trace.Wrap(err)
}
fmt.Printf("certificate authority '%s' has been updated\n", certAuthority.GetName())
return nil
}

func (u *ResourceCommand) createGithubConnector(client auth.ClientI, raw services.UnknownResource) error {
connector, err := services.GetGithubConnectorMarshaler().Unmarshal(raw.Raw)
if err != nil {
Expand Down