Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add has_package_changes and has_destructive_changes booleans to stdout #558

Open
AllanOricil opened this issue Apr 3, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@AllanOricil
Copy link
Contributor

AllanOricil commented Apr 3, 2023

Is your proposal related to a problem?

sgd currently does not have any useful stdout and because of that we have to parse xml files to determine if our automations must continue or not. For example, we have to do something like shown below to determine if there are or not changes in the package.xml before we can schedule a deploy job in salesforce

local mdapi=$(xmllint --xpath "count(//*[local-name()='types' and namespace-uri()='http://soap.sforce.com/2006/04/metadata'])" dist/$orgAlias/package/package.xml)
    echo "Number of types is: $mdapi" 
    if [ "$mdapi" != "0" ]; then
        // we can schedule a metadata deploy or validation job
    fi

Describe a solution you propose

I believe that all automations run their next steps when:

  • package.xml has changes
  • destructiveChanges.xml has changes
  • when both files have changes

so maybe it would be nice to add the following information in the stdout of the command so that developers don't need to waste additional time parsing xml files

{
  {
      "status": 0,
      "result": {
          "has_package_changes": "true" // true when package/package.xml has changes
          "has_destructive_changes": "false"  // true when destructiveChanges/destructiveChanges.xml has changes
    }
}

Describe alternatives you've considered

I have to use an xml parser to count the number of <types> in the package.xml to decide the path my automations should follow.

Additional context

N/a

@AllanOricil AllanOricil added the enhancement New feature or request label Apr 3, 2023
@scolladon
Copy link
Owner

Hi @AllanOricil !

Thanks for this enhancement request and thanks for contributing in making this project better!

I think we already had an issue related to that topic and here is how we proposed to deal with this situation.

That being said, I like the idea of having more information in case of success.
It would make easier to drive behavior of other tools relaying on sgd based on sgd result.
And the way have those information using json output of the command is nice, elegant and portable IMHO

So here is a spec based on the one you proposed (we can debate):

  • The output of the commands will have a new attributs info that will contain hasPackage boolean attribut and hasDestructive boolean attribut.
  • The info attribut will be filled only if success is true, else the info attribut will be empty object {}
  • The info.hasPackage attribut will be true if the package.xml generated contains member, else false
  • The info.hasDestructive attribut will be true if the destructiveChanges.xml generated contains member, else false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants