~james-page/ubuntu/wily/juju-core/mir-fixes

« back to all changes in this revision

Viewing changes to src/launchpad.net/juju-core/worker/uniter/charm/git.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-03-28 08:58:42 UTC
  • mfrom: (1.1.21)
  • Revision ID: package-import@ubuntu.com-20140328085842-cyzrgc120bdfxwj0
Tags: 1.17.7-0ubuntu1
* New upstream point release, including fixes for:
  - no debug log with all providers on Ubuntu 14.04 (LP: #1294776).
* d/control: Add cpu-checker dependency to juju-local (LP: #1297077).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright 2012, 2013 Canonical Ltd.
 
1
// Copyright 2012-2014 Canonical Ltd.
2
2
// Licensed under the AGPLv3, see LICENCE file for details.
3
3
 
4
4
package charm
5
5
 
6
6
import (
7
 
        "errors"
8
7
        "fmt"
9
8
        "io"
10
9
        "io/ioutil"
14
13
        "strings"
15
14
 
16
15
        "launchpad.net/juju-core/charm"
17
 
        "launchpad.net/juju-core/log"
18
 
        "launchpad.net/juju-core/utils"
19
16
)
20
17
 
21
 
var ErrConflict = errors.New("charm upgrade has conflicts")
22
 
 
23
18
// GitDir exposes a specialized subset of git operations on a directory.
24
19
type GitDir struct {
25
20
        path string
212
207
}
213
208
 
214
209
func (d *GitDir) logError(err error, output string, args ...string) error {
215
 
        log.Errorf("worker/uniter/charm: git command failed: %s\npath: %s\nargs: %#v\n%s",
 
210
        logger.Errorf("git command failed: %s\npath: %s\nargs: %#v\n%s",
216
211
                err, d.path, args, output)
217
212
        return fmt.Errorf("git %s failed: %s", args[0], err)
218
213
}
234
229
        return statuses, nil
235
230
}
236
231
 
237
 
// ReadCharmURL reads the charm identity file from the supplied GitDir.
238
 
func ReadCharmURL(d *GitDir) (*charm.URL, error) {
239
 
        path := filepath.Join(d.path, ".juju-charm")
240
 
        surl := ""
241
 
        if err := utils.ReadYaml(path, &surl); err != nil {
242
 
                return nil, err
243
 
        }
244
 
        return charm.ParseURL(surl)
 
232
// ReadCharmURL reads the charm identity file from the GitDir.
 
233
func (d *GitDir) ReadCharmURL() (*charm.URL, error) {
 
234
        path := filepath.Join(d.path, charmURLPath)
 
235
        return ReadCharmURL(path)
245
236
}
246
237
 
247
 
// WriteCharmURL writes a charm identity file into the directory.
248
 
func WriteCharmURL(d *GitDir, url *charm.URL) error {
249
 
        return utils.WriteYaml(filepath.Join(d.path, ".juju-charm"), url.String())
 
238
// WriteCharmURL writes the charm identity file into the GitDir.
 
239
func (d *GitDir) WriteCharmURL(url *charm.URL) error {
 
240
        return WriteCharmURL(filepath.Join(d.path, charmURLPath), url)
250
241
}