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

Define library models on OpenAPI #451

Closed
filippomc opened this issue Mar 1, 2022 · 1 comment · Fixed by #454 or #503
Closed

Define library models on OpenAPI #451

filippomc opened this issue Mar 1, 2022 · 1 comment · Fixed by #454 or #503
Labels
alert:deployment Something may break in the scope of this issue/pr in existing deployments enhancement New feature or request refactoring scope:python-runtime
Milestone

Comments

@filippomc
Copy link
Collaborator

filippomc commented Mar 1, 2022

Using the runtime can be confusing for the user as the data structures are not always clear.
The idea here is to use openapi to define the model and generate the stubs in Python and eventually in typescript.

Define openapi models for:

  • values.yaml objects
  • All other DTOs used in library apis
@filippomc
Copy link
Collaborator Author

Spec for values.yaml objects

---
openapi: 3.0.2
info:
  title: cloudharness
  version: 1.0.0
components:
  schemas:
    AutoArtifactSpec:
      description: ""
      required:
      - auto
      type: object
      properties:
        auto:
          description: "When true, enables automatic template"
          type: boolean
        name:
          description: ""
          type: string
    UriRoleMappingConfig:
      description: "Defines the application Gatekeeper configuration, if enabled (i.e.\
        \ `secured: true`."
      required:
      - roles
      - uri
      type: object
      properties:
        uri:
          $ref: '#/components/schemas/Filename'
          description: Path to secure
        roles:
          description: Roles allowed to access the present uri
          type: array
          items:
            type: string
    ServiceAutoArtifactConfig:
      description: ""
      type: object
      allOf:
      - type: object
        properties:
          port:
            description: Service port
            type: integer
      - $ref: '#/components/schemas/AutoArtifactSpec'
    DeploymentAutoArtifactConfig:
      description: ""
      type: object
      allOf:
      - type: object
      - $ref: '#/components/schemas/AutoArtifactSpec'
      properties:
        port:
          description: Deployment port
        replicas:
          description: Number of replicas
          type: integer
        image:
          description: |-
            Image name to use in the deployment. Leave it blank to set from the application's
            Docker file
          pattern: "(?:[a-z]+/)?([a-z]+)(?::[0-9]+)?"
          type: string
        resources:
          description: Deployment resources
    ApplicationHarnessConfig:
      description: ""
      type: object
      properties:
        deployment:
          description: Defines reference deployment parameters. Values maps to k8s
            spec
        service:
          description: Defines automatic service parameters.
        subdomain:
          description: "If specified, an ingress will be created at [subdomain].[.Values.domain]"
          type: string
        aliases:
          description: "If specified, an ingress will be created at [alias].[.Values.domain]\
            \ for each alias"
          type: array
          items:
            type: string
        domain:
          description: "If specified, an ingress will be created at [domain]"
          type: string
        dependencies:
          description: Application dependencies are used to define what is required
            in the deployment when --include (-i) is used. Specify application names
            in the list.
        secured:
          description: "When true, the application is shielded with a getekeeper"
          type: boolean
        uri_role_mapping:
          description: "Map uri/roles to secure with the Gatekeeper (if `secured:\
            \ true`)"
          type: array
          items:
            $ref: '#/components/schemas/UriRoleMappingConfig'
        secrets:
          description: |-
            Define secrets will be mounted in the deployment

            Define as

            ```yaml
            secrets:
                secret_name: 'value'

            ```

            Values if left empty are randomly generated
        use_services:
          description: "Specify which services this application uses in the frontend\
            \ to create proxy ingresses. e.g. \n```\n- name: samples\n```"
          type: array
          items:
            type: string
        database:
          description: ""
        resources:
          description: |-
            Application file resources. Maps from deploy/resources folder and mounts as
            configmaps
          type: array
          items:
            $ref: '#/components/schemas/FileResourcesConfig'
        readinessProbe:
          description: ""
        startupProbe:
          $ref: '#/components/schemas/ApplicationProbe'
          description: ""
        livenessProbe:
          $ref: '#/components/schemas/ApplicationProbe'
          description: ""
    ApplicationDependenciesConfig:
      description: ""
      type: object
      properties:
        hard:
          description: Hard dependencies indicate that the application may not start
            without these other applications.
          type: array
          items:
            type: string
        soft:
          description: Soft dependencies indicate that the application will work partially
            without these other applications.
          type: array
          items:
            type: string
        build:
          description: Hard dependencies indicate that the application Docker image
            build requires these base/common images
          type: array
          items:
            type: string
    DeploymentResourcesConf:
      description: ""
      type: object
      properties:
        requests:
          $ref: '#/components/schemas/CpuMemoryConfig'
          description: ""
        limits:
          $ref: '#/components/schemas/CpuMemoryConfig'
          description: ""
    CpuMemoryConfig:
      description: ""
      type: object
      properties:
        cpu:
          description: ""
          type: string
        memory:
          description: ""
          type: string
    FileResourcesConfig:
      description: ""
      required:
      - name
      - src
      - dst
      type: object
      properties:
        name:
          $ref: '#/components/schemas/Filename'
          description: ""
        src:
          $ref: '#/components/schemas/Filename'
          description: ""
        dst:
          description: ""
          type: string
    Filename:
      description: ""
      pattern: "^[^<>:;,?\"*|/]+$"
      type: string
    ApplicationProbe:
      description: ""
      required:
      - path
      type: object
      properties:
        path:
          $ref: '#/components/schemas/URL'
          description: ""
        periodSeconds:
          description: ""
          type: number
        failureThreshold:
          description: ""
          type: number
        initialDelaySeconds:
          description: ""
          type: number
    URL:
      description: ""
      type: string
    ApplicationConfig:
      description: ""
      required:
      - harness
      type: object
      properties:
        harness:
          $ref: '#/components/schemas/ApplicationHarnessConfig'
          description: ""
      additionalProperties: true
    HarnessMainConfig:
      description: ""
      required:
      - local
      - secured_gatekeepers
      - domain
      - namespace
      - mainapp
      - apps
      type: object
      properties:
        local:
          description: "If set to true, local DNS mapping is added to pods."
          type: boolean
        secured_gatekeepers:
          description: Enables/disables Gatekeepers on secured applications. Set to
            false for testing/development
          type: boolean
        domain:
          description: The root domain
          type: string
          example: The root domain.
        namespace:
          description: The K8s namespace.
          type: string
        mainapp:
          description: Defines the app to map to the root domain
          type: string
        registry:
          $ref: '#/components/schemas/RegistryConfig'
          description: ""
        tag:
          description: Docker tag used to push/pull the built images.
          type: string
        apps:
          $ref: '#/components/schemas/ApplicationsConfigsMap'
          description: ""
        env:
          description: Environmental variables added to all pods
          type: array
          items:
            $ref: '#/components/schemas/NameValue'
        privenv:
          $ref: '#/components/schemas/NameValue'
          description: Private environmental variables added to all pods
        backup:
          description: ""
    RegistryConfig:
      description: ""
      required:
      - name
      type: object
      properties:
        name:
          $ref: '#/components/schemas/URL'
          description: The docker registry where built images are pushed
        secret:
          description: Optional secret used for pulling from docker registry.
          type: string
    SimpleMap:
      description: ""
      type: object
      additionalProperties:
        type: string
    FreeObject:
      description: ""
      type: object
      additionalProperties: true
    DatabaseDeploymentConfig:
      description: ""
      type: object
      allOf:
      - type: object
        properties:
          type:
            description: |-
              Define the database type.

              One of (mongo, postgres, neo4j)
            pattern: ^(mongo|postgres|neo4j)$
            type: string
            example: '"neo4j"'
          size:
            description: Specify database disk size
            type: string
            example: 1Gi
          user:
            description: database username
            type: string
          pass:
            format: password
            description: Database password
            type: string
          mongo:
            $ref: '#/components/schemas/FreeObject'
            description: Mongo db specific configuration
          postgres:
            $ref: '#/components/schemas/FreeObject'
            description: Postgres database specific configuration
          neo4j:
            description: Neo4j database specific configuration
          resources:
            $ref: '#/components/schemas/DeploymentResourcesConf'
            description: Database deployment resources
      - $ref: '#/components/schemas/AutoArtifactSpec'
    ApplicationsConfigsMap:
      description: ""
      type: object
      additionalProperties:
        $ref: '#/components/schemas/ApplicationConfig'
    NameValue:
      description: ""
      required:
      - name
      type: object
      properties:
        name:
          description: ""
          type: string
        value:
          description: ""
          type: string
    IngressConfig:
      description: ""
      type: object
      allOf:
      - type: object
        properties:
          ssl_redirect:
            description: ""
            type: boolean
          letsencrypt:
            description: ""
            type: object
            properties:
              email:
                type: string
      - $ref: '#/components/schemas/AutoArtifactSpec'
    BackupConfig:
      description: ""
      required:
      - dir
      - resources
      type: object
      properties:
        active:
          description: ""
          type: boolean
        keep_days:
          description: ""
          type: integer
        keep_weeks:
          description: ""
          type: integer
        keep_months:
          description: ""
          type: integer
        schedule:
          description: Cron expression
          pattern: "/(@(annually|yearly|monthly|weekly|daily|hourly|reboot))|(@every\
            \ (\\d+(ns|us|µs|ms|s|m|h))+)|((((\\d+,)+\\d+|(\\d+(\\/|-)\\d+)|\\d+|\\\
            *) ?){5,7})/"
          type: string
        suffix:
          description: The file suffix added to backup files
        volumesize:
          description: The volume size for backups (all backups share the same volume)
          type: string
        dir:
          $ref: '#/components/schemas/Filename'
          description: "Target directory of backups, the mount point of the persistent\
            \ volume."
        resources:
          $ref: '#/components/schemas/DeploymentResourcesConf'
          description: ""

