func NewLustreService()

in pkg/cloud_provider/lustre/lustre.go [99:124]


func NewLustreService(ctx context.Context, client *http.Client, version, endpoint string) (Service, error) {
	endpointMap := map[string]string{
		autopush: autopushEndpoint,
		staging:  stagingEndpoint,
		prod:     prodEndpoint,
	}
	address, exists := endpointMap[endpoint]
	if !exists {
		return nil, fmt.Errorf("invalid lustre API endpoint %q. Supported endpoints are autopush, staging, or prod", endpoint)
	}

	opts := []option.ClientOption{
		option.WithHTTPClient(client),
		option.WithEndpoint(address),
		option.WithUserAgent(fmt.Sprintf("Lustre CSI Driver/%s (%s %s)", version, runtime.GOOS, runtime.GOARCH)),
	}
	lustreClient, err := lustre.NewRESTClient(ctx, opts...)
	if err != nil {
		return nil, err
	}
	klog.Infof("Using %s endpoint %q for lustre service", endpoint, address)

	return &lustreServiceManager{
		lustreClient: lustreClient,
	}, nil
}