| 
									
										
										
										
											2023-03-03 14:43:11 +01:00
										 |  |  | package services | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"os" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-29 18:02:29 +02:00
										 |  |  | 	conf "cloud.o-forge.io/core/deprecated-oc-catalog/conf" | 
					
						
							| 
									
										
										
										
											2024-07-04 15:57:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-29 18:02:29 +02:00
										 |  |  | 	SelfAPI "cloud.o-forge.io/core/deprecated-oc-catalog/selfapi" | 
					
						
							| 
									
										
										
										
											2023-03-03 14:43:11 +01:00
										 |  |  | 	"github.com/beego/beego/v2/core/logs" | 
					
						
							|  |  |  | 	beego "github.com/beego/beego/v2/server/web" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var DC_NAME string | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func GetSelfAPI(host string) *SelfAPI.APIClient { | 
					
						
							|  |  |  | 	return SelfAPI.NewAPIClient(&SelfAPI.Configuration{BasePath: "http://" + host + "/v1"}) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-04 15:57:28 +02:00
										 |  |  | // Need to understand why there are so many different DC name | 
					
						
							| 
									
										
										
										
											2023-03-03 14:43:11 +01:00
										 |  |  | func Discoveryinit() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	dcNameOS := os.Getenv("DOCKER_DCNAME") | 
					
						
							|  |  |  | 	if len(dcNameOS) != 0 { | 
					
						
							|  |  |  | 		DC_NAME = dcNameOS | 
					
						
							|  |  |  | 		return | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	//FIXME: Beego doesn't retrieve the dcname | 
					
						
							|  |  |  | 	beegoDC, err := beego.AppConfig.String("DCNAME") | 
					
						
							|  |  |  | 	if err == nil && len(beegoDC) != 0 { | 
					
						
							|  |  |  | 		DC_NAME = beegoDC | 
					
						
							|  |  |  | 		return | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	DC_NAME = "DC_DEFAULT" | 
					
						
							|  |  |  | 	logs.Warning("Default DC name is used") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-04 15:57:28 +02:00
										 |  |  | 	// Quickfix for scheduling | 
					
						
							|  |  |  | 	DC_NAME = conf.GetConfig().DCNAME | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-03 14:43:11 +01:00
										 |  |  | } |