Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 69 additions & 69 deletions google-cloud-sdk/data/cli/gcloud_completions.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class InvalidRepositoryError(exceptions.Error):
"""Attempted to fetch or clone from a repository missing something basic.

This gets raised if we try to fetch or clone from a repo that is either
missing a HEAD or missing both a "latest" tag and a master branch.
missing a HEAD or missing both a "latest" tag and a main branch.
"""


Expand Down Expand Up @@ -149,7 +149,7 @@ def _PullTags(local_repo, client_wrapper, target_dir):

Returns:
(str, dulwich.objects.Commit) The tag that was actually pulled (we try to
get "latest" but fall back to "master") and the commit object
get "latest" but fall back to "main") and the commit object
associated with it.

Raises:
Expand All @@ -166,7 +166,7 @@ def _PullTags(local_repo, client_wrapper, target_dir):
# Try to get the "latest" tag (latest released version)
revision = None
tag = None
for tag in (b'refs/tags/latest', b'refs/heads/master'):
for tag in (b'refs/tags/latest', b'refs/heads/main'):
try:
log.debug('looking up ref %s', tag)
revision = local_repo[tag]
Expand All @@ -175,7 +175,7 @@ def _PullTags(local_repo, client_wrapper, target_dir):
log.warning('Unable to checkout branch %s', tag)

else:
raise AssertionError('No "refs/heads/master" tag found in repository.')
raise AssertionError('No "refs/heads/main" tag found in repository.')

return tag, revision

Expand Down Expand Up @@ -260,7 +260,7 @@ def InstallRuntimeDef(url, target_dir):
directory. At this time, the runtime definition url must be the URL of a
git repository and we identify the tree to checkout based on 1) the presence
of a "latest" tag ("refs/tags/latest") 2) if there is no "latest" tag, the
head of the "master" branch ("refs/heads/master").
head of the "main" branch ("refs/heads/main").

