You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DEVELOPMENT.md
+52
Original file line number
Diff line number
Diff line change
@@ -103,6 +103,58 @@ For more details behind the logic of config changes see [the Skaffold config man
103
103
104
104
We build the API directly through gRPC, which gets translated into REST API through a reverse proxy gateway library. If you make changes to the [proto/skaffold.proto](https://github.com/GoogleContainerTools/skaffold/blob/master/proto/skaffold.proto) file you can run `./hack/generate-proto.sh` to generate the equivalent Go code.
105
105
106
+
## Adding actionable error messages to code.
107
+
Skaffold has a built-in framework to provide actionable error messages for user to help bootstrap skaffold errors.
108
+
109
+
Also, [v1.19.0](https://github.com/GoogleContainerTools/skaffold/releases/tag/v1.19.0) onwards, skaffold is collecting failure error codes to help the team get more insights into common failure scenarios.
110
+
111
+
To take advantage of this framework, contributors can simply use the [`ErrDef`](https://github.com/GoogleContainerTools/skaffold/blob/master/pkg/skaffold/errors/err_def.go#L32) struct to throw meaningful actionable error messages and
112
+
improve user experience.
113
+
114
+
e.g In this example [PR](https://github.com/GoogleContainerTools/skaffold/pull/5273),
115
+
1. The contributor created 3 distinct error codes in [skaffold.proto](https://github.com/GoogleContainerTools/skaffold/pull/5088/files#diff-3883fe4549a47ae73a7a3a0afc00896b197d5ba8570906ba423769cf5a93a26f)
116
+
```
117
+
// Docker build error when listing containers.
118
+
INIT_DOCKER_NETWORK_LISTING_CONTAINERS = 122;
119
+
// Docker build error indicating an invalid container name (or id).
120
+
INIT_DOCKER_NETWORK_INVALID_CONTAINER_NAME = 123;
121
+
// Docker build error indicating the container referenced does not exists in the docker context used.
3. The contributor then used these error codes when creating an error in their [proposed code change](https://github.com/GoogleContainerTools/skaffold/pull/5088/files#diff-3fc5246574bf7367a232c6d682b22a4e22795d52eb1c81fe2c27ff052939d507R220).
135
+
They used the constructor `sErrors.NewError` in [pkg/skaffold/errors](https://github.com/GoogleContainerTools/skaffold/blob/54466ff6983e9fcf977d6e549119b4c1c4dc9e2b/pkg/skaffold/errors/err_def.go#L57) to inantiate an object of struct `ErrDef`.
// cacheRepo downloads the referenced git repository to skaffold's cache if required and returns the path to the target configuration file in that repository.
logrus.Fatalf("unable to check download status of repo %s at ref %s", g.Repo, g.Ref)
217
+
return"", nil
218
+
}
219
+
} else {
220
+
p, err:=git.SyncRepo(g, opts)
221
+
iferr!=nil {
222
+
r.cachedRepos[key] =err
223
+
return"", err
224
+
}
225
+
r.cachedRepos[key] =p
226
+
returnfilepath.Join(p, g.Path), nil
227
+
}
228
+
}
229
+
183
230
// checkRevisit ensures that each config is activated with the same set of active profiles
184
231
// It returns true if this config was visited once before. It additionally returns an error if the previous visit was with a different set of active profiles.
0 commit comments