Skip to content
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

refine sdk automation tool #23959

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

refine sdk automation tool #23959

wants to merge 2 commits into from

Conversation

tadelesh
Copy link
Member

@tadelesh tadelesh commented Jan 15, 2025

  1. do not throw error is no exports found
  2. support sub package generation

follow up tasks:

  1. migrate current mpg generation from call tsp-client directly to use go generate to do so
  2. decide how code generator support sub package generation

@lirenhe
Copy link
Member

lirenhe commented Jan 17, 2025

@JiaqiZhang-Dev, could you help to review this PR? Thanks

@JiaqiZhang-Dev
Copy link
Member

@lirenhe 👌

log.Printf("##[command]Executing go mod tidy in %s\n", packagePath)
if err = ExecuteGo(packagePath, "mod", "tidy"); err != nil {
if packageRelativePath != moduleRelativePath {
// remove go.mod for sub package
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some questions about this operation

  1. The condition of existing sub package is like this?
    service-dir: "sdk/resourcemanager/service_name"
    package-dir: "package_name"
    module: "github.com/Azure/azure-sdk-for-go/{service-dir}/{package-dir}/subpackage_name"
  2. why was the sub package's go.mod generated? Is it a problem of 'tsp-client init' command?
  3. Does there has existed these sub package go.mod? how about processing the current existed go.mod for sub package in the repo?

Copy link
Member

@JiaqiZhang-Dev JiaqiZhang-Dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check for the comments, thx~

if err != nil {
return nil, err
}

log.Printf("Update module definition if v2+...")
err = UpdateModuleDefinition(packagePath, packageModuleRelativePath, version)
err = UpdateModuleDefinition(packagePath, packageRelativePath, version)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there should be the modelPath and moduleRelativePath?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current impl is kind of a workaround. i separated the module from package since current go code generator does not support namespace in typespec.

@@ -191,9 +203,6 @@ func (tc TypeSpecConfig) GetModuleName() ([2]string, error) {
module := (option.(map[string]any))["module"].(string)
s := strings.Split(module, "/")
l := len(s)
if l != 7 {
return [2]string{}, fmt.Errorf("module is invalid and must be in the format of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/{rpName}/{packageName}`")
}
if !strings.Contains(s[l-1], "arm") && !strings.Contains(s[l-1], "az") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid an array out-of-bounds error, there could be added a length check~

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just leave this pr open. after we have a conclusion about the sub package generation, you could refactor all the generator tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants