<commit_before>package volumeplugin

import (
	"encoding/json"
	"fmt"

	"github.com/Sirupsen/logrus"
	"github.com/docker/go-plugins-helpers/volume"
	"github.com/pkg/errors"
	"github.com/rancher/go-rancher-metadata/metadata"
	"github.com/rancher/go-rancher/v2"
)

const (
	metadataURL = "http://169.254.169.250/2015-12-19"
)

var goodStates = map[string]bool{
	"active":       true,
	"activating":   true,
	"deactivating": true,
	"detached":     true,
	"removing":     true,
}

type RancherState struct {
	client   *client.RancherClient
	driver   string
	hostID   string
	driverID string
}

func NewRancherState(driver string, client *client.RancherClient) (*RancherState, error) {
	host, err := getHostID(client)
	if err != nil {
		return nil, errors.Wrap(err, "getting host ID")
	}
	driverID, err := getDriverID(driver, client)
	if err != nil {
		return nil, errors.Wrap(err, "getting host ID")
	}

	logrus.Infof("Running on host %s(%s) with driver %s(%s)", host.Hostname, host.Id, driver, driverID)
	return &RancherState{
		client:   client,
		driver:   driver,
		hostID:   host.Id,
		driverID: driverID,
	}, nil
}

func (r *RancherState) IsCreated(name string) (bool, error) {
	_, _, err := r.Get(name)
	if err == errNoSuchVolume {
		return false, nil
	}
	if err != nil {<commit_msg>Fix error message when getting driver ID<commit_after>package volumeplugin

import (
	"encoding/json"
	"fmt"

	"github.com/Sirupsen/logrus"
	"github.com/docker/go-plugins-helpers/volume"
	"github.com/pkg/errors"
	"github.com/rancher/go-rancher-metadata/metadata"
	"github.com/rancher/go-rancher/v2"
)

const (
	metadataURL = "http://169.254.169.250/2015-12-19"
)

var goodStates = map[string]bool{
	"active":       true,
	"activating":   true,
	"deactivating": true,
	"detached":     true,
	"removing":     true,
}

type RancherState struct {
	client   *client.RancherClient
	driver   string
	hostID   string
	driverID string
}

func NewRancherState(driver string, client *client.RancherClient) (*RancherState, error) {
	host, err := getHostID(client)
	if err != nil {
		return nil, errors.Wrap(err, "getting host ID")
	}
	driverID, err := getDriverID(driver, client)
	if err != nil {
		return nil, errors.Wrap(err, "getting driver ID")
	}

	logrus.Infof("Running on host %s(%s) with driver %s(%s)", host.Hostname, host.Id, driver, driverID)
	return &RancherState{
		client:   client,
		driver:   driver,
		hostID:   host.Id,
		driverID: driverID,
	}, nil
}

func (r *RancherState) IsCreated(name string) (bool, error) {
	_, _, err := r.Get(name)
	if err == errNoSuchVolume {
		return false, nil
	}
	if err != nil {
{'fraction_non_alphanumeric': 0.14302191464821223, 'fraction_numerical': 0.016147635524798153, 'mean_word_length': 3.975143403441683, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6862672', 'n_tokens_mistral': 1037, 'n_tokens_neox': 988, 'n_words': 224}