Skip to content

Commit bf6978a

Browse files
committed
Merge pull request #3569 from andersonmills/improvement/master/PUP-3254-Remove_Modulefile_functionality
(PUP-3254) Removing Modulefile functionality
2 parents 5e4877c + 83be0ee commit bf6978a

File tree

12 files changed

+59
-152
lines changed

12 files changed

+59
-152
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
test_name 'puppet module changes (on a module which is missing checksums.json)'
2+
3+
step 'Setup'
4+
5+
stub_forge_on(master)
6+
testdir = master.tmpdir('module_changes_on_invalid_checksums')
7+
8+
apply_manifest_on master, %Q{
9+
file { '#{testdir}/nginx': ensure => directory;
10+
'#{testdir}/nginx/metadata.json': ensure => present,
11+
content => '
12+
{
13+
"name": "puppetlabs-nginx",
14+
"version": "0.0.1",
15+
"author": "Puppet Labs",
16+
"summary": "Nginx Module",
17+
"license": "Apache Version 2.0",
18+
"source": "git://github.com/puppetlabs/puppetlabs-nginx.git",
19+
"project_page": "http://github.com/puppetlabs/puppetlabs-nginx",
20+
"issues_url": "http://github.com/puppetlabs/puppetlabs-nginx",
21+
"dependencies": [
22+
{"name":"puppetlabs-stdlub","version_requirement":">= 1.0.0"}
23+
]
24+
}'
25+
}
26+
}
27+
28+
step 'Run module changes on a module which is missing checksums.json'
29+
on( master, puppet("module changes #{testdir}/nginx"),
30+
:acceptable_exit_codes => [1] ) do
31+
32+
pattern = Regexp.new([
33+
%Q{.*Error: No file containing checksums found.*},
34+
%Q{.*Error: Try 'puppet help module changes' for usage.*},
35+
].join("\n"), Regexp::MULTILINE)
36+
assert_match(pattern, result.stderr)
37+
end

acceptance/tests/modules/changes/missing_metadata_json.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@
66
testdir = master.tmpdir('module_changes_on_invalid_metadata')
77

88
apply_manifest_on master, %Q{
9-
file { '#{testdir}/nginx': ensure => directory;
10-
'#{testdir}/nginx/Modulefile': ensure => present }
9+
file { '#{testdir}/nginx': ensure => directory }
1110
}
1211

13-
step 'Run module changes on a module witch is missing metadata.json'
12+
step 'Run module changes on a module which is missing metadata.json'
1413
on( master, puppet("module changes #{testdir}/nginx"),
1514
:acceptable_exit_codes => [1] ) do
1615

1716
pattern = Regexp.new([
18-
%Q{.*Error: No file containing checksums found.*},
17+
%Q{.*Error: Could not find a valid module at.*},
1918
%Q{.*Error: Try 'puppet help module changes' for usage.*},
2019
].join("\n"), Regexp::MULTILINE)
2120
assert_match(pattern, result.stderr)

lib/puppet/face/module/build.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
Prepares a local module for release on the Puppet Forge by building a
66
ready-to-upload archive file.
77
8-
This action uses the Modulefile in the module directory to set metadata
9-
used by the Forge. See <http://links.puppetlabs.com/modulefile> for more
10-
about writing modulefiles.
8+
This action uses the metadata.json file in the module directory to set metadata
9+
used by the Forge. See <https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html> for more
10+
about writing metadata.json files.
1111
1212
After being built, the release archive file can be found in the module's
1313
`pkg` directory.
@@ -43,11 +43,11 @@
4343
pwd = Dir.pwd
4444
module_path = Puppet::ModuleTool.find_module_root(pwd)
4545
if module_path.nil?
46-
raise "Unable to find metadata.json or Modulefile in module root #{pwd} or parent directories. See <http://links.puppetlabs.com/modulefile> for required file format."
46+
raise "Unable to find metadata.json in module root #{pwd} or parent directories. See <https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html> for required file format."
4747
end
4848
else
4949
unless Puppet::ModuleTool.is_module_root?(module_path)
50-
raise "Unable to find metadata.json or Modulefile in module root #{module_path}. See <http://links.puppetlabs.com/modulefile> for required file format."
50+
raise "Unable to find metadata.json in module root #{module_path} or parent directories. See <https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html> for required file format."
5151
end
5252
end
5353

