// DetermineSecretName resolves the name of the secret that corresponds to the supplied component name and port
DetermineSecretName resolves the name of the secret that corresponds to the supplied component name and port
// DetermineSecretName resolves the name of the secret that corresponds to the supplied component name and port
func DetermineSecretName(client *occlient.Client, componentName, applicationName, port string) (string, error) {
	labelSelector := fmt.Sprintf("%v=%v", applabels.ApplicationLabel, applicationName) +
		fmt.Sprintf(",%v=%v", componentlabels.ComponentLabel, componentName)
	secrets, err := client.ListSecrets(labelSelector)
	if err != nil {
		return "", err
	}
	if len(secrets) == 0 {
		return "", fmt.Errorf(`A secret should have been created for component %s. 
Please delete the component and recreate it using 'odo create'`, componentName)
	}
	if len(port) == 0 {
		if len(secrets) == 1 {
			return secrets[0].Name, nil
		}
		return "", fmt.Errorf(`Multiple secrets exist for component %s. 
Please select one of the following ports: '%s'`, componentName, strings.Join(availablePorts(secrets), ","))
	}
	for _, secret := range secrets {
		if secret.Annotations[occlient.ComponentPortAnnotationName] == port {
			return secret.Name, nil
		}
	}
	return "", fmt.Errorf(`None of the secrets that exist for component %s match port %s. 
Please select one of the following ports: '%s'`, componentName, port, strings.Join(availablePorts(secrets), ","))
}
func DetermineSecretName ( client * occlient . Client , componentName , applicationName , port string ) ( string , error ) { labelSelector := fmt . Sprintf ( " " , applabels . ApplicationLabel , applicationName ) + fmt . Sprintf ( " " , componentlabels . ComponentLabel , componentName ) secrets , err := client . ListSecrets ( labelSelector ) if err != nil { return " " , err } if len ( secrets ) == 0 { return " " , fmt . Errorf ( `A secret should have been created for component %s. 
Please delete the component and recreate it using 'odo create'` , componentName ) } if len ( port ) == 0 { if len ( secrets ) == 1 { return secrets [ 0 ] . Name , nil } return " " , fmt . Errorf ( `Multiple secrets exist for component %s. 
Please select one of the following ports: '%s'` , componentName , strings . Join ( availablePorts ( secrets ) , " " ) ) } for _ , secret := range secrets { if secret . Annotations [ occlient . ComponentPortAnnotationName ] == port { return secret . Name , nil } } return " " , fmt . Errorf ( `None of the secrets that exist for component %s match port %s. 
Please select one of the following ports: '%s'` , componentName , port , strings . Join ( availablePorts ( secrets ) , " " ) ) }
DetermineSecretName resolves the name of the secret that corresponds to the supplied component name and port
DetermineSecretName resolves the name of the secret that corresponds to the supplied component name and port
// when the port is not supplied, then we either select the only one exposed is so is the case, // or when there multiple ports exposed, we fail // search each secret to see which port is corresponds to