Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
urso committed Jun 29, 2021
1 parent 2bc9dae commit 77c3981
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions x-pack/elastic-agent/pkg/agent/cmd/enroll_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,14 @@ func (c *enrollCmd) fleetServerBootstrap(ctx context.Context) (string, error) {
return "", err
}

localFleetServer := c.options.FleetServer.ConnStr != ""
proxyDisabled := c.options.FleetServer.ProxyDisabled || localFleetServer

fleetConfig, err := createFleetServerBootstrapConfig(
c.options.FleetServer.ConnStr, c.options.FleetServer.ServiceToken,
c.options.FleetServer.PolicyID,
c.options.FleetServer.Host, c.options.FleetServer.Port,
c.options.FleetServer.Cert, c.options.FleetServer.CertKey, c.options.FleetServer.ElasticsearchCA,
c.options.FleetServer.Headers,
c.options.FleetServer.ProxyURL,
proxyDisabled,
c.options.FleetServer.ProxyDisabled,
c.options.FleetServer.ProxyHeaders,
)
if err != nil {
Expand Down Expand Up @@ -465,7 +462,8 @@ func (c *enrollCmd) enroll(ctx context.Context, persistentConfig map[string]inte
return err
}

if c.options.FleetServer.ConnStr != "" {
localFleetServer := c.options.FleetServer.ConnStr != ""
if localFleetServer {
serverConfig, err := createFleetServerBootstrapConfig(
c.options.FleetServer.ConnStr, c.options.FleetServer.ServiceToken,
c.options.FleetServer.PolicyID,
Expand Down Expand Up @@ -776,6 +774,8 @@ func createFleetServerBootstrapConfig(
proxyDisabled bool,
proxyHeaders map[string]string,
) (*configuration.FleetAgentConfig, error) {
localFleetServer := connStr != ""

es, err := configuration.ElasticsearchFromConnStr(connStr, serviceToken)
if err != nil {
return nil, err
Expand Down Expand Up @@ -826,6 +826,10 @@ func createFleetServerBootstrapConfig(
}
}

if localFleetServer {
cfg.Client.Transport.Proxy.Disable = true
}

if err := cfg.Valid(); err != nil {
return nil, errors.New(err, "invalid enrollment options", errors.TypeConfig)
}
Expand Down

0 comments on commit 77c3981

Please sign in to comment.