api api api
This commit is contained in:
parent
46e61cb409
commit
5e55c799ec
@ -132,7 +132,7 @@ public function create_application(Request $request)
|
||||
sharedDataApplications(),
|
||||
'git_repository' => 'string|required',
|
||||
'git_branch' => 'string|required',
|
||||
'build_pack' => [Rule::enum(BuildPackTypes::class)],
|
||||
'build_pack' => ['required', Rule::enum(BuildPackTypes::class)],
|
||||
'ports_exposes' => 'string|regex:/^(\d+)(,\d+)*$/|required',
|
||||
'docker_compose_location' => 'string',
|
||||
'docker_compose' => 'string|nullable',
|
||||
@ -174,6 +174,10 @@ public function create_application(Request $request)
|
||||
$application->destination_type = $destination->getMorphClass();
|
||||
$application->environment_id = $environment->id;
|
||||
$application->save();
|
||||
$application->refresh();
|
||||
$application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");
|
||||
$application->save();
|
||||
$application->isConfigurationChanged(true);
|
||||
|
||||
if ($instantDeploy) {
|
||||
$deployment_uuid = new Cuid2(7);
|
||||
@ -190,7 +194,12 @@ public function create_application(Request $request)
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json(serializeApiResponse($application);
|
||||
return response()->json(serializeApiResponse([
|
||||
'uuid' => data_get($application, 'uuid'),
|
||||
'name' => data_get($application, 'name'),
|
||||
'description' => data_get($application, 'description'),
|
||||
'domains' => data_get($application, 'domains'),
|
||||
]));
|
||||
} elseif ($type === 'private-gh-app') {
|
||||
if (! $request->has('name')) {
|
||||
$request->offsetSet('name', generate_application_name($request->git_repository, $request->git_branch));
|
||||
@ -259,6 +268,10 @@ public function create_application(Request $request)
|
||||
$application->source_type = $githubApp->getMorphClass();
|
||||
$application->source_id = $githubApp->id;
|
||||
$application->save();
|
||||
$application->refresh();
|
||||
$application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");
|
||||
$application->save();
|
||||
$application->isConfigurationChanged(true);
|
||||
|
||||
if ($instantDeploy) {
|
||||
$deployment_uuid = new Cuid2(7);
|
||||
@ -275,7 +288,12 @@ public function create_application(Request $request)
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json(serializeApiResponse($application));
|
||||
return response()->json(serializeApiResponse([
|
||||
'uuid' => data_get($application, 'uuid'),
|
||||
'name' => data_get($application, 'name'),
|
||||
'description' => data_get($application, 'description'),
|
||||
'domains' => data_get($application, 'domains'),
|
||||
]));
|
||||
} elseif ($type === 'private-deploy-key') {
|
||||
if (! $request->has('name')) {
|
||||
$request->offsetSet('name', generate_application_name($request->git_repository, $request->git_branch));
|
||||
@ -340,6 +358,10 @@ public function create_application(Request $request)
|
||||
$application->destination_type = $destination->getMorphClass();
|
||||
$application->environment_id = $environment->id;
|
||||
$application->save();
|
||||
$application->refresh();
|
||||
$application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");
|
||||
$application->save();
|
||||
$application->isConfigurationChanged(true);
|
||||
|
||||
if ($instantDeploy) {
|
||||
$deployment_uuid = new Cuid2(7);
|
||||
@ -356,7 +378,12 @@ public function create_application(Request $request)
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json(serializeApiResponse($application));
|
||||
return response()->json(serializeApiResponse([
|
||||
'uuid' => data_get($application, 'uuid'),
|
||||
'name' => data_get($application, 'name'),
|
||||
'description' => data_get($application, 'description'),
|
||||
'domains' => data_get($application, 'domains'),
|
||||
]));
|
||||
} elseif ($type === 'dockerfile') {
|
||||
if (! $request->has('name')) {
|
||||
$request->offsetSet('name', 'dockerfile-'.new Cuid2(7));
|
||||
@ -413,6 +440,10 @@ public function create_application(Request $request)
|
||||
$application->git_repository = 'coollabsio/coolify';
|
||||
$application->git_branch = 'main';
|
||||
$application->save();
|
||||
$application->refresh();
|
||||
$application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");
|
||||
$application->save();
|
||||
$application->isConfigurationChanged(true);
|
||||
|
||||
if ($instantDeploy) {
|
||||
$deployment_uuid = new Cuid2(7);
|
||||
@ -425,7 +456,12 @@ public function create_application(Request $request)
|
||||
);
|
||||
}
|
||||
|
||||
return response()->json(serializeApiResponse($application));
|
||||
return response()->json(serializeApiResponse([
|
||||
'uuid' => data_get($application, 'uuid'),
|
||||
'name' => data_get($application, 'name'),
|
||||
'description' => data_get($application, 'description'),
|
||||
'domains' => data_get($application, 'domains'),
|
||||
]));
|
||||
} elseif ($type === 'docker-image') {
|
||||
if (! $request->has('name')) {
|
||||
$request->offsetSet('name', 'docker-image-'.new Cuid2(7));
|
||||
@ -462,6 +498,10 @@ public function create_application(Request $request)
|
||||
$application->git_repository = 'coollabsio/coolify';
|
||||
$application->git_branch = 'main';
|
||||
$application->save();
|
||||
$application->refresh();
|
||||
$application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");
|
||||
$application->save();
|
||||
$application->isConfigurationChanged(true);
|
||||
|
||||
if ($instantDeploy) {
|
||||
$deployment_uuid = new Cuid2(7);
|
||||
@ -474,7 +514,12 @@ public function create_application(Request $request)
|
||||
);
|
||||
}
|
||||
|
||||
return response()->json(serializeApiResponse($application));
|
||||
return response()->json(serializeApiResponse([
|
||||
'uuid' => data_get($application, 'uuid'),
|
||||
'name' => data_get($application, 'name'),
|
||||
'description' => data_get($application, 'description'),
|
||||
'domains' => data_get($application, 'domains'),
|
||||
]));
|
||||
} elseif ($type === 'dockercompose') {
|
||||
$allowedFields = ['project_uuid', 'environment_name', 'server_uuid', 'destination_uuid', 'type', 'name', 'description', 'instant_deploy', 'docker_compose_raw'];
|
||||
|
||||
@ -549,7 +594,11 @@ public function create_application(Request $request)
|
||||
$service->parse(isNew: true);
|
||||
StartService::dispatch($service);
|
||||
|
||||
return response()->json(serializeApiResponse($service));
|
||||
return response()->json(serializeApiResponse([
|
||||
'uuid' => data_get($service, 'uuid'),
|
||||
'name' => data_get($service, 'name'),
|
||||
'description' => data_get($service, 'description'),
|
||||
]));
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Invalid type.'], 400);
|
||||
|
Loading…
Reference in New Issue
Block a user