knife-org-utils 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/chef/knife/switch_add.rb +12 -6
- data/lib/knife-org-utils/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c80873057bb6eb726d5b52771e8ef9a0d1a4f56f
|
4
|
+
data.tar.gz: 97c4d6f7c5a377836ff757655423a5a5ce2dffb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9217d50b00eb06e7aa6e6b646cccb6e752e0cd725a9f2c19a5777a6a287c400739b9bf1c3d58629e5c5538de25b1fd9224fed6f133bcf4a2fb0c53bb676d762
|
7
|
+
data.tar.gz: 68e4507107c407fa957e8fb341d33efec6a6b69f38134ee0819d542bdaf7fde6d719ce23ab23ca58a74ca8e947bc5042f5eedd3cd6a4f301c4451853ed7a07f1
|
data/README.md
CHANGED
@@ -28,15 +28,23 @@ git repository and run the following command from inside the cloned repo:
|
|
28
28
|
|
29
29
|
### `knife switch init`
|
30
30
|
Initializes your `.chef` directory.
|
31
|
+
- - -
|
31
32
|
|
32
33
|
### `knife switch add $CHEF_RERO_DIR`
|
33
34
|
Imports `.chef` files from `$CHEF_RERO_DIR/.chef` into `~/.chef` folder. The name of the imported CONFIG will be based on the `chef_server_url` in the `knife.rb` file. Starter Kit is a valid chef-repo directory.
|
34
35
|
|
36
|
+
*Options*
|
37
|
+
* `--overwrite`: Overwrites configuration files if they exists
|
38
|
+
|
39
|
+
- - -
|
40
|
+
|
35
41
|
### `knife switch CONFIG`
|
36
42
|
switches the configuration in `~/.chef` to the named CONFIG
|
43
|
+
- - -
|
37
44
|
|
38
45
|
### `knife switch list`
|
39
46
|
list of available CONFIGS in `~/.chef` folder.
|
47
|
+
- - -
|
40
48
|
|
41
49
|
### `knife info [options]`
|
42
50
|
prints the current chef server referenced by your `~/.chef/knife.rb`.
|
@@ -7,6 +7,12 @@ module KnifeOrgUtils
|
|
7
7
|
|
8
8
|
banner 'knife switch add CHEF_RERO_DIR'
|
9
9
|
|
10
|
+
option :overwrite,
|
11
|
+
:long => '--overwrite',
|
12
|
+
:description => 'Overwrites configuration files if they exists',
|
13
|
+
:boolean => true | false,
|
14
|
+
:default => false
|
15
|
+
|
10
16
|
def kit_path
|
11
17
|
@kit_path ||= ::File.join( ::File.expand_path( @name_args[0] ), '.chef' )
|
12
18
|
end
|
@@ -92,12 +98,12 @@ module KnifeOrgUtils
|
|
92
98
|
dest_dir = ( user_pem == filename ) ? server_dir : org_dir
|
93
99
|
dest = ::File.join( dest_dir, filename )
|
94
100
|
|
95
|
-
if ::File.exist?( dest )
|
101
|
+
if ( !(::File.exist?( dest )) || config[:overwrite] )
|
102
|
+
::FileUtils.copy( source, dest )
|
103
|
+
else
|
96
104
|
source_sha = Digest::SHA2.file( source ).hexdigest
|
97
105
|
dest_sha = Digest::SHA2.file( dest ).hexdigest
|
98
106
|
ui.warn "File #{dest} already exists with different content. Skipped." unless source_sha.eql?( dest_sha )
|
99
|
-
else
|
100
|
-
::FileUtils.copy( source, dest )
|
101
107
|
end
|
102
108
|
end
|
103
109
|
end
|
@@ -113,12 +119,12 @@ module KnifeOrgUtils
|
|
113
119
|
config_name = get_config_name
|
114
120
|
dest_path = get_dest_path config_name
|
115
121
|
|
116
|
-
if ::File.directory? dest_path
|
117
|
-
ui.info "Configuration for #{dest_path} already exists."
|
118
|
-
else
|
122
|
+
if ( !(::File.directory? dest_path) || config[:overwrite] )
|
119
123
|
::FileUtils.mkpath dest_path
|
120
124
|
copy_files( kit_files )
|
121
125
|
ui.msg "Added #{config_name} to #{root}."
|
126
|
+
else
|
127
|
+
ui.info "Configuration for #{dest_path} already exists."
|
122
128
|
end
|
123
129
|
end
|
124
130
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-org-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Venkat Venkataraju
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-12-
|
12
|
+
date: 2014-12-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef
|