diff --git a/dashboard/src/lib/env-groups/types.ts b/dashboard/src/lib/env-groups/types.ts index bbea0ea062..0ad3dfcf2d 100644 --- a/dashboard/src/lib/env-groups/types.ts +++ b/dashboard/src/lib/env-groups/types.ts @@ -33,6 +33,15 @@ export const envGroupValidator = z.object({ secret_variables: z.record(z.string()).optional().default({}), created_at: z.string(), linked_applications: z.array(z.string()).optional().default([]), + files: z + .array( + z.object({ + name: z.string(), + contents: z.string(), + }) + ) + .optional() + .default([]), type: z .string() .pipe( diff --git a/dashboard/src/main/home/env-dashboard/CreateEnvGroup.tsx b/dashboard/src/main/home/env-dashboard/CreateEnvGroup.tsx index 92c427a101..c80de880cf 100644 --- a/dashboard/src/main/home/env-dashboard/CreateEnvGroup.tsx +++ b/dashboard/src/main/home/env-dashboard/CreateEnvGroup.tsx @@ -34,15 +34,7 @@ const CreateEnvGroup: React.FC = ({ history }) => { reValidateMode: "onSubmit", defaultValues: { name: "", - envVariables: [ - { - key: "", - value: "", - hidden: false, - locked: false, - deleted: false, - }, - ], + envVariables: [], envFiles: [], }, }); @@ -66,7 +58,11 @@ const CreateEnvGroup: React.FC = ({ history }) => { const validate = async (): Promise => { const isNameValid = await trigger("name"); const isEnvVariablesValid = await trigger("envVariables"); - if (isNameValid && isEnvVariablesValid) { + if ( + isNameValid && + ((isEnvVariablesValid && envVariables.length > 0) || + envFiles.length > 0) + ) { setStep(3); } else if (isNameValid) { setStep(2); @@ -75,7 +71,7 @@ const CreateEnvGroup: React.FC = ({ history }) => { } }; void validate(); - }, [name, envVariables]); + }, [name, envVariables, envFiles]); const onSubmit = handleSubmit(async (data) => { setSubmitErrorMessage(""); @@ -206,7 +202,8 @@ const CreateEnvGroup: React.FC = ({ history }) => { Files containing sensitive data that will be injected into - your app's root directory. + your app's root directory, at the path{" "} + {`/etc/secrets/${name}`}. ` width: 100%; margin-top: ${(props) => props.antiHeight || "-5px"}; `; + +const Code = styled.span` + font-family: monospace; +`; diff --git a/dashboard/src/main/home/env-dashboard/tabs/EnvVarsTab.tsx b/dashboard/src/main/home/env-dashboard/tabs/EnvVarsTab.tsx index df23c70c03..86d64e518f 100644 --- a/dashboard/src/main/home/env-dashboard/tabs/EnvVarsTab.tsx +++ b/dashboard/src/main/home/env-dashboard/tabs/EnvVarsTab.tsx @@ -215,7 +215,8 @@ const EnvVarsTab: React.FC = ({ envGroup, fetchEnvGroup }) => { Files containing sensitive data that will be injected into your - app's root directory. + app's root directory, at the path{" "} + {`/etc/secrets/${envGroup.name}`}. (props.success ? "#4797ff" : "#fcba03")}; } `; + +const Code = styled.span` + font-family: monospace; +`; diff --git a/internal/kubernetes/environment_groups/list.go b/internal/kubernetes/environment_groups/list.go index 2696345610..671f40a345 100644 --- a/internal/kubernetes/environment_groups/list.go +++ b/internal/kubernetes/environment_groups/list.go @@ -2,7 +2,6 @@ package environment_groups import ( "context" - "encoding/base64" "fmt" "strconv" "strings" @@ -41,8 +40,8 @@ const ( type EnvGroupFile struct { // Name is the name of the file Name string `json:"name"` - // B64Contents is the base64 encoded contents of the file - B64Contents string `json:"contents"` + // Contents is the contents of the file + Contents string `json:"contents"` } // EnvironmentGroup represents a ConfigMap in the porter-env-group namespace @@ -239,10 +238,9 @@ func listEnvironmentGroups(ctx context.Context, a *kubernetes.Agent, listOpts .. if ok && isFileSecret == "true" { var files []EnvGroupFile for k, v := range secret.Data { - encodedContents := base64.StdEncoding.EncodeToString(v) files = append(files, EnvGroupFile{ - Name: k, - B64Contents: encodedContents, + Name: k, + Contents: string(v), }) } envGroupSet[versionedName] = EnvironmentGroup{