Skip to content
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

fix(azure-pg): dont try to load admin secret #276

Merged
merged 4 commits into from Nov 5, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 0 additions & 34 deletions src/components/azure-pg/__snapshots__/index.test.ts.snap
Expand Up @@ -2,23 +2,6 @@

exports[`should return create an job 1`] = `
Array [
Object {
"apiVersion": "v1",
"kind": "ConfigMap",
"metadata": Object {
"annotations": Object {
"app.gitlab.com/app": "socialgouv-sample",
"app.gitlab.com/env": "my-test",
"app.gitlab.com/env.name": "fabrique-dev",
},
"labels": Object {
"application": "my-test-sample",
"owner": "sample",
"team": "sample",
},
"namespace": "sample-42-my-test",
},
},
Object {
"apiVersion": "batch/v1",
"kind": "Job",
Expand Down Expand Up @@ -138,23 +121,6 @@ exports[`should throw because of a missing envs 1`] = `"Missing process.env.CI_C

exports[`should use custom pgHost 1`] = `
Array [
Object {
"apiVersion": "v1",
"kind": "ConfigMap",
"metadata": Object {
"annotations": Object {
"app.gitlab.com/app": "socialgouv-sample",
"app.gitlab.com/env": "my-test",
"app.gitlab.com/env.name": "fabrique-dev",
},
"labels": Object {
"application": "my-test-sample-next-app",
"owner": "sample-next-app",
"team": "sample-next-app",
},
"namespace": "sample-42-my-test",
},
},
Object {
"apiVersion": "batch/v1",
"kind": "Job",
Expand Down
6 changes: 0 additions & 6 deletions src/components/azure-pg/index.test.ts
Expand Up @@ -29,12 +29,6 @@ test("should throw because of a missing envs", () => {
expect(() => create({ env })).toThrowErrorMatchingSnapshot();
});

test("should throw because of a missing pg.sealed-secret.yaml", () => {
Object.assign(process.env, gitlabEnv);
const env = new Environment("/tmp");
expect(() => create({ env })).toThrowError("Missing pg.sealed-secret.yaml");
});

test("should return create an job", async () => {
Object.assign(process.env, gitlabEnv);
const cwd = directory();
Expand Down
18 changes: 2 additions & 16 deletions src/components/azure-pg/index.ts
@@ -1,10 +1,8 @@
import { Environment } from "@kosko/env";
import { SealedSecret } from "@kubernetes-models/sealed-secrets/bitnami.com/v1alpha1/SealedSecret";
import gitlab from "@socialgouv/kosko-charts/environments/gitlab";
import { ok } from "assert";

import { DeploymentParams } from "../../utils/createDeployment";
import { loadYaml } from "../../utils/getEnvironmentComponent";
import { getPgServerHostname } from "../../utils/getPgServerHostname";
import { updateMetadata } from "../../utils/updateMetadata";
import { createSecret } from "../pg-secret/create";
Expand Down Expand Up @@ -54,7 +52,7 @@ interface CreateParams {
config?: Partial<CreateConfig>;
}

export const create = ({ env, config = {} }: CreateParams): unknown[] => {
export const create = ({ config = {} }: CreateParams): unknown[] => {
const defaultParams = getDefaultPgParams(config);

// kosko component env values
Expand All @@ -64,18 +62,6 @@ export const create = ({ env, config = {} }: CreateParams): unknown[] => {
...config, // create options
};

/* SEALED-SECRET */
// try to import environment sealed-secret
const sealedSecret = loadYaml<SealedSecret>(env, `pg.sealed-secret.yaml`);
ok(sealedSecret, "Missing pg.sealed-secret.yaml");
// add gitlab annotations
updateMetadata(sealedSecret, {
annotations: envParams.annotations ?? {},
labels: envParams.labels ?? {},
namespace: envParams.namespace,
});
// add to deployment.envFrom

const secretNamespace = { name: `${process.env.CI_PROJECT_NAME}-secret` };

const job = createDbJob(defaultParams);
Expand All @@ -93,5 +79,5 @@ export const create = ({ env, config = {} }: CreateParams): unknown[] => {
name: defaultParams.name,
namespace: envParams.namespace,
});
return [sealedSecret, job, secret];
return [job, secret];
};