Esempio n. 1
0
        private static async Task <Platform> LoadInstanceAsync()
        {
            // The order matters here:
            // * GAE runs on GCE, so do GAE before GCE.
            // * GKE runs on GCE, so do GKE before GCE.
            // * Metadata server access can take time, so do GAE first.
            GaePlatformDetails gaeDetails = LoadGaeDetails();

            if (gaeDetails != null)
            {
                return(new Platform(gaeDetails));
            }
            var metadataJson = await LoadMetadataAsync().ConfigureAwait(false);

            if (metadataJson != null)
            {
                var kubernetesData = await GkePlatformDetails.LoadKubernetesDataAsync().ConfigureAwait(false);

                if (kubernetesData != null)
                {
                    GkePlatformDetails gkeDetails = GkePlatformDetails.TryLoad(metadataJson, kubernetesData);
                    if (gkeDetails != null)
                    {
                        return(new Platform(gkeDetails));
                    }
                }
                GcePlatformDetails gceDetails = GcePlatformDetails.TryLoad(metadataJson);
                if (gceDetails != null)
                {
                    return(new Platform(gceDetails));
                }
            }
            return(new Platform());
        }
Esempio n. 2
0
 /// <summary>
 /// Construct with details of Google Container (Kubernetes) Engine.
 /// </summary>
 /// <param name="gkeDetails">Details of Google Container (Kubernetes) Engine.</param>
 public Platform(GkePlatformDetails gkeDetails)
 {
     GkeDetails = GaxPreconditions.CheckNotNull(gkeDetails, nameof(gkeDetails));
 }
Esempio n. 3
0
 public static GkePlatformDetails TryLoad(string metadataJson) =>
 TryLoad(metadataJson, GkePlatformDetails.LoadKubernetesDataAsync().Result);