-
Notifications
You must be signed in to change notification settings - Fork 619
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
metadata service continued #981
Changes from 1 commit
6e9aadd
ed6aaef
203ec87
d04bb67
14274b3
9d5d867
011b1d4
b2ee17c
a152504
cdf61a5
b06c3f3
9e0d80f
4640038
508d9e5
de5fa33
d5146c5
13fb758
68fa765
b4f68c6
e9fd7cf
6817a23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- v1.90.0
- v1.89.3
- v1.89.2
- v1.89.1
- v1.88.0
- v1.87.1
- v1.87.0
- v1.86.3
- v1.86.2
- v1.86.1
- v1.86.0
- v1.85.2
- v1.85.1
- v1.85.0
- v1.84.0
- v1.83.0
- v1.82.4
- v1.82.3
- v1.82.2
- v1.82.1
- v1.82.0
- v1.81.1
- v1.81.0
- v1.80.0
- v1.79.2
- v1.79.1
- v1.79.0
- v1.78.1
- v1.78.0
- v1.77.0
- v1.76.0
- v1.75.3
- v1.75.0
- v1.74.1
- v1.73.1
- v1.73.0
- v1.72.0
- v1.71.2
- v1.71.1
- v1.71.0
- v1.70.2
- v1.70.1
- v1.70.0
- v1.69.0
- v1.68.2
- v1.68.0
- v1.67.2
- v1.67.1
- v1.67.0
- v1.66.2
- v1.66.1
- v1.66.0
- v1.65.1
- v1.65.0
- v1.64.0
- v1.63.1
- v1.63.0
- v1.62.2
- v1.62.1
- v1.62.0
- v1.61.3
- v1.61.2
- v1.61.1
- v1.61.0
- v1.60.1
- v1.60.0
- v1.59.0
- v1.58.0
- v1.57.1
- v1.57.0
- v1.56.0
- v1.55.5
- v1.55.4
- v1.55.3
- v1.55.2
- v1.55.1
- v1.55.0
- v1.54.1
- v1.54.0
- v1.53.1
- v1.53.0
- v1.52.2
- v1.52.1
- v1.52.0
- v1.51.0
- v1.50.3
- v1.50.2
- v1.50.1
- v1.50.0
- v1.49.0
- v1.48.1
- v1.48.0
- v1.47.0
- v1.46.0
- v1.45.0
- v1.44.4
- v1.44.3
- v1.44.2
- v1.44.1
- v1.44.0
- v1.43.0
- v1.42.0
- v1.41.1
- v1.41.0
- v1.40.0
- v1.39.0
- v1.38.0
- v1.37.0
- v1.36.2
- v1.36.1
- v1.36.0
- v1.35.0
- v1.34.0
- v1.33.0
- v1.32.1
- v1.32.0
- v1.31.0
- v1.30.0
- v1.29.1
- v1.29.0
- v1.28.1
- v1.28.0
- v1.27.0
- v1.26.1
- v1.26.0
- v1.25.3
- v1.25.2
- v1.25.1
- v1.25.0
- v1.24.0
- v1.23.0
- v1.22.0
- v1.21.0
- v1.20.3
- v1.20.2
- v1.20.1
- v1.20.0
- v1.19.1
- v1.19.0
- v1.18.0
- v1.17.3
- v1.17.2
- v1.17.1
- v1.17.0
- v1.16.2
- v1.16.1
- v1.16.0
- v1.15.2
- v1.15.1
- v1.15.0
- 1.85.3
- 1.68.1
- 1.44.4
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,13 +114,7 @@ func (manager *metadataManager) Create(config *docker.Config, hostConfig *docker | |
|
||
// Acquire the metadata then write it in JSON format to the file | ||
metadata := manager.parseMetadataAtContainerCreate(taskARN, containerName) | ||
data, err := json.MarshalIndent(metadata, "", "\t") | ||
if err != nil { | ||
return fmt.Errorf("create metadata for task %s container %s: %v", taskARN, containerName, err) | ||
} | ||
|
||
// Write the metadata to file | ||
err = writeToMetadataFile(manager.osWrap, manager.ioutilWrap, data, taskARN, containerName, manager.dataDir) | ||
err = manager.marshalAndWrite(metadata, taskARN, containerName) | ||
if err != nil { | ||
return err | ||
} | ||
|
@@ -148,12 +142,11 @@ func (manager *metadataManager) Update(dockerID string, taskARN string, containe | |
|
||
// Acquire the metadata then write it in JSON format to the file | ||
metadata := manager.parseMetadata(dockerContainer, taskARN, containerName) | ||
data, err := json.MarshalIndent(metadata, "", "\t") | ||
err = manager.marshalAndWrite(metadata, taskARN, containerName) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: if you aren't doing anything with the error returned, you can just do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense, fixed. |
||
if err != nil { | ||
return fmt.Errorf("update metadata for task %s container %s: %v", taskARN, containerName, err) | ||
return err | ||
} | ||
|
||
return writeToMetadataFile(manager.osWrap, manager.ioutilWrap, data, taskARN, containerName, manager.dataDir) | ||
return nil | ||
} | ||
|
||
// Clean removes the metadata files of all containers associated with a task | ||
|
@@ -164,3 +157,18 @@ func (manager *metadataManager) Clean(taskARN string) error { | |
} | ||
return manager.osWrap.RemoveAll(metadataPath) | ||
} | ||
|
||
func (manager *metadataManager) marshalAndWrite(metadata Metadata, taskARN string, containerName string) error { | ||
data, err := json.MarshalIndent(metadata, "", "\t") | ||
if err != nil { | ||
return fmt.Errorf("create metadata for task %s container %s: %v", taskARN, containerName, err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, needs more context: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed. |
||
} | ||
|
||
// Write the metadata to file | ||
err = writeToMetadataFile(manager.osWrap, manager.ioutilWrap, data, taskARN, containerName, manager.dataDir) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here too, you could just do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense, fixed. |
||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic of parsing, marshaling and writing the metadata file is duplicated between this and the
Update
method. Please extract that to a method of its own.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.