copy profile to another server1

This commit is contained in:
Priec
2026-09-03 19:21:54 +02:00
parent cfb3bde02e
commit 05c387406c
7 changed files with 454 additions and 2 deletions

View File

@@ -55,6 +55,17 @@ service TableDefinition {
// Copies one complete profile into a new profile without copying table data. // Copies one complete profile into a new profile without copying table data.
rpc CopyProfile(CopyProfileRequest) returns (CopyProfileResponse); rpc CopyProfile(CopyProfileRequest) returns (CopyProfileResponse);
// Serializes selected table structure and every required structural dependency.
// Dynamic table rows and deployment-local security state are never included.
rpc ExportProfileBlueprint(ExportProfileBlueprintRequest) returns (ExportProfileBlueprintResponse);
// Reconciles a portable blueprint against a destination profile without writing.
rpc PlanProfileBlueprintImport(PlanProfileBlueprintImportRequest) returns (PlanProfileBlueprintImportResponse);
// Applies a previously reviewed blueprint plan atomically. The plan hash protects
// against both a changed package and destination drift between preview and apply.
rpc ImportProfileBlueprint(ImportProfileBlueprintRequest) returns (ImportProfileBlueprintResponse);
// Returns the unified append-only history for column and option aliases. // Returns the unified append-only history for column and option aliases.
rpc GetAliasChangeHistory(GetAliasChangeHistoryRequest) returns (GetAliasChangeHistoryResponse); rpc GetAliasChangeHistory(GetAliasChangeHistoryRequest) returns (GetAliasChangeHistoryResponse);
@@ -482,6 +493,56 @@ message CopyProfileResponse {
int32 scripts_copied = 4; int32 scripts_copied = 4;
} }
message ExportProfileBlueprintRequest {
string profile_name = 1;
// Empty exports every dynamic table in the profile. Otherwise only these tables
// are created by import; their unselected local dependencies become requirements.
repeated string table_names = 2;
}
message ExportProfileBlueprintResponse {
string blueprint_json = 1;
string blueprint_sha256 = 2;
int32 tables = 3;
int32 required_local_tables = 4;
int32 required_global_tables = 5;
int32 templates = 6;
}
message PlanProfileBlueprintImportRequest {
string target_profile_name = 1;
string blueprint_json = 2;
}
message ProfileBlueprintImportAction {
// One of create, reuse, add, or conflict.
string action = 1;
string resource = 2;
string detail = 3;
}
message PlanProfileBlueprintImportResponse {
bool can_import = 1;
string plan_sha256 = 2;
repeated ProfileBlueprintImportAction actions = 3;
}
message ImportProfileBlueprintRequest {
string target_profile_name = 1;
string blueprint_json = 2;
string expected_plan_sha256 = 3;
}
message ImportProfileBlueprintResponse {
bool success = 1;
string message = 2;
int32 tables_created = 3;
int32 globals_created = 4;
int32 globals_reused = 5;
int32 templates_created = 6;
int32 templates_reused = 7;
}
enum AliasChangeKind { enum AliasChangeKind {
ALIAS_CHANGE_KIND_UNSPECIFIED = 0; ALIAS_CHANGE_KIND_UNSPECIFIED = 0;
ALIAS_CHANGE_KIND_COLUMN = 1; ALIAS_CHANGE_KIND_COLUMN = 1;

Binary file not shown.

View File

@@ -456,6 +456,89 @@ pub struct CopyProfileResponse {
} }
#[derive(serde::Serialize, serde::Deserialize)] #[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ExportProfileBlueprintRequest {
#[prost(string, tag = "1")]
pub profile_name: ::prost::alloc::string::String,
/// Empty exports every dynamic table in the profile. Otherwise only these tables
/// are created by import; their unselected local dependencies become requirements.
#[prost(string, repeated, tag = "2")]
pub table_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ExportProfileBlueprintResponse {
#[prost(string, tag = "1")]
pub blueprint_json: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub blueprint_sha256: ::prost::alloc::string::String,
#[prost(int32, tag = "3")]
pub tables: i32,
#[prost(int32, tag = "4")]
pub required_local_tables: i32,
#[prost(int32, tag = "5")]
pub required_global_tables: i32,
#[prost(int32, tag = "6")]
pub templates: i32,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct PlanProfileBlueprintImportRequest {
#[prost(string, tag = "1")]
pub target_profile_name: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub blueprint_json: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ProfileBlueprintImportAction {
/// One of create, reuse, add, or conflict.
#[prost(string, tag = "1")]
pub action: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub resource: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub detail: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PlanProfileBlueprintImportResponse {
#[prost(bool, tag = "1")]
pub can_import: bool,
#[prost(string, tag = "2")]
pub plan_sha256: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "3")]
pub actions: ::prost::alloc::vec::Vec<ProfileBlueprintImportAction>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ImportProfileBlueprintRequest {
#[prost(string, tag = "1")]
pub target_profile_name: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub blueprint_json: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub expected_plan_sha256: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ImportProfileBlueprintResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, tag = "2")]
pub message: ::prost::alloc::string::String,
#[prost(int32, tag = "3")]
pub tables_created: i32,
#[prost(int32, tag = "4")]
pub globals_created: i32,
#[prost(int32, tag = "5")]
pub globals_reused: i32,
#[prost(int32, tag = "6")]
pub templates_created: i32,
#[prost(int32, tag = "7")]
pub templates_reused: i32,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetAliasChangeHistoryRequest { pub struct GetAliasChangeHistoryRequest {
#[prost(string, tag = "1")] #[prost(string, tag = "1")]
pub profile_name: ::prost::alloc::string::String, pub profile_name: ::prost::alloc::string::String,
@@ -1533,6 +1616,98 @@ pub mod table_definition_client {
); );
self.inner.unary(req, path, codec).await self.inner.unary(req, path, codec).await
} }
/// Serializes selected table structure and every required structural dependency.
/// Dynamic table rows and deployment-local security state are never included.
pub async fn export_profile_blueprint(
&mut self,
request: impl tonic::IntoRequest<super::ExportProfileBlueprintRequest>,
) -> std::result::Result<
tonic::Response<super::ExportProfileBlueprintResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/komp_ac.table_definition.TableDefinition/ExportProfileBlueprint",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"komp_ac.table_definition.TableDefinition",
"ExportProfileBlueprint",
),
);
self.inner.unary(req, path, codec).await
}
/// Reconciles a portable blueprint against a destination profile without writing.
pub async fn plan_profile_blueprint_import(
&mut self,
request: impl tonic::IntoRequest<super::PlanProfileBlueprintImportRequest>,
) -> std::result::Result<
tonic::Response<super::PlanProfileBlueprintImportResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/komp_ac.table_definition.TableDefinition/PlanProfileBlueprintImport",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"komp_ac.table_definition.TableDefinition",
"PlanProfileBlueprintImport",
),
);
self.inner.unary(req, path, codec).await
}
/// Applies a previously reviewed blueprint plan atomically. The plan hash protects
/// against both a changed package and destination drift between preview and apply.
pub async fn import_profile_blueprint(
&mut self,
request: impl tonic::IntoRequest<super::ImportProfileBlueprintRequest>,
) -> std::result::Result<
tonic::Response<super::ImportProfileBlueprintResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/komp_ac.table_definition.TableDefinition/ImportProfileBlueprint",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"komp_ac.table_definition.TableDefinition",
"ImportProfileBlueprint",
),
);
self.inner.unary(req, path, codec).await
}
/// Returns the unified append-only history for column and option aliases. /// Returns the unified append-only history for column and option aliases.
pub async fn get_alias_change_history( pub async fn get_alias_change_history(
&mut self, &mut self,
@@ -1927,6 +2102,32 @@ pub mod table_definition_server {
tonic::Response<super::CopyProfileResponse>, tonic::Response<super::CopyProfileResponse>,
tonic::Status, tonic::Status,
>; >;
/// Serializes selected table structure and every required structural dependency.
/// Dynamic table rows and deployment-local security state are never included.
async fn export_profile_blueprint(
&self,
request: tonic::Request<super::ExportProfileBlueprintRequest>,
) -> std::result::Result<
tonic::Response<super::ExportProfileBlueprintResponse>,
tonic::Status,
>;
/// Reconciles a portable blueprint against a destination profile without writing.
async fn plan_profile_blueprint_import(
&self,
request: tonic::Request<super::PlanProfileBlueprintImportRequest>,
) -> std::result::Result<
tonic::Response<super::PlanProfileBlueprintImportResponse>,
tonic::Status,
>;
/// Applies a previously reviewed blueprint plan atomically. The plan hash protects
/// against both a changed package and destination drift between preview and apply.
async fn import_profile_blueprint(
&self,
request: tonic::Request<super::ImportProfileBlueprintRequest>,
) -> std::result::Result<
tonic::Response<super::ImportProfileBlueprintResponse>,
tonic::Status,
>;
/// Returns the unified append-only history for column and option aliases. /// Returns the unified append-only history for column and option aliases.
async fn get_alias_change_history( async fn get_alias_change_history(
&self, &self,
@@ -2619,6 +2820,156 @@ pub mod table_definition_server {
}; };
Box::pin(fut) Box::pin(fut)
} }
"/komp_ac.table_definition.TableDefinition/ExportProfileBlueprint" => {
#[allow(non_camel_case_types)]
struct ExportProfileBlueprintSvc<T: TableDefinition>(pub Arc<T>);
impl<
T: TableDefinition,
> tonic::server::UnaryService<super::ExportProfileBlueprintRequest>
for ExportProfileBlueprintSvc<T> {
type Response = super::ExportProfileBlueprintResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::ExportProfileBlueprintRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TableDefinition>::export_profile_blueprint(
&inner,
request,
)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = ExportProfileBlueprintSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/komp_ac.table_definition.TableDefinition/PlanProfileBlueprintImport" => {
#[allow(non_camel_case_types)]
struct PlanProfileBlueprintImportSvc<T: TableDefinition>(pub Arc<T>);
impl<
T: TableDefinition,
> tonic::server::UnaryService<
super::PlanProfileBlueprintImportRequest,
> for PlanProfileBlueprintImportSvc<T> {
type Response = super::PlanProfileBlueprintImportResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
super::PlanProfileBlueprintImportRequest,
>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TableDefinition>::plan_profile_blueprint_import(
&inner,
request,
)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = PlanProfileBlueprintImportSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/komp_ac.table_definition.TableDefinition/ImportProfileBlueprint" => {
#[allow(non_camel_case_types)]
struct ImportProfileBlueprintSvc<T: TableDefinition>(pub Arc<T>);
impl<
T: TableDefinition,
> tonic::server::UnaryService<super::ImportProfileBlueprintRequest>
for ImportProfileBlueprintSvc<T> {
type Response = super::ImportProfileBlueprintResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::ImportProfileBlueprintRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TableDefinition>::import_profile_blueprint(
&inner,
request,
)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = ImportProfileBlueprintSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/komp_ac.table_definition.TableDefinition/GetAliasChangeHistory" => { "/komp_ac.table_definition.TableDefinition/GetAliasChangeHistory" => {
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
struct GetAliasChangeHistorySvc<T: TableDefinition>(pub Arc<T>); struct GetAliasChangeHistorySvc<T: TableDefinition>(pub Arc<T>);

View File

@@ -1335,6 +1335,33 @@ impl GrpcClient {
.into_inner()) .into_inner())
} }
pub async fn export_profile_blueprint(
&mut self,
request: common::proto::komp_ac::table_definition::ExportProfileBlueprintRequest,
) -> Result<common::proto::komp_ac::table_definition::ExportProfileBlueprintResponse> {
let request = self.authenticated_request(request)?;
Ok(self.table_definition_client.export_profile_blueprint(request).await
.context("gRPC ExportProfileBlueprint call failed")?.into_inner())
}
pub async fn plan_profile_blueprint_import(
&mut self,
request: common::proto::komp_ac::table_definition::PlanProfileBlueprintImportRequest,
) -> Result<common::proto::komp_ac::table_definition::PlanProfileBlueprintImportResponse> {
let request = self.authenticated_request(request)?;
Ok(self.table_definition_client.plan_profile_blueprint_import(request).await
.context("gRPC PlanProfileBlueprintImport call failed")?.into_inner())
}
pub async fn import_profile_blueprint(
&mut self,
request: common::proto::komp_ac::table_definition::ImportProfileBlueprintRequest,
) -> Result<common::proto::komp_ac::table_definition::ImportProfileBlueprintResponse> {
let request = self.authenticated_request(request)?;
Ok(self.table_definition_client.import_profile_blueprint(request).await
.context("gRPC ImportProfileBlueprint call failed")?.into_inner())
}
pub async fn get_alias_change_history( pub async fn get_alias_change_history(
&mut self, &mut self,
request: common::proto::komp_ac::table_definition::GetAliasChangeHistoryRequest, request: common::proto::komp_ac::table_definition::GetAliasChangeHistoryRequest,

View File

@@ -34,12 +34,20 @@ process_csv() {
OFS = FS OFS = FS
} }
{
sub(/\r$/, "", $0)
}
NR == 1 { NR == 1 {
print print
next next
} }
{ {
if ($6 == "- -") {
$6 = ""
}
cleaned = clean_account($10) cleaned = clean_account($10)
if (cleaned == "") { if (cleaned == "") {
@@ -47,6 +55,11 @@ process_csv() {
} }
key = cleaned key = cleaned
if (key == "000") {
next
}
key_count[key]++ key_count[key]++
if (!(key in key_order)) { if (!(key in key_order)) {
key_order[key] = ++key_total key_order[key] = ++key_total

2
server

Submodule server updated: cfc1998121...9325e5b537