filippomc added a commit that referenced this issue Mar 3, 2022
filippomc added a commit that referenced this issue Mar 3, 2022
filippomc added a commit that referenced this issue Mar 3, 2022
filippomc added a commit that referenced this issue Mar 4, 2022
filippomc added a commit that referenced this issue Mar 4, 2022
filippomc added a commit that referenced this issue Mar 4, 2022
filippomc added a commit that referenced this issue Mar 4, 2022
filippomc added a commit that referenced this issue Mar 4, 2022
filippomc added a commit that referenced this issue Mar 4, 2022
filippomc added a commit that referenced this issue Mar 4, 2022
filippomc added a commit that referenced this issue Mar 4, 2022
filippomc added a commit that referenced this issue Mar 4, 2022
filippomc added a commit that referenced this issue Mar 4, 2022
filippomc added a commit that referenced this issue Mar 4, 2022
@filippomc filippomc mentioned this issue Mar 4, 2022
18 tasks
filippomc added a commit that referenced this issue Mar 4, 2022
filippomc added a commit that referenced this issue Mar 4, 2022
filippomc added a commit that referenced this issue Mar 4, 2022
filippomc added a commit that referenced this issue Mar 4, 2022
@filippomc filippomc added this to the v2.0.0 milestone Mar 7, 2022
filippomc added a commit that referenced this issue Mar 7, 2022
@filippomc filippomc added the alert:deployment Something may break in the scope of this issue/pr in existing deployments label Mar 7, 2022
filippomc added a commit that referenced this issue Mar 8, 2022
filippomc added a commit that referenced this issue Mar 8, 2022
filippomc added a commit that referenced this issue Mar 10, 2022
filippomc added a commit that referenced this issue Mar 10, 2022
filippomc added a commit that referenced this issue Mar 10, 2022
filippomc added a commit that referenced this issue Mar 11, 2022
filippomc added a commit that referenced this issue May 4, 2022
filippomc added a commit that referenced this issue May 6, 2022
filippomc added a commit that referenced this issue May 6, 2022
filippomc added a commit that referenced this issue May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alert:deployment Something may break in the scope of this issue/pr in existing deployments enhancement New feature or request refactoring scope:python-runtime
Projects
None yet
1 participant