Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Do not merge] WIP/Adding result json output file #172

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vinay-satish
Copy link

Signed-off-by: Vinay Satish vinay.satish@progress.com

Description

Related Issue

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (non-breaking change that does not add functionality or fix an issue)

Checklist:

  • I have read the CONTRIBUTING document.
  • I have run the pre-merge tests locally and they pass.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • All commits have been signed-off for the Developer Certificate of Origin.

@@ -91,11 +98,13 @@ def for_each_user

def for_each_organization
rest.get('/organizations').each_pair do |name, url|
$organizations_hash["total"]=$organizations_hash["total"]+1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$organizations_hash["total"]=$organizations_hash["total"]+1
next unless (config[:org].nil? || config[:org] == name)
$organizations_hash["total"]=$organizations_hash["total"]+1

I'm not sure, but do we want this instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Maybe we should ask Marc)

@@ -91,11 +98,13 @@ def for_each_user

def for_each_organization
rest.get('/organizations').each_pair do |name, url|
$organizations_hash["total"]=$organizations_hash["total"]+1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$organizations_hash["total"]=$organizations_hash["total"]+1
$organizations_hash["total"]+=1

Shorter and more idiomatic.

@@ -115,18 +124,24 @@ def for_each_organization
end

def download_user(username, url)
$users_hash["total"]=$users_hash["total"]+1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$users_hash["total"]=$users_hash["total"]+1
$users_hash["total"]+=1

File.open("#{dest_dir}/users/#{username}.json", 'w') do |file|
file.write(Chef::JSONCompat.to_json_pretty(rest.get(url)))
end
$users_hash["success_count"]=$users_hash["success_count"]+1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$users_hash["success_count"]=$users_hash["success_count"]+1
$users_hash["success_count"]+=1

knife_ec_error_handler.add(ex)
end

def download_user_acl(username)
$user_acls_hash["total"]=$user_acls_hash["total"]+1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$user_acls_hash["total"]=$user_acls_hash["total"]+1
$user_acls_hash["total"]+=1

File.open("#{dest_dir}/user_acls/#{username}.json", 'w') do |file|
file.write(Chef::JSONCompat.to_json_pretty(user_acl_rest.get("users/#{username}/_acl")))
end
$user_acls_hash["success_count"]=$user_acls_hash["success_count"]+1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$user_acls_hash["success_count"]=$user_acls_hash["success_count"]+1
$user_acls_hash["success_count"]+=1

Signed-off-by: Vinay Satish <vinay.satish@progress.com>
@sonarcloud
Copy link

sonarcloud bot commented Aug 2, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@lbakerchef
Copy link
Contributor

Is this acceptance criteria being satisfied for this PR, or is there another PR?

- knife-ec-backup accepts a new flag “--results-path”.  Defaults to current backup directory. 

- knife-ec-backup outputs a new file, containing the results of the run as documented in description. Output file name includes date-time stamp. 

- file will not be overwritten if it already exists. 

- the file is created no matter what failures have occurred. 

@lbakerchef
Copy link
Contributor

It looks like the verify pipeline has some failures.

@PrajaktaPurohit PrajaktaPurohit changed the title WIP/Adding result json output file [Do not merge] WIP/Adding result json output file Oct 13, 2022
@PrajaktaPurohit
Copy link

PrajaktaPurohit commented Oct 13, 2022

Do not merge until chef/chef#13107 is merged and Gemfile.lock is updated to point to the new chef/chef

gem "chef", "~> 17"
gem "ohai", "~> 17"
gem "knife", "~> 17"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might as well bump all of these to chef-18, this would be a major gem bump for knife-ec-backup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants