istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pkg/test/framework/resource/config/apply/option.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 apply
    16  
    17  import "istio.io/istio/pkg/test/framework/resource/config/cleanup"
    18  
    19  // Option is a strategy for updating Options.
    20  type Option interface {
    21  	// Set this option on the provided Options
    22  	Set(*Options)
    23  }
    24  
    25  // OptionFunc is a function-based Option.
    26  type OptionFunc func(*Options)
    27  
    28  // Set just invokes this function to update the Options.
    29  func (f OptionFunc) Set(opts *Options) {
    30  	f(opts)
    31  }
    32  
    33  // NoCleanup is an Option that disables config cleanup.
    34  var NoCleanup Option = OptionFunc(func(opts *Options) {
    35  	opts.Cleanup = cleanup.None
    36  })
    37  
    38  // CleanupConditionally is an Option that sets Cleanup = cleanup.Conditionally.
    39  var CleanupConditionally Option = OptionFunc(func(opts *Options) {
    40  	opts.Cleanup = cleanup.Conditionally
    41  })
    42  
    43  // Wait configures the Options to wait for configuration to propagate.
    44  // This method currently does nothing, due to https://github.com/istio/istio/issues/37148
    45  var Wait Option = OptionFunc(func(opts *Options) {
    46  	// opts.Wait = true
    47  })