public static K8sDeployment GetMyDeployment()

in src/ApplicationInsights.Kubernetes/EntityExtensions/ReplicaSetExtensions.cs [9:23]


        public static K8sDeployment GetMyDeployment(this K8sReplicaSet self, IEnumerable<K8sDeployment> scope)
        {
            IDictionary<string, string> replicaLabels = self.Metadata.Labels;

            foreach (K8sDeployment deployment in scope)
            {
                IDictionary<string, string> matchRule = deployment.Spec.Selector.MatchLabels;
                if (matchRule.Intersect(replicaLabels).Count() == matchRule.Count)
                {
                    // All labels are matched
                    return deployment;
                }
            }
            return null;
        }