// Add updates Postgres connection service file at the default location with
// the connection information for the provided profile.
Add updates Postgres connection service file at the default location with
the connection information for the provided profile.
// Add updates Postgres connection service file at the default location with // the connection information for the provided profile .
func Add(cluster, name, user, database string, profile client.ProfileStatus, quiet bool) error {
	serviceFile, err := Load()
	if err != nil {
		return trace.Wrap(err)
	}
	addr, err := utils.ParseAddr(profile.ProxyURL.Host)
	if err != nil {
		return trace.Wrap(err)
	}
	connectProfile := ConnectProfile{
		Name:        serviceName(cluster, name),
		Host:        addr.Host(),
		Port:        addr.Port(defaults.HTTPListenPort),
		User:        user,
		Database:    database,
		SSLMode:     SSLModeVerifyFull, 
		SSLRootCert: profile.CACertPath(),
		SSLCert:     profile.DatabaseCertPath(name),
		SSLKey:      profile.KeyPath(),
	}
	err = serviceFile.Upsert(connectProfile)
	if err != nil {
		return trace.Wrap(err)
	}
	if quiet {
		return nil
	}
	return tshMessageTpl.Execute(os.Stdout, connectProfile)
}
func Add ( cluster , name , user , database string , profile client . ProfileStatus , quiet bool ) error { serviceFile , err := Load ( ) if err != nil { return trace . Wrap ( err ) } addr , err := utils . ParseAddr ( profile . ProxyURL . Host ) if err != nil { return trace . Wrap ( err ) } connectProfile := ConnectProfile { Name : serviceName ( cluster , name ) , Host : addr . Host ( ) , Port : addr . Port ( defaults . HTTPListenPort ) , User : user , Database : database , SSLMode : SSLModeVerifyFull , SSLRootCert : profile . CACertPath ( ) , SSLCert : profile . DatabaseCertPath ( name ) , SSLKey : profile . KeyPath ( ) , } err = serviceFile . Upsert ( connectProfile ) if err != nil { return trace . Wrap ( err ) } if quiet { return nil } return tshMessageTpl . Execute ( os . Stdout , connectProfile ) }
Add updates Postgres connection service file at the default location with
the connection information for the provided profile.
Add updates Postgres connection service file at the default location with the connection information for the provided profile .
// TODO(r0mant): Support insecure mode.