github.com/LukasHeimann/cloudfoundrycli/v8@v8.4.4/command/v7/bind_running_security_group_command.go (about)

     1  package v7
     2  
     3  import (
     4  	"github.com/LukasHeimann/cloudfoundrycli/v8/api/cloudcontroller/ccv3/constant"
     5  	"github.com/LukasHeimann/cloudfoundrycli/v8/command/flag"
     6  )
     7  
     8  type BindRunningSecurityGroupCommand struct {
     9  	BaseCommand
    10  
    11  	SecurityGroup   flag.SecurityGroup `positional-args:"yes"`
    12  	usage           interface{}        `usage:"CF_NAME bind-running-security-group SECURITY_GROUP\n\nTIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart (for running) or restage (for staging) to apply to existing applications."`
    13  	relatedCommands interface{}        `related_commands:"apps, bind-security-group, bind-staging-security-group, restart, running-security-groups, security-groups"`
    14  }
    15  
    16  func (cmd BindRunningSecurityGroupCommand) Execute(args []string) error {
    17  	var err error
    18  
    19  	err = cmd.SharedActor.CheckTarget(false, false)
    20  	if err != nil {
    21  		return err
    22  	}
    23  
    24  	user, err := cmd.Actor.GetCurrentUser()
    25  	if err != nil {
    26  		return err
    27  	}
    28  
    29  	cmd.UI.DisplayTextWithFlavor("Binding security group {{.security_group}} to running as {{.username}}...", map[string]interface{}{
    30  		"security_group": cmd.SecurityGroup.SecurityGroup,
    31  		"username":       user.Name,
    32  	})
    33  
    34  	warnings, err := cmd.Actor.UpdateSecurityGroupGloballyEnabled(cmd.SecurityGroup.SecurityGroup, constant.SecurityGroupLifecycleRunning, true)
    35  	cmd.UI.DisplayWarnings(warnings)
    36  	if err != nil {
    37  		return err
    38  	}
    39  	cmd.UI.DisplayOK()
    40  
    41  	cmd.UI.DisplayText("TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart (for running) or restage (for staging) to apply to existing applications.")
    42  
    43  	return nil
    44  }