Add golang cookbook

Needs updating of ark and git cookbooks
This commit is contained in:
2020-08-23 11:01:05 +02:00
parent 217ab471ce
commit 0005f9ab7d
55 changed files with 670 additions and 716 deletions

View File

@@ -1 +0,0 @@
~FC016

View File

@@ -2,6 +2,63 @@
This file is used to list changes made in each version of the git cookbook.
## 10.0.0 (2019-10-16)
- Add testing for CentOS 8, openSUSE 15, Ubuntu 18.04 in Travis
- Require Chef Infra Client 14 or later so we can drop the dependency on build-essential
- Resolve multiple cookstyle warnings
## 9.0.1 (2018-06-02)
- Update the platforms we test on
- Remove extra attr_accessor in config and requires
- Bump git version to 2.17.1 to resolve CVE
## 9.0.0 (2018-03-08)
- Remove the dependency on the homebrew cookbook by not automatically installing homebrew in the git resource on macOS systems. Homebrew needs to be setup before this resource runs and that should probably be the very first thing you do on a macOS system
- Use the build_essential resource instead of including the default recipe. This requires version 5.0 or later of the build-essential cookbook and allows us to use the build_essential resource that will be built into Chef 14 when that ships
- Remove extra includes in the resources that weren't necessary
- Updated testing to include Fedora 27, Ubuntu 18.04, Debian 9, macOS 10.12, and Windows 2016
## 8.0.1 (2018-02-10)
- Resolve the new FC118 foodcritic warning
- Remove the ChefSpec matchers which are auto generated now
- Resolve FC104 warning
## 8.0.0 (2017-09-01)
### Breaking Changes
- macOS resource now properly executes and uses homebrew to install git instead of dmg and packages posted to SourceForge
- Default to Git 2.9.5 now, which properly compiles on Fedora / Amazon Linux
## Other Changes
- Fixed support for Amazon Linux on Chef 13
- Unified the package setup for source installs which fixes Amazon/Fedora
- Removed an entirely duplicate service provider
- Remove unused runit templates
- Properly fail when we're on an unsupported platform
## 7.0.0 (2017-09-01)
- Remove support for RHEL 5 which removes the need for the yum-epel cookbook
- Move templates out of the default directory now that we require Chef 12
- Remove support for Ubuntu 10.04
- Remove the version requirement on mac_os_x in the metadata
- Move maintainer information to the readme
- Expand Travis testing
## 6.1.0 (2017-05-30)
- Test with Local Delivery and not Rake
- Remove EOL platforms from the kitchen configs
- Use a SPDX standard license string
- Updated default versions documented in README to fix Issue #120.
- Remove class_eval and require chef 12.7+
## 6.0.0 (2017-02-14)
- Fail on deprecations is now enabled so we're fully Chef 13 compatible

View File

