Skip to content

Commit 4d86018

Browse files
HamzaHamza Bharmal
authored andcommitted
Update to use default values, Support single-trusted-profile
Signed-off-by: Hamza Bharmal <[email protected]>
1 parent 04058a8 commit 4d86018

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

code-engine-cos2cos/main.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ import (
1212
func main() {
1313
fmt.Println("Starting application with Job Index:", os.Getenv("JOB_INDEX"))
1414

15-
// Setting default values
16-
os.Setenv("IBM_COS_CRTokenFilePath_PRIMARY", "/var/run/secrets/codeengine.cloud.ibm.com/compute-resource-token/token")
17-
os.Setenv("IBM_COS_CRTokenFilePath_SECONDARY", "/var/run/secrets/codeengine.cloud.ibm.com/compute-resource-token/token")
18-
os.Setenv("BUCKET_TIMESTAMP_FILENAME", "last_modified_time.json")
19-
2015
fmt.Println("Any errors while processing objects:", processingMain())
2116

2217
fmt.Println("Closing application")
@@ -27,34 +22,36 @@ func main() {
2722
func processingMain() error {
2823
var cosClient_PRIMARY, cosClient_SECONDARY *s3.S3
2924

25+
// CR Token_FilePath (stays default)
26+
crTokenFilePath := "/var/run/secrets/codeengine.cloud.ibm.com/compute-resource-token/token"
27+
3028
// Create a cosClient using Trusted Profile
31-
cosClient_PRIMARY = bucketOperations.NewCosClientTrustedProfile(os.Getenv("IBM_COS_TRUSTED_PROFILE_ID_PRIMARY"),
32-
os.Getenv("IBM_COS_CRTokenFilePath_PRIMARY"),
29+
cosClient_PRIMARY = bucketOperations.NewCosClientTrustedProfile(os.Getenv("IBM_COS_TRUSTED_PROFILE_ID"),
30+
crTokenFilePath,
3331
os.Getenv("IBM_COS_RESOURCE_INSTANCE_ID_PRIMARY"),
3432
os.Getenv("IBM_COS_ENDPOINT_PRIMARY"),
3533
os.Getenv("IBM_COS_REGION_PRIMARY"),
3634
)
3735

38-
cosClient_SECONDARY = bucketOperations.NewCosClientTrustedProfile(os.Getenv("IBM_COS_TRUSTED_PROFILE_ID_SECONDARY"),
39-
os.Getenv("IBM_COS_CRTokenFilePath_SECONDARY"),
36+
cosClient_SECONDARY = bucketOperations.NewCosClientTrustedProfile(os.Getenv("IBM_COS_TRUSTED_PROFILE_ID"),
37+
crTokenFilePath,
4038
os.Getenv("IBM_COS_RESOURCE_INSTANCE_ID_SECONDARY"),
4139
os.Getenv("IBM_COS_ENDPOINT_SECONDARY"),
4240
os.Getenv("IBM_COS_REGION_SECONDARY"),
4341
)
4442

4543
// Creating Primary bucket instance
4644
primary_bucket := bucketOperations.NewBucket(
47-
os.Getenv("PRIMARY_COS_BUCKET_NAME"),
45+
os.Getenv("COS_BUCKET_NAME_PRIMARY"),
4846
cosClient_PRIMARY,
4947
)
5048

5149
// Creating secondary bucket instance
5250
secondary_bucket := bucketOperations.NewBucket(
53-
os.Getenv("SECONDARY_COS_BUCKET_NAME"),
51+
os.Getenv("COS_BUCKET_NAME_SECONDARY"),
5452
cosClient_SECONDARY,
5553
)
5654
// Initiate the process from primary bucket to secondary bucket
57-
// err := process.StartProcessing(primary_bucket, secondary_bucket)
5855
err := process.StartProcessingPagination(primary_bucket, secondary_bucket)
5956
if err != nil {
6057
return fmt.Errorf("\nProcessing failed: %v", err)

0 commit comments

Comments
 (0)