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

Add export import variable for v2 #290

Merged
merged 2 commits into from
Aug 12, 2020

Conversation

medamineziraoui
Copy link
Contributor

@medamineziraoui medamineziraoui commented Aug 11, 2020

Why ?

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.

Links / Ressources

#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 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 GLOBAL creation:
image (8)

For scope GLOBAL edition:

image (9)

For scope PROJECT creation:

image (10)

For scope PROJECT edition:

image (11)

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

{status=success, job=[{id=22712, name=jupyter/scipy-notebook}], pipeline=[]}

to

{status=success, job=[{id=22712, name=jupyter/scipy-notebook}], pipeline=[],env=[name=env1,name=env2}
  • Write unit test for Export v2 and Import v2

@medamineziraoui medamineziraoui merged commit 1caab16 into develop Aug 12, 2020
@medamineziraoui medamineziraoui deleted the feat-export-import-env-var branch September 1, 2020 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant