forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovider.go
36 lines (30 loc) · 1.08 KB
/
provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package common
import (
"github.com/juju/errors"
"github.com/juju/juju/environs"
"github.com/juju/juju/environs/context"
)
// DefaultProvider exposes the various common implementations found in
// this package as methods of a single type. This facilitates treating
// the implementations as a bundle, e.g. satisfying interfaces.
type DefaultProvider struct {
// Env is the Juju environment that methods target.
Env environs.Environ
}
// BootstrapEnv bootstraps the Juju environment.
func (dp DefaultProvider) BootstrapEnv(ctx environs.BootstrapContext, callCtx context.ProviderCallContext, args environs.BootstrapParams) (*environs.BootstrapResult, error) {
result, err := Bootstrap(ctx, dp.Env, callCtx, args)
if err != nil {
return nil, errors.Trace(err)
}
return result, nil
}
// DestroyEnv destroys the Juju environment.
func (dp DefaultProvider) DestroyEnv(ctx context.ProviderCallContext) error {
if err := Destroy(dp.Env, ctx); err != nil {
return errors.Trace(err)
}
return nil
}