integration-tests/src/test/java/oracle/kubernetes/operator/MiiConfigUpdateBaseTest.java
protected void modifyDomainYamlWithSecretName(Domain domain, String secretName) {
    // get domain namespace name
    Map<String, Object> domainMap = domain.getDomainMap();
    final String domainNS = domainMap.get("namespace").toString();
    ExecResult result = null;

    StringBuffer getExistSecretsCmd = new StringBuffer("kubectl -n ");
    getExistSecretsCmd
        .append(domainNS)
        .append(" get domain ")
        .append(domain.getDomainUid())
        .append(" -o jsonpath='{.spec.configuration.secrets}' | sed 's/[][]//g'");
    LoggerHelper.getLocal().log(Level.INFO, "Command to get existing secrets: " + getExistSecretsCmd);

    try {
      // get existing secret names in domain
      result = TestUtils.execOrAbortProcess(getExistSecretsCmd.toString());
      LoggerHelper.getLocal().log(Level.INFO, "Existing secrets are: " + result.stdout());
    } catch (Exception ex) {
      ex.printStackTrace();
      StringBuffer errorMsg = new StringBuffer("FAILURE: command: ");
      errorMsg
          .append(getExistSecretsCmd)
          .append(" failed, returned ")
          .append(result.stdout())
          .append("\n")
          .append(result.stderr());
    }

    String allSecrets = secretName;
    if (!result.stdout().isEmpty()) {
      // append new secret name to existing secret names in domain
      allSecrets += "," + result.stdout().trim();
    }

    StringBuffer patchDomainCmd = new StringBuffer("kubectl -n ");
    patchDomainCmd
        .append(domainNS)
        .append(" patch domain ")
        .append(domain.getDomainUid())
        .append(" --type='json' ")
        .append(" -p='[{\"op\": \"replace\", \"path\": \"/spec/configuration/secrets\", \"value\": [\"")
        .append(allSecrets)
        .append("\"] }]'");
    LoggerHelper.getLocal().log(Level.INFO, "Command to patch domain: " + patchDomainCmd);

    try {
      // patch the domain
      LoggerHelper.getLocal().log(Level.INFO, "Adding [" + allSecrets + "] to domain dynamically");
      result = TestUtils.execOrAbortProcess(patchDomainCmd.toString());
      LoggerHelper.getLocal().log(Level.INFO, "Domain patch result: " + result.stdout());
    } catch (Exception ex) {
      ex.printStackTrace();
      StringBuffer errorMsg = new StringBuffer("FAILURE: command: ");
      errorMsg
          .append(patchDomainCmd)
          .append(" failed, returned ")
          .append(result.stdout())
          .append("\n")
          .append(result.stderr());

      fail(errorMsg.toString(), ex.getCause());
    }
  }
/**
   * Modify the domain yaml to change image name and verify the domain restarted.
   * @param domain the Domain where to change the image name
   * @param imageName image name to be updated in the Domain
   */