Args:
url: (str) A URL identifying a git repository. The HTTP, TCP and local
Expand Down
120 changes: 60 additions & 60 deletions google-cloud-sdk/lib/googlecloudsdk/api_lib/container/api_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
"""

MISMATCH_AUTHORIZED_NETWORKS_ERROR_MSG = """\
Cannot use --master-authorized-networks \
if --enable-master-authorized-networks is not \
Cannot use --main-authorized-networks \
if --enable-main-authorized-networks is not \
specified."""

NO_AUTOPROVISIONING_MSG = """\
Expand Down Expand Up @@ -352,8 +352,8 @@ def __init__(self,
enable_autorepair=None,
enable_autoupgrade=None,
service_account=None,
enable_master_authorized_networks=None,
master_authorized_networks=None,
enable_main_authorized_networks=None,
main_authorized_networks=None,
enable_legacy_authorization=None,
labels=None,
disk_type=None,
Expand All @@ -373,7 +373,7 @@ def __init__(self,
private_cluster=None,
enable_private_nodes=None,
enable_private_endpoint=None,
master_ipv4_cidr=None,
main_ipv4_cidr=None,
tpu_ipv4_cidr=None,
enable_tpu=None,
enable_tpu_service_networking=None,
Expand Down Expand Up @@ -428,8 +428,8 @@ def __init__(self,
self.enable_autorepair = enable_autorepair
self.enable_autoupgrade = enable_autoupgrade
self.service_account = service_account
self.enable_master_authorized_networks = enable_master_authorized_networks
self.master_authorized_networks = master_authorized_networks
self.enable_main_authorized_networks = enable_main_authorized_networks
self.main_authorized_networks = main_authorized_networks
self.enable_legacy_authorization = enable_legacy_authorization
self.enable_network_policy = enable_network_policy
self.labels = labels
Expand All @@ -449,7 +449,7 @@ def __init__(self,
self.private_cluster = private_cluster
self.enable_private_nodes = enable_private_nodes
self.enable_private_endpoint = enable_private_endpoint
self.master_ipv4_cidr = master_ipv4_cidr
self.main_ipv4_cidr = main_ipv4_cidr
self.tpu_ipv4_cidr = tpu_ipv4_cidr
self.enable_tpu_service_networking = enable_tpu_service_networking
self.enable_tpu = enable_tpu
Expand All @@ -472,7 +472,7 @@ class UpdateClusterOptions(object):

def __init__(self,
version=None,
update_master=None,
update_main=None,
update_nodes=None,
node_pool=None,
monitoring_service=None,
Expand All @@ -486,8 +486,8 @@ def __init__(self,
image=None,
image_project=None,
locations=None,
enable_master_authorized_networks=None,
master_authorized_networks=None,
enable_main_authorized_networks=None,
main_authorized_networks=None,
enable_autoprovisioning=None,
enable_pod_security_policy=None,
enable_binauthz=None,
Expand All @@ -496,7 +496,7 @@ def __init__(self,
security_profile=None,
security_profile_runtime_rules=None):
self.version = version
self.update_master = bool(update_master)
self.update_main = bool(update_main)
self.update_nodes = bool(update_nodes)
self.node_pool = node_pool
self.monitoring_service = monitoring_service
Expand All @@ -510,8 +510,8 @@ def __init__(self,
self.image = image
self.image_project = image_project
self.locations = locations
self.enable_master_authorized_networks = enable_master_authorized_networks
self.master_authorized_networks = master_authorized_networks
self.enable_main_authorized_networks = enable_main_authorized_networks
self.main_authorized_networks = main_authorized_networks
self.enable_autoprovisioning = enable_autoprovisioning
self.enable_pod_security_policy = enable_pod_security_policy
self.enable_binauthz = enable_binauthz
Expand All @@ -521,8 +521,8 @@ def __init__(self,
self.security_profile_runtime_rules = security_profile_runtime_rules


class SetMasterAuthOptions(object):
"""Options to pass to SetMasterAuth."""
class SetMainAuthOptions(object):
"""Options to pass to SetMainAuth."""

SET_PASSWORD = 'SetPassword'
GENERATE_PASSWORD = 'GeneratePassword'
Expand Down Expand Up @@ -836,7 +836,7 @@ def CreateClusterCommon(self, cluster_ref, options):
NETWORK_POLICY not in options.addons))
cluster.addonsConfig = addons

self.ParseMasterAuthorizedNetworkOptions(options, cluster)
self.ParseMainAuthorizedNetworkOptions(options, cluster)

if options.enable_kubernetes_alpha:
cluster.enableKubernetesAlpha = options.enable_kubernetes_alpha
Expand Down Expand Up @@ -900,16 +900,16 @@ def CreateClusterCommon(self, cluster_ref, options):
elif options.enable_network_egress_metering is not None:
raise util.Error(ENABLE_NETWORK_EGRESS_METERING_ERROR_MSG)

# Only instantiate the masterAuth struct if one or both of `user` or
# Only instantiate the mainAuth struct if one or both of `user` or
# `issue_client_certificate` is configured. Server-side Basic auth default
# behavior is dependent on the absence of the MasterAuth struct. For this
# behavior is dependent on the absence of the MainAuth struct. For this
# reason, if only `issue_client_certificate` is configured, Basic auth will
# be disabled.
if options.user is not None or options.issue_client_certificate is not None:
cluster.masterAuth = self.messages.MasterAuth(
cluster.mainAuth = self.messages.MainAuth(
username=options.user, password=options.password)
if options.issue_client_certificate is not None:
cluster.masterAuth.clientCertificateConfig = (
cluster.mainAuth.clientCertificateConfig = (
self.messages.ClientCertificateConfig(
issueClientCertificate=options.issue_client_certificate))

Expand Down Expand Up @@ -1114,16 +1114,16 @@ def ParsePrivateClusterOptions(self, options, cluster):
prerequisite='enable-private-nodes',
opt='enable-private-endpoint'))

if options.master_ipv4_cidr and not options.enable_private_nodes:
if options.main_ipv4_cidr and not options.enable_private_nodes:
raise util.Error(
PREREQUISITE_OPTION_ERROR_MSG.format(
prerequisite='enable-private-nodes', opt='master-ipv4-cidr'))
prerequisite='enable-private-nodes', opt='main-ipv4-cidr'))

if options.enable_private_nodes:
config = self.messages.PrivateClusterConfig(
enablePrivateNodes=options.enable_private_nodes,
enablePrivateEndpoint=options.enable_private_endpoint,
masterIpv4CidrBlock=options.master_ipv4_cidr)
mainIpv4CidrBlock=options.main_ipv4_cidr)
cluster.privateClusterConfig = config
return cluster

Expand Down Expand Up @@ -1151,19 +1151,19 @@ def ParseTpuOptions(self, options, cluster):
if options.enable_tpu:
cluster.enableTpu = options.enable_tpu

def ParseMasterAuthorizedNetworkOptions(self, options, cluster):
"""Parses the options for master authorized networks."""
if options.enable_master_authorized_networks:
authorized_networks = self.messages.MasterAuthorizedNetworksConfig(
enabled=options.enable_master_authorized_networks)
if options.master_authorized_networks:
for network in options.master_authorized_networks:
def ParseMainAuthorizedNetworkOptions(self, options, cluster):
"""Parses the options for main authorized networks."""
if options.enable_main_authorized_networks:
authorized_networks = self.messages.MainAuthorizedNetworksConfig(
enabled=options.enable_main_authorized_networks)
if options.main_authorized_networks:
for network in options.main_authorized_networks:
authorized_networks.cidrBlocks.append(self.messages.CidrBlock(
cidrBlock=network))
cluster.masterAuthorizedNetworksConfig = authorized_networks
elif options.master_authorized_networks:
# Raise error if use --master-authorized-networks without
# --enable-master-authorized-networks.
cluster.mainAuthorizedNetworksConfig = authorized_networks
elif options.main_authorized_networks:
# Raise error if use --main-authorized-networks without
# --enable-main-authorized-networks.
raise util.Error(MISMATCH_AUTHORIZED_NETWORKS_ERROR_MSG)

def CreateCluster(self, cluster_ref, options):
Expand Down Expand Up @@ -1193,9 +1193,9 @@ def UpdateClusterCommon(self, options):
if options.security_profile is not None:
update.securityProfile = self.messages.SecurityProfile(
name=options.security_profile)
elif options.update_master:
elif options.update_main:
update = self.messages.ClusterUpdate(
desiredMasterVersion=options.version)
desiredMainVersion=options.version)
# security_profile may be set in upgrade command
if options.security_profile is not None:
update.securityProfile = self.messages.SecurityProfile(
Expand Down Expand Up @@ -1225,16 +1225,16 @@ def UpdateClusterCommon(self, options):
desiredNodePoolAutoscaling=autoscaling)
elif options.locations:
update = self.messages.ClusterUpdate(desiredLocations=options.locations)
elif options.enable_master_authorized_networks is not None:
elif options.enable_main_authorized_networks is not None:
# For update, we can either enable or disable.
authorized_networks = self.messages.MasterAuthorizedNetworksConfig(
enabled=options.enable_master_authorized_networks)
if options.master_authorized_networks:
for network in options.master_authorized_networks:
authorized_networks = self.messages.MainAuthorizedNetworksConfig(
enabled=options.enable_main_authorized_networks)
if options.main_authorized_networks:
for network in options.main_authorized_networks:
authorized_networks.cidrBlocks.append(self.messages.CidrBlock(
cidrBlock=network))
update = self.messages.ClusterUpdate(
desiredMasterAuthorizedNetworksConfig=authorized_networks)
desiredMainAuthorizedNetworksConfig=authorized_networks)
elif options.enable_autoprovisioning is not None:
autoscaling = self.CreateClusterAutoscalingCommon(options)
update = self.messages.ClusterUpdate(
Expand Down Expand Up @@ -1288,10 +1288,10 @@ def UpdateClusterCommon(self, options):
and options.security_profile_runtime_rules is not None):
update.securityProfile.disableRuntimeRules = \
not options.security_profile_runtime_rules
if (options.master_authorized_networks
and not options.enable_master_authorized_networks):
# Raise error if use --master-authorized-networks without
# --enable-master-authorized-networks.
if (options.main_authorized_networks
and not options.enable_main_authorized_networks):
# Raise error if use --main-authorized-networks without
# --enable-main-authorized-networks.
raise util.Error(MISMATCH_AUTHORIZED_NETWORKS_ERROR_MSG)
return update

Expand Down Expand Up @@ -1422,29 +1422,29 @@ def SetNetworkPolicy(self, cluster_ref, options):
self.client.projects_locations_clusters.SetNetworkPolicy(req).name,
cluster_ref.zone)

