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

Diffable object can't be updated. #190

Open
sshyub opened this issue Dec 3, 2019 · 3 comments
Open

Diffable object can't be updated. #190

sshyub opened this issue Dec 3, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@sshyub
Copy link

sshyub commented Dec 3, 2019

Describe the bug
Gyro should be able to handle @Updatable fields in Diffable type without replacing whole object.

To Reproduce

class Foo extends Diffable {
  private String name;

  @Updateable
  public String getName() {
    return name;
  }
}

@Type("bar")
class Bar extends Resource {
  private Foo foo;

  public Foo getFoo() {
    return foo;
  }
}

bar.gyro

service-provider::bar bar-resource
  foo
    name: "title"
  end
  1. run gyro up bar.gyro.
  2. modify name to something else.
  3. run gyro up bar.gyro again.

Expected behavior
name in Foo type should be updated, but actual behavior is:

>>> gyro up gyro/managed-zone.gyro 
??? Loading plugin: gyro:gyro-google-provider:0.99.1-SNAPSHOT
??? Refreshed resources: 6

Looking for changes...

??? Replace service-provider::bar bar-resource bar (because of foo skipping without a workflow)
    ??? Update foo null::foo (change name)

Are you sure you want to change resources? (y/N) 

where the following output is expected.

>>> gyro up gyro/managed-zone.gyro 
??? Loading plugin: gyro:gyro-google-provider:0.99.1-SNAPSHOT
??? Refreshed resources: 6

Looking for changes...

??? Keep service-provider::bar bar-resource bar
    ??? Update foo null::foo (change name)

Are you sure you want to change resources? (y/N) 
@sshyub sshyub added the bug Something isn't working label Dec 3, 2019
@beetlebugorg
Copy link
Contributor

beetlebugorg commented Dec 3, 2019

This is the difference between a Diffable, and a Resource used as a subresource. There are no methods to call on the Diffable to trigger the update, so the parent needs to be called.

Is your suggestion to handle this case by having the output be:

>>> gyro up gyro/managed-zone.gyro 
??? Loading plugin: gyro:gyro-google-provider:0.99.1-SNAPSHOT
??? Refreshed resources: 6

Looking for changes...

??? Update service-provider::bar bar-resource bar
    ??? Update foo null::foo (change name)

Are you sure you want to change resources? (y/N) 

And then call the parent's update method and pass enough information to update the Diffable? (Not an easy change given the current method signature is just a list of strings).

@beetlebugorg beetlebugorg changed the title **Diffable** object can't be updated. Diffable object can't be updated. Dec 3, 2019
@beetlebugorg
Copy link
Contributor

beetlebugorg commented Dec 3, 2019

Also, so I have a more concrete example, can you provide the service provider resource you're trying to implement and specifically what complex type within that resource this is causing an problem with. It'd help me to better understand how to solve this. Thanks.

@sshyub
Copy link
Author

sshyub commented Dec 4, 2019

Updated OP to include expected output as well.

Here's the concrete example from Google provider implementation:

@Type("dns-managed-zone")
public class ManagedZoneResource extends GoogleResource {

    private String description;

    private String dnsName;

    private ZoneDnsSecConfig dnssecConfig;

    private String name;

    @Required
    @Updatable
    public String getDescription() {
        return description;
    }

    public String getDnsName() {
        return dnsName;
    }

    public ZoneDnsSecConfig getDnssecConfig() {
        return dnssecConfig;
    }

    @Required
    public String getName() {
        return name;
    }
}

public class ZoneDnsSecConfig extends Diffable {

    private String nonExistence;

    @Updatable
    @ValidStrings({ "nsec", "nsec3" })
    public String getNonExistence() {
        return nonExistence;
    }
}

Gyro configuration:

google::dns-managed-zone managed-zone-example-public
    name: "managed-zone-example-public"
    description: "Public Managed Zone Example"
    dns-name: "p.example.com."
    dnssec-config
        non-existence: "nsec"
    end
end

run gyro up
and then modify the configuration to:

google::dns-managed-zone managed-zone-example-public
    name: "managed-zone-example-public"
    description: "Public Managed Zone Example"
    dns-name: "p.example.com."
    dnssec-config
        non-existence: "nsec3"
    end
end

and run gyro up again, I expect to see:

>>> gyro up gyro/managed-zone.gyro 
??? Loading plugin: gyro:gyro-google-provider:0.99.1-SNAPSHOT
??? Refreshed resources: 3

Looking for changes...

??? Keep google::dns-managed-zone managed-zone-example-public
    ??? Update dnssec-config null::dnssec-config (change non-existence)

Are you sure you want to change resources? (y/N)

but the actual output is:

gyro up gyro/managed-zone.gyro 
??? Loading plugin: gyro:gyro-google-provider:0.99.1-SNAPSHOT
??? Refreshed resources: 3

Looking for changes...

??? Replace google::dns-managed-zone managed-zone-example-public (because of dnssec-config, skipping without a workflow)
    ??? Update dnssec-config null::dnssec-config (change non-existence)

Are you sure you want to change resources? (y/N)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants