Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2736)

Delta Between Two Patch Sets: state/util.go

Issue 5901058: cmd/juju: working bootstrap and destroy commands
Left Patch Set: cmd/juju: working bootstrap and destroy commands Created 13 years ago
Right Patch Set: cmd/juju: working bootstrap and destroy commands Created 12 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « state/unit.go ('k') | state/watch_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // launchpad.net/juju/state 1 // launchpad.net/juju/state
2 // 2 //
3 // Copyright (c) 2011-2012 Canonical Ltd. 3 // Copyright (c) 2011-2012 Canonical Ltd.
4 4
5 package state 5 package state
6 6
7 import ( 7 import (
8 "errors" 8 "errors"
9 "fmt" 9 "fmt"
10 "launchpad.net/goyaml" 10 "launchpad.net/goyaml"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 c := &ConfigNode{ 73 c := &ConfigNode{
74 zk: zk, 74 zk: zk,
75 path: path, 75 path: path,
76 pristineCache: make(map[string]interface{}), 76 pristineCache: make(map[string]interface{}),
77 cache: copyCache(values), 77 cache: copyCache(values),
78 } 78 }
79 _, err := c.Write() 79 _, err := c.Write()
80 if err != nil { 80 if err != nil {
81 return nil, err 81 return nil, err
82 } 82 }
83 return c, nil
84 }
85
86 // parseConfigNode creates a config node based on a pre-read content.
87 func parseConfigNode(zk *zookeeper.Conn, path, content string) (*ConfigNode, err or) {
88 c := &ConfigNode{
89 zk: zk,
90 path: path,
91 }
92 if err := goyaml.Unmarshal([]byte(content), &c.cache); err != nil {
93 return nil, err
94 }
95 c.pristineCache = copyCache(c.cache)
83 return c, nil 96 return c, nil
84 } 97 }
85 98
86 // readConfigNode returns the ConfigNode for path. 99 // readConfigNode returns the ConfigNode for path.
87 func readConfigNode(zk *zookeeper.Conn, path string) (*ConfigNode, error) { 100 func readConfigNode(zk *zookeeper.Conn, path string) (*ConfigNode, error) {
88 c := &ConfigNode{ 101 c := &ConfigNode{
89 zk: zk, 102 zk: zk,
90 path: path, 103 path: path,
91 } 104 }
92 if err := c.Read(); err != nil { 105 if err := c.Read(); err != nil {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 b >= '0' && b <= '9', 298 b >= '0' && b <= '9',
286 b == '.', 299 b == '.',
287 b == '-': 300 b == '-':
288 safe = append(safe, b) 301 safe = append(safe, b)
289 default: 302 default:
290 safe = append(safe, fmt.Sprintf("_%02x_", b)...) 303 safe = append(safe, fmt.Sprintf("_%02x_", b)...)
291 } 304 }
292 } 305 }
293 return string(safe) 306 return string(safe)
294 } 307 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b