Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .eslintrc

This file was deleted.

4 changes: 2 additions & 2 deletions .github/actions/setup/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v4.0.2
uses: actions/setup-node@v4.4.0
with:
node-version-file: .nvmrc

- name: Cache dependencies
id: yarn-cache
uses: actions/cache@v4.0.0
uses: actions/cache@v4.2.3
with:
path: |
**/node_modules
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4.2.2

- name: Setup
uses: ./.github/actions/setup
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
HUSKY: 0
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4.2.2
with:
fetch-depth: 0

Expand Down
3 changes: 0 additions & 3 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no -- commitlint --edit "${1}"
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn precommit
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "avoid",
"trailingComma": "none"
"trailingComma": "es5"
}
56 changes: 28 additions & 28 deletions actions/add-application.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ import {
createIngress,
createService,
getDeploymentPatches,
getImageUpdaterAnnotations
getImageUpdaterAnnotations,
} from '../resources'

const getApplicationDestination = async () => {
const projects = getDirectoryList('projects')

const applicationName = await input({
message: 'What is the name of application?'
message: 'What is the name of application?',
})

const projectName = await select({
message: `To which project we are adding '${applicationName}' application?`,
choices: projects.map(value => ({ value }))
choices: projects.map(value => ({ value })),
})

const applicationDirectory = join(process.cwd(), 'projects', projectName, 'apps', applicationName)
Expand All @@ -36,7 +36,7 @@ const getApplicationDestination = async () => {

return {
applicationName,
projectName
projectName,
}
}

Expand All @@ -52,13 +52,13 @@ export const addApplicationWithOverlays = async (options: ApplicationOptions): P
project: projectName,
repoURL: config.mainRepositoryUrl,
path: `./${applicationDirectory}/overlays/${environment}`,
annotations: getImageUpdaterAnnotations(options)
annotations: getImageUpdaterAnnotations(options),
})
)

const configmap = createConfigMap({
applicationName,
data: {}
data: {},
})

const deployment = createDeployment(options)
Expand All @@ -75,7 +75,7 @@ export const addApplicationWithOverlays = async (options: ApplicationOptions): P

if (options.useHorizontalPodAutoscaler) {
const hpa = createHorizontalPodAutoscaler({
applicationName
applicationName,
})

await writeYamlFile(`${applicationDirectory}/base/hpa.yaml`, hpa)
Expand All @@ -87,22 +87,22 @@ export const addApplicationWithOverlays = async (options: ApplicationOptions): P
'./deployment.yaml',
'./service.yaml',
...(options.useIngress ? ['./ingress.yaml'] : []),
...(options.useHorizontalPodAutoscaler ? ['./hpa.yaml'] : [])
]
...(options.useHorizontalPodAutoscaler ? ['./hpa.yaml'] : []),
],
})

await Promise.all(
config.environments.map(async environment => {
const patches = getDeploymentPatches({
...options,
environment
environment,
})

await writeYamlFile(`${applicationDirectory}/overlays/${environment}/patches.yaml`, patches)
await writeYamlFile(`${applicationDirectory}/overlays/${environment}/kustomization.yaml`, {
resources: ['../../base'],
// images: [{ name: imageUrlOrName }],
patches: [{ path: './patches.yaml' }]
patches: [{ path: './patches.yaml' }],
})
})
)
Expand All @@ -119,12 +119,12 @@ export const addApplicationWithResources = async (options: ApplicationOptions):
project: projectName,
repoURL: config.mainRepositoryUrl,
path: applicationPath,
annotations: getImageUpdaterAnnotations(options)
annotations: getImageUpdaterAnnotations(options),
})

const configmap = createConfigMap({
applicationName,
data: {}
data: {},
})

const deployment = createDeployment(options)
Expand All @@ -141,7 +141,7 @@ export const addApplicationWithResources = async (options: ApplicationOptions):

if (options.useHorizontalPodAutoscaler) {
const hpa = createHorizontalPodAutoscaler({
applicationName
applicationName,
})

await writeYamlFile(`${applicationPath}/hpa.yaml`, hpa)
Expand All @@ -153,8 +153,8 @@ export const addApplicationWithResources = async (options: ApplicationOptions):
'./deployment.yaml',
'./service.yaml',
...(options.useIngress ? ['./ingress.yaml'] : []),
...(options.useHorizontalPodAutoscaler ? ['./hpa.yaml'] : [])
]
...(options.useHorizontalPodAutoscaler ? ['./hpa.yaml'] : []),
],
})

