Skip to content

Commit c91433c

Browse files
authored
Do not use entrypoint for cp-utility (#377)
1 parent 2c581b7 commit c91433c

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ FROM scratch
4848

4949
ARG ADOT_JAVA_VERSION
5050

51-
COPY --from=builder /usr/src/cp-utility/bin/cp-utility /
51+
COPY --from=builder /usr/src/cp-utility/bin/cp-utility /bin/cp
5252

53-
COPY ./otelagent/build/libs/aws-opentelemetry-agent-${ADOT_JAVA_VERSION}.jar /javaagent.jar
5453

55-
ENTRYPOINT ["/cp-utility"]
54+
COPY ./otelagent/build/libs/aws-opentelemetry-agent-${ADOT_JAVA_VERSION}.jar /javaagent.jar

tools/cp-utility/src/main.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,24 @@ struct CopyOperation {
4242

4343
/// Parse command line arguments and transform into `CopyOperation`
4444
fn parse_args(args: Vec<&str>) -> io::Result<CopyOperation> {
45-
if !((args.len() == 4 || args.len() == 5 && args[2].eq("-a")) && args[1].eq("cp")) {
45+
if !(args.len() == 3 || args.len() == 4 && args[1].eq("-a")) {
4646
return Err(io::Error::new(
4747
io::ErrorKind::InvalidInput,
4848
"Invalid parameters. Expected cp [-a] <source> <destination>",
4949
));
5050
}
5151

52-
if args.len() == 5 {
52+
if args.len() == 4 {
5353
return Ok(CopyOperation {
54-
source: PathBuf::from(args[3]),
55-
destination: PathBuf::from(args[4]),
54+
source: PathBuf::from(args[2]),
55+
destination: PathBuf::from(args[3]),
5656
copy_type: CopyType::Archive,
5757
});
5858
}
5959

6060
Ok(CopyOperation {
61-
source: PathBuf::from(args[2]),
62-
destination: PathBuf::from(args[3]),
61+
source: PathBuf::from(args[1]),
62+
destination: PathBuf::from(args[2]),
6363
copy_type: CopyType::SingleFile,
6464
})
6565
}
@@ -143,7 +143,7 @@ mod tests {
143143
#[test]
144144
fn test_parser_archive() {
145145
// prepare
146-
let input = vec!["cp-utility", "cp", "-a", "foo.txt", "dest.txt"];
146+
let input = vec!["cp", "-a", "foo.txt", "dest.txt"];
147147

148148
// act
149149
let result = parse_args(input).unwrap();
@@ -157,7 +157,7 @@ mod tests {
157157
#[test]
158158
fn test_parser_single() {
159159
// prepare
160-
let input: Vec<&str> = vec!["cp-utility", "cp", "foo.txt", "dest.txt"];
160+
let input: Vec<&str> = vec!["cp", "foo.txt", "dest.txt"];
161161

162162
// act
163163
let result = parse_args(input).unwrap();
@@ -172,11 +172,9 @@ mod tests {
172172
fn parser_failure() {
173173
// prepare
174174
let inputs = vec![
175-
vec!["cp-utility", "cp", "-r", "foo.txt", "bar.txt"],
176-
vec!["cp-utility", "cp", "-a", "param1", "param2", "param3"],
177-
vec!["cp-utility", "cp", "param1", "param2", "param3"],
178-
vec!["cp-utility", "mv", "param1", "param2"],
179-
vec!["cp-utility", "mv", "-a", "param1", "param2"],
175+
vec!["cp", "-r", "foo.txt", "bar.txt"],
176+
vec!["cp", "-a", "param1", "param2", "param3"],
177+
vec!["cp", "param1", "param2", "param3"],
180178
];
181179

182180
for input in inputs.into_iter() {

0 commit comments

Comments
 (0)