Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Commit

Permalink
Remove more string literal comments and fix some specs
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Smith <tsmith@chef.io>
  • Loading branch information
tas50 committed May 7, 2019
1 parent 3f94c99 commit 10eadcf
Show file tree
Hide file tree
Showing 32 changed files with 513 additions and 50 deletions.
15 changes: 7 additions & 8 deletions lib/chef-dk/command/generator_commands/repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,21 @@ class Repo < Base
short: "-r",
long: "--roles",
description: "Create roles and environments directories instead of using Policyfiles.",
default: true,
default: nil

option :policy,
short: "-P",
long: "--policy",
description: "Use Policyfiles instead of roles and environments.",
boolean: true,
default: true
default: nil

options.merge!(SharedGeneratorOptions.options)

def initialize(params)
@params_valid = true
@repo_name = nil
@use_roles = true
@use_policy = true
super
end

Expand All @@ -77,7 +76,7 @@ def setup_context
super
Generator.add_attr_to_context(:repo_root, repo_root)
Generator.add_attr_to_context(:repo_name, repo_name)
Generator.add_attr_to_context(:use_roles, use_roles?)
Generator.add_attr_to_context(:use_policy, use_policy?)
end

def recipe
Expand All @@ -96,8 +95,8 @@ def repo_full_path
File.expand_path(repo_name_or_path, Dir.pwd)
end

def use_roles?
@use_roles
def use_policy?
@use_policy
end

def read_and_validate_params
Expand All @@ -110,8 +109,8 @@ def read_and_validate_params
err("Roles and Policyfiles are exclusive. Please only select one.")
@params_valid = false
end
if config[:policy]
@use_roles = false
if config[:roles]
@use_policy = false
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# frozen_string_literal: true
%w(unit lint syntax).each do |phase|
# TODO: This works on Linux/Unix. Not Windows.
execute "HOME=/home/vagrant delivery job verify #{phase} --server localhost --ent test --org kitchen" do
Expand Down
1 change: 0 additions & 1 deletion lib/chef-dk/skeletons/code_generator/metadata.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# frozen_string_literal: true
name 'code_generator'
maintainer 'Chef Software, Inc.'
maintainer_email 'dev@chef.io'
Expand Down
2 changes: 0 additions & 2 deletions lib/chef-dk/skeletons/code_generator/recipes/attribute.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

context = ChefDK::Generator.context
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
attribute_dir = File.join(cookbook_dir, 'attributes')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

context = ChefDK::Generator.context
delivery_project_dir = context.delivery_project_dir
pipeline = context.pipeline
Expand Down
2 changes: 0 additions & 2 deletions lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

context = ChefDK::Generator.context
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)

Expand Down
2 changes: 0 additions & 2 deletions lib/chef-dk/skeletons/code_generator/recipes/cookbook_file.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

context = ChefDK::Generator.context
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
files_dir = File.join(cookbook_dir, 'files', 'default')
Expand Down
2 changes: 0 additions & 2 deletions lib/chef-dk/skeletons/code_generator/recipes/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

context = ChefDK::Generator.context
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
libraries_dir = File.join(cookbook_dir, 'libraries')
Expand Down
2 changes: 0 additions & 2 deletions lib/chef-dk/skeletons/code_generator/recipes/policyfile.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

context = ChefDK::Generator.context
policyfile_path = File.join(context.policyfile_dir, "#{context.new_file_basename}.rb")

Expand Down
2 changes: 0 additions & 2 deletions lib/chef-dk/skeletons/code_generator/recipes/recipe.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

context = ChefDK::Generator.context
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
recipe_path = File.join(cookbook_dir, 'recipes', "#{context.new_file_basename}.rb")
Expand Down
7 changes: 3 additions & 4 deletions lib/chef-dk/skeletons/code_generator/recipes/repo.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# frozen_string_literal: true
context = ChefDK::Generator.context
repo_dir = File.join(context.repo_root, context.repo_name)

Expand Down Expand Up @@ -29,10 +28,10 @@

directories_to_create = %w( cookbooks data_bags )

directories_to_create += if context.use_roles
%w( roles environments )
else
directories_to_create += if context.use_policy
%w( policyfiles )
else
%w( roles environments )
end

directories_to_create.each do |tlo|
Expand Down
1 change: 0 additions & 1 deletion lib/chef-dk/skeletons/code_generator/recipes/resource.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# frozen_string_literal: true
context = ChefDK::Generator.context
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)

Expand Down
1 change: 0 additions & 1 deletion lib/chef-dk/skeletons/code_generator/recipes/template.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# frozen_string_literal: true
context = ChefDK::Generator.context
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
template_dir = File.join(cookbook_dir, 'templates')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ driver:
provisioner:
name: chef_zero

