| 
									
										
										
										
											2017-12-10 11:28:01 -02:00
										 |  |  | package effectiveconfig | 
					
						
							| 
									
										
										
										
											2017-12-08 22:30:02 -02:00
										 |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							| 
									
										
										
										
											2021-04-25 13:00:51 -03:00
										 |  |  | 	"os" | 
					
						
							| 
									
										
										
										
											2017-12-08 22:30:02 -02:00
										 |  |  | 	"path/filepath" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-21 21:11:15 -03:00
										 |  |  | 	"github.com/caarlos0/log" | 
					
						
							| 
									
										
										
										
											2022-03-29 19:00:53 +02:00
										 |  |  | 	"github.com/goreleaser/goreleaser/internal/yaml" | 
					
						
							| 
									
										
										
										
											2018-08-14 23:50:20 -03:00
										 |  |  | 	"github.com/goreleaser/goreleaser/pkg/context" | 
					
						
							| 
									
										
										
										
											2017-12-08 22:30:02 -02:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-26 00:48:10 -03:00
										 |  |  | // Pipe that writes the effective config file to dist. | 
					
						
							| 
									
										
										
										
											2021-04-25 14:20:49 -03:00
										 |  |  | type Pipe struct{} | 
					
						
							| 
									
										
										
										
											2017-12-08 22:30:02 -02:00
										 |  |  | 
 | 
					
						
							|  |  |  | func (Pipe) String() string { | 
					
						
							| 
									
										
										
										
											2017-12-10 11:28:01 -02:00
										 |  |  | 	return "writing effective config file" | 
					
						
							| 
									
										
										
										
											2017-12-08 22:30:02 -02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-26 00:48:10 -03:00
										 |  |  | // Run the pipe. | 
					
						
							| 
									
										
										
										
											2017-12-08 22:30:02 -02:00
										 |  |  | func (Pipe) Run(ctx *context.Context) (err error) { | 
					
						
							| 
									
										
										
										
											2021-04-25 14:20:49 -03:00
										 |  |  | 	path := filepath.Join(ctx.Config.Dist, "config.yaml") | 
					
						
							| 
									
										
										
										
											2017-12-08 22:30:02 -02:00
										 |  |  | 	bts, err := yaml.Marshal(ctx.Config) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		return err | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-12-18 21:07:47 -02:00
										 |  |  | 	log.WithField("config", path).Info("writing") | 
					
						
							| 
									
										
										
										
											2021-04-25 14:20:49 -03:00
										 |  |  | 	return os.WriteFile(path, bts, 0o644) //nolint: gosec | 
					
						
							| 
									
										
										
										
											2017-12-08 22:30:02 -02:00
										 |  |  | } |