Repository: smithy-lang/smithy-rs (language: rust)

Issue:
Remove special handling logic for the old SDK examples directory layout
Address the `TODO(https://github.com/awslabs/smithy-rs/issues/2810)` comments after confirming that there is no longer a `Cargo.toml` file in `aws-sdk-rust/examples/` in the aws-sdk-rust main branch.



Discussion / hints:

Fix patch:
diff --git a/tools/ci-build/sdk-versioner/src/main.rs b/tools/ci-build/sdk-versioner/src/main.rs
index 63ffd6bd2f..df148894d1 100644
--- a/tools/ci-build/sdk-versioner/src/main.rs
+++ b/tools/ci-build/sdk-versioner/src/main.rs
@@ -29,10 +29,6 @@ enum Args {
         /// Path(s) to recursively update Cargo.toml files in
         #[clap()]
         crate_paths: Vec<PathBuf>,
-        // TODO(https://github.com/awslabs/smithy-rs/issues/2810): `isolate_crates` can be removed once the `Flat` example directory structure is cleaned up
-        /// Makes each individual crate its own workspace
-        #[clap(long)]
-        isolate_crates: bool,
     },
     /// Revise crates to use version numbers in dependencies
     UseVersionDependencies {
@@ -42,10 +38,6 @@ enum Args {
         /// Path(s) to recursively update Cargo.toml files in
         #[clap()]
         crate_paths: Vec<PathBuf>,
-        // TODO(https://github.com/awslabs/smithy-rs/issues/2810): `isolate_crates` can be removed once the `Flat` example directory structure is cleaned up
-        /// Makes each individual crate its own workspace
-        #[clap(long)]
-        isolate_crates: bool,
     },
     /// Revise crates to use version numbers AND paths in dependencies
     UsePathAndVersionDependencies {
@@ -58,10 +50,6 @@ enum Args {
         /// Path(s) to recursively update Cargo.toml files in
         #[clap()]
         crate_paths: Vec<PathBuf>,
-        // TODO(https://github.com/awslabs/smithy-rs/issues/2810): `isolate_crates` can be removed once the `Flat` example directory structure is cleaned up
-        /// Makes each individual crate its own workspace
-        #[clap(long)]
-        isolate_crates: bool,
     },
 }
 
@@ -74,14 +62,6 @@ impl Args {
         }
     }
 
