Skip to content

Commit

Permalink
clientsecopts: rename PGURL to MakeURLForServer
Browse files Browse the repository at this point in the history
We have enough things called "PGURL" as it is. This rename clarifies
the purpose.

Release note: None
  • Loading branch information
knz committed May 30, 2022
1 parent 2b9556e commit e96011d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pkg/cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ func runStart(cmd *cobra.Command, args []string, startSingleNode bool) (returnEr
// earlier (e.g. above, in the runStart function) because
// at this time the address and port have not been resolved yet.
clientConnOptions, serverParams := makeServerOptionsForURL(&serverCfg)
pgURL, err := clientsecopts.PGURL(clientConnOptions, serverParams, url.User(username.RootUser))
pgURL, err := clientsecopts.MakeURLForServer(clientConnOptions, serverParams, url.User(username.RootUser))
if err != nil {
log.Errorf(ctx, "failed computing the URL: %v", err)
return
Expand Down Expand Up @@ -912,7 +912,7 @@ func waitForShutdown(
return returnErr
}

// makeServerOptionsForURL creates the input for PGURL().
// makeServerOptionsForURL creates the input for MakeURLForServer().
// Beware of not calling this too early; the server address
// is finalized late in the network initialization sequence.
func makeServerOptionsForURL(
Expand Down Expand Up @@ -956,7 +956,7 @@ func reportServerInfo(
// earlier (e.g. above, in the runStart function) because
// at this time the address and port have not been resolved yet.
clientConnOptions, serverParams := makeServerOptionsForURL(serverCfg)
pgURL, err := clientsecopts.PGURL(clientConnOptions, serverParams, url.User(username.RootUser))
pgURL, err := clientsecopts.MakeURLForServer(clientConnOptions, serverParams, url.User(username.RootUser))
if err != nil {
log.Ops.Errorf(ctx, "failed computing the URL: %v", err)
return err
Expand Down
6 changes: 4 additions & 2 deletions pkg/security/clientsecopts/client_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,11 @@ type ServerParameters struct {
DefaultDatabase string
}

// PGURL constructs a URL for the postgres endpoint, given a server
// MakeURLForServer constructs a URL for the postgres endpoint, given a server
// config.
func PGURL(copts ClientOptions, sparams ServerParameters, user *url.Userinfo) (*pgurl.URL, error) {
func MakeURLForServer(
copts ClientOptions, sparams ServerParameters, user *url.Userinfo,
) (*pgurl.URL, error) {
host, port, _ := addr.SplitHostPort(sparams.ServerAddr, sparams.DefaultPort)
u := pgurl.New().
WithNet(pgurl.NetTCP(host, port)).
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/server_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ func newSQLServer(ctx context.Context, cfg sqlServerArgs) (*SQLServer, error) {
nodeInfo := sql.NodeInfo{
AdminURL: cfg.AdminURL,
PGURL: func(user *url.Userinfo) (*pgurl.URL, error) {
return clientsecopts.PGURL(ccopts, sparams, user)
return clientsecopts.MakeURLForServer(ccopts, sparams, user)
},
LogicalClusterID: cfg.rpcContext.LogicalClusterID.Get,
NodeID: cfg.nodeIDContainer,
Expand Down

0 comments on commit e96011d

Please sign in to comment.