mirror of
				https://github.com/onepanelio/onepanel.git
				synced 2025-10-31 16:56:19 +08:00 
			
		
		
		
	fix constant name
This commit is contained in:
		| @@ -19,12 +19,12 @@ import ( | |||||||
| ) | ) | ||||||
|  |  | ||||||
| const ( | const ( | ||||||
| 	artifactRepositoryEndpointKey       = "artifactRepositoryS3Endpoint" | 	ArtifactRepositoryEndpointKey       = "artifactRepositoryS3Endpoint" | ||||||
| 	artifactRepositoryBucketKey         = "artifactRepositoryS3Bucket" | 	ArtifactRepositoryBucketKey         = "artifactRepositoryS3Bucket" | ||||||
| 	artifactRepositoryRegionKey         = "artifactRepositoryS3Region" | 	ArtifactRepositoryRegionKey         = "artifactRepositoryS3Region" | ||||||
| 	artifactRepositoryInsecureKey       = "artifactRepositoryS3Insecure" | 	ArtifactRepositoryInsecureKey       = "artifactRepositoryS3Insecure" | ||||||
| 	artifactRepositoryAccessKeyValueKey = "artifactRepositoryS3AccessKey" | 	ArtifactRepositoryAccessKeyValueKey = "artifactRepositoryS3AccessKey" | ||||||
| 	artifactRepositorySecretKeyValueKey = "artifactRepositoryS3SecretKey" | 	ArtifactRepositorySecretKeyValueKey = "artifactRepositoryS3SecretKey" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| type Config = rest.Config | type Config = rest.Config | ||||||
| @@ -108,12 +108,12 @@ func (c *Client) GetNamespaceConfig(namespace string) (config map[string]string, | |||||||
| 	s3Conf := ArtifactRepositoryS3Config{} | 	s3Conf := ArtifactRepositoryS3Config{} | ||||||
|  |  | ||||||
| 	err = yaml.Unmarshal([]byte(configMap.Data["artifactRepository"]), &s3Conf) | 	err = yaml.Unmarshal([]byte(configMap.Data["artifactRepository"]), &s3Conf) | ||||||
| 	config[artifactRepositoryEndpointKey] = s3Conf.S3.Endpoint | 	config[ArtifactRepositoryEndpointKey] = s3Conf.S3.Endpoint | ||||||
| 	config[artifactRepositoryBucketKey] = s3Conf.S3.Bucket | 	config[ArtifactRepositoryBucketKey] = s3Conf.S3.Bucket | ||||||
| 	config[artifactRepositoryRegionKey] = s3Conf.S3.Region | 	config[ArtifactRepositoryRegionKey] = s3Conf.S3.Region | ||||||
| 	config[artifactRepositoryInsecureKey] = s3Conf.S3.Insecure | 	config[ArtifactRepositoryInsecureKey] = s3Conf.S3.Insecure | ||||||
| 	config[artifactRepositoryAccessKeyValueKey] = s3Conf.S3.AccessKeySecret.Key | 	config[ArtifactRepositoryAccessKeyValueKey] = s3Conf.S3.AccessKeySecret.Key | ||||||
| 	config[artifactRepositorySecretKeyValueKey] = s3Conf.S3.SecretKeySecret.Key | 	config[ArtifactRepositorySecretKeyValueKey] = s3Conf.S3.SecretKeySecret.Key | ||||||
|  |  | ||||||
| 	secret, err := c.GetSecret(namespace, "onepanel") | 	secret, err := c.GetSecret(namespace, "onepanel") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| @@ -123,16 +123,16 @@ func (c *Client) GetNamespaceConfig(namespace string) (config map[string]string, | |||||||
| 		}).Error("getNamespaceConfig failed getting secret.") | 		}).Error("getNamespaceConfig failed getting secret.") | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 	accessKey, _ := base64.StdEncoding.DecodeString(secret.Data[artifactRepositoryAccessKeyValueKey]) | 	accessKey, _ := base64.StdEncoding.DecodeString(secret.Data[ArtifactRepositoryAccessKeyValueKey]) | ||||||
| 	config[artifactRepositoryAccessKeyValueKey] = string(accessKey) | 	config[ArtifactRepositoryAccessKeyValueKey] = string(accessKey) | ||||||
| 	secretKey, _ := base64.StdEncoding.DecodeString(secret.Data[artifactRepositorySecretKeyValueKey]) | 	secretKey, _ := base64.StdEncoding.DecodeString(secret.Data[ArtifactRepositorySecretKeyValueKey]) | ||||||
| 	config[artifactRepositorySecretKeyValueKey] = string(secretKey) | 	config[ArtifactRepositorySecretKeyValueKey] = string(secretKey) | ||||||
|  |  | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
|  |  | ||||||
| func (c *Client) GetS3Client(namespace string, config map[string]string) (s3Client *s3.Client, err error) { | func (c *Client) GetS3Client(namespace string, config map[string]string) (s3Client *s3.Client, err error) { | ||||||
| 	insecure, err := strconv.ParseBool(config[artifactRepositoryInsecureKey]) | 	insecure, err := strconv.ParseBool(config[ArtifactRepositoryInsecureKey]) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		log.WithFields(log.Fields{ | 		log.WithFields(log.Fields{ | ||||||
| 			"Namespace": namespace, | 			"Namespace": namespace, | ||||||
| @@ -142,10 +142,10 @@ func (c *Client) GetS3Client(namespace string, config map[string]string) (s3Clie | |||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 	s3Client, err = s3.NewClient(s3.Config{ | 	s3Client, err = s3.NewClient(s3.Config{ | ||||||
| 		Endpoint:  config[artifactRepositoryEndpointKey], | 		Endpoint:  config[ArtifactRepositoryEndpointKey], | ||||||
| 		Region:    config[artifactRepositoryRegionKey], | 		Region:    config[ArtifactRepositoryRegionKey], | ||||||
| 		AccessKey: config[artifactRepositoryAccessKeyValueKey], | 		AccessKey: config[ArtifactRepositoryAccessKeyValueKey], | ||||||
| 		SecretKey: config[artifactRepositorySecretKeyValueKey], | 		SecretKey: config[ArtifactRepositorySecretKeyValueKey], | ||||||
| 		InSecure:  insecure, | 		InSecure:  insecure, | ||||||
| 	}) | 	}) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
|   | |||||||
| @@ -812,7 +812,7 @@ func (c *Client) GetWorkflowExecutionLogs(namespace, name, podName, containerNam | |||||||
| 			return nil, util.NewUserError(codes.InvalidArgument, "Invaild range.") | 			return nil, util.NewUserError(codes.InvalidArgument, "Invaild range.") | ||||||
| 		} | 		} | ||||||
| 		opts.SetRange(0, int64(endOffset)) | 		opts.SetRange(0, int64(endOffset)) | ||||||
| 		stream, err = s3Client.GetObject(config[artifactRepositoryBucketKey], "artifacts/"+namespace+"/"+name+"/"+podName+"/"+containerName+".log", opts) | 		stream, err = s3Client.GetObject(config[ArtifactRepositoryBucketKey], "artifacts/"+namespace+"/"+name+"/"+podName+"/"+containerName+".log", opts) | ||||||
| 	} else { | 	} else { | ||||||
| 		stream, err = c.CoreV1().Pods(namespace).GetLogs(podName, &corev1.PodLogOptions{ | 		stream, err = c.CoreV1().Pods(namespace).GetLogs(podName, &corev1.PodLogOptions{ | ||||||
| 			Container:  containerName, | 			Container:  containerName, | ||||||
| @@ -891,7 +891,7 @@ func (c *Client) GetWorkflowExecutionMetrics(namespace, name, podName string) (m | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	opts := s3.GetObjectOptions{} | 	opts := s3.GetObjectOptions{} | ||||||
| 	stream, err = s3Client.GetObject(config[artifactRepositoryBucketKey], "artifacts/"+namespace+"/"+name+"/"+podName+"/sys-metrics.json", opts) | 	stream, err = s3Client.GetObject(config[ArtifactRepositoryBucketKey], "artifacts/"+namespace+"/"+name+"/"+podName+"/sys-metrics.json", opts) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		log.WithFields(log.Fields{ | 		log.WithFields(log.Fields{ | ||||||
| 			"Namespace": namespace, | 			"Namespace": namespace, | ||||||
| @@ -1010,7 +1010,7 @@ func (c *Client) GetArtifact(namespace, name, key string) (data []byte, err erro | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	opts := s3.GetObjectOptions{} | 	opts := s3.GetObjectOptions{} | ||||||
| 	stream, err := s3Client.GetObject(config[artifactRepositoryBucketKey], key, opts) | 	stream, err := s3Client.GetObject(config[ArtifactRepositoryBucketKey], key, opts) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		log.WithFields(log.Fields{ | 		log.WithFields(log.Fields{ | ||||||
| 			"Namespace": namespace, | 			"Namespace": namespace, | ||||||
| @@ -1050,7 +1050,7 @@ func (c *Client) ListFiles(namespace, key string) (files []*File, err error) { | |||||||
|  |  | ||||||
| 	doneCh := make(chan struct{}) | 	doneCh := make(chan struct{}) | ||||||
| 	defer close(doneCh) | 	defer close(doneCh) | ||||||
| 	for objInfo := range s3Client.ListObjectsV2(config[artifactRepositoryBucketKey], key, false, doneCh) { | 	for objInfo := range s3Client.ListObjectsV2(config[ArtifactRepositoryBucketKey], key, false, doneCh) { | ||||||
| 		if objInfo.Key == key { | 		if objInfo.Key == key { | ||||||
| 			continue | 			continue | ||||||
| 		} | 		} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 rushtehrani
					rushtehrani