-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SALTO-7399: advanced fields references #7209
Changes from 1 commit
35341cd
872de59
fe71705
ac59d56
7f89b0f
5e25404
78722bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* | ||
* CERTAIN THIRD PARTY SOFTWARE MAY BE CONTAINED IN PORTIONS OF THE SOFTWARE. See NOTICE FILE AT https://github.com/salto-io/salto/blob/main/NOTICES | ||
*/ | ||
import { Element, InstanceElement, isInstanceElement } from '@salto-io/adapter-api' | ||
import { InstanceElement, isInstanceElement } from '@salto-io/adapter-api' | ||
import { references as referenceUtils } from '@salto-io/adapter-components' | ||
import _ from 'lodash' | ||
import { referencesRules, JiraFieldReferenceResolver, contextStrategyLookup } from '../reference_mapping' | ||
|
@@ -22,14 +22,15 @@ import { addFieldsTemplateReferences } from './fields/reference_to_fields' | |
|
||
const NO_REFERENCES_TYPES = (): string[] => [PROJECT_COMPONENT_TYPE, FIELD_CONFIGURATION_TYPE_NAME] | ||
|
||
const addWalkOnReferences = (elements: Element[], config: JiraConfig): void => { | ||
const addWalkOnReferences = (instances: InstanceElement[], config: JiraConfig): void => { | ||
if (!config.fetch.walkOnReferences) { | ||
return | ||
} | ||
const instances = elements.filter(isInstanceElement) | ||
const fieldInstances = instances.filter(instance => instance.elemID.typeName === FIELD_TYPE_NAME) | ||
const fieldInstancesById = new Map( | ||
fieldInstances.map(instance => [instance.value.id, instance] as [string, InstanceElement]), | ||
fieldInstances | ||
.filter(instance => typeof instance.value.id === 'string') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tend to go with a natural solution over a package one |
||
.map(instance => [instance.value.id, instance] as [string, InstanceElement]), | ||
) | ||
walkOnAutomations( | ||
instances.filter(instance => instance.elemID.typeName === AUTOMATION_TYPE), | ||
|
@@ -42,7 +43,7 @@ const addWalkOnReferences = (elements: Element[], config: JiraConfig): void => { | |
const filter: FilterCreator = ({ config }) => ({ | ||
name: 'fieldReferencesFilter', | ||
onFetch: async elements => { | ||
addWalkOnReferences(elements, config) | ||
addWalkOnReferences(elements.filter(isInstanceElement), config) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
|
||
const fixedDefs = referencesRules.map(def => | ||
config.fetch.enableMissingReferences ? def : _.omit(def, 'missingRefStrategy'), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need it as a function?
I agree that it should be a constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as I answered in the previous comment