Skip to content

Commit

Permalink
fix(hasura): handle deployment options (#184)
Browse files Browse the repository at this point in the history
* fix(hasura): handle deployment options

* lint

* lint
  • Loading branch information
Julien Bouquillon committed Sep 18, 2020
1 parent 251c4d1 commit 3ed8f4a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
Expand Up @@ -51,6 +51,8 @@ spec:
team: sample-next-app
cert: wildcard
spec:
imagePullSecrets:
- name: regcred
containers:
- image: >-
registry.gitlab.factory.social.gouv.fr/socialgouv/sample-next-app/hasura:8843083edb7f873cad1d1420731a60773594ffae
Expand Down
Expand Up @@ -51,6 +51,8 @@ spec:
team: sample-next-app
cert: wildcard
spec:
imagePullSecrets:
- name: regcred
containers:
- image: >-
registry.gitlab.factory.social.gouv.fr/socialgouv/sample-next-app/hasura:1.2.3
Expand Down
Expand Up @@ -33,6 +33,8 @@ spec:
team: sample-next-app
cert: wildcard
spec:
imagePullSecrets:
- name: regcred
containers:
- image: >-
registry.gitlab.factory.social.gouv.fr/socialgouv/sample-next-app/hasura:1.2.3
Expand Down
21 changes: 16 additions & 5 deletions src/components/hasura/index.ts
@@ -1,3 +1,4 @@
/* eslint-disable simple-import-sort/sort */
import { Environment } from "@kosko/env";
import { merge } from "@socialgouv/kosko-charts/utils/merge";
import { ok } from "assert";
Expand All @@ -6,12 +7,21 @@ import { Deployment } from "kubernetes-models/apps/v1/Deployment";
import { addPostgresUserSecret } from "../../utils/addPostgresUserSecret";
import { addWaitForPostgres } from "../../utils/addWaitForPostgres";
import { AppConfig, create as createApp } from "../app";
import { DeploymentParams } from "../../utils/createDeployment";

type CreateResult = unknown[];

export const create = (
// eslint-disable-next-line @typescript-eslint/ban-types
{ env, config = {} }: { env: Environment; config?: Partial<AppConfig> }
{
env,
config = {},
deployment = {},
}: {
env: Environment;
config?: Partial<AppConfig>;
deployment?: Partial<DeploymentParams>;
}
): CreateResult => {
ok(process.env.CI_REGISTRY_IMAGE);
ok(process.env.CI_ENVIRONMENT_URL);
Expand Down Expand Up @@ -46,18 +56,19 @@ export const create = (
},
config
),
deployment,
env,
});

// DEV: add secret to access DB
const deployment = manifests.find(
const hasuraDeployment = manifests.find(
(manifest): manifest is Deployment => manifest.kind === "Deployment"
);
ok(deployment);
ok(hasuraDeployment);

addPostgresUserSecret(deployment);
addPostgresUserSecret(hasuraDeployment);

addWaitForPostgres(deployment);
addWaitForPostgres(hasuraDeployment);

//

Expand Down
3 changes: 3 additions & 0 deletions templates/simple/components/hasura.ts
Expand Up @@ -6,6 +6,9 @@ const manifests = create({
ingress: false,
},
env,
deployment: {
imagePullSecrets: [{ name: "regcred" }],
},
});

export default manifests;

0 comments on commit 3ed8f4a

Please sign in to comment.