
                             d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddl	mZ  G d d	ej                  ej                  e
j                        Zy
)z.Manages content bundles for Policy Controller.    )absolute_import)division)unicode_literals)base)command)contentc                   4    e Zd ZdZdZdZed        Zd Zd Z	y)Seta  Sets bundle installation for Policy Controller content.

  Google-defined policy bundles of constraints can be installed onto Policy
  Controller installations.

  The namespace exclusion flag (`--exempted-namespaces`) will specify a set of
  namespaces that the installed bundle will ignore. Subsequent calls with the
  same bundle name and this flag will overwrite what namespaces are being
  ignored. Using `--no-exempted-namespaces` or specifying no namespaces with
  `--exempted-namespaces` will remove all namespaces from the ignore list.

  To uninstall a bundle, use the `remove` command.

  ## EXAMPLES

  To install a policy bundle:

    $ {command} cis-k8s-v1.5.1

  To install a policy bundle, while ignoring (exempting) certain namespaces from
  being affected by the bundle:

    $ {command} cis-k8s-v1.5.1
        --exempted-namespaces=kube-system,gatekeeper-system

  To remove all exempted namespaces from a particular bundles ignore list:

    $ {command} cis-k8s-v1.5.1 --no-exempted-namespaces
  policycontrollerc                     t        j                  |d      }|j                          |j                          |j	                  t         j
                  d       y )Nbundlesz6The constraint bundle to install in Policy Controller.)help)r   Flagsadd_membershipsadd_exempted_namespacesadd_argumentARG_LABEL_BUNDLE)clsparser	cmd_flagss      Clib/surface/container/fleet/policycontroller/content/bundles/set.pyArgszSet.Args<   sI    fi0I%%'
  E      c           	          t        j                  || j                        }| j                  |d      }|j	                         D ci c]  \  }}|| j                  ||       }}}| j                  |      S c c}}w )NT)r   
FlagParsermessages
path_specsitemsmodifyupdate_specs)selfargsr   specspathsupdated_specss          r   RunzSet.RunG   sm    dmm4FOOD$'EAFOgdAT4;;q&11MO]++ Ps   A7c                     |j                   j                  j                  }|j                  |      |j                   j                  _        |S )N)r   policyControllerHubConfigpolicyContentinstall_bundle)r!   specr   policy_contents       r   r   z
Set.modifyM   sG    77EE  	n- 	33A Kr   N)
__name__
__module____qualname____doc__feature_namemf_nameclassmethodr   r'   r    r   r   r
   r
      s/    < $,' ,r   r
   N)r1   
__future__r   r   r   3googlecloudsdk.command_lib.container.fleet.featuresr   =googlecloudsdk.command_lib.container.fleet.membershipfeaturesmf_base;googlecloudsdk.command_lib.container.fleet.policycontrollerr   r   UpdateCommandPocoCommandr
   r5   r   r   <module>r=      sA    5 &  ' D Y O O:$

g33W5H5H :r   