Easypanel-Community / easypanel

Unofficial Easypanel JS SDK
MIT License
6 stars 4 forks source link

feat: added templates #15

Closed sangdth closed 10 months ago

sangdth commented 10 months ago

Add templates.createFromSchema

Make the create from template schema works with SDK. Close #13

The problem

I still not sure about the input interface, this is what I see when using my own schema of Next.js and a Postgres service as demo from the POST request when using EasyPanel (I wish they have official documentation for developers.)

{
    "projectName": "customers",
    "schema": {
        "services": [
            {
                "type": "app",
                "data": {
                    "projectName": "...",
                    "serviceName": "nextjs",
                    "source": {
                        "type": "github",
                        "owner": "...",
                        "repo": "...",
                        "ref": "master",
                        "path": "/",
                        "autoDeploy": true
                    },
                    "build": {
                        "type": "nixpacks"
                    },
                    "env": "...",
                    "deploy": {
                        "replicas": 1,
                        "command": null,
                        "zeroDowntime": true
                    },
                    "domains": [
                        {
                            "host": "...",
                            "https": true,
                            "port": 80,
                            "path": "/"
                        },
                        {
                            "host": "....easypanel.host",
                            "https": true,
                            "port": 80,
                            "path": "/"
                        }
                    ]
                }
            },
            {
                "type": "postgres",
                "data": {
                    "projectName": "...",
                    "serviceName": "postgres",
                    "image": "postgres:16",
                    "password": "..."
                }
            }
        ]
    }
}

So I converted them into this interface:

export interface CreateServiceSchema {
  type: ServiceType
  data: Service
}

export interface ProjectFromSchema {
  projectName: string
  schema: Record<string, unknown> & {
    services: CreateServiceSchema[]
  }
}
Supernova3339 commented 10 months ago

I can't unfourtantly alow this PR as this conflicts with internal code

sangdth commented 10 months ago

I can't unfourtantly alow this PR as this conflicts with internal code

Could you elaborate more about the conflicts, so other people might be able to help to resolve it?

Supernova3339 commented 10 months ago

This conflicts with the parser for templates, only we are able to change this.

On Wed, Nov 29, 2023, 6:10 AM Sang Dang @.***> wrote:

I can't unfourtantly alow this PR as this conflicts with internal code

Could you elaborate more about the conflicts, so other people might be able to help to resolve it?

— Reply to this email directly, view it on GitHub https://github.com/Easypanel-Community/easypanel/pull/15#issuecomment-1831776434, or unsubscribe https://github.com/notifications/unsubscribe-auth/APESZJXILW3QFAB3OXE7YODYG4Q4DAVCNFSM6AAAAAA75NA4USVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZRG43TMNBTGQ . You are receiving this because your review was requested.Message ID: @.***>