Skip to content

Commit 46ef373

Browse files
authored
Merge branch 'master' into directory-enforcement
2 parents e42daf9 + 8e2a726 commit 46ef373

File tree

5 files changed

+67
-22
lines changed

5 files changed

+67
-22
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.walmartlabs.concord.cli;
2+
3+
/*-
4+
* *****
5+
* Concord
6+
* -----
7+
* Copyright (C) 2017 - 2025 Walmart Inc.
8+
* -----
9+
* Licensed under the Apache License, Version 2.0 (the "License");
10+
* you may not use this file except in compliance with the License.
11+
* You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS,
17+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* See the License for the specific language governing permissions and
19+
* limitations under the License.
20+
* =====
21+
*/
22+
23+
public class AbortException extends RuntimeException {
24+
25+
public AbortException() {
26+
super("Aborted");
27+
}
28+
}

cli/src/main/java/com/walmartlabs/concord/cli/CliConfig.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* =====
2121
*/
2222

23+
import com.fasterxml.jackson.databind.DeserializationFeature;
2324
import com.fasterxml.jackson.databind.JsonMappingException;
2425
import com.fasterxml.jackson.databind.JsonNode;
2526
import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -38,7 +39,8 @@
3839
public record CliConfig(Map<String, CliConfigContext> contexts) {
3940

4041
public static CliConfig load(Path path) throws IOException {
41-
var mapper = new YAMLMapper();
42+
var mapper = new YAMLMapper()
43+
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
4244

4345
JsonNode defaults = mapper.readTree(readDefaultConfig());
4446

cli/src/main/java/com/walmartlabs/concord/cli/runner/secrets/RemoteSecretsProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* =====
2121
*/
2222

23+
import com.walmartlabs.concord.cli.AbortException;
2324
import com.walmartlabs.concord.cli.Version;
2425
import com.walmartlabs.concord.client2.*;
2526
import com.walmartlabs.concord.common.secret.BinaryDataSecret;
@@ -190,8 +191,7 @@ private void askForAccessConfirmation(String orgName, String secretName) throws
190191
int response = System.in.read();
191192
// y == 121, Y == 89
192193
if (response != 121 && response != 89) {
193-
System.out.println(ansi().fgRed().a("Aborting.").reset());
194-
System.exit(-1);
194+
throw new AbortException();
195195
}
196196
}
197197
}

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
<processStartTag>*****</processStartTag>
131131
<sectionDelimiter>-----</sectionDelimiter>
132132
<processEndTag>=====</processEndTag>
133+
<trimHeaderLine>true</trimHeaderLine>
133134
<roots>
134135
<root>src/main/java</root>
135136
<root>src/test/java</root>

server/plugins/noderoster/impl/src/main/java/com/walmartlabs/concord/server/plugins/noderoster/processor/AnsibleEventsProcessor.java

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -112,31 +112,45 @@ public List<AnsibleEvent> list(EventMarker marker, OffsetDateTime startTimestamp
112112
return txResult(tx -> {
113113
ProcessQueue pq = PROCESS_QUEUE.as("pq");
114114
ProcessEvents pe = PROCESS_EVENTS.as("pe");
115-
Field<String> username = tx.select(USERS.USERNAME).from(USERS).where(USERS.USER_ID.eq(pq.INITIATOR_ID)).asField();
116-
117115
Field<Object> eventData = function("jsonb_strip_nulls", Object.class, pe.EVENT_DATA);
118-
SelectConditionStep<Record9<UUID, Long, UUID, OffsetDateTime, OffsetDateTime, Object, String, UUID, UUID>> s = tx.select(
119-
pe.EVENT_ID,
120-
pe.EVENT_SEQ,
121-
pe.INSTANCE_ID,
122-
pe.INSTANCE_CREATED_AT,
123-
pe.EVENT_DATE,
124-
eventData,
125-
username,
126-
pq.INITIATOR_ID,
127-
pq.PROJECT_ID)
128-
.from(pe)
129-
.innerJoin(pq).on(pq.INSTANCE_ID.eq(pe.INSTANCE_ID).and(pq.CREATED_AT.eq(pe.INSTANCE_CREATED_AT)))
130-
.where(pe.EVENT_TYPE.eq("ANSIBLE")
131-
.and(pe.EVENT_SEQ.greaterThan(marker.eventSeq())));
116+
117+
SelectConditionStep<Record6<UUID, Long, UUID, OffsetDateTime, OffsetDateTime, Object>> selectEventsSubQuery =
118+
tx.select(pe.EVENT_ID,
119+
pe.EVENT_SEQ,
120+
pe.INSTANCE_ID,
121+
pe.INSTANCE_CREATED_AT,
122+
pe.EVENT_DATE,
123+
eventData.as("event_data"))
124+
.from(pe)
125+
.where(pe.EVENT_TYPE.eq("ANSIBLE"))
126+
.and(pe.EVENT_SEQ.greaterThan(marker.eventSeq()));
132127

133128
if (startTimestamp != null) {
134-
s.and(pe.INSTANCE_CREATED_AT.greaterOrEqual(startTimestamp));
129+
selectEventsSubQuery.and(pe.INSTANCE_CREATED_AT.greaterOrEqual(startTimestamp));
135130
}
136131

137-
return s.orderBy(pe.EVENT_SEQ)
132+
Table<Record6<UUID, Long, UUID, OffsetDateTime, OffsetDateTime, Object>> eventsAlias = selectEventsSubQuery
133+
.orderBy(pe.EVENT_SEQ)
138134
.limit(count)
139-
.fetch(this::toEntity);
135+
.asTable("events_batch");
136+
137+
SelectOnConditionStep<Record9<UUID, Long, UUID, OffsetDateTime, OffsetDateTime, Object, String, UUID, UUID>> s = tx.select(
138+
eventsAlias.field("event_id", UUID.class),
139+
eventsAlias.field("event_seq", Long.class),
140+
eventsAlias.field("instance_id", UUID.class),
141+
eventsAlias.field("instance_created_at", OffsetDateTime.class),
142+
eventsAlias.field("event_date", OffsetDateTime.class),
143+
eventsAlias.field("event_data", Object.class),
144+
USERS.USERNAME,
145+
pq.INITIATOR_ID,
146+
pq.PROJECT_ID
147+
)
148+
.from(eventsAlias)
149+
.leftOuterJoin(pq)
150+
.on(pq.INSTANCE_ID.eq(eventsAlias.field("instance_id", UUID.class)))
151+
.leftOuterJoin(USERS).on(USERS.USER_ID.eq(pq.INITIATOR_ID));
152+
153+
return s.fetch(this::toEntity);
140154
});
141155
}
142156

0 commit comments

Comments
 (0)