@Test void testGetNamedUserIndexFromConfig() { Config config = getTestKubeConfig(); int index = KubeConfigUtils.getNamedUserIndexFromConfig(config, "test/test-cluster:443"); assertEquals(2, index); }
public static int getNamedUserIndexFromConfig(Config config, String userName) { for (int i = 0; i < config.getUsers().size(); i++) { if (config.getUsers().get(i).getName().equals(userName)) { return i; } } return -1; }
KubeConfigUtils { public static int getNamedUserIndexFromConfig(Config config, String userName) { for (int i = 0; i < config.getUsers().size(); i++) { if (config.getUsers().get(i).getName().equals(userName)) { return i; } } return -1; } }
KubeConfigUtils { public static int getNamedUserIndexFromConfig(Config config, String userName) { for (int i = 0; i < config.getUsers().size(); i++) { if (config.getUsers().get(i).getName().equals(userName)) { return i; } } return -1; } private  KubeConfigUtils(); }
KubeConfigUtils { public static int getNamedUserIndexFromConfig(Config config, String userName) { for (int i = 0; i < config.getUsers().size(); i++) { if (config.getUsers().get(i).getName().equals(userName)) { return i; } } return -1; } private  KubeConfigUtils(); static Config parseConfig(File file); static Config parseConfigFromString(String contents); static NamedContext getCurrentContext(Config config); static String getUserToken(Config config, Context context); static AuthInfo getUserAuthInfo(Config config, Context context); static Cluster getCluster(Config config, Context context); static int getNamedUserIndexFromConfig(Config config, String userName); static void persistKubeConfigIntoFile(Config kubeConfig, String kubeConfigPath); }
KubeConfigUtils { public static int getNamedUserIndexFromConfig(Config config, String userName) { for (int i = 0; i < config.getUsers().size(); i++) { if (config.getUsers().get(i).getName().equals(userName)) { return i; } } return -1; } private  KubeConfigUtils(); static Config parseConfig(File file); static Config parseConfigFromString(String contents); static NamedContext getCurrentContext(Config config); static String getUserToken(Config config, Context context); static AuthInfo getUserAuthInfo(Config config, Context context); static Cluster getCluster(Config config, Context context); static int getNamedUserIndexFromConfig(Config config, String userName); static void persistKubeConfigIntoFile(Config kubeConfig, String kubeConfigPath);  }