#
# Copyright:: Copyright (c) Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

source "https://rubygems.org"

group(:omnibus_package, :development, :test) do
  # Require a minimum version that is packaged in the Ruby install, so we do
  # not install old unecessary versions. When we bump Ruby we need to look
  # at these pins and adjust them. (Ruby 3.4)
  gem "minitest", ">= 5.16"

  gem "rake", ">= 13.0"
  gem "guard"
  gem "cookstyle", ">= 8.0"
  gem "ffi-libarchive"

  # NOTE: pin openssl to the version shipped as a default gem with the bundled
  # ruby (ruby 3.4.9 ships openssl 3.3.1). Other gems depend on openssl, so we
  # must declare it here, but bundler must resolve to the same version that
  # ruby ships or activation will conflict with the default gem at runtime
  # (Gem::LoadError: can't activate openssl-X, already activated openssl-Y).
  # NOTE: update this pin whenever the bundled ruby version changes.
  gem "openssl", "= 3.3.1"

  gem "net-imap", ">= 0.2.5" # 0.2.5+ required for CVE fix - GHSA-j3g3-5qv5-52mj
end

# We tend to track latest stable release without pinning.
# In order to prevent the depsolver from downgrading we pin some floors with ">=".
# We should only be using "~>" to work around bugs, or temporarily pinning some tech debt.
# We equality pin the chef gem itself to assert which version we're shipping.
group(:omnibus_package) do
  gem "unf_ext", ">= 0.0.8.2"

  gem "appbundler"

  # Cinc-branded chef gems are published to rubygems.cinc.sh. Letting this
  # float on latest should always give us the latest stable release.

  gem "chef", ">= 19.0", source: "https://rubygems.cinc.sh"
  gem "chef-bin", ">= 19.0", source: "https://rubygems.cinc.sh"
  gem "ohai", ">= 19.0"
  gem "cinc-auditor-bin", ">= 7", source: "https://rubygems.cinc.sh"
  gem "inspec", ">= 7", source: "https://rubygems.cinc.sh"

  gem "chef-zero", source: "https://rubygems.cinc.sh"
  gem "chef-utils", source: "https://rubygems.cinc.sh"
  gem "cheffish", ">= 17.0"

  gem "inspec-bin", ">= 7"

  # chefspec & fauxhai, now forked into https://github.com/chef
  gem "chefspec", ">= 9.3"
  gem "fauxhai-chef", ">= 9.3"

  # test-kitchen and plugins
  gem "test-kitchen", ">= 3.0"
  gem "kitchen-azurerm", ">= 1.12.0"
  gem "kitchen-ec2", ">= 3.10"
  gem "kitchen-digitalocean", ">= 0.13"
  gem "kitchen-dokken", ">= 2.14"
  gem "docker-api", ">= 2.0" # make sure we get the Ruby 2.7+ compatible release
  gem "kitchen-google", ">= 2.2"
  gem "kitchen-hyperv", ">= 0.6"
  gem "kitchen-inspec", ">= 2.5"
  gem "kitchen-sync", github: "test-kitchen/kitchen-sync", branch: "main"
  gem "kitchen-openstack", ">= 7.0"
  gem "kitchen-vagrant", ">= 1.9"
  gem "kitchen-vcenter", ">= 2.8"
  gem "kitchen-vra", ">= 3.0"
  gem "kitchen-cinc", ">= 1.0"
  gem "kitchen-terraform", ">= 8.0", source: "https://rubygems.cinc.sh"

  # knife & plugins
  gem "knife", ">= 19.0", source: "https://rubygems.cinc.sh"
  gem "knife-azure", ">= 3.0.0"
  gem "knife-ec2", ">= 1.0.28"
  gem "knife-google", ">= 4.2.7"
  gem "knife-tidy", ">= 2.0.9"
  gem "knife-windows", ">= 3.0.11"
  gem "knife-vcenter", ">= 3.0.1"
  gem "knife-vsphere", ">= 4.1.1"
  gem "knife-vrealize", ">= 7.0.0"

  # ed25519 ssh key support done here as it's a native gem we can't put in train
  gem "ed25519"
  gem "bcrypt_pbkdf", ">= 1.1.0.rc1"
  gem "chef-cli", ">= 5.3.1", source: "https://rubygems.cinc.sh"

  # chef-telemetry previously pulled in an unecessary library (http)
  gem "chef-telemetry", ">= 1.0.8"

  gem "artifactory"
  gem "mixlib-archive", ">= 1.0"
  gem "net-ssh", ">= 4.2.0"
  gem "listen"
  gem "mixlib-install", source: "https://rubygems.cinc.sh"
  gem "nokogiri", ">= 1.11.7"
  gem "pry", ">= 0.13.0"
  gem "pry-byebug"
  gem "pry-remote"
  gem "pry-stack_explorer", ">= 0.5.1"
  gem "rb-readline"
  gem "winrm-fs"
  gem "winrm-elevated"
  gem "berkshelf", ">= 8.0"
  gem "mdl", ">= 0.7.0"
  # Useful for unit testing with acme cookbook
  gem "acme-client"
  # Useful for Facebook/Meta usage
  gem "taste_tester", github: "facebook/taste-tester", branch: "main"
  gem "chef-handler-mail"
  gem "deepsort"
  gem "toml"
end

# Everything except Windows
group(:ruby_shadow) do
  gem "ruby-shadow", git: "https://gitlab.com/cinc-project/upstream/ruby-shadow", branch: "stable/cinc", platforms: :ruby unless RUBY_PLATFORM == "x64-mingw-ucrt"
end

# Ensure support for push-client on Windows
if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
  gem "rdp-ruby-wmi"
  gem "windows-pr"
  gem "win32-api"
  gem "win32-dir"
  gem "win32-event"
  gem "win32-mutex"
  gem "win32-process", ">= 0.9.0" # resolves Ruby 2.7+ warnings
  gem "win32-service", ">= 2.1.5" # 2.1.5 resolves ffi warnings
  gem "win32-security" # remove this once https://github.com/eitoball/net-ping/pull/32 is merged
end