## product_name and product_version specifies a specific Chef product and version to install.
## see the Chef documentation for more details: https://docs.chef.io/config_yml_kitchen.html
# product_name: chef
# product_version: 14
## product_name and product_version specifies a specific Chef product and version to install.
## see the Chef documentation for more details: https://docs.chef.io/config_yml_kitchen.html
# product_name: chef
# product_version: 14

verifier:
name: inspec
Expand Down
6 changes: 6 additions & 0 deletions myrepo/.chef-repo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.chef-repo.txt
==============

This file gives Chef DK's generators a hint that you are using a Chef Repo and
this is the root directory of your Chef Repo. Chef DK's generators use this to
generate code that is designed to work with the Chef Repo workflow.
124 changes: 124 additions & 0 deletions myrepo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
## Below are example of common git excludes.
## Please note that /cookbooks folder is ignored. This allows users to
## clone individual cookbooks into the /cookbook folder of the chef repo
## and work on them in parallel. This pattern also allows for chef-workstation
## pattern, where base repo also builds out a dynamic chef workstation.
## Examples of workstation cookbooks:
## https://github.com/mwrock/chef_workstation
## https://github.com/Nordstrom/chefdk_bootstrap


## Ignore Chef related files and secrets
.chef
.chef/*.pem
.chef/encrypted_data_bag_secret

## Ignore Chef-Zero files
clients
nodes

# ## OS junk files
# [Tt]humbs.db
# *.DS_Store

# ## Example of the workstation pattern.
# !/cookbooks/chef_workstation/files/default/bundler/Gemfile
# !/cookbooks/chef_workstation/files/default/bundler/Gemfile.lock
# cookbooks/*
# !cookbooks/chef_workstation

# ##Chef
# .kitchen/
# .vagrant
# nodes
# metadata.json

# ##ruby
# *.gem
# Gemfile
# Gemfile.lock
.rake_test_cache

# ## Rails Heroku and other bits to ignore
# *.log
# *.sqlite3
# db/*.sqlite3
# .bundle
# log/*
# tmp/*
# public/system/*

# ##nodejs
# node_modules

# # Nuget (exclude all exes except for the one in the global build folder)
# nuget.exe
# !build/nuget/nuget.exe
# *.nupkg
# # NuGet packages (based on default naming convention)
# [Bb]uild/[Pp]ackages/

# # Build System # common build output folders
# build-common/
# output/

# ## Probably not a good idea to be keeing VM inages in source control
# *.vhd
# *.vhdx

# ## Pester Test summary
# Test.xml

# ##Webstorm files
# *.idea
# .idea
# .idea/

# ##Mono (or something?) files
# *.pidb
# *.userprefs

# ## Visual Studio files
# *.docstates
# *.[Oo]bj
# *.dat
# *.crc
# *.dbmdl
# *.pdb
# *.user
# *.aps
# *.pch
# *.vspscc
# *.vssscc
# *_i.c
# *_p.c
# *.ncb
# *.suo
# *.tlb
# *.tlh
# *.bak
# *.[Cc]ache
# *.ilk
# *.log
# *.lib
# *.sbr
# *.schemaview
# ipch/
# [Oo]bj/
# [Bb]in/*
# [Dd]ebug*/
# [Rr]elease*/
# Ankh.NoLoad

# ##Tooling
# _ReSharper*/
# *.[Rr]e[Ss]harper
# [Tt]est[Rr]esult*
# .[Jj]ust[Cc]ode
# *ncrunch*

# ##Subversion files
# .svn

# ## Office Temp Files
# ~$*
3 changes: 3 additions & 0 deletions myrepo/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Copyright 2019 The Authors

All rights reserved, do not redistribute.
22 changes: 22 additions & 0 deletions myrepo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Overview

Every Chef Infra installation needs a Chef Repository. This is the place where cookbooks, policyfiles, config files and other artifacts for managing systems with Chef Infra will live. We strongly recommend storing this repository in a version control system such as Git and treating it like source code.

# Repository Directories

This repository contains several directories, and each directory contains a README file that describes what it is for in greater detail, and how to use it for managing your systems with Chef.

- `cookbooks/` - Cookbooks you download or create.
- `data_bags/` - Store data bags and items in .json in the repository.
- `roles/` - Store roles in .rb or .json in the repository.
- `environments/` - Store environments in .rb or .json in the repository.

# Configuration

The config file, `.chef/config.rb` is a repository specific configuration file for knife. If you're using the Chef Platform, you can download one for your organization from the management console. You can generate a new one with `knife configure`. For more information about configuring Knife, see the Knife documentation.

<https://docs.chef.io/knife.html>

# Next Steps

Read the README file in each of the subdirectories for more information about what goes in those directories.
Loading

0 comments on commit 10eadcf

Please sign in to comment.