Newer
Older
import git
import os
import subprocess as spr
import glob
{% if cookiecutter.use_reuse == "yes" %}
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
spr.check_call(
[
"reuse",
"annotate",
"--year",
"{{ cookiecutter.copyright_year }}",
"--license",
"{{ cookiecutter.documentation_license }}",
"--copyright",
"{{ cookiecutter.copyright_holder }}",
"--recursive",
"README.md",
]
)
spr.check_call(
[
"reuse",
"annotate",
"--year",
"{{ cookiecutter.copyright_year }}",
"--license",
"{{ cookiecutter.supplementary_files_license }}",
"--copyright",
"{{ cookiecutter.copyright_holder }}",
"--recursive",
".gitignore",
".pre-commit-config.yaml",
"Chart.yaml",
"values.yaml",
"linter_values.yaml",
".gitlab-ci.yml",
]
)
spr.check_call(
[
"reuse",
"annotate",
"--year",
"{{ cookiecutter.copyright_year }}",
"--license",
"{{ cookiecutter.supplementary_files_license }}",
"--copyright",
"{{ cookiecutter.copyright_holder }}",
"--recursive",
"--style",
"python",
".helmignore",
]
)
spr.check_call(
[
"reuse",
"annotate",
"--year",
"{{ cookiecutter.copyright_year }}",
"--license",
"{{ cookiecutter.templates_license }}",
"--copyright",
"{{ cookiecutter.copyright_holder }}",
"--recursive",
"--force-dot-license",
"templates/NOTES.txt",
"templates/_helpers.tpl",
]
)
spr.check_call(
[
"reuse",
"annotate",
"--year",
"{{ cookiecutter.copyright_year }}",
"--license",
"{{ cookiecutter.templates_license }}",
"--copyright",
"{{ cookiecutter.copyright_holder }}",
"--recursive",
"templates",
]
)
spr.check_call(
[
"reuse",
"annotate",
"--year",
"{{ cookiecutter.copyright_year }}",
"--license",
"Unlicense",
"--copyright",
"{{ cookiecutter.copyright_holder }}",
"scripts/print_version.py",
]
)
spr.check_call(["reuse", "download", "--all"])
{% endif %}
{% if not cookiecutter.install_basic_hereon_setup == "yes" %}
os.remove("templates/k8sgitlab-secret.yaml")
os.remove("templates/{{cookiecutter.template_base_name}}-deploymentconfig.yaml")
os.remove("templates/{{cookiecutter.template_base_name}}-buildconfig.yaml")
os.remove("templates/{{cookiecutter.template_base_name}}-imagestream.yaml")
os.remove("templates/{{cookiecutter.template_base_name}}-service.yaml")
{% elif not cookiecutter.service_port %}
os.remove("templates/{{cookiecutter.template_base_name}}-service.yaml")
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
{% endif %}
print("Fixing files for project at {{cookiecutter.project_slug}}")
repo = git.Repo.init(".", mkdir=False)
{% if cookiecutter.git_remote_protocoll == "ssh" %}
repo.create_remote(
"origin",
"git@{{ cookiecutter.gitlab_host }}:{{ cookiecutter.gitlab_username }}/{{ cookiecutter.project_slug }}.git",
)
{% else %}
repo.create_remote(
"origin",
"https://{{ cookiecutter.gitlab_host }}/{{ cookiecutter.gitlab_username }}/{{ cookiecutter.project_slug }}.git",
)
{% endif %}
repo.git.add(".")
spr.check_call(["pre-commit", "install"])
# make a silent run first to fix the files
spr.call(["pre-commit", "run"], stdout=spr.DEVNULL)
# add the files again after pre-commit hook has been run
repo.git.add(".")
spr.check_call(["pre-commit", "run"])
for dirpath, dirnames, filenames in os.walk("."):
if "__pycache__" in dirnames:
shutil.rmtree(os.path.join(dirpath, "__pycache__"))
print("""
===============================================================================
Contratulations!
===============================================================================
You just created a new helm chart for deployments in openshift.
{% if cookiecutter.use_reuse == "yes" -%}
+-------------------------------------------------------------+
| IMPORTANT NOTE: |
| |
| If you used cruft to create this package, please now run |
| the following commands to stage the .cruft.json file and |
| assign it the correct license: |
| |
+-------------------------------------------------------------+
1. Set the correct license information:
$ reuse --root {{ cookiecutter.project_slug }} annotate --year {{ cookiecutter.copyright_year }} --license {{ cookiecutter.supplementary_files_license }} --copyright "{{ cookiecutter.copyright_holder }}" {{ cookiecutter.project_slug }}/.cruft.json
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
2. Stage the file:
$ git -C {{ cookiecutter.project_slug }} add .cruft.json .cruft.json.license
3. Make your first commit via
$ git -C {{ cookiecutter.project_slug }} commit -m "Initial commit"
4. Make sure that the repository at https://{{ cookiecutter.gitlab_host }}/{{ cookiecutter.gitlab_username }}/{{ cookiecutter.project_slug }}
exists and bring your project on the web with
$ git -C {{ cookiecutter.project_slug }} push origin main
{% else %}
+-------------------------------------------------------------+
| IMPORTANT NOTE: |
| |
| You can now push everything to gitlab! |
| |
+-------------------------------------------------------------+
1. Make your first commit via
$ git -C {{ cookiecutter.project_slug }} commit -m "Initial commit"
2. Make sure that the repository at https://{{ cookiecutter.gitlab_host }}/{{ cookiecutter.gitlab_username }}/{{ cookiecutter.project_slug }}
exists and bring your project on the web with
$ git -C {{ cookiecutter.project_slug }} push origin main
{% endif -%}
""")