Modify the domain yaml to change image name and verify the domain restarted.
@param domain the Domain where to change the image name
@param imageName image name to be updated in the Domain
Modify the domain yaml to change image name and verify the domain restarted . @param domain the Domain where to change the image name @param imageName image name to be updated in the Domain
protected void modifyDomainYamlWithSecretName(Domain domain, String secretName) {
    Map<String, Object> domainMap = domain.getDomainMap();
    final String domainNS = domainMap.get("namespace").toString();
    ExecResult result = null;
    StringBuffer getExistSecretsCmd = new StringBuffer("kubectl -n ");
    getExistSecretsCmd
        .append(domainNS)
        .append(" get domain ")
        .append(domain.getDomainUid())
        .append(" -o jsonpath='{.spec.configuration.secrets}' | sed 's/[][]//g'");
    LoggerHelper.getLocal().log(Level.INFO, "Command to get existing secrets: " + getExistSecretsCmd);
    try {
      result = TestUtils.execOrAbortProcess(getExistSecretsCmd.toString());
      LoggerHelper.getLocal().log(Level.INFO, "Existing secrets are: " + result.stdout());
    } catch (Exception ex) {
      ex.printStackTrace();
      StringBuffer errorMsg = new StringBuffer("FAILURE: command: ");
      errorMsg
          .append(getExistSecretsCmd)
          .append(" failed, returned ")
          .append(result.stdout())
          .append("\n")
          .append(result.stderr());
    }
    String allSecrets = secretName;
    if (!result.stdout().isEmpty()) {
      allSecrets += "," + result.stdout().trim();
    }
    StringBuffer patchDomainCmd = new StringBuffer("kubectl -n ");
    patchDomainCmd
        .append(domainNS)
        .append(" patch domain ")
        .append(domain.getDomainUid())
        .append(" --type='json' ")
        .append(" -p='[{\"op\": \"replace\", \"path\": \"/spec/configuration/secrets\", \"value\": [\"")
        .append(allSecrets)
        .append("\"] }]'");
    LoggerHelper.getLocal().log(Level.INFO, "Command to patch domain: " + patchDomainCmd);
    try {
      LoggerHelper.getLocal().log(Level.INFO, "Adding [" + allSecrets + "] to domain dynamically");
      result = TestUtils.execOrAbortProcess(patchDomainCmd.toString());
      LoggerHelper.getLocal().log(Level.INFO, "Domain patch result: " + result.stdout());
    } catch (Exception ex) {
      ex.printStackTrace();
      StringBuffer errorMsg = new StringBuffer("FAILURE: command: ");
      errorMsg
          .append(patchDomainCmd)
          .append(" failed, returned ")
          .append(result.stdout())
          .append("\n")
          .append(result.stderr());
      fail(errorMsg.toString(), ex.getCause());
    }
  }
protected void modifyDomainYamlWithSecretName ( Domain domain , String secretName ) { Map < String , Object > domainMap = domain . getDomainMap ( ) ; final String domainNS = domainMap . get ( "namespace" ) . toString ( ) ; ExecResult result = null ; StringBuffer getExistSecretsCmd = new StringBuffer ( "kubectl -n " ) ; getExistSecretsCmd . append ( domainNS ) . append ( " get domain " ) . append ( domain . getDomainUid ( ) ) . append ( " -o jsonpath='{.spec.configuration.secrets}' | sed 's/[][]//g'" ) ; LoggerHelper . getLocal ( ) . log ( Level . INFO , "Command to get existing secrets: " + getExistSecretsCmd ) ; try { result = TestUtils . execOrAbortProcess ( getExistSecretsCmd . toString ( ) ) ; LoggerHelper . getLocal ( ) . log ( Level . INFO , "Existing secrets are: " + result . stdout ( ) ) ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; StringBuffer errorMsg = new StringBuffer ( "FAILURE: command: " ) ; errorMsg . append ( getExistSecretsCmd ) . append ( " failed, returned " ) . append ( result . stdout ( ) ) . append ( "\n" ) . append ( result . stderr ( ) ) ; } String allSecrets = secretName ; if ( ! result . stdout ( ) . isEmpty ( ) ) { allSecrets += "," + result . stdout ( ) . trim ( ) ; } StringBuffer patchDomainCmd = new StringBuffer ( "kubectl -n " ) ; patchDomainCmd . append ( domainNS ) . append ( " patch domain " ) . append ( domain . getDomainUid ( ) ) . append ( " --type='json' " ) . append ( " -p='[{\"op\": \"replace\", \"path\": \"/spec/configuration/secrets\", \"value\": [\"" ) . append ( allSecrets ) . append ( "\"] }]'" ) ; LoggerHelper . getLocal ( ) . log ( Level . INFO , "Command to patch domain: " + patchDomainCmd ) ; try { LoggerHelper . getLocal ( ) . log ( Level . INFO , "Adding [" + allSecrets + "] to domain dynamically" ) ; result = TestUtils . execOrAbortProcess ( patchDomainCmd . toString ( ) ) ; LoggerHelper . getLocal ( ) . log ( Level . INFO , "Domain patch result: " + result . stdout ( ) ) ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; StringBuffer errorMsg = new StringBuffer ( "FAILURE: command: " ) ; errorMsg . append ( patchDomainCmd ) . append ( " failed, returned " ) . append ( result . stdout ( ) ) . append ( "\n" ) . append ( result . stderr ( ) ) ; fail ( errorMsg . toString ( ) , ex . getCause ( ) ) ; } }
Modify the domain yaml to change image name and verify the domain restarted.
Modify the domain yaml to change image name and verify the domain restarted .
// get domain namespace name // get existing secret names in domain // append new secret name to existing secret names in domain // patch the domain