return application
Expand All @@ -165,47 +165,47 @@ export const addApplicationAction = async () => {
const { applicationName, projectName } = await getApplicationDestination()

const imageName = await input({
message: 'What is the image name (for example: your-registry.com/your-app, nginx:latest etc.)?'
message: 'What is the image name (for example: your-registry.com/your-app, nginx:latest etc.)?',
})

const containerPort = await input({
message: 'What is the container port?'
message: 'What is the container port?',
})

const servicePort = await input({
message: 'What is the service port?',
default: containerPort
default: containerPort,
})

// note: we could use `choices`
const useOverlays = await confirm({
message: 'Use overlays (multiple environments)?',
default: true
default: true,
})

const useIngress = await confirm({
message: 'Use ingress?',
default: true
default: true,
})

const useImageUpdater = await confirm({
message: 'Use image-updater?',
default: true
default: true,
})

const useHorizontalPodAutoscaler = await confirm({
message: 'Use HPA (Horizontal Pod Autoscaler)?',
default: true
default: true,
})

const useHealthCheck = await confirm({
message: 'Use health check?',
default: true
default: true,
})

const useSecurityContext = await confirm({
message: 'Use security context?',
default: true
default: true,
})

const applicationDirectory = `projects/${projectName}/apps/${applicationName}`
Expand All @@ -221,20 +221,20 @@ export const addApplicationAction = async () => {
useHorizontalPodAutoscaler,
useImageUpdater,
useHealthCheck,
useSecurityContext
useSecurityContext,
}

const applicationResources = useOverlays ? await addApplicationWithOverlays(options) : await addApplicationWithResources(options)

await writeYamlFile(`${applicationDirectory}/application.yaml`, applicationResources)
await writeYamlFile(`${applicationDirectory}/kustomization.yaml`, {
resources: ['./application.yaml']
resources: ['./application.yaml'],
})

const applicationsKustomizationPath = `projects/${projectName}/apps/kustomization.yaml`
const applicationsKustomization = await readYamlFile<Kustomization>(applicationsKustomizationPath)

await writeYamlFile(applicationsKustomizationPath, {
resources: [...applicationsKustomization.resources, `./${applicationName}`]
resources: [...applicationsKustomization.resources, `./${applicationName}`],
})
}
8 changes: 4 additions & 4 deletions actions/add-project.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const addProjectAction = async () => {
const { mainRepositoryUrl } = getProjectConfig()

const projectName = await input({
message: 'What name would you like to use for the project?'
message: 'What name would you like to use for the project?',
})
const isProjectExists = isPathExists(`projects/${projectName}`)

Expand All @@ -18,16 +18,16 @@ export const addProjectAction = async () => {
const currentProjectsKustomization = await readYamlFile<Kustomization>('projects/kustomization.yaml')
const appProjectResource = createAppProject({
name: projectName,
sourceRepos: [mainRepositoryUrl]
sourceRepos: [mainRepositoryUrl],
})
const kustomizationResource: Kustomization = {
resources: ['./apps', './project.yaml']
resources: ['./apps', './project.yaml'],
}

await writeYamlFile(`projects/${projectName}/project.yaml`, appProjectResource)
await writeYamlFile(`projects/${projectName}/kustomization.yaml`, kustomizationResource)
await writeYamlFile(`projects/${projectName}/apps/kustomization.yaml`, { resources: [] })
await writeYamlFile(`projects/kustomization.yaml`, {
resources: [...(currentProjectsKustomization?.resources ?? []), `./${projectName}`]
resources: [...(currentProjectsKustomization?.resources ?? []), `./${projectName}`],
})
}
32 changes: 16 additions & 16 deletions actions/init-project.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ const addAddonApplication = async (rootDirectory: string, addonsProjectName: str
const { name: applicationName, resource: applicationResource } = resource
const application = override(applicationResource, {
spec: {
project: addonsProjectName
}
project: addonsProjectName,
},
})

await writeYamlFile(`${rootDirectory}/projects/${addonsProjectName}/apps/${applicationName}/application.yaml`, application)
await writeYamlFile(`${rootDirectory}/projects/${addonsProjectName}/apps/${applicationName}/kustomization.yaml`, {
resources: ['./application.yaml']
resources: ['./application.yaml'],
})

return {
path: `./${applicationName}`,
sourceRepoUrl: application.spec.source.repoURL
sourceRepoUrl: application.spec.source.repoURL,
}
}