lib/puppet/face/module/generate.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@
107107
begin
108108
# A default dependency for all newly generated modules is being
109109
# introduced as a substitute for the comments we used to include in the
110-
# Modulefile. While introducing a default dependency is less than
111-
# perfectly desirable, the cost is low, and the syntax is obtuse enough
112-
# to justify its inclusion.
110+
# previous module data specifications. While introducing a default
111+
# dependency is less than perfectly desirable, the cost is low, and the
112+
# syntax is obtuse enough to justify its inclusion.
113113
metadata = Puppet::ModuleTool::Metadata.new.update(
114114
'name' => name,
115115
'version' => '0.1.0',

lib/puppet/module_tool.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ def self.username_and_modname_from(full_module_name)
3939
end
4040

4141
# Find the module root when given a path by checking each directory up from
42-
# its current location until it finds one that contains a file called
43-
# 'Modulefile'.
42+
# its current location until it finds one that satisfies is_module_root?
4443
#
4544
# @param path [Pathname, String] path to start from
4645
# @return [Pathname, nil] the root path of the module directory or nil if
@@ -56,14 +55,14 @@ def self.find_module_root(path)
5655
end
5756

5857
# Analyse path to see if it is a module root directory by detecting a
59-
# file named 'metadata.json' or 'Modulefile' in the directory.
58+
# file named 'metadata.json'
6059
#
6160
# @param path [Pathname, String] path to analyse
6261
# @return [Boolean] true if the path is a module root, false otherwise
6362
def self.is_module_root?(path)
6463
path = Pathname.new(path) if path.class == String
6564

66-
FileTest.file?(path + 'metadata.json') || FileTest.file?(path + 'Modulefile')
65+
FileTest.file?(path + 'metadata.json')
6766
end
6867

6968
# Builds a formatted tree from a list of node hashes containing +:text+
@@ -189,6 +188,5 @@ def self.parse_module_dependency(where, dep)
189188
require 'puppet/module_tool/contents_description'
190189
require 'puppet/module_tool/dependency'
191190
require 'puppet/module_tool/metadata'
192-
require 'puppet/module_tool/modulefile'
193191
require 'puppet/forge/cache'
194192
require 'puppet/forge'

lib/puppet/module_tool/applications/application.rb

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ def metadata(require_metadata = false)
4141
end
4242

4343
if require_metadata && !Puppet::ModuleTool.is_module_root?(@path)
44-
raise ArgumentError, "Unable to find metadata.json or Modulefile in module root at #{@path} See http://links.puppetlabs.com/modulefile for required file format."
44+
raise ArgumentError, "Unable to find metadata.json in module root at #{@path} See https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html for required file format."
4545
end
4646

47-
modulefile_path = File.join(@path, 'Modulefile')
4847
metadata_path = File.join(@path, 'metadata.json')
4948

5049
if File.file?(metadata_path)
@@ -57,14 +56,8 @@ def metadata(require_metadata = false)
5756
end
5857
end
5958

60-
if File.file?(modulefile_path)
61-
if File.file?(metadata_path)
62-
Puppet.warning "Modulefile is deprecated. Merging your Modulefile and metadata.json."
63-
else
64-
Puppet.warning "Modulefile is deprecated. Building metadata.json from Modulefile."
65-
end
66-
67-
Puppet::ModuleTool::ModulefileReader.evaluate(@metadata, modulefile_path)
59+
if File.file?(File.join(@path, 'Modulefile'))
60+
Puppet.warning "A Modulefile was found in the root directory of the module. This file will be ignored and can safely be removed."
6861
end
6962

7063
return @metadata

lib/puppet/module_tool/metadata.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def add_dependency(name, version_requirement=nil, repository=nil)
6666
validate_version_range(version_requirement) if version_requirement
6767

6868
if dup = @data['dependencies'].find { |d| d.full_module_name == name && d.version_requirement != version_requirement }
69-
raise ArgumentError, "Dependency conflict for #{full_module_name}: Dependency #{name} was given conflicting version requirements #{version_requirement} and #{dup.version_requirement}. Verify that there are no duplicates in the metadata.json or the Modulefile."
69+
raise ArgumentError, "Dependency conflict for #{full_module_name}: Dependency #{name} was given conflicting version requirements #{version_requirement} and #{dup.version_requirement}. Verify that there are no duplicates in the metadata.json."
7070
end
7171

7272
dep = Dependency.new(name, version_requirement, repository)

lib/puppet/module_tool/modulefile.rb

Lines changed: 0 additions & 78 deletions
This file was deleted.

spec/unit/face/module/build_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
it "if current directory or parents contain no module root, should return exception" do
2626
Dir.expects(:pwd).returns('/a/b/c')
2727
Puppet::ModuleTool.expects(:find_module_root).returns(nil)
28-
expect { subject.build }.to raise_error RuntimeError, "Unable to find metadata.json or Modulefile in module root /a/b/c or parent directories. See <http://links.puppetlabs.com/modulefile> for required file format."
28+
expect { subject.build }.to raise_error RuntimeError, "Unable to find metadata.json in module root /a/b/c or parent directories. See <https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html> for required file format."
2929
end
3030
end
3131

@@ -39,7 +39,7 @@
3939

4040
it "if path is not a module root should raise exception" do
4141
Puppet::ModuleTool.expects(:is_module_root?).with('/a/b/c').returns(false)
42-
expect { subject.build('/a/b/c') }.to raise_error RuntimeError, "Unable to find metadata.json or Modulefile in module root /a/b/c. See <http://links.puppetlabs.com/modulefile> for required file format."
42+
expect { subject.build('/a/b/c') }.to raise_error RuntimeError, "Unable to find metadata.json in module root /a/b/c or parent directories. See <https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html> for required file format."
4343
end
4444
end
4545

spec/unit/module_spec.rb

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -626,19 +626,7 @@
626626

627627
it "should not have metadata if has a metadata file and its data is empty" do
628628
Puppet::FileSystem.expects(:exist?).with(@module.metadata_file).returns true
629-
File.stubs(:read).with(@module.metadata_file).returns "/*
630-
+-----------------------------------------------------------------------+
631-
| |
632-
| ==> DO NOT EDIT THIS FILE! <== |
633-
| |
634-
| You should edit the `Modulefile` and run `puppet-module build` |
635-
| to generate the `metadata.json` file for your releases. |
636-
| |
637-
+-----------------------------------------------------------------------+
638-
*/
639-
640-
{}"
641-
629+
File.stubs(:read).with(@module.metadata_file).returns "This is some invalid json.\n"
642630
expect(@module).not_to be_has_metadata
643631
end
644632

0 commit comments

Comments
 (0)