istio.io/istio@v0.0.0-20240520182934-d79c90f27776/operator/cmd/mesh/profile.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 mesh
    16  
    17  import (
    18  	"github.com/spf13/cobra"
    19  
    20  	"istio.io/istio/istioctl/pkg/cli"
    21  )
    22  
    23  // ProfileCmd is a group of commands related to profile listing, dumping and diffing.
    24  func ProfileCmd(_ cli.Context) *cobra.Command {
    25  	pc := &cobra.Command{
    26  		Use:   "profile",
    27  		Short: "Commands related to Istio configuration profiles",
    28  		Long:  "The profile command lists, dumps or diffs Istio configuration profiles.",
    29  		Example: "istioctl profile list\n" +
    30  			"istioctl install --set profile=demo  # Use a profile from the list",
    31  	}
    32  
    33  	pdArgs := &profileDumpArgs{}
    34  	plArgs := &profileListArgs{}
    35  	pdfArgs := &profileDiffArgs{}
    36  	args := &RootArgs{}
    37  
    38  	plc := profileListCmd(plArgs)
    39  	pdc := profileDumpCmd(pdArgs)
    40  	pdfc := profileDiffCmd(pdfArgs)
    41  
    42  	addFlags(pc, args)
    43  	addFlags(plc, args)
    44  	addFlags(pdc, args)
    45  	addFlags(pdfc, args)
    46  
    47  	addProfileDumpFlags(pdc, pdArgs)
    48  	addProfileListFlags(plc, plArgs)
    49  	addProfileDiffFlags(pdfc, pdfArgs)
    50  
    51  	pc.AddCommand(plc)
    52  	pc.AddCommand(pdc)
    53  	pc.AddCommand(pdfc)
    54  
    55  	return pc
    56  }