Skip to content

Commit 243ed84

Browse files
committed
remove unused methods
1 parent 9266ff8 commit 243ed84

File tree

1 file changed

+0
-75
lines changed
  • framework/components/dockercompose/chip_ingress_set

1 file changed

+0
-75
lines changed

framework/components/dockercompose/chip_ingress_set/protos.go

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -143,81 +143,6 @@ func extractTopLevelMessageNamesWithRegex(protoSrc string) ([]string, error) {
143143
return names, nil
144144
}
145145

146-
// createSchemasForProto creates schemas for a proto file:
147-
// 1. The original proto file (registered first, Red Panda uses first message by default)
148-
// 2. Import-only schemas for each additional message (2nd, 3rd, etc., skipping the first)
149-
func createSchemasForProto(proto protoFile) ([]protoFile, error) {
150-
messageNames, err := extractTopLevelMessageNamesWithRegex(proto.Content)
151-
if err != nil {
152-
return nil, err
153-
}
154-
155-
var schemas []protoFile
156-
157-
// First, add the original proto file
158-
schemas = append(schemas, proto)
159-
160-
// If there are multiple messages, create import-only schemas for messages after the first
161-
if len(messageNames) > 1 {
162-
framework.L.Debug().Msgf("Creating import-only schemas for %d additional messages in %s: %v", len(messageNames)-1, proto.Path, messageNames[1:])
163-
164-
// Skip the first message (index 0) since it's covered by the original proto
165-
for _, messageName := range messageNames[1:] {
166-
importSchema, err := createImportOnlySchema(proto, messageName)
167-
if err != nil {
168-
return nil, errors.Wrapf(err, "failed to create import-only schema for message %s", messageName)
169-
}
170-
schemas = append(schemas, importSchema)
171-
}
172-
}
173-
174-
return schemas, nil
175-
}
176-
177-
// createImportOnlySchema creates an import-only schema for a specific message
178-
func createImportOnlySchema(originalProto protoFile, messageName string) (protoFile, error) {
179-
// Extract syntax and package from original proto
180-
syntax, err := extractSyntaxDeclaration(originalProto.Content)
181-
if err != nil {
182-
return protoFile{}, err
183-
}
184-
185-
packageName, err := extractPackageNameWithRegex(originalProto.Content)
186-
if err != nil {
187-
return protoFile{}, err
188-
}
189-
190-
// Create import-only schema content
191-
var content strings.Builder
192-
content.WriteString(syntax)
193-
content.WriteString("\n\n")
194-
content.WriteString(fmt.Sprintf("package %s;\n\n", packageName))
195-
content.WriteString(fmt.Sprintf("import \"%s\";\n", originalProto.Path))
196-
197-
// Create new schema with clear prefix: import_MessageName_originalname.proto
198-
baseNameWithoutExt := strings.TrimSuffix(originalProto.Name, ".proto")
199-
newPath := fmt.Sprintf("import_only_%s_%s.proto", messageName, baseNameWithoutExt)
200-
newName := fmt.Sprintf("import_only_%s_%s.proto", messageName, baseNameWithoutExt)
201-
202-
return protoFile{
203-
Name: newName,
204-
Path: newPath,
205-
Content: content.String(),
206-
IsImportOnly: true,
207-
TargetMessage: messageName,
208-
}, nil
209-
}
210-
211-
// extractSyntaxDeclaration extracts the syntax declaration from a proto file
212-
func extractSyntaxDeclaration(protoContent string) (string, error) {
213-
syntaxMatch := regexp.MustCompile(`(?m)^syntax\s*=\s*"[^"]+"\s*;`).FindString(protoContent)
214-
if syntaxMatch == "" {
215-
// Default to proto3 if no syntax specified
216-
return `syntax = "proto3";`, nil
217-
}
218-
return syntaxMatch, nil
219-
}
220-
221146
// Fetches .proto files from a GitHub repo optionally scoped to specific folders. It is recommended to use `*github.Client` with auth token to avoid rate limiting.
222147
func fetchProtoFilesInFolders(ctx context.Context, client *github.Client, owner, repository, ref string, folders []string) ([]protoFile, error) {
223148
framework.L.Debug().Msgf("Fetching proto files from %s/%s in folders: %s", owner, repository, strings.Join(folders, ", "))

0 commit comments

Comments
 (0)