Skip to content

Conversation

@slewis74
Copy link
Contributor

@slewis74 slewis74 commented Jan 27, 2023

This PR adds calls to the Capabilities API, so the users will get clearer error information if they're using something that relies on the Executions API but their Octopus instance is too old.

The checkForCapability method does not throw on purpose, that's the caller's choice. In the current calls, they do happen to all be errors that will throw, but in a number of cases for future use this method can be used to feature sniff with fallback behaviour.

const response = await client.get<CapabilitiesResponse>(`${apiLocation}/capabilities`);
return response.Capabilities.filter((c) => c === capabilityName).length === 1
? null
: `The Octopus instance does not support ${capabilityName}, you may need to upgrade it to get access to the feature you are trying to use.`;
Copy link
Contributor

Choose a reason for hiding this comment

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

extend this message to include a link/callout to support, and the same for the messages below

}

async create(command: CreateReleaseCommandV1): Promise<CreateReleaseResponseV1> {
const capabilityError = await checkForCapability(this.client, "CreateReleaseCommandV1");
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way we can link between the command that we are creating and the capability string? Perhaps the capability id could go in the Command object itself.
Just a thought

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What I'd love is for TS to support some equivalent to typeof(CreateReleaseCommandV1).Name that we have in C#, but it doesn't have such support.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, that was the sort of thing I had in mind

Copy link
Contributor

@benPearce1 benPearce1 left a comment

Choose a reason for hiding this comment

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

This looks good, just a couple of thoughts around magic strings and customer feedback messaging

@slewis74 slewis74 merged commit d0ce6f6 into main Jan 27, 2023
@slewis74 slewis74 deleted the fix-executionapi-detection branch January 27, 2023 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants