-
Notifications
You must be signed in to change notification settings - Fork 10
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
feat: add Client function to create custom image service #100
Conversation
Thanks a lot to your contribution! Most of them seem great. However, I would prefer to pass the TOML into createPrebuiltService using the rawSchema parameter. CLI users usually prefer to use their existing Prebuilt TOML definitions, like this PostgreSQL TOML definition. The GraphQL mutation of this method is: mutation CreatePrebuiltService($projectId: ObjectID!, $rawSchema: String) {
createPrebuiltService(projectID: $projectId, rawSchema: $rawSchema) {
_id
}
} |
which means just need to marshal struct to json string ? or keep both function, structured |
The general flow of this method would be "Read service.toml", then put the TOML in the parameter. 理論上是讀 service.toml 然後把 TOML 放進去 schemaRaw 裡面。 |
In some case, what if I just want to use cli package as sdk, it would be more helpful like this. package main
import (
"context"
"fmt"
"github.com/zeabur/cli/pkg/api"
"github.com/zeabur/cli/pkg/model"
"os"
)
func main() {
ctx := context.Background()
token := os.Getenv("ZEABUR_API_TOKEN")
client := api.New(token)
project, err := client.GetProject(ctx, "", "incubator4", "togitic")
if err != nil {
panic(err)
}
schema := model.ServiceSpecSchemaInput{
ID: "httpbin",
Name: "httpbin",
Source: &model.ServiceSpecSourceInput{
Image: "kennethreitz/httpbin",
},
}
service, err := client.CreateCustomService(ctx, project.ID, schema)
if err != nil {
panic(err)
}
fmt.Printf("Service: %+v\n", service)
} |
Understand. Seems reasonable. I will approve this. |
@pan93412 An additional update, rawSchema also be added to Client interface |
"RawService" seems weird. How about "CreatePrebuiltServiceRaw" and "CreatePrebuiltServiceCustom"? |
function name updated |
Description (required)
Add
Client
functionCreateCustomService
to create custom image serviceRelated issues & labels (optional)