Skip to content
This repository was archived by the owner on Aug 4, 2023. It is now read-only.

Commit cdd6fda

Browse files
re-generated documentation output
1 parent 232c412 commit cdd6fda

File tree

2 files changed

+72
-21
lines changed

2 files changed

+72
-21
lines changed

docs/api/gcip/addons/kaniko/jobs.html

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ <h1 class="title">Module <code>gcip.addons.kaniko.jobs</code></h1>
4040

4141

4242
def execute(
43-
gitlab_executor_image: Optional[Union[Image, str]] = Image(&#34;gcr.io/kaniko-project/executor:latest&#34;, entrypoint=[&#34;&#34;]),
43+
gitlab_executor_image: Optional[Union[Image, str]] = Image(&#34;gcr.io/kaniko-project/executor:debug&#34;, entrypoint=[&#34;&#34;]),
4444
context: Optional[str] = None,
4545
image_name: Optional[str] = None,
4646
image_tag: Optional[str] = None,
@@ -116,6 +116,9 @@ <h1 class="title">Module <code>gcip.addons.kaniko.jobs</code></h1>
116116

117117
executor_cmd: List[str] = [&#34;executor&#34;]
118118

119+
if not context and PredefinedVariables.CI_PROJECT_DIR:
120+
context = PredefinedVariables.CI_PROJECT_DIR
121+
119122
if context:
120123
if context.endswith(&#34;/&#34;):
121124
context = context[:-1]
@@ -130,6 +133,9 @@ <h1 class="title">Module <code>gcip.addons.kaniko.jobs</code></h1>
130133
if verbosity:
131134
executor_cmd.append(f&#34;--verbosity {verbosity}&#34;)
132135

136+
if not dockerfile and PredefinedVariables.CI_PROJECT_DIR:
137+
dockerfile = f&#34;{PredefinedVariables.CI_PROJECT_DIR}/Dockerfile&#34;
138+
133139
if dockerfile:
134140
executor_cmd.append(f&#34;--dockerfile {dockerfile}&#34;)
135141

@@ -163,11 +169,9 @@ <h1 class="title">Module <code>gcip.addons.kaniko.jobs</code></h1>
163169
job.prepend_scripts(&#39;mkdir -p /kaniko/.docker &amp;&amp; echo &#34;{\\&#34;credsStore\\&#34;:\\&#34;ecr-login\\&#34;}&#34; &gt; /kaniko/.docker/config.json&#39;)
164170

165171
if dockerhub_user_env_var and dockerhub_login_env_var:
166-
# auth=$(echo &#34;$DOCKER_USER:$DOCKER_LOGIN&#34; | base64)
167-
auth = f&#39;$(echo &#34;${dockerhub_user_env_var}:${dockerhub_login_env_var}&#34; | base64)&#39;
168172
job.prepend_scripts(
169-
&#39;mkdir -p /kaniko/.docker &amp;&amp; echo &#34;{\\&#34;auths\\&#34;:{\\&#34;https://index.docker.io/v1/\\&#34;:{\\&#34;auth\\&#34;:\\&#34;&#39; + auth +
170-
&#39;\\&#34;}}}&#34; &gt; /kaniko/.docker/config.json&#39;
173+
&#39;mkdir -p /kaniko/.docker &amp;&amp; echo &#34;{\\&#34;auths\\&#34;:{\\&#34;https://index.docker.io/v1/\\&#34;:{\\&#34;username\\&#34;:\\&#34;$&#39; +
174+
dockerhub_user_env_var + &#39;\\&#34;,\\&#34;password\\&#34;:\\&#34;$&#39; + dockerhub_login_env_var + &#39;\\&#34;}}}&#34; &gt; /kaniko/.docker/config.json&#39;
171175
)
172176

173177
job.append_scripts(&#34; &#34;.join(executor_cmd), &#34;rm -rf /kaniko/.docker/config.json&#34;)
@@ -249,7 +253,7 @@ <h2 id="returns">Returns</h2>
249253
<span>Expand source code</span>
250254
</summary>
251255
<pre><code class="python">def execute(
252-
gitlab_executor_image: Optional[Union[Image, str]] = Image(&#34;gcr.io/kaniko-project/executor:latest&#34;, entrypoint=[&#34;&#34;]),
256+
gitlab_executor_image: Optional[Union[Image, str]] = Image(&#34;gcr.io/kaniko-project/executor:debug&#34;, entrypoint=[&#34;&#34;]),
253257
context: Optional[str] = None,
254258
image_name: Optional[str] = None,
255259
image_tag: Optional[str] = None,
@@ -325,6 +329,9 @@ <h2 id="returns">Returns</h2>
325329

326330
executor_cmd: List[str] = [&#34;executor&#34;]
327331

332+
if not context and PredefinedVariables.CI_PROJECT_DIR:
333+
context = PredefinedVariables.CI_PROJECT_DIR
334+
328335
if context:
329336
if context.endswith(&#34;/&#34;):
330337
context = context[:-1]
@@ -339,6 +346,9 @@ <h2 id="returns">Returns</h2>
339346
if verbosity:
340347
executor_cmd.append(f&#34;--verbosity {verbosity}&#34;)
341348

349+
if not dockerfile and PredefinedVariables.CI_PROJECT_DIR:
350+
dockerfile = f&#34;{PredefinedVariables.CI_PROJECT_DIR}/Dockerfile&#34;
351+
342352
if dockerfile:
343353
executor_cmd.append(f&#34;--dockerfile {dockerfile}&#34;)
344354

@@ -372,11 +382,9 @@ <h2 id="returns">Returns</h2>
372382
job.prepend_scripts(&#39;mkdir -p /kaniko/.docker &amp;&amp; echo &#34;{\\&#34;credsStore\\&#34;:\\&#34;ecr-login\\&#34;}&#34; &gt; /kaniko/.docker/config.json&#39;)
373383

374384
if dockerhub_user_env_var and dockerhub_login_env_var:
375-
# auth=$(echo &#34;$DOCKER_USER:$DOCKER_LOGIN&#34; | base64)
376-
auth = f&#39;$(echo &#34;${dockerhub_user_env_var}:${dockerhub_login_env_var}&#34; | base64)&#39;
377385
job.prepend_scripts(
378-
&#39;mkdir -p /kaniko/.docker &amp;&amp; echo &#34;{\\&#34;auths\\&#34;:{\\&#34;https://index.docker.io/v1/\\&#34;:{\\&#34;auth\\&#34;:\\&#34;&#39; + auth +
379-
&#39;\\&#34;}}}&#34; &gt; /kaniko/.docker/config.json&#39;
386+
&#39;mkdir -p /kaniko/.docker &amp;&amp; echo &#34;{\\&#34;auths\\&#34;:{\\&#34;https://index.docker.io/v1/\\&#34;:{\\&#34;username\\&#34;:\\&#34;$&#39; +
387+
dockerhub_user_env_var + &#39;\\&#34;,\\&#34;password\\&#34;:\\&#34;$&#39; + dockerhub_login_env_var + &#39;\\&#34;}}}&#34; &gt; /kaniko/.docker/config.json&#39;
380388
)
381389

382390
job.append_scripts(&#34; &#34;.join(executor_cmd), &#34;rm -rf /kaniko/.docker/config.json&#34;)

docs/user/index.html

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -510,17 +510,30 @@ <h2 id="_code_documentation">Code documentation</h2>
510510
<h2 id="_configuring_your_project_to_use_gcip">Configuring your project to use gcip</h2>
511511
<div class="sectionbody">
512512
<div class="paragraph">
513-
<p>Create a <code>.gitlab-ci.yaml</code> with following static content:</p>
513+
<p>Your Gitlab project needs these two files:</p>
514+
</div>
515+
<div class="quoteblock">
516+
<blockquote>
517+
<div class="paragraph">
518+
<p>MyProject
519+
├ .gitlab-ci.py
520+
└ .gitlab-ci.yml</p>
521+
</div>
522+
</blockquote>
523+
</div>
524+
<div class="paragraph">
525+
<p>The <code>.gitlab-ci.yml</code> is the file you already know. It&#8217;s only task is to
526+
render and trigger the child Pipeline created with the Gitlab CI Python Library.
527+
Latter is written into the <code>.gitlab-ci.py</code>. Here is how your <code>.gitlab-ci.yml</code> should
528+
look like:</p>
514529
</div>
515530
<div class="listingblock">
516531
<div class="content">
517532
<pre>---
518533
generate-pipeline:
519534
stage: build
520-
image: python:3
521-
script:
522-
- pip3 install -r requirements.txt
523-
- python3 .gitlab-ci.py &gt; generated-config.yml
535+
image: thomass/gcip:0.3.0
536+
script: /usr/src/app/docker/gcip.sh
524537
artifacts:
525538
paths:
526539
- generated-config.yml
@@ -537,7 +550,8 @@ <h2 id="_configuring_your_project_to_use_gcip">Configuring your project to use g
537550
</div>
538551
</div>
539552
<div class="paragraph">
540-
<p>Your gcip pipeline code then goes into a file named <code>.gitlab-ci.py</code>.</p>
553+
<p>Your gcip pipeline code then goes into the file named <code>.gitlab-ci.py</code>. The following
554+
chapers show to crete the pipeline code.</p>
541555
</div>
542556
</div>
543557
</div>
@@ -546,7 +560,23 @@ <h2 id="_hints_regarding_the_following_examples">Hints regarding the following e
546560
<div class="sectionbody">
547561
<div class="paragraph">
548562
<p>All the code examples in the following chapters are made for also be run with Pytest.
549-
Thus to use the code for your real life Gitlab CI pipeline you have to change the following:</p>
563+
For instance a code example could look like following:</p>
564+
</div>
565+
<div class="listingblock">
566+
<div class="content">
567+
<pre>import gcip
568+
from tests import conftest
569+
570+
571+
def test():
572+
pipeline = gcip.Pipeline()
573+
pipeline.add_children(gcip.Job(namespace="print_date", script="date"))
574+
575+
conftest.check(pipeline.render())</pre>
576+
</div>
577+
</div>
578+
<div class="paragraph">
579+
<p>To transform this pytest into a valid <code>.gitlab-ci.py</code> file your have to:</p>
550580
</div>
551581
<div class="ulist">
552582
<ul>
@@ -557,11 +587,24 @@ <h2 id="_hints_regarding_the_following_examples">Hints regarding the following e
557587
<p>Put your pipeline code plain into the Python script and not within the <code>def test():</code> method.</p>
558588
</li>
559589
<li>
560-
<p>Instead of routing the pipeline output to the test method (<code>conftest.check(pipeline.render())</code>)
561-
print the resulting pipeline to STDOUT with <code>pipeline.print_yaml()</code>.</p>
590+
<p>Instead of testing rendered pipelin with <code>conftest.check(pipeline.render())</code> you have to
591+
write the <code>generated-pipeline.yml</code> with <code>pipeline.write_yaml()</code>.</p>
562592
</li>
563593
</ul>
564594
</div>
595+
<div class="paragraph">
596+
<p>The real <code>.gitlab-ci.py</code> code derived from the example would look like following:</p>
597+
</div>
598+
<div class="listingblock">
599+
<div class="content">
600+
<pre>from tests import conftest
601+
602+
pipeline = gcip.Pipeline()
603+
pipeline.add_children(gcip.Job(namespace="print_date", script="date"))
604+
605+
pipeline.write_yaml()</pre>
606+
</div>
607+
</div>
565608
</div>
566609
</div>
567610
<div class="sect1">
@@ -585,7 +628,7 @@ <h2 id="_create_a_pipeline_with_one_job">Create a pipeline with one job</h2>
585628
</div>
586629
<div class="paragraph">
587630
<p>Remember: As stated in the <a href="#hints-regarding-the-following-examples">hints regarding the examples</a>,
588-
your real pipeline code must end with <code>pipeline.print_yaml()</code> instead of <code>conftest.check(pipeline.render())</code>!</p>
631+
your real pipeline code must end with <code>pipeline.write_yaml()</code> instead of <code>conftest.check(pipeline.render())</code>!</p>
589632
</div>
590633
<div class="paragraph">
591634
<p><strong>Output:</strong></p>
@@ -1689,7 +1732,7 @@ <h2 id="_licence">Licence</h2>
16891732
</div>
16901733
<div id="footer">
16911734
<div id="footer-text">
1692-
Last updated 2021-03-11 13:42:37 +0100
1735+
Last updated 2021-03-12 22:24:00 +0100
16931736
</div>
16941737
</div>
16951738
</body>

0 commit comments

Comments
 (0)