@@ -1,15 +0,0 @@
<!-- This is a generated file. Please do not edit directly -->
# Maintainers
This file lists how this cookbook project is maintained. When making changes to the system, this file tells you who needs to review your patch - you need a review from an existing maintainer for the cookbook to provide a :+1: on your pull request. Additionally, you need to not receive a veto from a Lieutenant or the Project Lead.
Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) for details on the process and how to become a maintainer or the project lead.
# Project Maintainer
* [Tim Smith](https://github.com/tas50)
# Maintainers
* [Jennifer Davis](https://github.com/sigje)
* [Tim Smith](https://github.com/tas50)
* [Thom May](https://github.com/thommay)

View File

@@ -20,17 +20,17 @@ The following platforms have been tested with Test Kitchen:
|---------------+-------|
| centos-7 | X |
|---------------+-------|
| centos-8 | X |
|---------------+-------|
| fedora | X |
|---------------+-------|
| debian-7 | X |
| debian-9 | X |
|---------------+-------|
| debian-8 | X |
|---------------+-------|
| ubuntu-14.04 | X |
| debian-10 | X |
|---------------+-------|
| ubuntu-16.04 | X |
|---------------+-------|
| openSUSE 13.2 | X |
| ubuntu-18.04 | X |
|---------------+-------|
| openSUSE Leap | X |
|---------------+-------|
@@ -38,13 +38,11 @@ The following platforms have been tested with Test Kitchen:
### Chef
- Chef 12.5+
- Chef 14+
### Cookbooks
- depends 'build-essential' - For compiling from source
- depends 'dmg' - For macOS Support
- depends 'yum-epel' - For older RHEL platform_family support
- none
## Usage
@@ -60,6 +58,8 @@ Add `git::default`, `git::source` or `git::windows` to your run_list OR add `dep
The `git_client` resource manages the installation of a Git client on a machine.
`Note`: on macOS systems homebrew must first be installed on the system before running this resource. Prior to version 9.0 of this cookbook homebrew was automatically installed.
#### Example
```ruby
@@ -68,6 +68,17 @@ git_client 'default' do
end
```
#### Example of source install
```ruby
git_client 'source' do
provider Chef::Provider::GitClient::Source
source_version '2.14.2'
source_checksum 'a03a12331d4f9b0f71733db9f47e1232d4ddce00e7f2a6e20f6ec9a19ce5ff61'
action :install
end
```
### git_config
The `git_config` resource manages the configuration of Git client on a machine.
@@ -96,23 +107,15 @@ Currently, there are distinct sets of resource properties, used by the providers
- `source_prefix` - Defaults to '/usr/local'
- `source_url` - Defaults to a calculated URL based on source_version
- `source_version` - Defaults to 2.7.4
- `source_version` - Defaults to 2.8.1
- `source_use_pcre` - configure option for build. Defaults to false
- `source_checksum` - Defaults to a known value for the 2.7.4 source tarball
# used by OSX package providers
- `osx_dmg_app_name` - Defaults to 'git-2.7.1-intel-universal-mavericks'
- `osx_dmg_package_id` - Defaults to 'GitOSX.Installer.git271.git.pkg'
- `osx_dmg_volumes_dir` - Defaults to 'Git 2.7.1 Mavericks Intel Universal'
- `osx_dmg_url` - Defaults to Sourceforge
- `osx_dmg_checksum` - Defaults to the value for 2.7.1
- `source_checksum` - Defaults to a known value for the 2.8.1 source tarball
# used by the Windows package providers
- `windows_display_name` - Windows display name
- `windows_package_url` - Defaults to the Internet
- `windows_package_checksum` - Defaults to the value for 2.7.4
- `windows_package_checksum` - Defaults to the value for 2.8.1
## Recipes
@@ -127,11 +130,6 @@ This cookbook ships with ready to use, attribute driven recipes that utilize the
- `node['git']['checksum']` - package SHA256 checksum
- `node['git']['display_name']` - `windows_package` resource Display Name (makes the package install idempotent)
### Mac OS X
- `node['git']['osx_dmg']['url']` - URL to git package
- `node['git']['osx_dmg']['checksum']` - package SHA256 checksum
### Linux
- `node['git']['prefix']` - git install directory
@@ -140,11 +138,13 @@ This cookbook ships with ready to use, attribute driven recipes that utilize the
- `node['git']['checksum']` - tarball SHA256 checksum
- `node['git']['use_pcre']` - if true, builds git with PCRE enabled
## License & Authors
## Maintainers
- Author:: Joshua Timberman ([joshua@chef.io](mailto:joshua@chef.io))
- Author:: Sean OMeara ([sean@sean.io](mailto:sean@sean.io))
- Copyright:: 2009-2017, Chef Software, Inc.
This cookbook is maintained by Chef's Community Cookbook Engineering team. Our goal is to improve cookbook quality and to aid the community in contributing to cookbooks. To learn more about our team, process, and design goals see our [team documentation](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/COOKBOOK_TEAM.MD). To learn more about contributing to cookbooks like this see our [contributing documentation](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD), or if you have general questions about this cookbook come chat with us in #cookbok-engineering on the [Chef Community Slack](http://community-slack.chef.io/)
## License
**Copyright:** 2009-2017, Chef Software, Inc.
```
Licensed under the Apache License, Version 2.0 (the "License");

View File

@@ -3,7 +3,7 @@
# Cookbook:: git
# Attributes:: default
#
# Copyright:: 2008-2016, Chef Software, Inc.
# Copyright:: 2008-2019, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
@@ -29,17 +29,11 @@ when 'windows'
end
default['git']['url'] = 'https://github.com/git-for-windows/git/releases/download/v%{version}.windows.1/Git-%{version}-%{architecture}-bit.exe'
default['git']['display_name'] = "Git version #{node['git']['version']}"
when 'mac_os_x'
default['git']['osx_dmg']['app_name'] = 'git-2.8.1-intel-universal-mavericks'
default['git']['osx_dmg']['volumes_dir'] = 'Git 2.8.1 Mavericks Intel Universal'
default['git']['osx_dmg']['package_id'] = 'GitOSX.Installer.git281Universal.git.pkg'
default['git']['osx_dmg']['url'] = 'http://sourceforge.net/projects/git-osx-installer/files/git-2.8.1-intel-universal-mavericks.dmg/download'
default['git']['osx_dmg']['checksum'] = 'c2912895a1e2018d9be4c646765d511f7c82e0114275505dbd13d1ac70c62023'
else
default['git']['prefix'] = '/usr/local'
default['git']['version'] = '2.8.1'
default['git']['version'] = '2.17.1'
default['git']['url'] = 'https://nodeload.github.com/git/git/tar.gz/v%{version}'
default['git']['checksum'] = 'e08503ecaf5d3ac10c40f22871c996a392256c8d038d16f52ebf974cba29ae42'
default['git']['checksum'] = '690f12cc5691e5adaf2dd390eae6f5acce68ae0d9bd9403814f8a1433833f02a'
default['git']['use_pcre'] = false
end

View File

@@ -3,9 +3,8 @@ module GitCookbook
# linux packages default to distro offering
def parsed_package_name
return new_resource.package_name if new_resource.package_name
return 'git-core' if node['platform'] == 'ubuntu' && node['platform_version'].to_f < 10.10
return 'developer/versioning/git' if node['platform'] == 'omnios'
return 'scmgit' if node['platform'] == 'smartos'
return 'developer/versioning/git' if platform?('smartos')
return 'scmgit' if platform?('smartos')
'git'
end
@@ -21,7 +20,7 @@ module GitCookbook
def parsed_source_checksum
return new_resource.source_checksum if new_resource.source_checksum
'8d53703d75890c03e26a915c7af3b7b98d8cfb94382f685a9bcbee1eeaec47b4' # 2.7.4 tarball
'690f12cc5691e5adaf2dd390eae6f5acce68ae0d9bd9403814f8a1433833f02a' # 2.17.1 tarball
end
# windows

View File

@@ -1,16 +0,0 @@
if defined?(ChefSpec)
ChefSpec.define_matcher(:git_client)
ChefSpec.define_matcher(:git_service)
def set_git_config(resource_name) # rubocop:disable Style/AccessorMethodName
ChefSpec::Matchers::ResourceMatcher.new(:git_config, :set, resource_name)
end
def install_git_client(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:git_client, :install, resource_name)
end
def install_git_service(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:git_service, :install, resource_name)
end
end

View File

@@ -1,12 +1,6 @@
class Chef
class Provider
class GitClient < Chef::Provider::LWRPBase
use_inline_resources
def whyrun_supported?
true
end
include GitCookbook::Helpers
end
end

View File

@@ -2,20 +2,10 @@ class Chef
class Provider
class GitClient
class Osx < Chef::Provider::GitClient
include Chef::DSL::IncludeRecipe
provides :git_client, os: 'mac_os_x'
provides :git_client, platform: 'mac_os_x'
action :install do
dmg_package 'GitOSX-Installer' do
app new_resource.osx_dmg_app_name
package_id new_resource.osx_dmg_package_id
volumes_dir new_resource.osx_dmg_volumes_dir
source new_resource.osx_dmg_url
checksum new_resource.osx_dmg_checksum
type 'pkg'
action :install
end
package 'git'
end
action :delete do

View File

@@ -2,14 +2,9 @@ class Chef
class Provider
class GitClient
class Package < Chef::Provider::GitClient
include Chef::DSL::IncludeRecipe
provides :git_client, os: 'linux'
action :install do
# FIXME: rhel 5
include_recipe 'yum-epel' if node['platform_family'] == 'rhel' && node['platform_version'].to_i == 5
# Software installation
package "#{new_resource.name} :create #{parsed_package_name}" do
package_name parsed_package_name

View File

@@ -2,30 +2,16 @@ class Chef
class Provider
class GitClient
class Source < Chef::Provider::GitClient
include Chef::DSL::IncludeRecipe
action :install do
return "#{node['platform']} is not supported by the #{cookbook_name}::#{recipe_name} recipe" unless platform_family?('rhel', 'suse', 'fedora', 'debian')
raise "#{node['platform']} is not supported by the git_client source resource" unless platform_family?('rhel', 'suse', 'fedora', 'debian', 'amazon')
include_recipe 'build-essential'
include_recipe 'yum-epel' if node['platform_family'] == 'rhel' && node['platform_version'].to_i == 5
build_essential 'install compilation tools for git'
# move this to attributes.
case node['platform_family']
when 'fedora'
pkgs = %w(tar openssl-devel libcurl-devel expat-devel perl-ExtUtils-MakeMaker)
when 'rhel'
case node['platform_version'].to_i
when 5
pkgs = %w(tar expat-devel gettext-devel curl-devel openssl-devel zlib-devel)
pkgs += %w( pcre-devel ) if new_resource.source_use_pcre
when 6, 7
pkgs = %w(tar expat-devel gettext-devel libcurl-devel openssl-devel perl-ExtUtils-MakeMaker zlib-devel)
pkgs += %w( pcre-devel ) if new_resource.source_use_pcre
else
pkgs = %w(expat-devel gettext-devel curl-devel openssl-devel perl-ExtUtils-MakeMaker zlib-devel) if node['platform'] == 'amazon'
pkgs += %w( pcre-devel ) if new_resource.source_use_pcre
end
when 'rhel', 'fedora', 'amazon'
pkgs = %w(tar expat-devel gettext-devel libcurl-devel openssl-devel perl-ExtUtils-MakeMaker zlib-devel)
pkgs += %w( pcre-devel ) if new_resource.source_use_pcre
when 'debian'
pkgs = %w(libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev)
pkgs += %w( libpcre3-dev ) if new_resource.source_use_pcre
@@ -52,7 +38,7 @@ class Chef
command <<-COMMAND
(mkdir git-#{new_resource.source_version} && tar -zxf git-#{new_resource.source_version}.tar.gz -C git-#{new_resource.source_version} --strip-components 1)
(cd git-#{new_resource.source_version} && make prefix=#{new_resource.source_prefix} #{additional_make_params} install)
COMMAND
COMMAND
not_if "git --version | grep #{new_resource.source_version}"
not_if "#{new_resource.source_prefix}/bin/git --version | grep #{new_resource.source_version}"
end

View File

@@ -3,8 +3,6 @@ class Chef
class Provider
class GitClient
class Windows < Chef::Provider::GitClient
include Chef::DSL::IncludeRecipe
provides :git_client, os: 'windows'
action :install do
@@ -22,7 +20,7 @@ class Chef
else
ENV['ProgramW6432'] || ENV['ProgramFiles']
end
GIT_PATH = "#{PROGRAM_FILES}\\Git\\Cmd".freeze
GIT_PATH = "#{PROGRAM_FILES}\\Git\\Cmd"
# COOK-3482 - windows_path resource doesn't change the current process
# environment variables. Therefore, git won't actually be on the PATH
@@ -36,7 +34,7 @@ class Chef
end
windows_path GIT_PATH do
notifies :create, 'ruby_block[Add Git Path]', :immediately
notifies :run, 'ruby_block[Add Git Path]', :immediately
action :add
end
end

View File

@@ -1,19 +1,13 @@
class Chef
class Provider
class GitClient < Chef::Provider::LWRPBase
use_inline_resources
def whyrun_supported?
true
end
include Chef::DSL::IncludeRecipe
include GitCookbook::Helpers
provides :git_service, os: 'linux'
action :create do
return "#{node['platform']} is not supported by the #{cookbook_name}::#{recipe_name} recipe" if node['platform'] == 'windows'
return "#{node['platform']} is not supported by the #{cookbook_name}::#{recipe_name} recipe" if platform?('windows')
include_recipe 'git'

View File

@@ -1,55 +0,0 @@
class Chef
class Provider
class GitClient < Chef::Provider::LWRPBase
use_inline_resources
def whyrun_supported?
true
end
include Chef::DSL::IncludeRecipe
include GitCookbook::Helpers
action :create do
return "#{node['platform']} is not supported by the #{cookbook_name}::#{recipe_name} recipe" if node['platform'] == 'windows'
include_recipe 'git'
directory new_resource.service_base_path do
owner 'root'
group 'root'
mode '0755'
end
case node['platform_family']
when 'debian'
package 'xinetd'
when 'rhel'
package 'git-daemon'
else
log 'Platform requires setting up a git daemon service script.'
log "Hint: /usr/bin/git daemon --export-all --user=nobody --group=daemon --base-path=#{new_resource.service_base_path}"
return
end
template '/etc/xinetd.d/git' do
backup false
source 'git-xinetd.d.erb'
owner 'root'
group 'root'
mode '0644'
variables(
git_daemon_binary: value_for_platform_family(
'debian' => '/usr/lib/git-core/git-daemon',
'rhel' => '/usr/libexec/git-core/git-daemon'
)
)
end
service 'xinetd' do
action [:enable, :restart]
end
end
end
end
end

File diff suppressed because one or more lines are too long

26
cookbooks/git/metadata.rb Normal file
View File

@@ -0,0 +1,26 @@
name 'git'
maintainer 'Chef Software, Inc.'
maintainer_email 'cookbooks@chef.io'
license 'Apache-2.0'
description 'Installs git and/or sets up a Git server daemon'
version '10.0.0'
supports 'amazon'
supports 'centos'
supports 'debian'
supports 'fedora'
supports 'freebsd'
supports 'mac_os_x'
supports 'omnios'
supports 'oracle'
supports 'redhat'
supports 'smartos'
supports 'scientific'
supports 'suse'
supports 'opensuseleap'
supports 'ubuntu'
supports 'windows'
source_url 'https://github.com/chef-cookbooks/git'
issues_url 'https://github.com/chef-cookbooks/git/issues'
chef_version '>= 14'

View File

@@ -2,7 +2,7 @@
# Cookbook:: git
# Recipe:: default
#
# Copyright:: 2008-2016, Chef Software, Inc.
# Copyright:: 2008-2019, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.

View File

@@ -2,7 +2,7 @@
# Cookbook:: git
# Recipe:: package
#
# Copyright:: 2008-2016, Chef Software, Inc.
# Copyright:: 2008-2019, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -17,17 +17,6 @@
# limitations under the License.
case node['platform']
when 'mac_os_x'
# FIXME: The resource has three distinct groups of properties used in
# different providers... should we make multiple resource types instead?
git_client 'default' do
osx_dmg_app_name node['git']['osx_dmg']['app_name']
osx_dmg_package_id node['git']['osx_dmg']['package_id']
osx_dmg_volumes_dir node['git']['osx_dmg']['volumes_dir']
osx_dmg_url node['git']['osx_dmg']['url']
osx_dmg_checksum node['git']['osx_dmg']['checksum']
action :install
end
when 'windows'
include_recipe 'git::windows'
else

View File

@@ -2,7 +2,7 @@
# Cookbook:: git
# Recipe:: server
#
# Copyright:: 2009-2016, Chef Software, Inc.
# Copyright:: 2009-2019, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.

View File

@@ -2,7 +2,7 @@
# Cookbook:: git
# Recipe:: windows
#
# Copyright:: 2008-2016, Chef Software, Inc.
# Copyright:: 2008-2019, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.

View File

@@ -1,4 +1,4 @@
property :key, String, name_attribute: true
property :key, String, name_property: true
property :value, String
property :scope, equal_to: %w(local global system), default: 'global', desired_state: false
property :path, String, desired_state: false
@@ -6,10 +6,6 @@ property :user, String, desired_state: false
property :group, String, desired_state: false
property :options, String, desired_state: false
attr_accessor :exists
require 'mixlib/shellout'
def initialize(*args)
super
@@ -38,7 +34,7 @@ action :set do
end
end
action_class.class_eval do
action_class do
def config_cmd
"git config --#{new_resource.scope}"
end

View File

@@ -1,2 +0,0 @@
#!/bin/sh
exec svlogd -tt ./main

View File

@@ -1,3 +0,0 @@
#!/bin/sh
exec 2>&1
exec /usr/bin/git daemon <%= node['git']['server']['export_all'] ? '--export-all' : nil %> --user=nobody --group=daemon --syslog --base-path=<%= node["git"]["server"]["base_path"] %> <%= node["git"]["server"]["base_path"] %>