-    fn isolate_crates(&self) -> bool {
-        *match self {
-            Self::UsePathDependencies { isolate_crates, .. } => isolate_crates,
-            Self::UseVersionDependencies { isolate_crates, .. } => isolate_crates,
-            Self::UsePathAndVersionDependencies { isolate_crates, .. } => isolate_crates,
-        }
-    }
-
     fn validate(self) -> Result<Self> {
         if self.crate_paths().is_empty() {
             bail!("Must provide at least one crate path to recursively update");
@@ -141,7 +121,7 @@ fn main() -> Result<()> {
     }
 
     for manifest_path in manifest_paths {
-        update_manifest(&manifest_path, &dependency_context, args.isolate_crates())?;
+        update_manifest(&manifest_path, &dependency_context)?;
     }
 
     println!("Finished in {:?}", start_time.elapsed());
@@ -151,7 +131,6 @@ fn main() -> Result<()> {
 fn update_manifest(
     manifest_path: &Path,
     dependency_context: &DependencyContext,
-    isolate_crates: bool,
 ) -> anyhow::Result<()> {
     println!("Updating {:?}...", manifest_path);
     let crate_path = manifest_path.parent().expect("manifest has a parent");
@@ -179,17 +158,6 @@ fn update_manifest(
             )? || changed;
         }
     }
-    if isolate_crates && !metadata.contains_key("workspace") {
-        let package_position = metadata["package"]
-            .as_table()
-            .expect("has a package")
-            .position()
-            .unwrap_or_default();
-        let mut workspace = Table::new();
-        workspace.set_position(package_position);
-        metadata.insert("workspace", Item::Table(workspace));
-        changed = true;
-    }
 
     if changed {
         fs::write(manifest_path, metadata.to_string())?;
@@ -373,7 +341,6 @@ features = ["foo", "baz"]
 
     #[track_caller]
     fn test_with_context(
-        isolate_crates: bool,
         crate_path_rel: &str,
         sdk_crates: &[&'static str],
         context: DependencyContext,
@@ -412,7 +379,7 @@ features = ["foo", "baz"]
         } else {
             context
         };
-        update_manifest(&manifest_path, &fixed_context, isolate_crates).expect("success");
+        update_manifest(&manifest_path, &fixed_context).expect("success");
 
         let actual =
             String::from_utf8(std::fs::read(&manifest_path).expect("read tmp file")).unwrap();
@@ -423,7 +390,6 @@ features = ["foo", "baz"]
     #[test]
     fn update_dependencies_with_versions() {
         test_with_context(
-            false,
             "examples/foo",
             &[],
             DependencyContext {
@@ -461,7 +427,6 @@ features = ["foo", "baz"]
     #[test]
     fn update_dependencies_with_paths() {
         test_with_context(
-            false,
             "path/to/test",
             &[
                 "aws-config",
@@ -496,11 +461,9 @@ features = ["foo", "baz"]
         );
     }
 
-    // TODO(https://github.com/awslabs/smithy-rs/issues/2810): Remove this test
     #[test]
     fn update_dependencies_with_paths_dumb_logic() {
         test_with_context(
-            false,
             "path/to/test",
             &[
                 "aws-config",
@@ -538,7 +501,6 @@ features = ["foo", "baz"]
     #[test]
     fn update_dependencies_with_versions_and_paths() {
         test_with_context(
-            false,
             "deep/path/to/test",
             &[
                 "aws-config",
@@ -569,51 +531,6 @@ aws-smithy-http = { version = "0.9.0", path = "../../../../sdk/aws-smithy-http",
 something-else = { version = "0.1", no-default-features = true }
 tokio = { version = "1.18", features = ["net"] }
 
-[dev-dependencies.another-thing]
-# some comment
-version = "5.0"
-# another comment
-features = ["foo", "baz"]
-"#
-        );
-    }
-
-    #[test]
-    fn update_dependencies_isolate_crates() {
-        test_with_context(
-            true,
-            "deep/path/to/test",
-            &[
-                "aws-config",
-                "aws-sdk-s3",
-                "aws-smithy-types",
-                "aws-smithy-http",
-            ],
-            DependencyContext {
-                sdk_path: Some(SdkPath::UseNewLogic(PathBuf::from("sdk"))),
-                versions_manifest: Some(versions_toml_for(&[
-                    ("aws-config", "0.5.0"),
-                    ("aws-sdk-s3", "0.13.0"),
-                    ("aws-smithy-types", "0.10.0"),
-                    ("aws-smithy-http", "0.9.0"),
-                ])),
-            },
-            br#"
-[package]
-name = "test"
-version = "0.1.0"
-
-[workspace]
-
-# Some comment that should be preserved
-[dependencies]
-aws-config = { version = "0.5.0", path = "../../../../sdk/aws-config" }
-aws-sdk-s3 = { version = "0.13.0", path = "../../../../sdk/s3" }
-aws-smithy-types = { version = "0.10.0", path = "../../../../sdk/aws-smithy-types" }
-aws-smithy-http = { version = "0.9.0", path = "../../../../sdk/aws-smithy-http", features = ["test-util"] }
-something-else = { version = "0.1", no-default-features = true }
-tokio = { version = "1.18", features = ["net"] }
-
 [dev-dependencies.another-thing]
 # some comment
 version = "5.0"
diff --git a/tools/ci-scripts/generate-aws-sdk b/tools/ci-scripts/generate-aws-sdk
index 18b29529ad..d2bf30ec85 100755
--- a/tools/ci-scripts/generate-aws-sdk
+++ b/tools/ci-scripts/generate-aws-sdk
@@ -25,8 +25,6 @@ echo -e "${C_YELLOW}Taking examples from 'awsdocs/aws-doc-sdk-examples'...${C_RE
 examples_revision=$(cd aws-doc-sdk-examples; git rev-parse HEAD)
 mv aws-doc-sdk-examples/rust_dev_preview smithy-rs/aws/sdk/examples
 rm -rf smithy-rs/aws/sdk/examples/.cargo
-# TODO(https://github.com/awslabs/smithy-rs/issues/2810): This Cargo.toml `rm` can be removed when the flat example structure is cleaned up
-rm -f smithy-rs/aws/sdk/examples/Cargo.toml
 
 echo -e "${C_YELLOW}Creating empty model metadata file since we don't have model update information...${C_RESET}"
 MODEL_METADATA_PATH="$(pwd)/model-metadata.toml"


Test patch: