chore: read environment addons from the workspace#4147
chore: read environment addons from the workspace#4147mergify[bot] merged 17 commits intoaws:mainlinefrom
Conversation
Codecov Report
@@ Coverage Diff @@
## mainline #4147 +/- ##
============================================
+ Coverage 69.21% 69.24% +0.02%
============================================
Files 250 250
Lines 35885 35927 +42
Branches 264 264
============================================
+ Hits 24838 24876 +38
- Misses 9854 9856 +2
- Partials 1193 1195 +2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
| ReadWorkloadAddonsDir(svcName string) ([]string, error) | ||
| ReadWorkloadAddon(svcName, fileName string) ([]byte, error) |
There was a problem hiding this comment.
Instead of ReadWorkloadAddonsDir vs ReadEnvAddonsDir, what do you think of the following API?
package workspace
// ListAddonsFiles returns a list of file paths to all the addons templates defined under the dir.
func (ws *Workspace) ListAddonsFiles(dirPath string) ([]string, error)
// ReadAddonsFile reads the addons template file under fpath.
func (ws *Workspace) ReadAddonsFile(fpath string) ([]byte, error)
// EnvAddonsPath returns the addons/ directory file path for environments.
func (ws *Workspace) EnvAddonsPath() string
// WorkloadAddonsPath returns the addons/ directory file path for a given workload.
func (ws *Workspace) WorkloadAddonsPath(name string) stringThe idea is to have a generic ListAddonsFiles that can be given as input the EnvAddonsPath or WorkloadAddonsPath.
There was a problem hiding this comment.
Addressed!
I actually had:
WorkloadAddonsPath(name string) (string, error)
WorkloadAddonFilePath(wkldName, fName string) (string, error)
EnvAddonsPath() string
EnvAddonFilePath() string
ListFiles(dirPath string) ([]string, error)
ReadFile(fPath string) ([]byte, error)
So that we are still letting the workspace package to determine how an addon file is arranged under an addons/ directory. lmk how you like it!
|
🍕 Here are the new binary sizes!
|
3f74dce to
3b02b15
Compare
bf3f1d5 to
61b59e5
Compare
dannyrandall
left a comment
There was a problem hiding this comment.
looks great, just a nit!
| func (ws *Workspace) ReadFile(fPath string) ([]byte, error) { | ||
| exist, err := ws.fs.Exists(fPath) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("check if manifest file %s exists: %w", fPath, err) |
There was a problem hiding this comment.
should probably update this error since it could be reading a manifest file or an addon file now
| func (ws *Workspace) ReadAddonsDir(svcName string) ([]string, error) { | ||
| // EnvAddonsPath returns the addons/ directory file path for environments. | ||
| func (ws *Workspace) EnvAddonsPath() (string, error) { | ||
| copilotPath, err := ws.copilotDirPath() |
There was a problem hiding this comment.
I wonder if we could have gotten-rid of so many of our errors if we had a different approach to New in our package. For example:
package workspace
// Workspace is a created copilot/ directory in a git repository.
type Workspace struct{...}
// Use returns an existing workspace and replaces the old "New" function.
// It searches a copilot/ directory from the current wd, up to 5 levels above.
func Use() (*Workspace, error) { ... }
// Create is no longer a method and instead is a function that creates a new *Workspace in the current working directory for appName.
func Create(appName string) (*Workspace, error)With the above API, I think we can completely ditch the copilotDirPath error because *Workspace will have the value stored in a field.
Let me know what you think of the above, if it sounds good we can do it as a follow-up to this PR?
There was a problem hiding this comment.
Makes sense to me!
We can use Use() to do what've been done by copilotDirPath so that the rest of the operations can proceed with the assumption that we are in a worksapce.
This PR implements a new API for the `workspace` package. With the new API, a workspace client that gets returned to the caller always have the `copilotDirAbs` field in it. This means that the method calls can assume non-empty value of that field. This addresses the proposal made in #4147 (comment) By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.
This PR implements methods to read environment addons from the workspace in `copilot/environments/addons` folder. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.
This PR implements a new API for the `workspace` package. With the new API, a workspace client that gets returned to the caller always have the `copilotDirAbs` field in it. This means that the method calls can assume non-empty value of that field. This addresses the proposal made in aws#4147 (comment) By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.

This PR implements methods to read environment addons from the workspace in
copilot/environments/addonsfolder.Related: #4219
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.