istio.io/istio@v0.0.0-20240520182934-d79c90f27776/tests/integration/telemetry/api/registry_setup_test.go (about) 1 //go:build integ 2 // +build integ 3 4 // Copyright Istio Authors. All Rights Reserved. 5 // 6 // Licensed under the Apache License, Version 2.0 (the "License"); 7 // you may not use this file except in compliance with the License. 8 // You may obtain a copy of the License at 9 // 10 // http://www.apache.org/licenses/LICENSE-2.0 11 // 12 // Unless required by applicable law or agreed to in writing, software 13 // distributed under the License is distributed on an "AS IS" BASIS, 14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 // See the License for the specific language governing permissions and 16 // limitations under the License. 17 18 package api 19 20 import ( 21 "encoding/base64" 22 "fmt" 23 24 "istio.io/istio/pkg/test/framework/components/registryredirector" 25 "istio.io/istio/pkg/test/framework/resource" 26 ) 27 28 var registry registryredirector.Instance 29 30 const ( 31 // Same user name and password as specified at pkg/test/fakes/imageregistry 32 registryUser = "user" 33 registryPasswd = "passwd" 34 ) 35 36 func testRegistrySetup(ctx resource.Context) (err error) { 37 registry, err = registryredirector.New(ctx, registryredirector.Config{ 38 Cluster: ctx.AllClusters().Default(), 39 }) 40 if err != nil { 41 return 42 } 43 44 return nil 45 } 46 47 func createDockerCredential(user, passwd, registry string) string { 48 credentials := `{ 49 "auths":{ 50 "%v":{ 51 "username": "%v", 52 "password": "%v", 53 "email": "test@example.com", 54 "auth": "%v" 55 } 56 } 57 }` 58 auth := base64.StdEncoding.EncodeToString([]byte(user + ":" + passwd)) 59 return fmt.Sprintf(credentials, registry, user, passwd, auth) 60 }