tvalentyn commented on code in PR #39595:
URL: https://github.com/apache/beam/pull/39595#discussion_r3728782464


##########
sdks/go/container/tools/pipeline_options.go:
##########
@@ -42,3 +46,179 @@ func MakePipelineOptionsFileAndEnvVar(options string) error 
{
        os.Setenv("PIPELINE_OPTIONS_FILE", f.Name())
        return nil
 }
+
+// PipelineOptions represents parsed pipeline options as a normalized map.
+type PipelineOptions struct {
+       options     map[string]any
+       experiments map[string]string
+}
+
+// ParseOptionsFromProto creates normalized PipelineOptions directly from a 
protobuf Struct.
+func ParseOptionsFromProto(opt *structpb.Struct, sdkNamespace string) 
*PipelineOptions {
+       if opt == nil {
+               return &PipelineOptions{options: make(map[string]any), 
experiments: make(map[string]string)}
+       }
+       raw := opt.AsMap()
+       flat := make(map[string]any)
+
+       // 1. Extract nested options if present (Dataflow runner uses this 
structure)
+       if optsVal, ok := raw["options"]; ok {
+               if optsMap, ok := optsVal.(map[string]any); ok {
+                       for k, v := range optsMap {
+                               flat[k] = v
+                       }
+               }
+       }
+
+       // 2. Extract standard URN keys (Portable runners use this structure)
+       for k, v := range raw {
+               if k == "options" || k == "display_data" {
+                       continue
+               }
+               if strings.HasPrefix(k, "beam:option:") && strings.HasSuffix(k, 
":v1") {

Review Comment:
   I doubt we will do it but I added a note elsewhere in codebase where we are 
asserting :v1 suffix to update.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to