func NewBottleRocketConfigurator()

in credentialproviderpackage/pkg/configurator/bottlerocket/bottlerocket.go [64:92]


func NewBottleRocketConfigurator(socketPath string) (*bottleRocket, error) {
	socket, err := os.Stat(socketPath)
	if err != nil {
		return nil, err
	}
	if socket.Mode().Type() != fs.ModeSocket {
		return nil, fmt.Errorf("Unexpected type %s expected socket\n", socket.Mode().Type())
	}

	br := &bottleRocket{
		baseURL: "http://localhost/",
		client: http.Client{
			Transport: &http.Transport{
				DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
					return net.Dial("unix", socketPath)
				},
			},
		},
	}

	valid, err := br.isSupportedBRVersion()
	if err != nil {
		return nil, fmt.Errorf("error retrieving BR version %v", err)
	}
	if !valid {
		return nil, fmt.Errorf("unsupported BR version %v", err)
	}
	return br, nil
}