mirror of
https://github.com/floci-io/floci.git
synced 2026-11-26 23:29:28 -05:00
feat(ssm): support UnlabelParameterVersion (#5339)
* feat(ssm): support UnlabelParameterVersion
Remove one or more labels from a parameter version. Labels attached to
the version are returned in RemovedLabels; labels that are not on that
version, including ones attached to a different version, are returned in
InvalidLabels and left in place. A missing parameter is ParameterNotFound,
a missing version ParameterVersionNotFound, and an omitted ParameterVersion
or an empty or oversized label list a ValidationException.
* fix(ssm): match AWS errors and ordering in UnlabelParameterVersion
Verified against real AWS (us-east-1):
- Report every missing or invalid member in one ValidationException, in
the order name, parameterVersion, labels, and render the label list
the way AWS does ('[prod, ]').
- Reject a string or boolean ParameterVersion and a non-string Name or
label with SerializationException; truncate a fractional version and
clamp one outside the range of a long, as AWS does.
- Reject an ARN, a malformed or ssm-prefixed name, and deny an
aws-prefixed one before the lookup; ignore surrounding whitespace in
the lookup but echo the name as sent in error messages.
- Word ParameterVersionNotFound as AWS does.
- Return RemovedLabels in the order the labels are stored on the
version, and InvalidLabels in request order.
LabelParameterVersion shares the label-list parsing, so its label
validation messages and non-string labels now match AWS too.
* fix(ssm): take the service monitor when deleting parameters
PutParameter, LabelParameterVersion and UnlabelParameterVersion already
run under the SsmService monitor, but DeleteParameter and
DeleteParameters did not. A delete landing between a label or unlabel
call's lookup and its history write left orphaned history that a later
PutParameter of the same name appended to.
Also pin LabelParameterVersion's AWS-verified label validation messages
and its SerializationException for a non-string label in its own
integration test, and share the parameter-name format rule between the
two reserved-name messages.
This commit is contained in:
1 parent
07ebc33d28
commit
4f34a903fc
7 files changed
+651
-81
No files matched your search
@@ -36,6 +36,8 @@ import software.amazon.awssdk.services.ssm.model.RemoveTagsFromResourceRequest;
|
||||
import software.amazon.awssdk.services.ssm.model.SendCommandRequest;
|
||||
import software.amazon.awssdk.services.ssm.model.SendCommandResponse;
|
||||
import software.amazon.awssdk.services.ssm.model.SsmException;
|
||||
import software.amazon.awssdk.services.ssm.model.UnlabelParameterVersionRequest;
|
||||
import software.amazon.awssdk.services.ssm.model.UnlabelParameterVersionResponse;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -109,6 +111,38 @@ class SsmTest {
|
||||
// No exception means success
|
||||
}
|
||||
|
||||
@Test
|
||||
void unlabelParameterVersion() {
|
||||
String name = "/sdk-test/unlabel";
|
||||
ssm.putParameter(PutParameterRequest.builder()
|
||||
.name(name)
|
||||
.value("v1")
|
||||
.type(ParameterType.STRING)
|
||||
.overwrite(true)
|
||||
.build());
|
||||
try {
|
||||
ssm.labelParameterVersion(LabelParameterVersionRequest.builder()
|
||||
.name(name)
|
||||
.labels("prod", "stable")
|
||||
.parameterVersion(1L)
|
||||
.build());
|
||||
|
||||
UnlabelParameterVersionResponse response = ssm.unlabelParameterVersion(
|
||||
UnlabelParameterVersionRequest.builder()
|
||||
.name(name)
|
||||
.parameterVersion(1L)
|
||||
.labels("prod", "missing")
|
||||
.build());
|
||||
|
||||
assertThat(response.removedLabels()).containsExactly("prod");
|
||||
assertThat(response.invalidLabels()).containsExactly("missing");
|
||||
assertThat(ssm.getParameterHistory(GetParameterHistoryRequest.builder().name(name).build())
|
||||
.parameters().get(0).labels()).containsExactly("stable");
|
||||
} finally {
|
||||
ssm.deleteParameter(DeleteParameterRequest.builder().name(name).build());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void getParameterHistory() {
|
||||
|
||||
Reference in new issue
Block a user