initial import for Open Source 🎉
This commit is contained in:
parent
1898c361f3
commit
9c0dd3b722
2048 changed files with 218743 additions and 0 deletions
|
@ -0,0 +1,18 @@
|
|||
.gh-button {
|
||||
color: #0366d6;
|
||||
background-color: #fff;
|
||||
padding: 3px 10px;
|
||||
font-size: 12px;
|
||||
border: 1px solid rgba(27,31,35,0.2);
|
||||
border-radius: 0.25em;
|
||||
}
|
||||
|
||||
.gh-grant-message {
|
||||
font-size: 16px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.gh-grant-message b {
|
||||
display: block;
|
||||
margin-bottom: 10px;
|
||||
}
|
|
@ -0,0 +1,437 @@
|
|||
<div class="manage-trigger-githost-element manage-trigger-control">
|
||||
<linear-workflow done-title="Create Trigger"
|
||||
(on-workflow-complete)="$ctrl.createTrigger($event)">
|
||||
<!-- Section: Namespace -->
|
||||
<linear-workflow-section class="row"
|
||||
section-id="namespace"
|
||||
section-title="::{{ 'Select ' + $ctrl.namespaceTitle }}"
|
||||
section-valid="$ctrl.local.selectedNamespace"
|
||||
skip-section="$ctrl.githost == 'custom-git'">
|
||||
<div class="col-lg-7 col-md-7 col-sm-12 main-col"
|
||||
ng-if="$ctrl.local.namespaces">
|
||||
<h3>Select {{ ::$ctrl.namespaceTitle }}</h3>
|
||||
<strong>Please select the {{ ::$ctrl.namespaceTitle }} under which the repository lives</strong>
|
||||
|
||||
<cor-table table-data="$ctrl.local.namespaces"
|
||||
table-item-title="namespaces"
|
||||
max-display-count="$ctrl.namespacesPerPage"
|
||||
filter-fields="::['title', 'id']">
|
||||
<cor-table-col datafield="title"
|
||||
style="width: 30px;"
|
||||
sortfield="title"
|
||||
bind-model="$ctrl.local.selectedNamespace"
|
||||
templateurl="/static/js/directives/ui/manage-trigger-githost/namespace-radio-input.html">
|
||||
<script type="text/ng-template" id="/static/js/directives/ui/manage-trigger-githost/namespace-radio-input.html">
|
||||
<input type="radio"
|
||||
ng-model="col.bindModel" ng-value="item"
|
||||
ng-dblclick="col.bindModel = null">
|
||||
</script>
|
||||
</cor-table-col>
|
||||
<cor-table-col title="{{ ::$ctrl.namespaceTitle }}"
|
||||
datafield="id"
|
||||
sortfield="id"
|
||||
templateurl="/static/js/directives/ui/manage-trigger-githost/namespace-name.html">
|
||||
<script type="text/ng-template" id="/static/js/directives/ui/manage-trigger-githost/namespace-name.html">
|
||||
<img class="namespace-avatar" ng-src="{{ ::item.avatar_url }}" ng-if="::item.avatar_url">
|
||||
<span class="anchor"
|
||||
href="{{ ::item.url }}"
|
||||
is-text-only="::!item.url">{{ ::item.title }}</span>
|
||||
</script>
|
||||
</cor-table-col>
|
||||
<cor-table-col title="Importance"
|
||||
datafield="score"
|
||||
bind-model="$ctrl.local.maxScore"
|
||||
style="display: flex; justify-content: flex-end"
|
||||
templateurl="/static/js/directives/ui/manage-trigger-githost/namespace-score.html">
|
||||
<script type="text/ng-template" id="/static/js/directives/ui/manage-trigger-githost/namespace-score.html">
|
||||
<div style="padding-right: 40px;">
|
||||
<span class="strength-indicator"
|
||||
value="::item.score" maximum="::col.bindModel" log-base="10"></span>
|
||||
</div>
|
||||
</script>
|
||||
</cor-table-col>
|
||||
</cor-table>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-8 col-md-8 col-sm-12 main-col"
|
||||
ng-if="!$ctrl.local.namespaces">
|
||||
<span class="cor-loader-inline"></span> Retrieving {{ $ctrl.namespaceTitle }}s
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 hidden-sm hidden-xs help-col" ng-if="$ctrl.local.namespaces">
|
||||
<p>
|
||||
<span class="registry-name"></span> has been granted access to read and view these {{ $ctrl.namespaceTitle }}s.
|
||||
</p>
|
||||
<p class="co-alert co-alert-info gh-grant-message" ng-if="$ctrl.githost == 'github'">
|
||||
<b>Don't see an expected organization here?</b>Please visit <a href="{{ $ctrl.githubTriggerEndpoint }}settings/connections/applications/{{ $ctrl.githubTriggerClientId }}" target="_blank" rel="nofollow noopener">Connections with <span class="registry-name"></span></a> and choose <span class="gh-button">Grant</span> or <span class="gh-button">Request</span> before reloading this page.
|
||||
</p>
|
||||
</div>
|
||||
</linear-workflow-section><!-- /Section: Namespace -->
|
||||
|
||||
<!-- Section: Githost Repository -->
|
||||
<linear-workflow-section class="row"
|
||||
section-id="repo"
|
||||
section-title="Select Repository"
|
||||
section-valid="$ctrl.local.selectedRepository.full_name"
|
||||
skip-section="$ctrl.githost == 'custom-git'">
|
||||
<div class="col-lg-7 col-md-7 col-sm-12 main-col"
|
||||
ng-if="$ctrl.local.repositories">
|
||||
<h3>Select Repository</h3>
|
||||
<strong>
|
||||
Select a repository in
|
||||
<img class="namespace-avatar"
|
||||
ng-src="{{ $ctrl.local.selectedNamespace.avatar_url }}"
|
||||
ng-if="$ctrl.local.selectedNamespace.avatar_url">
|
||||
{{ $ctrl.local.selectedNamespace.title }}
|
||||
</strong>
|
||||
|
||||
<div style="display: flex; justify-content: flex-end;">
|
||||
<div class="filter-options">
|
||||
<label>
|
||||
<input type="checkbox"
|
||||
ng-model="$ctrl.local.repositoryOptions.hideStale"
|
||||
ng-change="$ctrl.buildOrderedRepositories()">
|
||||
Hide stale repositories
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<cor-table table-data="$ctrl.local.orderedRepositories.entries"
|
||||
table-item-title="repositories"
|
||||
max-display-count="$ctrl.repositoriesPerPage"
|
||||
filter-fields="['name', 'description']">
|
||||
<cor-table-col bind-model="$ctrl.local.selectedRepository"
|
||||
templateurl="/static/js/directives/ui/manage-trigger-githost/repository-radio-input.html"
|
||||
style="width: 30px;">
|
||||
<script type="text/ng-template" id="/static/js/directives/ui/manage-trigger-githost/repository-radio-input.html">
|
||||
<span ng-if="!item.has_admin_permissions">
|
||||
<i class="fa fa-exclamation-triangle"
|
||||
data-title="Admin access is required to add the webhook trigger to this repository" bs-tooltip></i>
|
||||
</span>
|
||||
<div ng-if="item.has_admin_permissions">
|
||||
<input type="radio"
|
||||
ng-model="col.bindModel" ng-value="item"
|
||||
ng-dblclick="col.bindModel = null">
|
||||
</div>
|
||||
</script>
|
||||
</cor-table-col>
|
||||
<cor-table-col title="Repository Name"
|
||||
datafield="name"
|
||||
sortfield="name"
|
||||
bind-model="$ctrl.getTriggerIcon()"
|
||||
templateurl="/static/js/directives/ui/manage-trigger-githost/repository-name.html">
|
||||
<script type="text/ng-template" id="/static/js/directives/ui/manage-trigger-githost/repository-name.html">
|
||||
<i class="service-icon fa {{ ::col.bindModel }}"></i>
|
||||
<span class="anchor"
|
||||
href="{{ item.url }}"
|
||||
is-text-only="!item.url">{{ item.name }}</span>
|
||||
</script>
|
||||
</cor-table-col>
|
||||
<cor-table-col title="Updated"
|
||||
datafield="last_updated_datetime"
|
||||
templateurl="/static/js/directives/ui/manage-trigger-githost/repository-last-updated.html">
|
||||
<script type="text/ng-template" id="/static/js/directives/ui/manage-trigger-githost/repository-last-updated.html">
|
||||
<time-ago datetime="item.last_updated_datetime"></time-ago>
|
||||
</script>
|
||||
</cor-table-col>
|
||||
<cor-table-col title="Description"
|
||||
datafield="description"
|
||||
sortfield="description"
|
||||
templateurl="/static/js/directives/ui/manage-trigger-githost/repository-description.html"
|
||||
class="co-flowing-col">
|
||||
<script type="text/ng-template" id="/static/js/directives/ui/manage-trigger-githost/repository-description.html">
|
||||
<span ng-if="item.description" class="repo-description">
|
||||
{{ item.description }}
|
||||
</span>
|
||||
<span ng-if="!item.description" class="empty-description">(None)</span>
|
||||
</script>
|
||||
</cor-table-col>
|
||||
</cor-table>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-8 col-md-8 col-sm-12 main-col"
|
||||
ng-if="!$ctrl.local.repositories">
|
||||
<span class="cor-loader-inline"></span> Retrieving repositories
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 hidden-sm hidden-xs help-col"
|
||||
ng-if="$ctrl.local.repositories">
|
||||
<p>
|
||||
A webhook will be added to the selected repository in order to detect when new commits are made.
|
||||
</p>
|
||||
<p>
|
||||
Don't see an expected repository here? Please make sure you have admin access on that repository.
|
||||
</p>
|
||||
</div>
|
||||
</linear-workflow-section><!-- /Section: Githost Repository -->
|
||||
|
||||
<!-- Section: Custom Git Repository -->
|
||||
<linear-workflow-section class="row"
|
||||
section-id="repo"
|
||||
section-title="Git Repository"
|
||||
section-valid="$ctrl.local.selectedRepository.full_name"
|
||||
skip-section="$ctrl.githost != 'custom-git'">
|
||||
|
||||
<div class="col-lg-7 col-md-7 col-sm-12 main-col">
|
||||
<h3>Enter repository</h3>
|
||||
<strong>Please enter the HTTP or SSH style URL used to clone your git repository</strong>
|
||||
<input class="form-control" type="text" placeholder="git@example.com:namespace/repository.git"
|
||||
ng-model="$ctrl.buildSource"
|
||||
ng-change="$ctrl.checkBuildSource($ctrl.buildSource)"
|
||||
ng-pattern="/(((http|https):\/\/)(.+)|\w+@(.+):(.+))/">
|
||||
</div>
|
||||
<div class="col-lg-5 col-md-5 hidden-sm hidden-xs help-col">
|
||||
<p>Custom git triggers support any externally accessible git repository, via either the normal git protocol or HTTP.</p>
|
||||
|
||||
<p><b>It is the responsibility of the git repository to invoke a webhook to tell <span class="registry-name" short="true"></span> that a commit has been added.</b></p>
|
||||
</div>
|
||||
</linear-workflow-section><!-- /Section: Repository -->
|
||||
|
||||
<!-- Section: Trigger Options -->
|
||||
<linear-workflow-section class="row"
|
||||
section-id="triggeroptions"
|
||||
section-title="Configure Trigger"
|
||||
section-valid="$ctrl.local.triggerOptions"
|
||||
skip-section="$ctrl.githost == 'custom-git'">
|
||||
<div class="col-lg-7 col-md-7 col-sm-12 main-col" ng-if="$ctrl.local.repositoryRefs">
|
||||
<h3>Configure Trigger</h3>
|
||||
<strong>
|
||||
Configure trigger options for
|
||||
<img class="namespace-avatar"
|
||||
ng-src="{{ $ctrl.local.selectedNamespace.avatar_url }}"
|
||||
ng-if="$ctrl.local.selectedNamespace.avatar_url">
|
||||
{{ $ctrl.local.selectedNamespace.title }}/{{ $ctrl.local.selectedRepository.name }}
|
||||
</strong>
|
||||
|
||||
<div class="radio" style="margin-top: 20px;">
|
||||
<label>
|
||||
<input type="radio" name="optionRadio"
|
||||
ng-model="$ctrl.local.triggerOptions.hasBranchTagFilter"
|
||||
ng-value="false">
|
||||
<div class="title">Trigger for all branches and tags <span class="weak">(default)</span></div>
|
||||
<div class="description">Build a container image for each commit across all branches and tags</div>
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio"
|
||||
name="optionRadio"
|
||||
ng-model="$ctrl.local.triggerOptions.hasBranchTagFilter"
|
||||
ng-value="true">
|
||||
<div class="title">Trigger only on branches and tags matching a regular expression</div>
|
||||
<div class="description">Only build container images for a subset of branches and/or tags.</div>
|
||||
<div class="extended"
|
||||
ng-if="$ctrl.local.triggerOptions.hasBranchTagFilter">
|
||||
<table>
|
||||
<tr>
|
||||
<td style="white-space: nowrap;">Regular Expression:</td>
|
||||
<td>
|
||||
<input type="text" class="form-control"
|
||||
ng-model="$ctrl.local.triggerOptions.branchTagFilter"
|
||||
required>
|
||||
<div class="description">Examples: heads/master, tags/tagname, heads/.+</div>
|
||||
<regex-match-view items="$ctrl.local.repositoryFullRefs"
|
||||
regex="$ctrl.local.triggerOptions.branchTagFilter"
|
||||
ng-if="$ctrl.local.triggerOptions.branchTagFilter"></regex-match-view>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-8 col-md-8 col-sm-12 main-col"
|
||||
ng-if="!$ctrl.local.repositoryRefs">
|
||||
<span class="cor-loader-inline"></span> Retrieving repository refs
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 hidden-sm hidden-xs help-col">
|
||||
<p>Do you want to build a new container image for commits across all branches and tags, or limit to a subset?</p>
|
||||
<p>For example, if you use release branches instead of <code>master</code> for building versions of your software, you can configure the trigger to only build images for these branches.</p>
|
||||
<p>All images built will be tagged with the name of the branch or tag whose change invoked the trigger</p>
|
||||
</div>
|
||||
</linear-workflow-section><!-- /Section: Trigger Options -->
|
||||
|
||||
<!-- Section: Dockerfile Location -->
|
||||
<linear-workflow-section class="row"
|
||||
section-id="dockerfilelocation"
|
||||
section-title="Select Dockerfile"
|
||||
section-valid="$ctrl.local.hasValidDockerfilePath">
|
||||
<div class="col-lg-7 col-md-7 col-sm-12 main-col"
|
||||
ng-if="$ctrl.local.dockerfileLocations.status == 'error'">
|
||||
<div class="co-alert co-alert-warning">
|
||||
{{ $ctrl.local.dockerfileLocations.message }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-7 col-md-7 col-sm-12 main-col"
|
||||
ng-if="$ctrl.githost == 'custom-git' || $ctrl.local.dockerfileLocations.status == 'success'">
|
||||
<h3>Select Dockerfile</h3>
|
||||
<strong>Please select the location of the Dockerfile to build when this trigger is invoked</strong>
|
||||
<dockerfile-path-select current-path="$ctrl.local.dockerfilePath"
|
||||
paths="$ctrl.local.dockerfileLocations.dockerfile_paths"
|
||||
supports-full-listing="true"
|
||||
(path-changed)="$ctrl.checkDockerfilePath($event)"></dockerfile-path-select>
|
||||
<span ng-if="$ctrl.local.dockerfilePath.split('/').splice(-1)[0] == ''"
|
||||
style="color: #D64456;">
|
||||
Dockerfile path must end with a file, probably named <code>Dockerfile</code>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-8 col-md-8 col-sm-12 main-col"
|
||||
ng-if="$ctrl.githost != 'custom-git' && !$ctrl.local.dockerfileLocations">
|
||||
<span class="cor-loader-inline"></span> Retrieving Dockerfile locations
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 hidden-sm hidden-xs help-col">
|
||||
<p>Please select the location containing the Dockerfile to be built.</p>
|
||||
<p>The Dockerfile path starts with the context and ends with the path to the Dockefile that you would like to build</p>
|
||||
<p>If the Dockerfile is located at the root of the git repository and named Dockerfile, enter <code>/Dockerfile</code> as the Dockerfile path.</p>
|
||||
</div>
|
||||
</linear-workflow-section><!-- /Section: Dockerfile Location -->
|
||||
|
||||
<!-- Section: Context Location -->
|
||||
<linear-workflow-section class="row"
|
||||
section-id="contextlocation"
|
||||
section-title="Select Docker Context"
|
||||
section-valid="$ctrl.local.hasValidContextLocation">
|
||||
<div class="col-lg-7 col-md-7 col-sm-12 main-col"
|
||||
ng-if="$ctrl.local.dockerfileLocations.status == 'error'">
|
||||
<div class="co-alert co-alert-warning">
|
||||
{{ $ctrl.local.dockerfileLocations.message }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-7 col-md-7 col-sm-12 main-col"
|
||||
ng-if="$ctrl.githost == 'custom-git' || $ctrl.local.dockerfileLocations.status == 'success'">
|
||||
<h3>Select Context</h3>
|
||||
<strong>Please select the context for the Docker build</strong>
|
||||
|
||||
<context-path-select current-context="$ctrl.local.dockerContext"
|
||||
contexts="$ctrl.local.contexts"
|
||||
(context-changed)="$ctrl.checkBuildContext($event)"></context-path-select>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-8 col-md-8 col-sm-12 main-col"
|
||||
ng-if="$ctrl.githost != 'custom-git' && !$ctrl.local.dockerfileLocations">
|
||||
<span class="cor-loader-inline"></span> Retrieving Dockerfile locations
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 hidden-sm hidden-xs help-col">
|
||||
<p>Please select a Docker context.</p>
|
||||
<p>The build context directory is the path of the directory containing the Dockerfile and any other files to be made available when the build is triggered.</p>
|
||||
<p>If the Dockerfile is located at the root of the git repository, enter <code>/</code> as the build context directory.</p>
|
||||
</div>
|
||||
</linear-workflow-section><!-- /Section: Context Location -->
|
||||
|
||||
<!-- Section: Robot Account -->
|
||||
<linear-workflow-section class="row"
|
||||
section-id="robot"
|
||||
section-title="Robot Account"
|
||||
section-valid="$ctrl.local.triggerAnalysis.status != 'error' &&
|
||||
($ctrl.local.triggerAnalysis.status != 'requiresrobot' || $ctrl.local.robotAccount)">
|
||||
<!-- Error -->
|
||||
<div class="col-lg-7 col-md-7 col-sm-12 main-col"
|
||||
ng-if="$ctrl.local.triggerAnalysis.status == 'error'">
|
||||
<h3 class="error"><i class="fa fa-exclamation-circle"></i> Verification Error</h3>
|
||||
<strong>
|
||||
There was an error when verifying the state of <img class="namespace-avatar"
|
||||
ng-src="{{ $ctrl.local.selectedNamespace.avatar_url }}"
|
||||
ng-if="$ctrl.local.selectedNamespace.avatar_url">
|
||||
{{ $ctrl.local.selectedNamespace.title }}/{{ $ctrl.local.selectedRepository.name }}
|
||||
</strong>
|
||||
|
||||
{{ $ctrl.local.triggerAnalysis.message }}
|
||||
</div>
|
||||
|
||||
<!-- Robot display for non-error cases -->
|
||||
<div class="col-lg-7 col-md-7 col-sm-12 main-col"
|
||||
ng-if="$ctrl.local.triggerAnalysis.status != 'error'">
|
||||
<!-- Warning -->
|
||||
<div ng-if="$ctrl.local.triggerAnalysis.status == 'warning'">
|
||||
<h3 class="warning"><i class="fa fa-exclamation-triangle"></i> Verification Warning</h3>
|
||||
{{ $ctrl.local.triggerAnalysis.message }}
|
||||
</div>
|
||||
|
||||
<!-- Public base -->
|
||||
<div ng-if="$ctrl.local.triggerAnalysis.status == 'publicbase'">
|
||||
<h3>Optional Robot Account</h3>
|
||||
<strong>
|
||||
<span ng-if="$ctrl.local.triggerAnalysis.is_admin">Choose an optional robot account below or click "Continue" to complete setup of this build trigger.</span>
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
<!-- Requires robot and is not admin -->
|
||||
<div ng-if="$ctrl.local.triggerAnalysis.status == 'requiresrobot' && !$ctrl.local.triggerAnalysis.is_admin">
|
||||
<h3>Robot Account Required</h3>
|
||||
<p>The selected Dockerfile in the selected repository depends upon a private base image.</p>
|
||||
<p>A robot account with access to the base image is required to setup this trigger, but you are not the administrator of this namespace.</p>
|
||||
<p>Administrative access is required to continue to ensure security of the robot credentials.</p>
|
||||
</div>
|
||||
|
||||
<!-- Requires robot and is admin -->
|
||||
<div ng-if="$ctrl.local.triggerAnalysis.status == 'requiresrobot' && $ctrl.local.triggerAnalysis.is_admin">
|
||||
<h3>Robot Account Required</h3>
|
||||
<p>The selected Dockerfile in the selected repository depends upon a private base image.</p>
|
||||
<p>A robot account with access to the base image is required to setup this trigger.</p>
|
||||
</div>
|
||||
|
||||
<!-- Robots view -->
|
||||
<div ng-if="$ctrl.local.triggerAnalysis.is_admin">
|
||||
<cor-table table-data="$ctrl.local.triggerAnalysis.robots"
|
||||
table-item-title="robot accounts"
|
||||
filter-fields="['name']"
|
||||
max-display-count="$ctrl.robotsPerPage">
|
||||
<cor-table-col datafield="name"
|
||||
bind-model="$ctrl.local.robotAccount"
|
||||
style="width: 30px;"
|
||||
templateurl="/static/js/directives/ui/manage-trigger-custom-git/robot-radio-input.html">
|
||||
<script type="text/ng-template" id="/static/js/directives/ui/manage-trigger-custom-git/robot-radio-input.html">
|
||||
<input type="radio"
|
||||
ng-model="col.bindModel" ng-value="item"
|
||||
ng-dblclick="col.bindModel = null">
|
||||
</script>
|
||||
</cor-table-col>
|
||||
<cor-table-col title="Robot Account"
|
||||
sortfield="name"
|
||||
templateurl="/static/js/directives/ui/manage-trigger-custom-git/robot-name.html">
|
||||
<script type="text/ng-template" id="/static/js/directives/ui/manage-trigger-custom-git/robot-name.html">
|
||||
<span class="entity-reference" entity="item"></span>
|
||||
</script>
|
||||
</cor-table-col>
|
||||
<cor-table-col ng-if="$ctrl.local.triggerAnalysis.status == 'requiresrobot' || true"
|
||||
datafield="can_read"
|
||||
templateurl="/static/js/directives/ui/manage-trigger-custom-git/can-read.html">
|
||||
<script type="text/ng-template" id="/static/js/directives/ui/manage-trigger-custom-git/can-read.html">
|
||||
<span ng-if="item.can_read" class="success">Can Read</span>
|
||||
<span ng-if="!item.can_read">Read access will be added if selected</span>
|
||||
</script>
|
||||
</cor-table-col>
|
||||
</cor-table>
|
||||
</div> <!-- /Robots view -->
|
||||
</div>
|
||||
|
||||
<div class="col-lg-4 col-md-4 hidden-sm hidden-xs help-col"
|
||||
ng-if="$ctrl.local.triggerAnalysis.is_admin">
|
||||
<p>
|
||||
In order for the <span class="registry-name"></span> to pull a <b>private base image</b> during the build
|
||||
process, a robot account with access must be selected.
|
||||
</p>
|
||||
<p ng-if="$ctrl.local.triggerAnalysis.status != 'requiresrobot'">
|
||||
If you know that a private base image is not used, you can skip this step.
|
||||
</p>
|
||||
<p ng-if="$ctrl.local.triggerAnalysis.status == 'requiresrobot'">
|
||||
Robot accounts that already have access to this base image are listed first. If you select a robot account
|
||||
that does not currently have access, read permission will be granted to that robot account on trigger creation.
|
||||
</p>
|
||||
</div>
|
||||
</linear-workflow-section><!-- /Section: Verification and Robot Account -->
|
||||
|
||||
<!-- Verification -->
|
||||
<linear-workflow-section class="row"
|
||||
section-id="verification"
|
||||
section-title="Verification"
|
||||
section-valid="true">
|
||||
<span>
|
||||
<h3 class="success"><i class="fa fa-check-circle"></i> Ready to go!</h3>
|
||||
Click "Continue" to complete setup of this build trigger.
|
||||
</span>
|
||||
</linear-workflow-section><!-- /Section: Verification -->
|
||||
</linear-workflow>
|
||||
</div>
|
|
@ -0,0 +1,286 @@
|
|||
import { ManageTriggerComponent } from './manage-trigger.component';
|
||||
import { Local, Trigger, Repository } from '../../../types/common.types';
|
||||
import { ViewArray } from '../../../services/view-array/view-array';
|
||||
import { ContextChangeEvent } from '../context-path-select/context-path-select.component';
|
||||
import { PathChangeEvent } from '../dockerfile-path-select/dockerfile-path-select.component';
|
||||
import { Mock } from 'ts-mocks';
|
||||
import Spy = jasmine.Spy;
|
||||
|
||||
|
||||
describe("ManageTriggerComponent", () => {
|
||||
var component: ManageTriggerComponent;
|
||||
var apiServiceMock: Mock<any>;
|
||||
var tableServiceMock: Mock<any>;
|
||||
var triggerServiceMock: Mock<any>;
|
||||
var rolesServiceMock: Mock<any>;
|
||||
var keyServiceMock: Mock<any>;
|
||||
var repository: any;
|
||||
var $scopeMock: Mock<ng.IScope>;
|
||||
|
||||
beforeEach(() => {
|
||||
apiServiceMock = new Mock<any>();
|
||||
tableServiceMock = new Mock<any>();
|
||||
triggerServiceMock = new Mock<any>();
|
||||
rolesServiceMock = new Mock<any>();
|
||||
keyServiceMock = new Mock<any>();
|
||||
$scopeMock = new Mock<ng.IScope>();
|
||||
component = new ManageTriggerComponent(apiServiceMock.Object,
|
||||
tableServiceMock.Object,
|
||||
triggerServiceMock.Object,
|
||||
rolesServiceMock.Object,
|
||||
keyServiceMock.Object,
|
||||
$scopeMock.Object);
|
||||
component.repository = {namespace: "someuser", name: "somerepo"};
|
||||
component.trigger = {id: "2cac6317-754e-47d4-88d3-2a50b3f09ee3", service: "github"};
|
||||
});
|
||||
|
||||
describe("ngOnChanges", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
apiServiceMock.setup(mock => mock.listTriggerBuildSourceNamespaces).is(() => Promise.resolve({}));
|
||||
apiServiceMock.setup(mock => mock.errorDisplay).is((message) => null);
|
||||
$scopeMock.setup(mock => mock.$watch).is((val, callback) => null);
|
||||
});
|
||||
|
||||
it("sets default values for config and selected namespace", () => {
|
||||
component.ngOnChanges({});
|
||||
|
||||
expect(component.config).toEqual({});
|
||||
expect(component.local.selectedNamespace).toBe(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe("checkBuildSource", () => {
|
||||
|
||||
it("sets selected repository full name if given build source matches regex pattern", () => {
|
||||
const buildSource: string = "git@somegithost.net:user/repo.git";
|
||||
component.checkBuildSource(buildSource);
|
||||
|
||||
expect(component.local.selectedRepository.full_name).toEqual(buildSource);
|
||||
});
|
||||
|
||||
it("sets selected repository full name to null if given build source does not match regex pattern", () => {
|
||||
const buildSource: string = "a_randomstring";
|
||||
component.checkBuildSource(buildSource);
|
||||
|
||||
expect(component.local.selectedRepository.full_name).toBe(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getTriggerIcon", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
triggerServiceMock.setup(mock => mock.getIcon).is((service: any) => null);
|
||||
});
|
||||
|
||||
it("calls trigger service to get icon", () => {
|
||||
const icon: any = component.getTriggerIcon();
|
||||
|
||||
expect((<Spy>triggerServiceMock.Object.getIcon).calls.argsFor(0)[0]).toEqual(component.trigger.service);
|
||||
});
|
||||
});
|
||||
|
||||
describe("checkDockerfilePath", () => {
|
||||
var event: PathChangeEvent;
|
||||
|
||||
beforeEach(() => {
|
||||
event = {path: '/Dockerfile', isValid: true};
|
||||
component.local.selectedRepository = {name: "", full_name: "someorg/somerepo"};
|
||||
component.local.dockerContext = '/';
|
||||
component.local.dockerfileLocations = {contextMap: {}};
|
||||
spyOn(component, "analyzeDockerfilePath").and.returnValue(null);
|
||||
});
|
||||
|
||||
it("sets local Dockerfile path and validity to given event values", () => {
|
||||
component.checkDockerfilePath(event);
|
||||
|
||||
expect(component.local.hasValidDockerfilePath).toEqual(event.isValid);
|
||||
expect(component.local.dockerfilePath).toEqual(event.path);
|
||||
});
|
||||
|
||||
it("sets local Dockerfile contexts if present in local Dockerfile locations", () => {
|
||||
component.local.dockerfileLocations.contextMap[event.path] = ['/', '/dir'];
|
||||
component.checkDockerfilePath(event);
|
||||
|
||||
expect(component.local.contexts).toEqual(component.local.dockerfileLocations.contextMap[event.path]);
|
||||
});
|
||||
|
||||
it("sets local Dockerfile contexts to empty array if given path not present in local Dockerfile locations", () => {
|
||||
component.checkDockerfilePath(event);
|
||||
|
||||
expect(component.local.contexts).toEqual([]);
|
||||
});
|
||||
|
||||
it("calls component method to analyze new Dockerfile path", () => {
|
||||
component.checkDockerfilePath(event);
|
||||
|
||||
expect((<Spy>component.analyzeDockerfilePath).calls.argsFor(0)[0]).toEqual(component.local.selectedRepository);
|
||||
expect((<Spy>component.analyzeDockerfilePath).calls.argsFor(0)[1]).toEqual(event.path);
|
||||
expect((<Spy>component.analyzeDockerfilePath).calls.argsFor(0)[2]).toEqual(component.local.dockerContext);
|
||||
});
|
||||
});
|
||||
|
||||
describe("checkBuildContext", () => {
|
||||
var event: ContextChangeEvent;
|
||||
|
||||
beforeEach(() => {
|
||||
event = {contextDir: '/', isValid: true};
|
||||
});
|
||||
});
|
||||
|
||||
describe("analyzeDockerfilePath", () => {
|
||||
var selectedRepository: Repository;
|
||||
var path: string;
|
||||
var context: string;
|
||||
var robots: {robots: {[key: string]: any}[]};
|
||||
var analysis: {[key: string]: any};
|
||||
var orderedRobots: Mock<ViewArray>;
|
||||
|
||||
beforeEach(() => {
|
||||
selectedRepository = {name: "", full_name: "someorg/somerepo"};
|
||||
path = "/Dockerfile";
|
||||
context = "/";
|
||||
robots = {robots: [{name: 'robot'}]};
|
||||
analysis = {'publicbase': true, robots: robots.robots};
|
||||
orderedRobots = new Mock<ViewArray>();
|
||||
apiServiceMock.setup(mock => mock.analyzeBuildTrigger).is((data, params) => Promise.resolve(analysis));
|
||||
apiServiceMock.setup(mock => mock.getRobots).is((user, arg, params) => Promise.resolve(robots));
|
||||
apiServiceMock.setup(mock => mock.errorDisplay).is((message) => null);
|
||||
tableServiceMock.setup(mock => mock.buildOrderedItems).is((items, options, filterFields, numericFields) => orderedRobots.Object);
|
||||
});
|
||||
|
||||
it("does nothing if given invalid Git repository", (done) => {
|
||||
const invalidRepositories: Repository[] = [null];
|
||||
invalidRepositories.forEach((repo, index) => {
|
||||
component.analyzeDockerfilePath(repo, path, context);
|
||||
|
||||
expect((<Spy>apiServiceMock.Object.analyzeBuildTrigger)).not.toHaveBeenCalled();
|
||||
|
||||
if (index == invalidRepositories.length - 1) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("uses default values for Dockerfile path and context if not given", (done) => {
|
||||
const spy: Spy = <Spy>apiServiceMock.Object.analyzeBuildTrigger;
|
||||
component.analyzeDockerfilePath(selectedRepository);
|
||||
|
||||
setTimeout(() => {
|
||||
expect(spy.calls.argsFor(0)[0]['config']['build_source']).toEqual(selectedRepository.full_name);
|
||||
expect(spy.calls.argsFor(0)[0]['config']['dockerfile_path']).toEqual('Dockerfile');
|
||||
expect(spy.calls.argsFor(0)[0]['config']['context']).toEqual('/');
|
||||
expect(spy.calls.argsFor(0)[1]['repository']).toEqual(`${component.repository.namespace}/${component.repository.name}`);
|
||||
expect(spy.calls.argsFor(0)[1]['trigger_uuid']).toEqual(component.trigger.id);
|
||||
done();
|
||||
}, 10);
|
||||
});
|
||||
|
||||
it("calls API service to analyze build trigger config with given values", (done) => {
|
||||
const spy: Spy = <Spy>apiServiceMock.Object.analyzeBuildTrigger;
|
||||
component.analyzeDockerfilePath(selectedRepository, path, context);
|
||||
|
||||
setTimeout(() => {
|
||||
expect(spy.calls.argsFor(0)[0]['config']['build_source']).toEqual(selectedRepository.full_name);
|
||||
expect(spy.calls.argsFor(0)[0]['config']['dockerfile_path']).toEqual(path.substr(1));
|
||||
expect(spy.calls.argsFor(0)[0]['config']['context']).toEqual(context);
|
||||
expect(spy.calls.argsFor(0)[1]['repository']).toEqual(`${component.repository.namespace}/${component.repository.name}`);
|
||||
expect(spy.calls.argsFor(0)[1]['trigger_uuid']).toEqual(component.trigger.id);
|
||||
done();
|
||||
}, 10);
|
||||
});
|
||||
|
||||
it("calls API service to display error if API service's trigger analysis fails", (done) => {
|
||||
apiServiceMock.setup(mock => mock.analyzeBuildTrigger).is((data, params) => Promise.reject("Error"));
|
||||
component.analyzeDockerfilePath(selectedRepository, path, context);
|
||||
|
||||
setTimeout(() => {
|
||||
expect((<Spy>apiServiceMock.Object.errorDisplay).calls.argsFor(0)[0]).toEqual('Could not analyze trigger');
|
||||
done();
|
||||
}, 10);
|
||||
});
|
||||
|
||||
it("updates component trigger analysis with successful trigger analysis response", (done) => {
|
||||
component.analyzeDockerfilePath(selectedRepository, path, context);
|
||||
|
||||
setTimeout(() => {
|
||||
expect(component.local.triggerAnalysis).toEqual(analysis);
|
||||
done();
|
||||
}, 10);
|
||||
});
|
||||
});
|
||||
|
||||
describe("createTrigger", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
component.local.selectedRepository = new Mock<Repository>().Object;
|
||||
component.local.selectedRepository.full_name = "someorg/some-repository";
|
||||
component.local.dockerfilePath = "/Dockerfile";
|
||||
component.local.dockerContext = "/";
|
||||
component.local.triggerOptions = {};
|
||||
component.local.triggerAnalysis = {};
|
||||
rolesServiceMock.setup(mock => mock.setRepositoryRole).is((repo, role, entityKind, entityName, callback) => {
|
||||
callback();
|
||||
});
|
||||
});
|
||||
|
||||
it("does not call roles service if robot is required but robot is not selected", (done) => {
|
||||
component.local.triggerAnalysis = {status: 'requiresrobot', name: 'privatebase', namespace: 'someorg'};
|
||||
component.local.robotAccount = null;
|
||||
component.activateTrigger.subscribe((event: {config: any, pull_robot: any}) => {
|
||||
expect((<Spy>rolesServiceMock.Object.setRepositoryRole)).not.toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
|
||||
component.createTrigger();
|
||||
});
|
||||
|
||||
it("calls roles service to grant read access to selected robot if robot is required and cannot read", (done) => {
|
||||
component.local.triggerAnalysis = {status: 'requiresrobot', name: 'privatebase', namespace: 'someorg'};
|
||||
component.local.robotAccount = {can_read: false, is_robot: true, kind: 'user', name: 'test-robot'};
|
||||
component.activateTrigger.subscribe((event: {config: any, pull_robot: any}) => {
|
||||
expect((<Spy>rolesServiceMock.Object.setRepositoryRole).calls.argsFor(0)[0]).toEqual({
|
||||
name: component.local.triggerAnalysis.name,
|
||||
namespace: component.local.triggerAnalysis.namespace,
|
||||
});
|
||||
expect((<Spy>rolesServiceMock.Object.setRepositoryRole).calls.argsFor(0)[1]).toEqual('read');
|
||||
expect((<Spy>rolesServiceMock.Object.setRepositoryRole).calls.argsFor(0)[2]).toEqual('robot');
|
||||
done();
|
||||
});
|
||||
|
||||
component.createTrigger();
|
||||
});
|
||||
|
||||
it("does not call roles service if robot is required but already has read access", (done) => {
|
||||
component.local.triggerAnalysis = {status: 'requiresrobot', name: 'privatebase', namespace: 'someorg'};
|
||||
component.local.robotAccount = {can_read: true, is_robot: true, kind: 'user', name: 'test-robot'};
|
||||
component.activateTrigger.subscribe((event: {config: any, pull_robot: any}) => {
|
||||
expect((<Spy>rolesServiceMock.Object.setRepositoryRole)).not.toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
|
||||
component.createTrigger();
|
||||
});
|
||||
|
||||
it("does not call roles service if robot is not required", (done) => {
|
||||
component.local.triggerAnalysis = {status: 'publicbase', name: 'publicrepo', namespace: 'someorg'};
|
||||
component.activateTrigger.subscribe((event: {config: any, pull_robot: any}) => {
|
||||
expect((<Spy>rolesServiceMock.Object.setRepositoryRole)).not.toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
|
||||
component.createTrigger();
|
||||
});
|
||||
|
||||
it("emits output event with config and pull robot", (done) => {
|
||||
component.activateTrigger.subscribe((event: {config: any, pull_robot: any}) => {
|
||||
expect(event.config.build_source).toEqual(component.local.selectedRepository.full_name);
|
||||
expect(event.config.dockerfile_path).toEqual(component.local.dockerfilePath);
|
||||
expect(event.config.context).toEqual(component.local.dockerContext);
|
||||
done();
|
||||
});
|
||||
|
||||
component.createTrigger();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,343 @@
|
|||
import { Input, Output, Component, Inject, EventEmitter, OnChanges, SimpleChanges } from 'ng-metadata/core';
|
||||
import * as moment from 'moment';
|
||||
import { Local, Trigger, TriggerConfig, Repository, Namespace } from '../../../types/common.types';
|
||||
import { ContextChangeEvent } from '../context-path-select/context-path-select.component';
|
||||
import { PathChangeEvent } from '../dockerfile-path-select/dockerfile-path-select.component';
|
||||
import './manage-trigger.component.css';
|
||||
|
||||
|
||||
/**
|
||||
* A component that lets the user set up a build trigger for a public Git repository host service.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'manage-trigger',
|
||||
templateUrl: '/static/js/directives/ui/manage-trigger/manage-trigger.component.html'
|
||||
})
|
||||
export class ManageTriggerComponent implements OnChanges {
|
||||
|
||||
@Input('<') public githost: string = 'custom-git';
|
||||
@Input('<') public repository: Repository;
|
||||
@Input('<') public trigger: Trigger;
|
||||
|
||||
@Output() public activateTrigger: EventEmitter<{config: TriggerConfig, pull_robot?: any}> = new EventEmitter();
|
||||
|
||||
public config: TriggerConfig;
|
||||
public local: Local = {
|
||||
selectedRepository: {name: ''},
|
||||
hasValidDockerfilePath: false,
|
||||
dockerfileLocations: [],
|
||||
triggerOptions: {},
|
||||
namespaceOptions: {filter: '', predicate: 'score', reverse: false, page: 0},
|
||||
repositoryOptions: {filter: '', predicate: 'score', reverse: false, page: 0, hideStale: true},
|
||||
robotOptions: {filter: '', predicate: 'score', reverse: false, page: 0},
|
||||
};
|
||||
|
||||
private namespacesPerPage: number = 10;
|
||||
private repositoriesPerPage: number = 10;
|
||||
private robotsPerPage: number = 10;
|
||||
private namespaceTitle: string;
|
||||
private namespace: any;
|
||||
private buildSource: string;
|
||||
private githubTriggerEndpoint: string;
|
||||
private githubTriggerClientId: string;
|
||||
|
||||
constructor(@Inject('ApiService') private apiService: any,
|
||||
@Inject('TableService') private tableService: any,
|
||||
@Inject('TriggerService') private triggerService: any,
|
||||
@Inject('RolesService') private rolesService: any,
|
||||
@Inject('KeyService') private keyService: any,
|
||||
@Inject('$scope') private $scope: ng.IScope) {
|
||||
this.githubTriggerEndpoint = keyService['githubTriggerEndpoint'];
|
||||
this.githubTriggerClientId = keyService['githubTriggerClientId'];
|
||||
}
|
||||
|
||||
public ngOnChanges(changes: SimpleChanges): void {
|
||||
if (this.githost && this.repository && this.trigger) {
|
||||
this.config = this.trigger.config || {};
|
||||
this.namespaceTitle = 'organization';
|
||||
this.local.selectedNamespace = null;
|
||||
if (this.githost != 'custom-git') {
|
||||
this.loadNamespaces();
|
||||
}
|
||||
|
||||
// FIXME (Alec 5/26/17): Need to have watchers here because cor-table doesn't have ng-change functionality yet
|
||||
this.$scope.$watch(() => this.local.selectedNamespace, (namespace: Namespace) => {
|
||||
if (namespace) {
|
||||
this.loadRepositories(namespace);
|
||||
}
|
||||
});
|
||||
this.$scope.$watch(() => this.local.selectedRepository, (selectedRepository: Repository) => {
|
||||
if (selectedRepository && this.githost != 'custom-git') {
|
||||
this.loadRepositoryRefs(selectedRepository);
|
||||
this.loadDockerfileLocations(selectedRepository);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public getTriggerIcon(): any {
|
||||
return this.triggerService.getIcon(this.trigger.service);
|
||||
}
|
||||
|
||||
public checkBuildSource(buildSource: string): void {
|
||||
const buildSourceRegExp = new RegExp(/(((http|https):\/\/)(.+)|\w+@(.+):(.+))/, 'i');
|
||||
try {
|
||||
this.local.selectedRepository.full_name = buildSourceRegExp.test(buildSource) ? buildSource : null;
|
||||
} catch (error) {
|
||||
this.local.selectedRepository.full_name = null;
|
||||
}
|
||||
}
|
||||
|
||||
public checkDockerfilePath(event: PathChangeEvent): void {
|
||||
this.local.hasValidDockerfilePath = event.isValid && event.path.split('/')[event.path.split('/').length - 1] != '';
|
||||
this.local.dockerfilePath = event.path;
|
||||
|
||||
if (event.path && this.local.selectedRepository) {
|
||||
this.setPossibleContexts(event.path);
|
||||
this.analyzeDockerfilePath(this.local.selectedRepository, this.local.dockerfilePath, this.local.dockerContext);
|
||||
}
|
||||
}
|
||||
|
||||
public checkBuildContext(event: ContextChangeEvent): void {
|
||||
this.local.hasValidContextLocation = event.isValid;
|
||||
this.local.dockerContext = event.contextDir;
|
||||
|
||||
if (event.contextDir && this.local.selectedRepository) {
|
||||
this.analyzeDockerfilePath(this.local.selectedRepository, this.local.dockerfilePath, this.local.dockerContext);
|
||||
}
|
||||
}
|
||||
|
||||
public analyzeDockerfilePath(selectedRepo: Repository, path: string = '/Dockerfile', context: string = '/'): void {
|
||||
if (selectedRepo != undefined && selectedRepo.full_name) {
|
||||
this.local.triggerAnalysis = null;
|
||||
this.local.robotAccount = null;
|
||||
|
||||
const params = {
|
||||
'repository': this.repository.namespace + '/' + this.repository.name,
|
||||
'trigger_uuid': this.trigger.id
|
||||
};
|
||||
const config: TriggerConfig = {
|
||||
build_source: selectedRepo.full_name,
|
||||
dockerfile_path: path.substr(1),
|
||||
context: context
|
||||
};
|
||||
const data = {config: config};
|
||||
|
||||
// Try to analyze git repository, fall back to retrieving all namespace's robots
|
||||
this.apiService.analyzeBuildTrigger(data, params)
|
||||
.then((resp) => {
|
||||
if (resp['status'] === 'notimplemented') {
|
||||
return this.apiService.getRobots(this.repository.namespace, null, {'permissions': true, 'token': false});
|
||||
} else {
|
||||
this.local.triggerAnalysis = Object.assign({}, resp);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
this.apiService.errorDisplay('Could not analyze trigger');
|
||||
})
|
||||
.then((resp) => {
|
||||
if (resp) {
|
||||
this.local.triggerAnalysis = {
|
||||
status: 'publicbase',
|
||||
is_admin: true,
|
||||
robots: resp.robots,
|
||||
name: this.repository.name,
|
||||
namespace: this.repository.namespace
|
||||
};
|
||||
}
|
||||
this.buildOrderedRobotAccounts();
|
||||
})
|
||||
.catch((error) => {
|
||||
this.apiService.errorDisplay('Could not retrieve robot accounts');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public createTrigger(): void {
|
||||
var config: TriggerConfig = {
|
||||
build_source: this.local.selectedRepository.full_name,
|
||||
dockerfile_path: this.local.dockerfilePath,
|
||||
context: this.local.dockerContext
|
||||
};
|
||||
|
||||
if (this.local.triggerOptions['hasBranchTagFilter'] && this.local.triggerOptions['branchTagFilter']) {
|
||||
config.branchtag_regex = this.local.triggerOptions['branchTagFilter'];
|
||||
}
|
||||
|
||||
const activate = () => {
|
||||
this.activateTrigger.emit({config: config, pull_robot: Object.assign({}, this.local.robotAccount)});
|
||||
};
|
||||
|
||||
if (this.local.triggerAnalysis.status == 'requiresrobot' && this.local.robotAccount) {
|
||||
if (this.local.robotAccount.can_read) {
|
||||
activate();
|
||||
} else {
|
||||
// Add read permission onto the base repository for the robot and then activate the trigger.
|
||||
const baseRepo: any = {name: this.local.triggerAnalysis.name, namespace: this.local.triggerAnalysis.namespace};
|
||||
this.rolesService.setRepositoryRole(baseRepo, 'read', 'robot', this.local.robotAccount.name, activate);
|
||||
}
|
||||
} else {
|
||||
activate();
|
||||
}
|
||||
}
|
||||
|
||||
private setPossibleContexts(path: string) {
|
||||
if (this.local.dockerfileLocations.contextMap) {
|
||||
this.local.contexts = this.local.dockerfileLocations.contextMap[path] || [];
|
||||
} else {
|
||||
this.local.contexts = [path.split('/').slice(0, -1).join('/').concat('/')];
|
||||
}
|
||||
}
|
||||
|
||||
private buildOrderedNamespaces(): void {
|
||||
if (this.local.namespaces) {
|
||||
this.local.maxScore = 0;
|
||||
this.local.namespaces.forEach((namespace) => {
|
||||
this.local.maxScore = Math.max(namespace.score, this.local.maxScore);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private loadNamespaces(): void {
|
||||
this.local.namespaces = null;
|
||||
this.local.selectedNamespace = null;
|
||||
this.local.orderedNamespaces = null;
|
||||
|
||||
this.local.selectedRepository = null;
|
||||
this.local.orderedRepositories = null;
|
||||
|
||||
var params = {
|
||||
'repository': this.repository.namespace + '/' + this.repository.name,
|
||||
'trigger_uuid': this.trigger.id
|
||||
};
|
||||
|
||||
this.apiService.listTriggerBuildSourceNamespaces(null, params)
|
||||
.then((resp) => {
|
||||
this.local.namespaces = resp['namespaces'];
|
||||
this.local.repositories = null;
|
||||
this.buildOrderedNamespaces();
|
||||
}, this.apiService.errorDisplay('Could not retrieve the list of ' + this.namespaceTitle));
|
||||
}
|
||||
|
||||
private buildOrderedRepositories(): void {
|
||||
if (this.local.repositories) {
|
||||
var repositories = this.local.repositories || [];
|
||||
repositories.forEach((repository) => {
|
||||
repository['last_updated_datetime'] = new Date(repository['last_updated'] * 1000);
|
||||
});
|
||||
|
||||
if (this.local.repositoryOptions.hideStale) {
|
||||
var existingRepositories = repositories;
|
||||
|
||||
repositories = repositories.filter((repository) => {
|
||||
var older_date = moment(repository['last_updated_datetime']).add(1, 'months');
|
||||
return !moment().isAfter(older_date);
|
||||
});
|
||||
|
||||
if (existingRepositories.length > 0 && repositories.length == 0) {
|
||||
repositories = existingRepositories;
|
||||
}
|
||||
}
|
||||
|
||||
this.local.orderedRepositories = this.tableService.buildOrderedItems(repositories,
|
||||
this.local.repositoryOptions,
|
||||
['name', 'description'],
|
||||
[]);
|
||||
}
|
||||
}
|
||||
|
||||
private loadRepositories(namespace: any): void {
|
||||
this.local.repositories = null;
|
||||
this.local.selectedRepository = null;
|
||||
this.local.repositoryRefs = null;
|
||||
this.local.triggerOptions = {
|
||||
'hasBranchTagFilter': false
|
||||
};
|
||||
|
||||
this.local.orderedRepositories = null;
|
||||
|
||||
const params = {
|
||||
'repository': this.repository.namespace + '/' + this.repository.name,
|
||||
'trigger_uuid': this.trigger.id
|
||||
};
|
||||
|
||||
const data = {
|
||||
'namespace': namespace.id
|
||||
};
|
||||
|
||||
this.apiService.listTriggerBuildSources(data, params).then((resp) => {
|
||||
if (namespace == this.local.selectedNamespace) {
|
||||
this.local.repositories = resp['sources'];
|
||||
this.buildOrderedRepositories();
|
||||
}
|
||||
}, this.apiService.errorDisplay('Could not retrieve repositories'));
|
||||
}
|
||||
|
||||
private loadRepositoryRefs(repository: any): void {
|
||||
this.local.repositoryRefs = null;
|
||||
this.local.triggerOptions = {
|
||||
'hasBranchTagFilter': false
|
||||
};
|
||||
|
||||
const params = {
|
||||
'repository': this.repository.namespace + '/' + this.repository.name,
|
||||
'trigger_uuid': this.trigger.id,
|
||||
'field_name': 'refs'
|
||||
};
|
||||
|
||||
const config = {
|
||||
'build_source': repository.full_name
|
||||
};
|
||||
|
||||
this.apiService.listTriggerFieldValues(config, params).then((resp) => {
|
||||
if (repository == this.local.selectedRepository) {
|
||||
this.local.repositoryRefs = resp['values'];
|
||||
this.local.repositoryFullRefs = resp['values'].map((ref) => {
|
||||
const kind = ref.kind == 'branch' ? 'heads' : 'tags';
|
||||
const icon = ref.kind == 'branch' ? 'fa-code-fork' : 'fa-tag';
|
||||
return {
|
||||
'value': `${kind}/${ref.name}`,
|
||||
'icon': icon,
|
||||
'title': ref.name
|
||||
};
|
||||
});
|
||||
}
|
||||
}, this.apiService.errorDisplay('Could not retrieve repository refs'));
|
||||
}
|
||||
|
||||
private loadDockerfileLocations(repository: any): void {
|
||||
this.local.dockerfilePath = null;
|
||||
this.local.dockerContext = null;
|
||||
|
||||
const params = {
|
||||
'repository': this.repository.namespace + '/' + this.repository.name,
|
||||
'trigger_uuid': this.trigger.id
|
||||
};
|
||||
const config: TriggerConfig = {build_source: repository.full_name};
|
||||
|
||||
this.apiService.listBuildTriggerSubdirs(config, params)
|
||||
.then((resp) => {
|
||||
if (repository == this.local.selectedRepository) {
|
||||
this.local.dockerfileLocations = resp;
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
this.apiService.errorDisplay('Could not retrieve Dockerfile locations');
|
||||
});
|
||||
}
|
||||
|
||||
private buildOrderedRobotAccounts(): void {
|
||||
if (this.local.triggerAnalysis && this.local.triggerAnalysis.robots) {
|
||||
this.local.triggerAnalysis.robots = this.local.triggerAnalysis.robots.map((robot) => {
|
||||
robot.kind = robot.kind || 'user';
|
||||
robot.is_robot = robot.is_robot || true;
|
||||
return robot;
|
||||
});
|
||||
|
||||
this.local.orderedRobotAccounts = this.tableService.buildOrderedItems(this.local.triggerAnalysis.robots,
|
||||
this.local.robotOptions,
|
||||
['name'],
|
||||
[]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
import { element, by, browser, $, ElementFinder, ExpectedConditions as until } from 'protractor';
|
||||
|
||||
|
||||
export class ManageTriggerViewObject {
|
||||
|
||||
public sections: {[name: string]: ElementFinder} = {
|
||||
namespace: $('linear-workflow-section[section-id=namespace]'),
|
||||
githostrepo: $('linear-workflow-section[section-id=repo][section-title="Select Repository"]'),
|
||||
customrepo: $('linear-workflow-section[section-id=repo][section-title="Git Repository"]'),
|
||||
triggeroptions: $('linear-workflow-section[section-id=triggeroptions]'),
|
||||
dockerfilelocation: $('linear-workflow-section[section-id=dockerfilelocation]'),
|
||||
contextlocation: $('linear-workflow-section[section-id=contextlocation]'),
|
||||
robot: $('linear-workflow-section[section-id=robot]'),
|
||||
verification: $('linear-workflow-section[section-id=verification]'),
|
||||
};
|
||||
|
||||
private customGitRepoInput: ElementFinder = element(by.model('$ctrl.buildSource'));
|
||||
private dockerfileLocationInput: ElementFinder = this.sections['dockerfilelocation'].$('input');
|
||||
private dockerfileLocationDropdownButton: ElementFinder = this.sections['dockerfilelocation']
|
||||
.$('button[data-toggle=dropdown');
|
||||
private dockerContextInput: ElementFinder = this.sections['contextlocation'].$('input');
|
||||
private dockerContextDropdownButton: ElementFinder = this.sections['contextlocation']
|
||||
.$('button[data-toggle=dropdown');
|
||||
private robotAccountOptions: ElementFinder = this.sections['robot']
|
||||
.element(by.repeater('$ctrl.orderedData.visibleEntries'));
|
||||
|
||||
public continue() {
|
||||
return element(by.buttonText('Continue')).click();
|
||||
}
|
||||
|
||||
public enterRepositoryURL(url: string) {
|
||||
browser.wait(until.presenceOf(this.customGitRepoInput));
|
||||
this.customGitRepoInput.clear();
|
||||
|
||||
return this.customGitRepoInput.sendKeys(url);
|
||||
}
|
||||
|
||||
public enterDockerfileLocation(path: string) {
|
||||
browser.wait(until.presenceOf(this.dockerfileLocationInput));
|
||||
this.dockerfileLocationInput.clear();
|
||||
|
||||
return this.dockerfileLocationInput.sendKeys(path);
|
||||
}
|
||||
|
||||
public getDockerfileSuggestions() {
|
||||
return this.dockerfileLocationDropdownButton.click()
|
||||
.then<string[]>(() => element.all(by.repeater('$ctrl.paths')).map(result => result.getText()));
|
||||
}
|
||||
|
||||
public enterDockerContext(path: string) {
|
||||
browser.wait(until.presenceOf(this.dockerContextInput));
|
||||
this.dockerContextInput.clear();
|
||||
|
||||
return this.dockerContextInput.sendKeys(path);
|
||||
}
|
||||
|
||||
public getDockerContextSuggestions() {
|
||||
return this.dockerContextDropdownButton.click()
|
||||
.then<string[]>(() => element.all(by.repeater('$ctrl.contexts')).map(result => result.getText()));
|
||||
}
|
||||
|
||||
public selectRobotAccount(index: number) {
|
||||
return element.all(by.css('input[type=radio]')).get(index).click();
|
||||
}
|
||||
}
|
Reference in a new issue