We would like to export new environment variables from v2 platform with the projectsExport. to then import to the same target environment with projectsImport task.
We checked for the api call for export v2:
Those are the ones we need
Query for getting all scope GLOBAL:
query globalEnvironmentVariablesQuery {
globalEnvironmentVariables {
id name scope value description isPassword
}
}
Query for getting all scope PROJECT:
query environmentVariablesQuery($projectId: UUID!) {
projectEnvironmentVariables(projectId: $projectId) {
id scope name value description isPassword
overriddenValues {
id scope value description isPassword
}
}
}
Mutation for adding environment variables:
For scope GLOBALcreation:
For scope GLOBALedition:
For scope PROJECTcreation:
For scope PROJECTedition:
How?
Our work will be devided in two main part Export V2 and Import V2.
First part Export V2 :
[ ] Add object EnvVariable to groovy/io/saagie/plugin/dataops/models with properties
EnvVariable Class
scope : String
include_all_var: boolean
name: ArrayList
[ ] Add getGlobalEnvironmentVariables to groovy/io/saagie/plugin/dataops/utils/SaagieUtils.groovy that will fetch all global variables
[ ] Add getProjectEnvironmentVariables to groovy/io/saagie/plugin/dataops/utils/SaagieUtils.groovy that will fetch all project variables
[ ] updating exportArtifacts to SaagieClient.groovy, add the logic to get the list of variables from one the the query getGlobalEnvironmentVariables or getProjectEnvironmentVariables
depending on the value of scope (global|project)
[ ] Create a new Class ExportVariables that will include
ExportVariables Class
name: string
description: string
isPassword: boolean
value: string
scope: string
overriddenValues: OverridenValues
OverridenValues Class
id: String
[ ] After mapping results from the environment variables query to ExportVariables we need to change the FolderGenerator and add method generateFolderForVariables that will create a new folder for the exported variables.
### Second part Import:
[ ] we need to added static method extractVariableConfigAndPackageFromExportedVariables in the groovy/io/saagie/plugin/dataops/clients/SaagieClientUtils.groovy whitch will extract the information for the exported variable.
[ ] We create a callback callbackVariablesToExport which will be responsible for creating or updating variables from mutations.
[ ] We create a new Class service ImportVariableService which will extract the Variable exported from the zip file and pass them to callbackVariablesToExport
[ ] we change the log for the the resulting success of the task projectsImport
Why ?
We would like to export new environment variables from v2 platform with the
projectsExport
. to then import to the same target environment withprojectsImport
task.Links / Ressources
https://github.com/saagie/gradle-saagie-dataops-plugin/issues/285
Actual status / Investigations
We checked for the api call for export v2: Those are the ones we need Query for
getting
all scope GLOBAL:Query for
getting
all scope PROJECT:Mutation for adding environment variables: For scope GLOBAL
creation
:For scope GLOBAL
edition
:For scope PROJECT
creation
:For scope PROJECT
edition
:How?
Our work will be devided in two main part Export V2 and Import V2.
First part Export V2 :
[ ] Add object
EnvVariable
togroovy/io/saagie/plugin/dataops/models
with properties EnvVariable Classscope
: Stringinclude_all_var
: booleanname
: ArrayList[ ] Add
getGlobalEnvironmentVariables
togroovy/io/saagie/plugin/dataops/utils/SaagieUtils.groovy
that will fetch all global variables[ ] Add
getProjectEnvironmentVariables
togroovy/io/saagie/plugin/dataops/utils/SaagieUtils.groovy
that will fetch all project variables[ ] updating
exportArtifacts
toSaagieClient.groovy
, add the logic to get the list of variables from one the the querygetGlobalEnvironmentVariables
orgetProjectEnvironmentVariables
depending on the value ofscope
(global|project)[ ] Create a new Class
ExportVariables
that will include ExportVariables Classname
: stringdescription
: stringisPassword
: booleanvalue
: stringscope
: stringoverriddenValues
: OverridenValuesOverridenValues Class
id
: StringExportVariables
we need to change theFolderGenerator
and add methodgenerateFolderForVariables
that will create a new folder for the exported variables.### Second part Import:
extractVariableConfigAndPackageFromExportedVariables
in thegroovy/io/saagie/plugin/dataops/clients/SaagieClientUtils.groovy
whitch will extract the information for the exported variable.[ ] We create a callback
callbackVariablesToExport
which will be responsible for creating or updating variables from mutations.[ ] We create a new Class service
ImportVariableService
which will extract the Variable exported from the zip file and pass them tocallbackVariablesToExport
[ ] we change the log for the the resulting success of the task
projectsImport
to
[ ] Write unit test for Export v2 and Import v2