<commit_before>// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

// +build go1.3

package lxd

import (
	"github.com/juju/errors"

	"github.com/juju/juju/container/lxd/lxdclient"
	"github.com/juju/juju/provider/common"
)

type rawProvider struct {
	lxdInstances
	lxdProfiles
	common.Firewaller
	policyProvider
}

type lxdInstances interface {
	Instances(string, ...string) ([]lxdclient.Instance, error)
	AddInstance(lxdclient.InstanceSpec) (*lxdclient.Instance, error)
	RemoveInstances(string, ...string) error
}

type lxdProfiles interface {
	CreateProfile(string, map[string]string) error
	HasProfile(string) (bool, error)
}

func newRawProvider(ecfg *environConfig) (*rawProvider, error) {
	client, err := newClient(ecfg)
	if err != nil {
		return nil, errors.Trace(err)
	}

	firewaller, err := newFirewaller(ecfg)
	if err != nil {
		return nil, errors.Trace(err)
	}

	policy := &lxdPolicyProvider{}

	raw := &rawProvider{
		lxdInstances:   client,
		lxdProfiles:    client,
		Firewaller:     firewaller,
		policyProvider: policy,
	}
	return raw, nil
}

func newClient(ecfg *environConfig) (*lxdclient.Client, error) {
	clientCfg, err := ecfg.clientConfig()
	if err != nil {
		return nil, errors.Trace(err)
	}

	if err := clientCfg.Write(); err != nil {
		return nil, errors.Trace(err)
	}

	client, err := lxdclient.Connect(clientCfg)
	if err != nil {

		return nil, errors.Trace(err)
	}

	return client, nil
}

func newFirewaller(ecfg *environConfig) (common.Firewaller, error) {
	return common.NewFirewaller(), nil
}<commit_msg>touch up<commit_after>// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

// +build go1.3

package lxd

import (
	"github.com/juju/errors"

	"github.com/juju/juju/container/lxd/lxdclient"
	"github.com/juju/juju/provider/common"
)

type rawProvider struct {
	lxdInstances
	lxdProfiles
	common.Firewaller
	policyProvider
}

type lxdInstances interface {
	Instances(string, ...string) ([]lxdclient.Instance, error)
	AddInstance(lxdclient.InstanceSpec) (*lxdclient.Instance, error)
	RemoveInstances(string, ...string) error
}

type lxdProfiles interface {
	CreateProfile(string, map[string]string) error
	HasProfile(string) (bool, error)
}

func newRawProvider(ecfg *environConfig) (*rawProvider, error) {
	client, err := newClient(ecfg)
	if err != nil {
		return nil, errors.Trace(err)
	}

	firewaller, err := newFirewaller(ecfg)
	if err != nil {
		return nil, errors.Trace(err)
	}

	policy := &lxdPolicyProvider{}

	raw := &rawProvider{
		lxdInstances:   client,
		lxdProfiles:    client,
		Firewaller:     firewaller,
		policyProvider: policy,
	}
	return raw, nil
}

func newClient(ecfg *environConfig) (*lxdclient.Client, error) {
	clientCfg, err := ecfg.clientConfig()
	if err != nil {
		return nil, errors.Trace(err)
	}

	if err := clientCfg.Write(); err != nil {
		return nil, errors.Trace(err)
	}

	client, err := lxdclient.Connect(clientCfg)
	if err != nil {
		return nil, errors.Trace(err)
	}

	return client, nil
}

func newFirewaller(ecfg *environConfig) (common.Firewaller, error) {
	return common.NewFirewaller(), nil
}
{'fraction_non_alphanumeric': 0.12642947903430748, 'fraction_numerical': 0.0044472681067344345, 'mean_word_length': 4.438687392055268, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '2616150', 'n_tokens_mistral': 1171, 'n_tokens_neox': 1124, 'n_words': 263}