From d9b51c1ac90c00fb3af24332b6140e1201bc9be7 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Wed, 1 Feb 2023 16:42:50 +0100 Subject: [PATCH] implement sort by name and type --- crates/dagger-codegen/src/codegen.rs | 6 +- crates/dagger-sdk/src/gen.rs | 724 +++++++++++++-------------- 2 files changed, 366 insertions(+), 364 deletions(-) diff --git a/crates/dagger-codegen/src/codegen.rs b/crates/dagger-codegen/src/codegen.rs index e701c78..94d167e 100644 --- a/crates/dagger-codegen/src/codegen.rs +++ b/crates/dagger-codegen/src/codegen.rs @@ -49,9 +49,11 @@ impl CodeGeneration { output.append(render_base_types()); output.push(); - let types = get_types(schema)?; + let mut types = get_types(schema)?; //let remaining: Vec> = types.into_iter().map(type_name).collect(); - // + + types.sort_by_key(|a| a.name.as_ref()); + for (handler, types) in self.group_by_handlers(&types) { for t in types { if let Some(_) = self.type_name(&t) { diff --git a/crates/dagger-sdk/src/gen.rs b/crates/dagger-sdk/src/gen.rs index 9186a35..d3ee1f2 100644 --- a/crates/dagger-sdk/src/gen.rs +++ b/crates/dagger-sdk/src/gen.rs @@ -2,8 +2,8 @@ use dagger_core::{Boolean, Input, Int, Scalar}; // code generated by dagger. DO NOT EDIT. -/// A content-addressed socket identifier. -pub struct SocketID(Scalar); +/// A global cache volume identifier. +pub struct CacheID(Scalar); /// A unique container identifier. Null designates an empty container (scratch). pub struct ContainerID(Scalar); @@ -14,16 +14,16 @@ pub struct DirectoryID(Scalar); /// A file identifier. pub struct FileID(Scalar); -/// A unique identifier for a secret. -pub struct SecretID(Scalar); - -/// A global cache volume identifier. -pub struct CacheID(Scalar); - /// The platform config OS and architecture in a Container. /// The format is [os]/[platform]/[version] (e.g. darwin/arm64/v7, windows/amd64, linux/arm64). pub struct Platform(Scalar); +/// A unique identifier for a secret. +pub struct SecretID(Scalar); + +/// A content-addressed socket identifier. +pub struct SocketID(Scalar); + /// pub struct BuildArg { pub name: String, @@ -33,320 +33,6 @@ pub struct BuildArg { impl Input for BuildArg {} -/// A reference to a secret value, which can be handled more safely than the value itself. -pub struct Secret {} - -impl Secret { - /// The identifier for this secret. - pub fn id(&self) -> SecretID { - todo!() - } - - /// The value of this secret. - pub fn plaintext(&self) -> String { - todo!() - } -} - -impl Input for Secret {} - -/// A set of scripts and/or extensions -pub struct Project {} - -impl Project { - /// extensions in this project - pub fn extensions(&self) -> Option> { - todo!() - } - - /// Code files generated by the SDKs in the project - pub fn generated_code(&self) -> Directory { - todo!() - } - - /// install the project's schema - pub fn install(&self) -> Boolean { - todo!() - } - - /// name of the project - pub fn name(&self) -> String { - todo!() - } - - /// schema provided by the project - pub fn schema(&self) -> Option { - todo!() - } - - /// sdk used to generate code for and/or execute this project - pub fn sdk(&self) -> Option { - todo!() - } -} - -impl Input for Project {} - -/// A file. -pub struct File {} - -impl File { - /// Retrieves the contents of the file. - pub fn contents(&self) -> String { - todo!() - } - - /// Writes the file to a file path on the host. - pub fn export(&self, path: String) -> Boolean { - todo!() - } - - /// Retrieves the content-addressed identifier of the file. - pub fn id(&self) -> FileID { - todo!() - } - - /// Retrieves a secret referencing the contents of this file. - pub fn secret(&self) -> Secret { - todo!() - } - - /// Gets the size of the file, in bytes. - pub fn size(&self) -> Int { - todo!() - } - - /// Retrieves this file with its created/modified timestamps set to the given time, in seconds from the Unix epoch. - pub fn with_timestamps(&self, timestamp: Int) -> File { - todo!() - } -} - -impl Input for File {} - -/// A simple key value object that represents an environment variable. -pub struct EnvVariable {} - -impl EnvVariable { - /// The environment variable name. - pub fn name(&self) -> String { - todo!() - } - - /// The environment variable value. - pub fn value(&self) -> String { - todo!() - } -} - -impl Input for EnvVariable {} - -/// A directory. -pub struct Directory {} - -impl Directory { - /// Gets the difference between this directory and an another directory. - pub fn diff(&self, other: DirectoryID) -> Directory { - todo!() - } - - /// Retrieves a directory at the given path. - pub fn directory(&self, path: String) -> Directory { - todo!() - } - - /// Builds a new Docker container from this directory. - /// # Arguments - /// - /// * `dockerfile` - Path to the Dockerfile to use. - /// Defaults to './Dockerfile'. - /// * `platform` - The platform to build. - /// * `buildArgs` - Additional build arguments. - /// * `target` - Target build stage to build. - pub fn docker_build( - &self, - dockerfile: Option, - platform: Option, - build_args: Option>, - target: Option, - ) -> Container { - todo!() - } - - /// Returns a list of files and directories at the given path. - pub fn entries(&self, path: Option) -> Vec { - todo!() - } - - /// Writes the contents of the directory to a path on the host. - pub fn export(&self, path: String) -> Boolean { - todo!() - } - - /// Retrieves a file at the given path. - pub fn file(&self, path: String) -> File { - todo!() - } - - /// The content-addressed identifier of the directory. - pub fn id(&self) -> DirectoryID { - todo!() - } - - /// load a project's metadata - pub fn load_project(&self, config_path: String) -> Project { - todo!() - } - - /// Creates a named sub-pipeline. - pub fn pipeline(&self, name: String, description: Option) -> Directory { - todo!() - } - - /// Retrieves this directory plus a directory written at the given path. - /// # Arguments - /// - /// * `exclude` - Exclude artifacts that match the given pattern. - /// (e.g. ["node_modules/", ".git*"]). - /// * `include` - Include only artifacts that match the given pattern. - /// (e.g. ["app/", "package.*"]). - pub fn with_directory( - &self, - path: String, - directory: DirectoryID, - exclude: Option>, - include: Option>, - ) -> Directory { - todo!() - } - - /// Retrieves this directory plus the contents of the given file copied to the given path. - pub fn with_file(&self, path: String, source: FileID, permissions: Option) -> Directory { - todo!() - } - - /// Retrieves this directory plus a new directory created at the given path. - pub fn with_new_directory(&self, path: String, permissions: Option) -> Directory { - todo!() - } - - /// Retrieves this directory plus a new file written at the given path. - pub fn with_new_file( - &self, - path: String, - contents: String, - permissions: Option, - ) -> Directory { - todo!() - } - - /// Retrieves this directory with all file/dir timestamps set to the given time, in seconds from the Unix epoch. - pub fn with_timestamps(&self, timestamp: Int) -> Directory { - todo!() - } - - /// Retrieves this directory with the directory at the given path removed. - pub fn without_directory(&self, path: String) -> Directory { - todo!() - } - - /// Retrieves this directory with the file at the given path removed. - pub fn without_file(&self, path: String) -> Directory { - todo!() - } -} - -impl Input for Directory {} - -/// -pub struct Query {} - -impl Query { - /// Constructs a cache volume for a given cache key. - /// # Arguments - /// - /// * `key` - A string identifier to target this cache volume (e.g. "myapp-cache"). - pub fn cache_volume(&self, key: String) -> CacheVolume { - todo!() - } - - /// Loads a container from ID. - /// Null ID returns an empty container (scratch). - /// Optional platform argument initializes new containers to execute and publish as that platform. Platform defaults to that of the builder's host. - pub fn container(&self, id: Option, platform: Option) -> Container { - todo!() - } - - /// The default platform of the builder. - pub fn default_platform(&self) -> Platform { - todo!() - } - - /// Load a directory by ID. No argument produces an empty directory. - pub fn directory(&self, id: Option) -> Directory { - todo!() - } - - /// Loads a file by ID. - pub fn file(&self, id: FileID) -> Option { - todo!() - } - - /// Queries a git repository. - pub fn git(&self, url: String, keep_git_dir: Option) -> GitRepository { - todo!() - } - - /// Queries the host environment. - pub fn host(&self) -> Host { - todo!() - } - - /// Returns a file containing an http remote url content. - pub fn http(&self, url: String) -> File { - todo!() - } - - /// Creates a named sub-pipeline - pub fn pipeline(&self, name: String, description: Option) -> Query { - todo!() - } - - /// Look up a project by name - pub fn project(&self, name: String) -> Project { - todo!() - } - - /// Loads a secret from its ID. - pub fn secret(&self, id: SecretID) -> Secret { - todo!() - } - - /// Loads a socket by its ID. - pub fn socket(&self, id: Option) -> Socket { - todo!() - } -} - -impl Input for Query {} - -/// An environment variable on the host environment. -pub struct HostVariable {} - -impl HostVariable { - /// A secret referencing the value of this variable. - pub fn secret(&self) -> Secret { - todo!() - } - - /// The value of this variable. - pub fn value(&self) -> String { - todo!() - } -} - -impl Input for HostVariable {} - /// A directory whose contents persist across runs. pub struct CacheVolume {} @@ -682,6 +368,177 @@ impl Container { impl Input for Container {} +/// A directory. +pub struct Directory {} + +impl Directory { + /// Gets the difference between this directory and an another directory. + pub fn diff(&self, other: DirectoryID) -> Directory { + todo!() + } + + /// Retrieves a directory at the given path. + pub fn directory(&self, path: String) -> Directory { + todo!() + } + + /// Builds a new Docker container from this directory. + /// # Arguments + /// + /// * `dockerfile` - Path to the Dockerfile to use. + /// Defaults to './Dockerfile'. + /// * `platform` - The platform to build. + /// * `buildArgs` - Additional build arguments. + /// * `target` - Target build stage to build. + pub fn docker_build( + &self, + dockerfile: Option, + platform: Option, + build_args: Option>, + target: Option, + ) -> Container { + todo!() + } + + /// Returns a list of files and directories at the given path. + pub fn entries(&self, path: Option) -> Vec { + todo!() + } + + /// Writes the contents of the directory to a path on the host. + pub fn export(&self, path: String) -> Boolean { + todo!() + } + + /// Retrieves a file at the given path. + pub fn file(&self, path: String) -> File { + todo!() + } + + /// The content-addressed identifier of the directory. + pub fn id(&self) -> DirectoryID { + todo!() + } + + /// load a project's metadata + pub fn load_project(&self, config_path: String) -> Project { + todo!() + } + + /// Creates a named sub-pipeline. + pub fn pipeline(&self, name: String, description: Option) -> Directory { + todo!() + } + + /// Retrieves this directory plus a directory written at the given path. + /// # Arguments + /// + /// * `exclude` - Exclude artifacts that match the given pattern. + /// (e.g. ["node_modules/", ".git*"]). + /// * `include` - Include only artifacts that match the given pattern. + /// (e.g. ["app/", "package.*"]). + pub fn with_directory( + &self, + path: String, + directory: DirectoryID, + exclude: Option>, + include: Option>, + ) -> Directory { + todo!() + } + + /// Retrieves this directory plus the contents of the given file copied to the given path. + pub fn with_file(&self, path: String, source: FileID, permissions: Option) -> Directory { + todo!() + } + + /// Retrieves this directory plus a new directory created at the given path. + pub fn with_new_directory(&self, path: String, permissions: Option) -> Directory { + todo!() + } + + /// Retrieves this directory plus a new file written at the given path. + pub fn with_new_file( + &self, + path: String, + contents: String, + permissions: Option, + ) -> Directory { + todo!() + } + + /// Retrieves this directory with all file/dir timestamps set to the given time, in seconds from the Unix epoch. + pub fn with_timestamps(&self, timestamp: Int) -> Directory { + todo!() + } + + /// Retrieves this directory with the directory at the given path removed. + pub fn without_directory(&self, path: String) -> Directory { + todo!() + } + + /// Retrieves this directory with the file at the given path removed. + pub fn without_file(&self, path: String) -> Directory { + todo!() + } +} + +impl Input for Directory {} + +/// A simple key value object that represents an environment variable. +pub struct EnvVariable {} + +impl EnvVariable { + /// The environment variable name. + pub fn name(&self) -> String { + todo!() + } + + /// The environment variable value. + pub fn value(&self) -> String { + todo!() + } +} + +impl Input for EnvVariable {} + +/// A file. +pub struct File {} + +impl File { + /// Retrieves the contents of the file. + pub fn contents(&self) -> String { + todo!() + } + + /// Writes the file to a file path on the host. + pub fn export(&self, path: String) -> Boolean { + todo!() + } + + /// Retrieves the content-addressed identifier of the file. + pub fn id(&self) -> FileID { + todo!() + } + + /// Retrieves a secret referencing the contents of this file. + pub fn secret(&self) -> Secret { + todo!() + } + + /// Gets the size of the file, in bytes. + pub fn size(&self) -> Int { + todo!() + } + + /// Retrieves this file with its created/modified timestamps set to the given time, in seconds from the Unix epoch. + pub fn with_timestamps(&self, timestamp: Int) -> File { + todo!() + } +} + +impl Input for File {} + /// A git ref (tag, branch or commit). pub struct GitRef {} @@ -703,22 +560,37 @@ impl GitRef { impl Input for GitRef {} -/// A simple key value object that represents a label. -pub struct Label {} +/// A git repository. +pub struct GitRepository {} -impl Label { - /// The label name. - pub fn name(&self) -> String { +impl GitRepository { + /// Returns details on one branch. + pub fn branch(&self, name: String) -> GitRef { todo!() } - /// The label value. - pub fn value(&self) -> String { + /// Lists of branches on the repository. + pub fn branches(&self) -> Vec { + todo!() + } + + /// Returns details on one commit. + pub fn commit(&self, id: String) -> GitRef { + todo!() + } + + /// Returns details on one tag. + pub fn tag(&self, name: String) -> GitRef { + todo!() + } + + /// Lists of tags on the repository. + pub fn tags(&self) -> Vec { todo!() } } -impl Input for Label {} +impl Input for GitRepository {} /// Information about the host execution environment. pub struct Host {} @@ -752,6 +624,166 @@ impl Host { impl Input for Host {} +/// An environment variable on the host environment. +pub struct HostVariable {} + +impl HostVariable { + /// A secret referencing the value of this variable. + pub fn secret(&self) -> Secret { + todo!() + } + + /// The value of this variable. + pub fn value(&self) -> String { + todo!() + } +} + +impl Input for HostVariable {} + +/// A simple key value object that represents a label. +pub struct Label {} + +impl Label { + /// The label name. + pub fn name(&self) -> String { + todo!() + } + + /// The label value. + pub fn value(&self) -> String { + todo!() + } +} + +impl Input for Label {} + +/// A set of scripts and/or extensions +pub struct Project {} + +impl Project { + /// extensions in this project + pub fn extensions(&self) -> Option> { + todo!() + } + + /// Code files generated by the SDKs in the project + pub fn generated_code(&self) -> Directory { + todo!() + } + + /// install the project's schema + pub fn install(&self) -> Boolean { + todo!() + } + + /// name of the project + pub fn name(&self) -> String { + todo!() + } + + /// schema provided by the project + pub fn schema(&self) -> Option { + todo!() + } + + /// sdk used to generate code for and/or execute this project + pub fn sdk(&self) -> Option { + todo!() + } +} + +impl Input for Project {} + +/// +pub struct Query {} + +impl Query { + /// Constructs a cache volume for a given cache key. + /// # Arguments + /// + /// * `key` - A string identifier to target this cache volume (e.g. "myapp-cache"). + pub fn cache_volume(&self, key: String) -> CacheVolume { + todo!() + } + + /// Loads a container from ID. + /// Null ID returns an empty container (scratch). + /// Optional platform argument initializes new containers to execute and publish as that platform. Platform defaults to that of the builder's host. + pub fn container(&self, id: Option, platform: Option) -> Container { + todo!() + } + + /// The default platform of the builder. + pub fn default_platform(&self) -> Platform { + todo!() + } + + /// Load a directory by ID. No argument produces an empty directory. + pub fn directory(&self, id: Option) -> Directory { + todo!() + } + + /// Loads a file by ID. + pub fn file(&self, id: FileID) -> Option { + todo!() + } + + /// Queries a git repository. + pub fn git(&self, url: String, keep_git_dir: Option) -> GitRepository { + todo!() + } + + /// Queries the host environment. + pub fn host(&self) -> Host { + todo!() + } + + /// Returns a file containing an http remote url content. + pub fn http(&self, url: String) -> File { + todo!() + } + + /// Creates a named sub-pipeline + pub fn pipeline(&self, name: String, description: Option) -> Query { + todo!() + } + + /// Look up a project by name + pub fn project(&self, name: String) -> Project { + todo!() + } + + /// Loads a secret from its ID. + pub fn secret(&self, id: SecretID) -> Secret { + todo!() + } + + /// Loads a socket by its ID. + pub fn socket(&self, id: Option) -> Socket { + todo!() + } +} + +impl Input for Query {} + +/// A reference to a secret value, which can be handled more safely than the value itself. +pub struct Secret {} + +impl Secret { + /// The identifier for this secret. + pub fn id(&self) -> SecretID { + todo!() + } + + /// The value of this secret. + pub fn plaintext(&self) -> String { + todo!() + } +} + +impl Input for Secret {} + /// pub struct Socket {} @@ -763,35 +795,3 @@ impl Socket { } impl Input for Socket {} - -/// A git repository. -pub struct GitRepository {} - -impl GitRepository { - /// Returns details on one branch. - pub fn branch(&self, name: String) -> GitRef { - todo!() - } - - /// Lists of branches on the repository. - pub fn branches(&self) -> Vec { - todo!() - } - - /// Returns details on one commit. - pub fn commit(&self, id: String) -> GitRef { - todo!() - } - - /// Returns details on one tag. - pub fn tag(&self, name: String) -> GitRef { - todo!() - } - - /// Lists of tags on the repository. - pub fn tags(&self) -> Vec { - todo!() - } -} - -impl Input for GitRepository {}