istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pkg/test/echo/server/endpoint/grpcbootstrap.go (about)

     1  // Copyright Istio Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package endpoint
    16  
    17  import "encoding/json"
    18  
    19  // Mirror types from grpc to avoid pulling in a bunch of deps
    20  
    21  const FileWatcherCertProviderName = "file_watcher"
    22  
    23  type FileWatcherCertProviderConfig struct {
    24  	CertificateFile   string          `json:"certificate_file,omitempty"`
    25  	PrivateKeyFile    string          `json:"private_key_file,omitempty"`
    26  	CACertificateFile string          `json:"ca_certificate_file,omitempty"`
    27  	RefreshDuration   json.RawMessage `json:"refresh_interval,omitempty"`
    28  }
    29  
    30  // FileWatcherProvider returns the FileWatcherCertProviderConfig if one exists in CertProviders
    31  func (b *Bootstrap) FileWatcherProvider() *FileWatcherCertProviderConfig {
    32  	if b == nil || b.CertProviders == nil {
    33  		return nil
    34  	}
    35  	for _, provider := range b.CertProviders {
    36  		if provider.PluginName == FileWatcherCertProviderName {
    37  			return &provider.Config
    38  		}
    39  	}
    40  	return nil
    41  }
    42  
    43  type Bootstrap struct {
    44  	CertProviders map[string]CertificateProvider `json:"certificate_providers,omitempty"`
    45  }
    46  
    47  type CertificateProvider struct {
    48  	PluginName string                        `json:"plugin_name,omitempty"`
    49  	Config     FileWatcherCertProviderConfig `json:"config,omitempty"`
    50  }