...

Source file src/github.com/chaos-mesh/chaos-mesh/controllers/chaosimpl/httpchaos/podhttpchaosmanager/builder.go

Documentation: github.com/chaos-mesh/chaos-mesh/controllers/chaosimpl/httpchaos/podhttpchaosmanager

     1  // Copyright 2021 Chaos Mesh 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  
    16  package podhttpchaosmanager
    17  
    18  import (
    19  	"github.com/go-logr/logr"
    20  	"go.uber.org/fx"
    21  	"k8s.io/apimachinery/pkg/runtime"
    22  	"k8s.io/apimachinery/pkg/types"
    23  	"sigs.k8s.io/controller-runtime/pkg/client"
    24  )
    25  
    26  type Builder struct {
    27  	Log logr.Logger
    28  	client.Client
    29  	client.Reader
    30  	scheme *runtime.Scheme
    31  }
    32  
    33  type Params struct {
    34  	fx.In
    35  
    36  	Logger logr.Logger
    37  	Client client.Client
    38  	Reader client.Reader `name:"no-cache"`
    39  	Scheme *runtime.Scheme
    40  }
    41  
    42  func NewBuilder(params Params) *Builder {
    43  	return &Builder{
    44  		Log:    params.Logger,
    45  		Client: params.Client,
    46  		Reader: params.Reader,
    47  		scheme: params.Scheme,
    48  	}
    49  }
    50  
    51  func (b *Builder) WithInit(source string, key types.NamespacedName) *PodHttpManager {
    52  	t := &PodHttpTransaction{}
    53  	t.Clear(source)
    54  
    55  	return &PodHttpManager{
    56  		Source: source,
    57  		Log:    b.Log,
    58  		Client: b.Client,
    59  		Reader: b.Reader,
    60  		scheme: b.scheme,
    61  
    62  		Key: key,
    63  		T:   t,
    64  	}
    65  }
    66