Skip to content

Commit

Permalink
Merge pull request #302 from cskiwi/feat/environment-values-copy-paste
Browse files Browse the repository at this point in the history
Feat/environment values file upload
  • Loading branch information
mms-gianni committed Mar 22, 2024
2 parents 04fd773 + e35b353 commit 87cde41
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
35 changes: 34 additions & 1 deletion client/src/components/apps/form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,11 @@
mdi-plus
</v-icon>
</v-btn>
</v-col>
</v-col>
</v-row>

<v-row>
<v-file-input prepend-icon="mdi-file" label="Drop or select .env file" show-size v-model="envFile" @change="handleFileInput"></v-file-input>
</v-row>
</v-expansion-panel-text>
</v-expansion-panel>
Expand Down Expand Up @@ -1170,6 +1174,7 @@ export default defineComponent({
advanced: false,
panel: [0],
valid: false,
envFile: [],
buildpacks: [] as { text: string, value: Buildpack }[],
buildpack: {
run: {
Expand Down Expand Up @@ -1973,6 +1978,34 @@ export default defineComponent({
}
}
},
handleFileInput() {
for (let i = 0; i < this.envFile.length; i++) {
const file = this.envFile[i];
const reader = new FileReader();
reader.onload = () => {
const text = reader.result;
this.parseEnvFile(text);
};
reader.readAsText(file);
}
// clear file input
this.envFile = [];
},
parseEnvFile(text: any) {
const lines = text.split('\n');
for (const line of lines) {
const [name, value] = line.split('=');
// check if name isn't commented out
if (name && !name.startsWith('#') && value) {
if (!this.envvars.some(envvar => envvar.name === name.trim())) {
this.envvars.push({ name: name.trim(), value: value.trim() });
}
}
}
},
addVolumeLine() {
this.extraVolumes.push({
name: 'example-volume',
Expand Down
1 change: 1 addition & 0 deletions client/src/components/pipelines/form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ export default defineComponent({
(v: any) => !!v || 'Name is required',
(v: any) => v.length <= 60 || 'Name must be less than 60 characters',
(v: any) => /^[a-z0-9][a-z0-9-]*$/.test(v) || 'Allowed characters : [a-z0-9-]',
(v: any) => v !== 'new' || 'Name cannot be "new"',
],
domainRules: [
(v: any) => v.length <= 253 || 'Name must be less than 253 characters',
Expand Down

0 comments on commit 87cde41

Please sign in to comment.