mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Merge pull request #12849 from AlexSCorey/12413-trackSCMInventory
Adds project revision hash to inventory source views
This commit is contained in:
commit
358024d029
@ -2232,6 +2232,7 @@ class InventoryUpdateSerializer(UnifiedJobSerializer, InventorySourceOptionsSeri
|
||||
'source_project_update',
|
||||
'custom_virtualenv',
|
||||
'instance_group',
|
||||
'scm_revision',
|
||||
)
|
||||
|
||||
def get_related(self, obj):
|
||||
|
||||
25
awx/main/migrations/0168_inventoryupdate_scm_revision.py
Normal file
25
awx/main/migrations/0168_inventoryupdate_scm_revision.py
Normal file
@ -0,0 +1,25 @@
|
||||
# Generated by Django 3.2.13 on 2022-09-08 16:03
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('main', '0167_project_signature_validation_credential'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='inventoryupdate',
|
||||
name='scm_revision',
|
||||
field=models.CharField(
|
||||
blank=True,
|
||||
default='',
|
||||
editable=False,
|
||||
help_text='The SCM Revision from the Project used for this inventory update. Only applicable to inventories source from scm',
|
||||
max_length=1024,
|
||||
verbose_name='SCM Revision',
|
||||
),
|
||||
),
|
||||
]
|
||||
@ -1191,6 +1191,14 @@ class InventoryUpdate(UnifiedJob, InventorySourceOptions, JobNotificationMixin,
|
||||
default=None,
|
||||
null=True,
|
||||
)
|
||||
scm_revision = models.CharField(
|
||||
max_length=1024,
|
||||
blank=True,
|
||||
default='',
|
||||
editable=False,
|
||||
verbose_name=_('SCM Revision'),
|
||||
help_text=_('The SCM Revision from the Project used for this inventory update. Only applicable to inventories source from scm'),
|
||||
)
|
||||
|
||||
@property
|
||||
def is_container_group_task(self):
|
||||
|
||||
@ -739,8 +739,7 @@ class SourceControlMixin(BaseTask):
|
||||
sync_task = RunProjectUpdate(job_private_data_dir=private_data_dir)
|
||||
sync_task.run(local_project_sync.id)
|
||||
local_project_sync.refresh_from_db()
|
||||
if isinstance(self.instance, Job):
|
||||
self.instance = self.update_model(self.instance.pk, scm_revision=local_project_sync.scm_revision)
|
||||
self.instance = self.update_model(self.instance.pk, scm_revision=local_project_sync.scm_revision)
|
||||
except Exception:
|
||||
local_project_sync.refresh_from_db()
|
||||
if local_project_sync.status != 'canceled':
|
||||
@ -759,8 +758,7 @@ class SourceControlMixin(BaseTask):
|
||||
else:
|
||||
# Case where a local sync is not needed, meaning that local tree is
|
||||
# up-to-date with project, job is running project current version
|
||||
if isinstance(self.instance, Job):
|
||||
self.instance = self.update_model(self.instance.pk, scm_revision=project.scm_revision)
|
||||
self.instance = self.update_model(self.instance.pk, scm_revision=project.scm_revision)
|
||||
# Project update does not copy the folder, so copy here
|
||||
RunProjectUpdate.make_local_copy(project, private_data_dir)
|
||||
|
||||
|
||||
@ -4,7 +4,8 @@ import { t } from '@lingui/macro';
|
||||
const jobHelpText = () => ({
|
||||
jobType: t`For job templates, select run to execute the playbook. Select check to only check playbook syntax, test environment setup, and report problems without executing the playbook.`,
|
||||
inventory: t`Select the inventory containing the hosts you want this job to manage.`,
|
||||
project: t`Select the project containing the playbook you want this job to execute.`,
|
||||
project: t`The project containing the playbook this job will execute.`,
|
||||
project_source: t`The project from which this inventory update is sourced.`,
|
||||
executionEnvironment: t`The execution environment that will be used when launching this job template. The resolved execution environment can be overridden by explicitly assigning a different one to this job template.`,
|
||||
playbook: t`Select the playbook to be executed by this job.`,
|
||||
credentials: t`Select credentials for accessing the nodes this job will be ran against. You can only select one credential of each type. For machine credentials (SSH), checking "Prompt on launch" without selecting credentials will require you to select a machine credential at run time. If you select credentials and check "Prompt on launch", the selected credential(s) become the defaults that can be updated at run time.`,
|
||||
|
||||
@ -147,27 +147,48 @@ function JobDetail({ job, inventorySourceLabels }) {
|
||||
|
||||
const renderProjectDetail = () => {
|
||||
if (
|
||||
job.type !== 'ad_hoc_command' &&
|
||||
job.type !== 'inventory_update' &&
|
||||
job.type !== 'system_job' &&
|
||||
job.type !== 'workflow_job'
|
||||
(job.type !== 'ad_hoc_command' &&
|
||||
job.type !== 'inventory_update' &&
|
||||
job.type !== 'system_job' &&
|
||||
job.type !== 'workflow_job') ||
|
||||
source_project
|
||||
) {
|
||||
return project ? (
|
||||
const projectDetailsLink = `/projects/${
|
||||
project ? project?.id : source_project?.id
|
||||
}/details`;
|
||||
|
||||
const jobLink = `/jobs/project/${
|
||||
project ? projectUpdate?.id : job.source_project_update
|
||||
}`;
|
||||
|
||||
let projectName = '';
|
||||
if (project?.name || source_project?.name) {
|
||||
projectName = project ? project.name : source_project.name;
|
||||
}
|
||||
return project || inventory_source ? (
|
||||
<>
|
||||
<Detail
|
||||
dataCy="job-project"
|
||||
label={t`Project`}
|
||||
helpText={jobHelpText.project}
|
||||
value={<Link to={`/projects/${project.id}`}>{project.name}</Link>}
|
||||
label={project ? t`Project` : t`Source`}
|
||||
helpText={
|
||||
project ? jobHelpText.project : jobHelpText.project_source
|
||||
}
|
||||
value={<Link to={`${projectDetailsLink}`}>{projectName}</Link>}
|
||||
/>
|
||||
<Detail
|
||||
dataCy="job-project-status"
|
||||
label={t`Project Update Status`}
|
||||
helpText={jobHelpText.projectUpdate}
|
||||
value={
|
||||
projectUpdate ? (
|
||||
<Link to={`/jobs/project/${projectUpdate.id}`}>
|
||||
<StatusLabel status={projectUpdate.status} />
|
||||
projectUpdate || job.source_project_update ? (
|
||||
<Link to={`${jobLink}`}>
|
||||
<StatusLabel
|
||||
status={
|
||||
projectUpdate
|
||||
? projectUpdate.status
|
||||
: source_project.status
|
||||
}
|
||||
/>
|
||||
</Link>
|
||||
) : null
|
||||
}
|
||||
@ -190,9 +211,7 @@ function JobDetail({ job, inventorySourceLabels }) {
|
||||
value={
|
||||
<StatusDetailValue>
|
||||
{job.status && <StatusLabel status={job.status} />}
|
||||
{job.job_explanation && job.job_explanation !== job.status
|
||||
? job.job_explanation
|
||||
: null}
|
||||
{job?.job_explanation !== job.status ? job.job_explanation : null}
|
||||
</StatusDetailValue>
|
||||
}
|
||||
/>
|
||||
@ -269,31 +288,17 @@ function JobDetail({ job, inventorySourceLabels }) {
|
||||
</Link>
|
||||
}
|
||||
/>
|
||||
<Detail
|
||||
dataCy="job-inventory-source-type"
|
||||
label={t`Source`}
|
||||
value={inventorySourceLabels.map(([string, label]) =>
|
||||
string === job.source ? label : null
|
||||
)}
|
||||
isEmpty={inventorySourceLabels.length === 0}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{inventory_source && inventory_source.source === 'scm' && (
|
||||
<Detail
|
||||
dataCy="job-inventory-source-project"
|
||||
label={t`Inventory Source Project`}
|
||||
value={
|
||||
<StatusDetailValue>
|
||||
{source_project.status && (
|
||||
<StatusLabel status={source_project.status} />
|
||||
{!source_project && (
|
||||
<Detail
|
||||
dataCy="job-inventory-source-type"
|
||||
label={t`Source`}
|
||||
value={inventorySourceLabels.map(([string, label]) =>
|
||||
string === job.source ? label : null
|
||||
)}
|
||||
<Link to={`/projects/${source_project.id}`}>
|
||||
{source_project.name}
|
||||
</Link>
|
||||
</StatusDetailValue>
|
||||
}
|
||||
/>
|
||||
isEmpty={inventorySourceLabels.length === 0}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{renderProjectDetail()}
|
||||
{scmBranch && (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user