Expand All @@ -32,8 +32,8 @@ const addAdditionalApps = async (rootDirectory: string, repoURL: string) => {
{ name: 'ingress-nginx', value: INGRESS_NGINX_ADDON_RESOURCE },
{ name: 'cert-manager', value: CERT_MANAGER_ADDON_RESOURCE },
{ name: 'reflector', value: REFLECTOR_ADDON_RESOURCE },
{ name: 'image-updater', value: IMAGE_UPDATER_ADDON_RESOURCE }
]
{ name: 'image-updater', value: IMAGE_UPDATER_ADDON_RESOURCE },
],
})

if (!additionalAppChoices.length) {
Expand All @@ -46,15 +46,15 @@ const addAdditionalApps = async (rootDirectory: string, repoURL: string) => {

const appProjectResource = createAppProject({
name: addonsProjectName,
sourceRepos: [repoURL, ...addonApps.map(({ sourceRepoUrl }) => sourceRepoUrl)]
sourceRepos: [repoURL, ...addonApps.map(({ sourceRepoUrl }) => sourceRepoUrl)],
})

const appsKustomizationResource: Kustomization = {
resources: addonApps.map(({ path }) => path)
resources: addonApps.map(({ path }) => path),
}

const appProjectKustomizationResource: Kustomization = {
resources: ['./project.yaml', './apps']
resources: ['./project.yaml', './apps'],
}

await writeYamlFile(`${rootDirectory}/projects/${addonsProjectName}/apps/kustomization.yaml`, appsKustomizationResource)
Expand All @@ -63,7 +63,7 @@ const addAdditionalApps = async (rootDirectory: string, repoURL: string) => {

return {
path: `./${addonsProjectName}`,
addedInDefaultProject
addedInDefaultProject,
}
}

Expand All @@ -77,7 +77,7 @@ export const initProjectAction = async () => {
const mainRepositoryUrl = await input({ message: 'What is the base URL of GitHub repository?' })
const environments = await input({
message: 'What will be the environment inside your cluster? Provide separated by `,`',
default: 'dev,prod'
default: 'dev,prod',
}).then(environments =>
environments
.toLowerCase()
Expand All @@ -87,7 +87,7 @@ export const initProjectAction = async () => {

const config: ProjectConfig = {
mainRepositoryUrl,
environments
environments,
}

const addons = await addAdditionalApps(rootDirectory, mainRepositoryUrl)
Expand All @@ -97,17 +97,17 @@ export const initProjectAction = async () => {
name: 'root-app',
namespace: 'default',
repoURL: mainRepositoryUrl,
path: 'projects'
path: 'projects',
})

if (!addonsAddedInDefaultProject) {
const defaultAppProjectResource = createAppProject({
name: 'default',
sourceRepos: [mainRepositoryUrl]
sourceRepos: [mainRepositoryUrl],
})

const kustomizationResource: Kustomization = {
resources: ['./apps', './project.yaml']
resources: ['./apps', './project.yaml'],
}

await writeYamlFile(`${rootDirectory}/projects/default/kustomization.yaml`, kustomizationResource)
Expand All @@ -118,6 +118,6 @@ export const initProjectAction = async () => {
await writeYamlFile(`${rootDirectory}/root-app.yaml`, rootAppResource)
await writeYamlFile(`${rootDirectory}/argo-composer.config.yaml`, config)
await writeYamlFile(`${rootDirectory}/projects/kustomization.yaml`, {
resources: !addonsAddedInDefaultProject ? ['./default', addons?.path].filter(isNotNil) : [addons.path]
resources: !addonsAddedInDefaultProject ? ['./default', addons?.path].filter(isNotNil) : [addons.path],
})
}
Loading