github.com/mirantis/virtlet@v1.5.2-0.20191204181327-1659b8a48e9b/pkg/imagetranslation/interface.go (about) 1 /* 2 Copyright 2017 Mirantis 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package imagetranslation 18 19 import ( 20 "context" 21 22 "github.com/Mirantis/virtlet/pkg/api/virtlet.k8s/v1" 23 "github.com/Mirantis/virtlet/pkg/image" 24 ) 25 26 // TranslationConfig represents a single config (prefix + rule list) in a config-set 27 type TranslationConfig interface { 28 // ConfigName returns the config name (any string identifier) 29 ConfigName() string 30 31 // Payload returns ImageTranslation object associated with the config 32 Payload() (v1.ImageTranslation, error) 33 } 34 35 // ConfigSource is the data-source for translation configs 36 type ConfigSource interface { 37 // Configs returns list of configs that are available in this data source 38 Configs(ctx context.Context) ([]TranslationConfig, error) 39 40 // Description returns the data-source description to be used in the logs 41 Description() string 42 } 43 44 // ImageNameTranslator is the main translator interface 45 type ImageNameTranslator interface { 46 // LoadConfigs initializes translator with configs from supplied data sources. All previous mappings are discarded. 47 LoadConfigs(ctx context.Context, sources ...ConfigSource) 48 49 // Translate translates image name to ins Endpoint. If no suitable mapping was found, the default Endpoint is returned 50 Translate(name string) image.Endpoint 51 }