Skip to main content

Folder Structure

Default Structure

By default, all environment files are stored in environments folder as below.

└── environments
├── dev
│ ├── index.js
│ └── nginx.js
└── prod
├── index.js
└── nginx.js

You can configure path of environment files in kosko.toml. The default setting are:

global = "environments/#{environment}"
component = "environments/#{environment}/#{component}"

Larger Project

If you have tens or hundreds of components, moving environment files closer to your components might be better, so you don't need to jump between components and environments folder frequently.


You can configure paths.environment.component in kosko.toml to change the path of component environment files as below.

component = "components/#{component}/#{environment}"

And the updated folder structure will be like this.

├── components
│ └── nginx
│ ├── dev.js
│ ├── index.js
│ └── prod.js
└── environments
├── dev.js
└── prod.js


Type definitions can also be moved to components folder. For example, you can move type of component variables to components/<component>/types.ts, and import them in typings/@kosko__env/index.d.ts.

import NginxEnvironment from "../../components/nginx/types";
import "@kosko/env";

declare module "@kosko/env" {
interface GlobalEnvironment {
imageRegistry: string;

interface ComponentEnvironment {
[key: string]: unknown;
nginx: NginxEnvironment;

interface Environment {
global(): GlobalEnvironment;

component<K extends string>(
name: K
): GlobalEnvironment & ComponentEnvironment[K];