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

feat(md): Types and new data source for environments #8020

Merged
merged 3 commits into from Mar 10, 2020

Conversation

alanmquach
Copy link
Contributor

Depends on spinnaker/keel#848

The types are probably the most interesting thing in this PR. There's a fair amount of duplication in different views of an entity, for example:

  • environments vs artifact.version.environments
    • environments: a light summary of all resources and all artifacts related to those resources
    • artifact.version.environments: a view of each environment as it relates to the artifact's specific version (i.e. time that version was deployed in that specific environment)
  • artifacts vs environment.artifacts vs resource.artifact
    • artifacts: summary of all artifacts and all versions also including a join between a specific version and it's environment
    • environment.artifacts: a view of each artifact that is in a given environment (i.e. approved, vetoed)
    • resource.artifact: (not yet present) a view of a specific artifact as it relates to the resource (i.e. deploying, pending)

The shapes or mostly different, so I'm not sure if it's even useful to have common attributes between the types. I also don't know if there's a sane way to name them.

optional and optIn mean this datasource is only enabled if explicitly enabled.

hidden means this (for now) is not yet exposed in the application config UI.

@alanmquach alanmquach added the Do Not Merge Don't merge yet label Mar 10, 2020
Copy link
Member

@erikmunson erikmunson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳🎊👯‍♀️

I had some suggestions and questions, nothing big. Very cool to see this getting its way into deck for real.

pending: string[];
approved: string[];
previous: string[];
vetoed: string[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deploying: string;?

versions: IManagedArtifactVersion[];
}

export interface IManagedApplicationEnvironmentsSummary extends IManagedApplicationSummary {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could do something like this:

type IManagedApplicationSummary<
    T extends keyof IManagedApplicationEntities = 'resources'
> = Pick<IManagedApplicationEntities, T> & {
  applicationPaused: boolean;
  hasManagedResources: boolean;
}

interface IManagedApplicationEntities {
  resources: IManagedResourceSummary[];
  environments: IManagedEnviromentSummary[];
  artifacts: IManagedArtifactSummary[];
}

And then in the reader:

class ManagedReader {
  public static getApplicationSummary(app: string, entities = ['resources']): IPromise<IManagedApplicationSummary<'resources'>> {
    // ...
  }

  public static getEnvironmentsSummary(app: string): IPromise<IManagedApplicationSummary<'resources' | 'artifacts' | 'environments'>> {
    // ...
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

giphy-1


export interface IManagedArtifactVersion {
version: string;
environments: IManagedArtifactVersionEnvironmentSummary[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crazy idea: what if... we just didn't give this thing a name and inlined it? Seems somewhat futile to try to name a thing that's really just a particular join on a couple other discrete things.

Can always extract it like IManagedArtifactVersion['environments'] if / when you need it on it's own.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was thinking that too. Will go with that, at least for now.

}

export interface IManagedEnviromentSummary {
artifacts: IManagedEnvironmentArtifact[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly to IManagedArtifactVersionEnvironmentSummary, what if we just inlined this?

return ManagedReader.getEnvironmentsSummary(application.name);
};

const addEnvironments = (_application: Application, data: IManagedApplicationSummary) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be IManagedApplicationEnvironmentsSummary? (or IManagedApplicationSummary<'resources' | 'artifacts' | 'environments'> if you do that thing I commented about)

hasManagedResources: false,
environments: [],
artifacts: [],
resources: [],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is duplicating the resources data into this data source a temporary/convenience thing, or do you intend on it being permanent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well originally temporary/convenience, but thinking about it some more I think it might be more permanent.

I don't like the duplication either but because the managedResource data source is visible: false, it doesn't contribute to the application ready state, so I don't have a guarantee that it will be available when my route loads.

@alanmquach alanmquach merged commit 41c96b6 into spinnaker:master Mar 10, 2020
@alanmquach
Copy link
Contributor Author

Whoops, that merge was unintended... I was trying to update my branch with the latest master.

alanmquach added a commit that referenced this pull request Mar 10, 2020
Revert "feat(md): Types and new data source for environments"
@alanmquach
Copy link
Contributor Author

Reverted and reopeened as #8022

@alanmquach alanmquach deleted the environments-data-source branch March 11, 2020 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants