-
Notifications
You must be signed in to change notification settings - Fork 7
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
Refactor git-push-service action #1767
Conversation
annotations: { | ||
...parseApplicationAnnotations(inputs.applicationAnnotations), | ||
'github.ref': inputs.currentRef, | ||
'github.sha': inputs.currentSha, | ||
'github.action': 'git-push-service', | ||
}, |
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.
Moved from:
monorepo-deploy-actions/git-push-service/src/run.ts
Lines 71 to 76 in 05ab919
const applicationAnnotations = [ | |
...inputs.applicationAnnotations, | |
`github.ref=${github.context.ref}`, | |
`github.sha=${github.context.sha}`, | |
`github.action=git-push-service`, | |
] |
core.info(`writing to ${destination}`) | ||
const content = generateApplicationManifest(application) | ||
await fs.writeFile(destination, content) | ||
const parseApplicationAnnotations = (applicationAnnotations: string[]): Record<string, string> => { |
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.
Moved from:
monorepo-deploy-actions/git-push-service/src/application.ts
Lines 72 to 80 in 05ab919
if (a.annotations.length > 0) { | |
const annotations: { [_: string]: string } = {} | |
for (const s of a.annotations) { | |
const k = s.substring(0, s.indexOf('=')) | |
const v = s.substring(s.indexOf('=') + 1) | |
annotations[k] = v | |
} | |
application.metadata.annotations = annotations | |
} |
const application = { | ||
apiVersion: 'argoproj.io/v1alpha1', | ||
kind: 'Application', | ||
metadata: { | ||
name: `${inputs.namespace}--${inputs.service}`, | ||
namespace: 'argocd', | ||
finalizers: ['resources-finalizer.argocd.argoproj.io'], | ||
annotations: { | ||
...parseApplicationAnnotations(inputs.applicationAnnotations), | ||
'github.ref': inputs.currentRef, | ||
'github.sha': inputs.currentSha, | ||
'github.action': 'git-push-service', | ||
}, | ||
}, | ||
spec: { | ||
project: inputs.project, | ||
source: { | ||
repository: inputs.destinationRepository, | ||
branch: inputs.branch, | ||
repoURL: `https://github.com/${inputs.destinationRepository}.git`, | ||
targetRevision: inputs.branch, | ||
path: `services/${inputs.service}`, | ||
}, | ||
destination: { | ||
server: `https://kubernetes.default.svc`, | ||
namespace: inputs.namespace, | ||
}, | ||
annotations: inputs.applicationAnnotations, | ||
syncPolicy: { | ||
automated: { | ||
prune: true, | ||
}, | ||
}, | ||
}, | ||
inputs.workspace, | ||
) | ||
} | ||
} |
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.
Moved from:
monorepo-deploy-actions/git-push-service/src/application.ts
Lines 46 to 71 in 05ab919
const application: KubernetesApplication = { | |
apiVersion: 'argoproj.io/v1alpha1', | |
kind: 'Application', | |
metadata: { | |
name: a.name, | |
namespace: 'argocd', | |
finalizers: ['resources-finalizer.argocd.argoproj.io'], | |
}, | |
spec: { | |
project: a.project, | |
source: { | |
repoURL: `https://github.com/${a.source.repository}.git`, | |
targetRevision: a.source.branch, | |
path: a.source.path, | |
}, | |
destination: { | |
server: `https://kubernetes.default.svc`, | |
namespace: a.destination.namespace, | |
}, | |
syncPolicy: { | |
automated: { | |
prune: true, | |
}, | |
}, | |
}, | |
} |
} | ||
|
||
export const arrangeManifests = async (inputs: Inputs): Promise<void> => { | ||
return await arrangeServiceManifests(inputs) | ||
export const writeManifests = async (inputs: Inputs): Promise<void> => { |
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.
Rename the functions to write
prefix.
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.
I feel readability became better than before :lgtm:
This will apply the refactoring. There is no specification change.