Git editor for functions in Serverless Manager
Introduction
We have created a visual component (on top of Vue) that allows editing of files in git.
This component has been enabled in the platform’s Serverless module, to ease the creation of functions.
Thanks to this change, it will be possible to upload, edit and select the files necessary for the execution of a function during its creation or edition.
How is it used?
First you must create an application, filling in all the details of your gitlab project.
Once the application is created, move on to the creation of functions, and this is where you can take advantage of the file editor. When selecting the option to create a new function, the following screen will be shown:
As you can see, not only do you have the git file editor, but the screen no longer asks for the relative path within git. Instead, now you can manually create the file in your repository thanks to the editor, and the path will be assigned automatically.
First, select the branch you want to work on. With the branch selected, the file editor will access the repository and display its contents:
From here, you can access all the directories of the repository. Now, you can create new files in the desired location to contain your function.
Note: It is important that, when creating the file, the desired extension is included.
In this case, we are using an example from the original post on how to use the serverless module that contains two files. Once the files are created, the content can be pasted inside:
With the files ready, make the commit with the Save button, saving the changes made in the repository:
Finally, give the function a name, and select the file that you want to execute by clicking on it. To know which file the function is pointing to, you can look at the indicator that is located above the editor:
This way, the function will be created and ready to be launched:
Uploading files from GitLab
In case your function needs multiple files to work and you don't want to create them from the file editor one by one, you can always upload them from GitLab and select them from the editor.
As you can see, a folder with the contents of a function has been uploaded from GitLab. Now you simply have to select the file to be executed in the editor and create the function:
The function will be created and will point to the file we have selected:
Â