Skip to content

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

Open
vinay-satish wants to merge 1 commit intomainfrom
zei/adding_output_json
Open

[Do not merge] WIP/Adding result json output file#172
vinay-satish wants to merge 1 commit intomainfrom
zei/adding_output_json

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.


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)


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.

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

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>
@vinay-satish vinay-satish force-pushed the zei/adding_output_json branch from ed9fc04 to 6650d51 Compare August 2, 2022 13:26
@sonarqubecloud
Copy link

sonarqubecloud 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

end No newline at end of file
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