Merge lp:~dave-cheney/juju-core/go-environs-config-fix into lp:~juju/juju-core/trunk

Proposed by Dave Cheney
Status: Rejected
Rejected by: Dave Cheney
Proposed branch: lp:~dave-cheney/juju-core/go-environs-config-fix
Merge into: lp:~juju/juju-core/trunk
Diff against target: 35 lines (+31/-0)
1 file modified
environs/config/current.go (+31/-0)
To merge this branch: bzr merge lp:~dave-cheney/juju-core/go-environs-config-fix
Reviewer Review Type Date Requested Status
The Go Language Gophers Pending
Review via email: mp+117818@code.launchpad.net

Description of the change

config/environs: fix build

Restore current.go which disappeared in rev 359.

https://codereview.appspot.com/6454084/

To post a comment you must log in.
Revision history for this message
William Reade (fwereade) wrote :
Revision history for this message
Roger Peppe (rogpeppe) wrote :

On 2012/08/01 23:48:20, dfc wrote:
> Please take a look.

doesn't LGTM.
this code is now in the version package, and everything builds ok for
me, at any rate.

https://codereview.appspot.com/6454084/

Unmerged revisions

362. By Dave Cheney

fix build

361. By Roger Peppe

state: make agents have proposed tools not versions.

With the proposed upgrade changes, we want to propose
a version of the tools and a URL to find the tools.
To do that, we move the Tool type into state and
make the old agentVersion type use it, renaming
it to agentTools.

R=niemeyer
CC=
https://codereview.appspot.com/6441078

360. By Roger Peppe

version: rename Version to Number, BinaryVersion to Binary.

Also implement Parse and String for Binary.

R=niemeyer
CC=
https://codereview.appspot.com/6458053

359. By Roger Peppe

environs: add ListTools function and related refactoring.

With the proposed upgrade scheme, we will want to explicitly
ask machines to run a particular version of the juju tools.
That means that the upgrader needs to be able to decide for
itself which tools are appropriate, so we factor out ListTools
so it doesn't have to list the storage for each agent.

As a knock-on effect, Environ.StartInstance now takes
the tools to start.

R=fwereade, niemeyer
CC=
https://codereview.appspot.com/6449062

358. By William Reade

reworked ClientContext to HookContext

HookContext now offers facilities sufficient to implement relation-get,
relation-set, relation-ids, and relation-list. Expect followups
implementing those shortly; for now, sigh, and observe the annoyingly
large amount of test changes that support what STM to be a worthwhile
simplification of the hook context as a whole.

R=rog, niemeyer
CC=
https://codereview.appspot.com/6445058

357. By William Reade

add RelationContext type

The RelationContext manages a single relation's unit settings, as a step
towards implementing relation-aware jujuc commands. It exposes features that
will be used directly by the relation-get, relation-set, relation-list and
relation-ids commands; the interface is designed to allow convenient
creation from uniter.RelationState instances, and convenient updates from
uniter.HookInfo values.

This doesn't yet fit cleanly with the ClientContext type, but integrating
the types will have somewhat noisy consequences, so the RelationContext is
currently exercised alone. Expect an imminent followup integrating
RelationContext into ClientContext as follows:

  drop LocalUnitName string; add Unit *state.Unit
  drop RelationName string; add RelationId int
  keep RemoteUnitName
  add Relations map[int]*RelationContext, keyed on relation id

...and:

  change name to HookContext

We expect every HookContext to contain full details of all relations the
unit is currently participating in, in Relations; this is needed to allow
commands like relation-ids and relation-list to run regardless of context.
The relation-specific JUJU_RELATION and JUJU_RELATION_ID environment
variables (along with JUJU_REMOTE_UNIT where apropriate) would be set when
RelationId were valid (ie it must not be -1, and it must bea valid key into
Relations).

R=rog, niemeyer
CC=
https://codereview.appspot.com/6448074

356. By William Reade

implement --format changes as discussed live

* Nothing has a --test flag
* YAML output now has trailing newlines stripped
* --format now accepts "smart", everywhere except status

R=rog, niemeyer
CC=
https://codereview.appspot.com/6448090

355. By William Reade

implement RelationState persistence

RelationState gets a new field, Path, and two new methods:

  (*RelationState) Validate(HookInfo) error

...which allows a client to verify the sanity of a hook before
it is run, and:

  (*RelationState) Commit(HookInfo) error

...which persists the state change to disk, and should be called on
successful execution of a hook, or resolution of an error state.
RelationState is aggressive about error detection and should always
write consistent states; errors while committing a hook should not
cause any change to the RelationState or its persistence directory.

A new AllRelationStates function, which scans a complete relations
directory and returns a map of relation id to *RelationState stored
therein, will be convenient when reconciling persisted relation state
against the unit's service's latest relation membership.

R=rog, niemeyer
CC=
https://codereview.appspot.com/6453061

354. By Roger Peppe

state: implement MachineInfoWatcher

R=niemeyer
CC=
https://codereview.appspot.com/6447054

353. By William Reade

add RelationState type...

...and use it to reconcile HookQueue state with initial watcher event on
load.

As part of this, I added a RelationId to HookQueue, and return it in every
HookInfo, so that we can identify what relation the hook is actually meant
to run against.

R=niemeyer
CC=
https://codereview.appspot.com/6441047

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'environs/config/current.go'
2--- environs/config/current.go 1970-01-01 00:00:00 +0000
3+++ environs/config/current.go 2012-08-01 23:48:21 +0000
4@@ -0,0 +1,31 @@
5+package config
6+
7+import (
8+ "io/ioutil"
9+"runtime"
10+ "strings"
11+)
12+
13+var CurrentSeries = readSeries("/etc/lsb-release") // current Ubuntu release name.
14+var CurrentArch = ubuntuArch(runtime.GOARCH)
15+
16+func readSeries(releaseFile string) string {
17+ data, err := ioutil.ReadFile(releaseFile)
18+ if err != nil {
19+ return "unknown"
20+ }
21+ for _, line := range strings.Split(string(data), "\n") {
22+ const p = "DISTRIB_CODENAME="
23+ if strings.HasPrefix(line, p) {
24+ return strings.Trim(line[len(p):], "\t '\"")
25+ }
26+ }
27+ return "unknown"
28+}
29+
30+func ubuntuArch(arch string) string {
31+ if arch == "386" {
32+ arch = "i386"
33+ }
34+ return arch
35+}

Subscribers

People subscribed via source and target branches