def SetMasterAuthCommon(self, options):
"""Returns a SetMasterAuth action."""
update = self.messages.MasterAuth(
def SetMainAuthCommon(self, options):
"""Returns a SetMainAuth action."""
update = self.messages.MainAuth(
username=options.username, password=options.password)
if options.action == SetMasterAuthOptions.SET_PASSWORD:
action = (self.messages.SetMasterAuthRequest.
if options.action == SetMainAuthOptions.SET_PASSWORD:
action = (self.messages.SetMainAuthRequest.
ActionValueValuesEnum.SET_PASSWORD)
elif options.action == SetMasterAuthOptions.GENERATE_PASSWORD:
action = (self.messages.SetMasterAuthRequest.
elif options.action == SetMainAuthOptions.GENERATE_PASSWORD:
action = (self.messages.SetMainAuthRequest.
ActionValueValuesEnum.GENERATE_PASSWORD)
else: # options.action == SetMasterAuthOptions.SET_USERNAME
else: # options.action == SetMainAuthOptions.SET_USERNAME
action = (
self.messages.SetMasterAuthRequest.ActionValueValuesEnum.SET_USERNAME)
self.messages.SetMainAuthRequest.ActionValueValuesEnum.SET_USERNAME)
return update, action

def SetMasterAuth(self, cluster_ref, options):
update, action = self.SetMasterAuthCommon(options)
req = self.messages.SetMasterAuthRequest(
def SetMainAuth(self, cluster_ref, options):
update, action = self.SetMainAuthCommon(options)
req = self.messages.SetMainAuthRequest(
name=ProjectLocationCluster(cluster_ref.projectId, cluster_ref.zone,
cluster_ref.clusterId),
action=action,
update=update)
op = self.client.projects_locations_clusters.SetMasterAuth(req)
op = self.client.projects_locations_clusters.SetMainAuth(req)
return self.ParseOperation(op.name, cluster_ref.zone)

def StartIpRotation(self, cluster_ref, rotate_credentials):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def _AuthProvider(name='gcp'):

Constructs an auth provider config entry readable by kubectl. This tells
kubectl to call out to a specific gcloud command and parse the output to
retrieve access tokens to authenticate to the kubernetes master.
retrieve access tokens to authenticate to the kubernetes main.
Kubernetes gcp auth provider plugin at
https://github.com/kubernetes/kubernetes/tree/master/staging/src/k8s.io/client-go/plugin/pkg/client/auth/gcp

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ def ParseExpireTime(s):
return expire_dt - times.Now(expire_dt.tzinfo)


def TransformMasterVersion(r, undefined=''):
"""Returns the formatted master version.
def TransformMainVersion(r, undefined=''):
"""Returns the formatted main version.

Args:
r: JSON-serializable object.
undefined: Returns this value if the resource cannot be formatted.
Returns:
The formatted master version.
The formatted main version.
"""
version = r.get('currentMasterVersion', None)
version = r.get('currentMainVersion', None)
if version is None:
return undefined
if r.get('enableKubernetesAlpha', False):
Expand All @@ -96,7 +96,7 @@ def TransformMasterVersion(r, undefined=''):


_TRANSFORMS = {
'master_version': TransformMasterVersion,
'main_version': TransformMainVersion,
}


Expand Down
4 changes: 2 additions & 2 deletions google-cloud-sdk/lib/googlecloudsdk/api_lib/container/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
table(
name,
zone:label=LOCATION,
master_version():label=MASTER_VERSION,
main_version():label=MASTER_VERSION,
endpoint:label=MASTER_IP,
nodePools[0].config.machineType,
currentNodeVersion:label=NODE_VERSION,
Expand Down Expand Up @@ -277,7 +277,7 @@ def Persist(cls, cluster, project_id, use_internal_ip=False):
'project_id': project_id,
'server': 'https://' + endpoint,
}
auth = cluster.masterAuth
auth = cluster.mainAuth
if auth and auth.clusterCaCertificate:
kwargs['ca_data'] = auth.clusterCaCertificate
else:
Expand Down
Loading