mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-01 00:23:56 +08:00 
			
		
		
		
	update github.com/compose-spec/compose-go to v1.4.0
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
		
							
								
								
									
										10
									
								
								vendor/github.com/compose-spec/compose-go/loader/loader.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								vendor/github.com/compose-spec/compose-go/loader/loader.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -43,11 +43,6 @@ import ( | ||||
| 	"gopkg.in/yaml.v2" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
| 	DefaultSeparator       = "-" | ||||
| 	CompatibilitySeparator = "_" | ||||
| ) | ||||
|  | ||||
| // Options supported by Load | ||||
| type Options struct { | ||||
| 	// Skip schema validation | ||||
| @@ -72,8 +67,6 @@ type Options struct { | ||||
| 	projectName string | ||||
| 	// Indicates when the projectName was imperatively set or guessed from path | ||||
| 	projectNameImperativelySet bool | ||||
| 	// Set separator used for naming resources | ||||
| 	Separator string | ||||
| } | ||||
|  | ||||
| func (o *Options) SetProjectName(name string, imperativelySet bool) { | ||||
| @@ -162,7 +155,6 @@ func Load(configDetails types.ConfigDetails, options ...func(*Options)) (*types. | ||||
| 			LookupValue:     configDetails.LookupEnv, | ||||
| 			TypeCastMapping: interpolateTypeCastMapping, | ||||
| 		}, | ||||
| 		Separator: DefaultSeparator, | ||||
| 	} | ||||
|  | ||||
| 	for _, op := range options { | ||||
| @@ -231,7 +223,7 @@ func Load(configDetails types.ConfigDetails, options ...func(*Options)) (*types. | ||||
| 	} | ||||
|  | ||||
| 	if !opts.SkipNormalization { | ||||
| 		err = normalize(project, opts.ResolvePaths, opts.Separator) | ||||
| 		err = normalize(project, opts.ResolvePaths) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
|   | ||||
							
								
								
									
										14
									
								
								vendor/github.com/compose-spec/compose-go/loader/normalize.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										14
									
								
								vendor/github.com/compose-spec/compose-go/loader/normalize.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -28,7 +28,7 @@ import ( | ||||
| ) | ||||
|  | ||||
| // normalize compose project by moving deprecated attributes to their canonical position and injecting implicit defaults | ||||
| func normalize(project *types.Project, resolvePaths bool, separator string) error { | ||||
| func normalize(project *types.Project, resolvePaths bool) error { | ||||
| 	absWorkingDir, err := filepath.Abs(project.WorkingDir) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| @@ -110,7 +110,7 @@ func normalize(project *types.Project, resolvePaths bool, separator string) erro | ||||
| 		project.Services[i] = s | ||||
| 	} | ||||
|  | ||||
| 	setNameFromKey(project, separator) | ||||
| 	setNameFromKey(project) | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
| @@ -143,31 +143,31 @@ func absComposeFiles(composeFiles []string) ([]string, error) { | ||||
| } | ||||
|  | ||||
| // Resources with no explicit name are actually named by their key in map | ||||
| func setNameFromKey(project *types.Project, separator string) { | ||||
| func setNameFromKey(project *types.Project) { | ||||
| 	for i, n := range project.Networks { | ||||
| 		if n.Name == "" { | ||||
| 			n.Name = fmt.Sprintf("%s%s%s", project.Name, separator, i) | ||||
| 			n.Name = fmt.Sprintf("%s_%s", project.Name, i) | ||||
| 			project.Networks[i] = n | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	for i, v := range project.Volumes { | ||||
| 		if v.Name == "" { | ||||
| 			v.Name = fmt.Sprintf("%s%s%s", project.Name, separator, i) | ||||
| 			v.Name = fmt.Sprintf("%s_%s", project.Name, i) | ||||
| 			project.Volumes[i] = v | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	for i, c := range project.Configs { | ||||
| 		if c.Name == "" { | ||||
| 			c.Name = fmt.Sprintf("%s%s%s", project.Name, separator, i) | ||||
| 			c.Name = fmt.Sprintf("%s_%s", project.Name, i) | ||||
| 			project.Configs[i] = c | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	for i, s := range project.Secrets { | ||||
| 		if s.Name == "" { | ||||
| 			s.Name = fmt.Sprintf("%s%s%s", project.Name, separator, i) | ||||
| 			s.Name = fmt.Sprintf("%s_%s", project.Name, i) | ||||
| 			project.Secrets[i] = s | ||||
| 		} | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										38
									
								
								vendor/github.com/compose-spec/compose-go/template/template.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										38
									
								
								vendor/github.com/compose-spec/compose-go/template/template.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -61,13 +61,14 @@ type SubstituteFunc func(string, Mapping) (string, bool, error) | ||||
| // SubstituteWith substitute variables in the string with their values. | ||||
| // It accepts additional substitute function. | ||||
| func SubstituteWith(template string, mapping Mapping, pattern *regexp.Regexp, subsFuncs ...SubstituteFunc) (string, error) { | ||||
| 	var err error | ||||
| 	var outerErr error | ||||
|  | ||||
| 	if len(subsFuncs) == 0 { | ||||
| 		_, subsFunc := getSubstitutionFunctionForTemplate(template) | ||||
| 		subsFuncs = []SubstituteFunc{subsFunc} | ||||
| 	} | ||||
| 	result := pattern.ReplaceAllStringFunc(template, func(substring string) string { | ||||
| 		_, subsFunc := getSubstitutionFunctionForTemplate(substring) | ||||
| 		if len(subsFuncs) > 0 { | ||||
| 			subsFunc = subsFuncs[0] | ||||
| 		} | ||||
|  | ||||
| 		closingBraceIndex := getFirstBraceClosingIndex(substring) | ||||
| 		rest := "" | ||||
| 		if closingBraceIndex > -1 { | ||||
| @@ -89,24 +90,21 @@ func SubstituteWith(template string, mapping Mapping, pattern *regexp.Regexp, su | ||||
| 		} | ||||
|  | ||||
| 		if substitution == "" { | ||||
| 			err = &InvalidTemplateError{Template: template} | ||||
| 			outerErr = &InvalidTemplateError{Template: template} | ||||
| 			return "" | ||||
| 		} | ||||
|  | ||||
| 		if braced { | ||||
| 			for _, f := range subsFuncs { | ||||
| 				var ( | ||||
| 					value   string | ||||
| 					applied bool | ||||
| 				) | ||||
| 				value, applied, err = f(substitution, mapping) | ||||
| 				if err != nil { | ||||
| 					return "" | ||||
| 				} | ||||
| 				if !applied { | ||||
| 					continue | ||||
| 				} | ||||
| 				interpolatedNested, err := SubstituteWith(rest, mapping, pattern, subsFuncs...) | ||||
| 			var ( | ||||
| 				value   string | ||||
| 				applied bool | ||||
| 			) | ||||
| 			value, applied, outerErr = subsFunc(substitution, mapping) | ||||
| 			if outerErr != nil { | ||||
| 				return "" | ||||
| 			} | ||||
| 			if applied { | ||||
| 				interpolatedNested, err := SubstituteWith(rest, mapping, pattern) | ||||
| 				if err != nil { | ||||
| 					return "" | ||||
| 				} | ||||
| @@ -121,7 +119,7 @@ func SubstituteWith(template string, mapping Mapping, pattern *regexp.Regexp, su | ||||
| 		return value | ||||
| 	}) | ||||
|  | ||||
| 	return result, err | ||||
| 	return result, outerErr | ||||
| } | ||||
|  | ||||
| func getSubstitutionFunctionForTemplate(template string) (string, SubstituteFunc) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 CrazyMax
					CrazyMax