josef 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff15bbffea6f50a5986d0e3b2d50af713366d66b846910ea053fc9bb633d0877
4
- data.tar.gz: 742331144309a11d30d57862bf152e7528159aab49498d8896f1b1489226c290
3
+ metadata.gz: ada1f2866aa63a291d4ba5146c05644e012a6b5294d296af30a49d608d6906f7
4
+ data.tar.gz: 4a82a8fd15a250d4e6563bf4184be273116cd3c54d87ebbf60ee1e4ca11ae419
5
5
  SHA512:
6
- metadata.gz: aecb121ab5de22cd7812ac984ba2aaf174ddc97bdfd4b7aaac936abba36c9bcdefd400c6947759ffe32eb6826c272a361d16aa56215164cc6de0f53666fb9b1f
7
- data.tar.gz: bfe23e5a8b06f0e47348024735e7c54cdd2f755e7684b6a946c7f4c8e880bedeffb4368d506537987e131b7ea6facb054e97c0f3cc0bfa35f4d282e271641fa8
6
+ metadata.gz: 570e4d9ae534b519d049633400210b5733c1e5e31bd2f56a1b371114db248733813ab0f24f75b08308b64e8cb245e127bb8e0162033b219d0a4035ec63a4e3a0
7
+ data.tar.gz: 6c0b6b75744f6013fb534c4929b4e9e4976da3e8c41fbcff4e2fcbe4ec9cb92f8bc7262b14fbb751d3e2be7cdd6bf4d024b09e3d1545879e7bf1cfe85bd14926
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- josef (0.2.0)
4
+ josef (0.3.0)
5
5
  activesupport
6
6
  google-api-client
7
7
  thor
data/README.md CHANGED
@@ -44,10 +44,23 @@ josef diff ./local_group_file.yml
44
44
 
45
45
  ### apply
46
46
 
47
- ```
47
+ ```sh
48
48
  josef apply ./local_group_file.yml
49
49
  ```
50
50
 
51
+ Josef can config exculusion group mail addresses.example
52
+
53
+ ```yaml
54
+ ---
55
+ exclued_groups:
56
+ - hoge@ml.example.com
57
+ - foo@example.com
58
+ ```
59
+
60
+ ```sh
61
+ josef apply ./local_group_file.yml --exculude ./excluded_groups.yml
62
+ ```
63
+
51
64
  ## Development
52
65
 
53
66
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/lib/josef/cli.rb CHANGED
@@ -7,6 +7,18 @@ module Josef
7
7
  include Josef::Remote
8
8
  include Josef::Diff
9
9
  class_option :dry_run, :type => :boolean, :default => false
10
+ class_option :exclude, :type => :string, :default => nil
11
+
12
+ no_commands do
13
+ def invoke_command(command, *args)
14
+ prepare
15
+ super
16
+ end
17
+
18
+ def prepare
19
+ exculued_groups(options[:exclude])
20
+ end
21
+ end
10
22
 
11
23
  desc "dump", "dump google workspace group"
12
24
  def dump
data/lib/josef/diff.rb CHANGED
@@ -4,6 +4,13 @@ module Josef
4
4
  module Diff
5
5
  include Josef::Remote
6
6
  include Josef::Local
7
+
8
+ def should_be_tareget?(local_group)
9
+ return false if exculued?(local_group[:group_mail_address])
10
+
11
+ true
12
+ end
13
+
7
14
  def changed?(local_group)
8
15
  remote_group = remote.find{|g| g[:group_mail_address] == local_group[:group_mail_address]}
9
16
  return false if local_group[:members].nil? || remote_group[:members].nil?
@@ -22,6 +29,8 @@ module Josef
22
29
 
23
30
  def remote_diff(remote, local, mode = "apply")
24
31
  local.each do | local_group |
32
+ next unless should_be_tareget?(local_group)
33
+
25
34
  if be_create?(local_group)
26
35
  puts "#{local_group[:group_mail_address]} will be create:#{mode}"
27
36
  local_group[:members].each do | member |
@@ -45,6 +54,8 @@ module Josef
45
54
  end
46
55
 
47
56
  remote.each do | remote_group |
57
+ next unless should_be_tareget?(remote_group)
58
+
48
59
  if be_delete?(remote_group)
49
60
  puts "#{remote_group[:group_mail_address]} will be delete:#{mode}"
50
61
  end
data/lib/josef/local.rb CHANGED
@@ -8,7 +8,23 @@ module Josef
8
8
  end
9
9
 
10
10
  def local!(local_file)
11
+ return [] if local_file.nil?
12
+
11
13
  YAML.load_file(local_file).map{|h| h.deep_symbolize_keys}
12
14
  end
15
+
16
+ def exculued?(group_mail_address)
17
+ exculued_groups.include?(group_mail_address)
18
+ end
19
+
20
+ def exculued_groups(exculued_groups_file = nil)
21
+ @_exculued_groups ||= exculued_groups!(exculued_groups_file)
22
+ end
23
+
24
+ def exculued_groups!(exculued_groups_file)
25
+ return [] if exculued_groups_file.nil?
26
+
27
+ YAML.load_file(exculued_groups_file).symbolize_keys[:exculued_groups]
28
+ end
13
29
  end
14
30
  end
data/lib/josef/remote.rb CHANGED
@@ -23,6 +23,8 @@ module Josef
23
23
  def remote_apply(local)
24
24
  remote_diff(remote, local)
25
25
  local.each do | local_group |
26
+ next unless should_be_tareget?(local_group)
27
+
26
28
  if be_create?(local_group)
27
29
  create_group(local_group[:group_mail_address])
28
30
 
@@ -46,6 +48,8 @@ module Josef
46
48
  end
47
49
 
48
50
  remote.each do | remote_group |
51
+ next unless should_be_tareget?(remote_group)
52
+
49
53
  if be_delete?(remote_group)
50
54
  delete_group(remote_group[:group_mail_address])
51
55
  end
data/lib/josef/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Josef
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: josef
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jolantern
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-15 00:00:00.000000000 Z
11
+ date: 2021-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-api-client