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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19d0abf791e3377010066677e0b004cd07a2723a
4
- data.tar.gz: dd002443f0a027407a77d2610d8fc5cd4193b184
3
+ metadata.gz: c80873057bb6eb726d5b52771e8ef9a0d1a4f56f
4
+ data.tar.gz: 97c4d6f7c5a377836ff757655423a5a5ce2dffb3
5
5
  SHA512:
6
- metadata.gz: 3070cf9eb65d75ef3136d76ae5855695dc77a9e90dc54a118621bf3823c2f80dafbadf745e72cce8aa11e562c448518487dd6b70637a65ae1ccfcb0c9dbb3358
7
- data.tar.gz: 832f6b4d9e2d133fc58e7b3cef415eb02e12ae3ee9704cfddc2d8a766b701cc2ec555ad27812b78b1c585382aa548ff2bf5b03548a33d3a99814915ca0b782a9
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
@@ -1,3 +1,3 @@
1
1
  module KnifeOrgUtils
2
- VERSION = '1.0.1'
2
+ VERSION = '1.1.0'
3
3
  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.1
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-05 00:00:00.000000000 Z
12
+ date: 2014-12-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chef