Skip to content

Commit f19770b

Browse files
authored
chore: Rename ProjectHistory to ProjectVersion (#165)
* chore: Rename ProjectHistory to ProjectVersion Version more accurately represents version storage. This forks from the WorkspaceHistory name, but I think it's easier to understand Workspace history. * Rename files
1 parent 2b41ac6 commit f19770b

28 files changed

+595
-595
lines changed

coderd/coderd.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ func New(options *Options) http.Handler {
6666
r.Get("/", api.parametersByProject)
6767
r.Post("/", api.postParametersByProject)
6868
})
69-
r.Route("/history", func(r chi.Router) {
70-
r.Get("/", api.projectHistoryByOrganization)
71-
r.Post("/", api.postProjectHistoryByOrganization)
72-
r.Route("/{projecthistory}", func(r chi.Router) {
73-
r.Use(httpmw.ExtractProjectHistoryParam(api.Database))
74-
r.Get("/", api.projectHistoryByOrganizationAndName)
75-
r.Get("/parameters", api.projectHistoryParametersByOrganizationAndName)
69+
r.Route("/versions", func(r chi.Router) {
70+
r.Get("/", api.projectVersionsByOrganization)
71+
r.Post("/", api.postProjectVersionByOrganization)
72+
r.Route("/{projectversion}", func(r chi.Router) {
73+
r.Use(httpmw.ExtractProjectVersionParam(api.Database))
74+
r.Get("/", api.projectVersionByOrganizationAndName)
75+
r.Get("/parameters", api.projectVersionParametersByOrganizationAndName)
7676
})
7777
})
7878
})
@@ -91,7 +91,7 @@ func New(options *Options) http.Handler {
9191
r.Route("/{workspace}", func(r chi.Router) {
9292
r.Use(httpmw.ExtractWorkspaceParam(options.Database))
9393
r.Get("/", api.workspaceByUser)
94-
r.Route("/history", func(r chi.Router) {
94+
r.Route("/version", func(r chi.Router) {
9595
r.Post("/", api.postWorkspaceHistoryByUser)
9696
r.Get("/", api.workspaceHistoryByUser)
9797
r.Route("/{workspacehistory}", func(r chi.Router) {

coderd/projectparameter/projectparameter.go

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
type Scope struct {
1818
OrganizationID string
1919
ProjectID uuid.UUID
20-
ProjectHistoryID uuid.UUID
20+
ProjectVersionID uuid.UUID
2121
UserID string
2222
WorkspaceID uuid.UUID
2323
WorkspaceHistoryID uuid.UUID
@@ -40,21 +40,21 @@ func Compute(ctx context.Context, db database.Store, scope Scope) ([]Value, erro
4040
compute := &compute{
4141
db: db,
4242
computedParameterByName: map[string]Value{},
43-
projectHistoryParametersByName: map[string]database.ProjectParameter{},
43+
projectVersionParametersByName: map[string]database.ProjectParameter{},
4444
}
4545

4646
// All parameters for the project version!
47-
projectHistoryParameters, err := db.GetProjectParametersByHistoryID(ctx, scope.ProjectHistoryID)
47+
projectVersionParameters, err := db.GetProjectParametersByVersionID(ctx, scope.ProjectVersionID)
4848
if errors.Is(err, sql.ErrNoRows) {
49-
// This occurs when the project history has defined
49+
// This occurs when the project version has defined
5050
// no parameters, so we have nothing to compute!
5151
return []Value{}, nil
5252
}
5353
if err != nil {
5454
return nil, xerrors.Errorf("get project parameters: %w", err)
5555
}
56-
for _, projectHistoryParameter := range projectHistoryParameters {
57-
compute.projectHistoryParametersByName[projectHistoryParameter.Name] = projectHistoryParameter
56+
for _, projectVersionParameter := range projectVersionParameters {
57+
compute.projectVersionParametersByName[projectVersionParameter.Name] = projectVersionParameter
5858
}
5959

6060
// Organization parameters come first!
@@ -67,33 +67,33 @@ func Compute(ctx context.Context, db database.Store, scope Scope) ([]Value, erro
6767
}
6868

6969
// Default project parameter values come second!
70-
for _, projectHistoryParameter := range projectHistoryParameters {
71-
if !projectHistoryParameter.DefaultSourceValue.Valid {
70+
for _, projectVersionParameter := range projectVersionParameters {
71+
if !projectVersionParameter.DefaultSourceValue.Valid {
7272
continue
7373
}
74-
if !projectHistoryParameter.DefaultDestinationValue.Valid {
74+
if !projectVersionParameter.DefaultDestinationValue.Valid {
7575
continue
7676
}
7777

78-
destinationScheme, err := convertDestinationScheme(projectHistoryParameter.DefaultDestinationScheme)
78+
destinationScheme, err := convertDestinationScheme(projectVersionParameter.DefaultDestinationScheme)
7979
if err != nil {
80-
return nil, xerrors.Errorf("convert default destination scheme for project history parameter %q: %w", projectHistoryParameter.Name, err)
80+
return nil, xerrors.Errorf("convert default destination scheme for project version parameter %q: %w", projectVersionParameter.Name, err)
8181
}
8282

83-
switch projectHistoryParameter.DefaultSourceScheme {
83+
switch projectVersionParameter.DefaultSourceScheme {
8484
case database.ParameterSourceSchemeData:
85-
compute.computedParameterByName[projectHistoryParameter.Name] = Value{
85+
compute.computedParameterByName[projectVersionParameter.Name] = Value{
8686
Proto: &proto.ParameterValue{
8787
DestinationScheme: destinationScheme,
88-
Name: projectHistoryParameter.DefaultDestinationValue.String,
89-
Value: projectHistoryParameter.DefaultSourceValue.String,
88+
Name: projectVersionParameter.DefaultDestinationValue.String,
89+
Value: projectVersionParameter.DefaultSourceValue.String,
9090
},
9191
DefaultValue: true,
9292
Scope: database.ParameterScopeProject,
9393
ScopeID: scope.ProjectID.String(),
9494
}
9595
default:
96-
return nil, xerrors.Errorf("unsupported source scheme for project history parameter %q: %q", projectHistoryParameter.Name, string(projectHistoryParameter.DefaultSourceScheme))
96+
return nil, xerrors.Errorf("unsupported source scheme for project version parameter %q: %q", projectVersionParameter.Name, string(projectVersionParameter.DefaultSourceScheme))
9797
}
9898
}
9999

@@ -124,13 +124,13 @@ func Compute(ctx context.Context, db database.Store, scope Scope) ([]Value, erro
124124
return nil, err
125125
}
126126

127-
for _, projectHistoryParameter := range compute.projectHistoryParametersByName {
128-
if _, ok := compute.computedParameterByName[projectHistoryParameter.Name]; ok {
127+
for _, projectVersionParameter := range compute.projectVersionParametersByName {
128+
if _, ok := compute.computedParameterByName[projectVersionParameter.Name]; ok {
129129
continue
130130
}
131131
return nil, NoValueError{
132-
ParameterID: projectHistoryParameter.ID,
133-
ParameterName: projectHistoryParameter.Name,
132+
ParameterID: projectVersionParameter.ID,
133+
ParameterName: projectVersionParameter.Name,
134134
}
135135
}
136136

@@ -144,7 +144,7 @@ func Compute(ctx context.Context, db database.Store, scope Scope) ([]Value, erro
144144
type compute struct {
145145
db database.Store
146146
computedParameterByName map[string]Value
147-
projectHistoryParametersByName map[string]database.ProjectParameter
147+
projectVersionParametersByName map[string]database.ProjectParameter
148148
}
149149

150150
// Validates and computes the value for parameters; setting the value on "parameterByName".
@@ -158,8 +158,8 @@ func (c *compute) inject(ctx context.Context, scopeParams database.GetParameterV
158158
}
159159

160160
for _, scopedParameter := range scopedParameters {
161-
projectHistoryParameter, hasProjectHistoryParameter := c.projectHistoryParametersByName[scopedParameter.Name]
162-
if !hasProjectHistoryParameter {
161+
projectVersionParameter, hasProjectVersionParameter := c.projectVersionParametersByName[scopedParameter.Name]
162+
if !hasProjectVersionParameter {
163163
// Don't inject parameters that aren't defined by the project.
164164
continue
165165
}
@@ -169,7 +169,7 @@ func (c *compute) inject(ctx context.Context, scopeParams database.GetParameterV
169169
// If a parameter already exists, check if this variable can override it.
170170
// Injection hierarchy is the responsibility of the caller. This check ensures
171171
// project parameters cannot be overridden if already set.
172-
if !projectHistoryParameter.AllowOverrideSource && scopedParameter.Scope != database.ParameterScopeProject {
172+
if !projectVersionParameter.AllowOverrideSource && scopedParameter.Scope != database.ParameterScopeProject {
173173
continue
174174
}
175175
}
@@ -181,15 +181,15 @@ func (c *compute) inject(ctx context.Context, scopeParams database.GetParameterV
181181

182182
switch scopedParameter.SourceScheme {
183183
case database.ParameterSourceSchemeData:
184-
c.computedParameterByName[projectHistoryParameter.Name] = Value{
184+
c.computedParameterByName[projectVersionParameter.Name] = Value{
185185
Proto: &proto.ParameterValue{
186186
DestinationScheme: destinationScheme,
187187
Name: scopedParameter.SourceValue,
188188
Value: scopedParameter.DestinationValue,
189189
},
190190
}
191191
default:
192-
return xerrors.Errorf("unsupported source scheme: %q", string(projectHistoryParameter.DefaultSourceScheme))
192+
return xerrors.Errorf("unsupported source scheme: %q", string(projectVersionParameter.DefaultSourceScheme))
193193
}
194194
}
195195
return nil

coderd/projectparameter/projectparameter_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ func TestCompute(t *testing.T) {
2121
return projectparameter.Scope{
2222
OrganizationID: uuid.New().String(),
2323
ProjectID: uuid.New(),
24-
ProjectHistoryID: uuid.New(),
24+
ProjectVersionID: uuid.New(),
2525
UserID: uuid.NewString(),
2626
}
2727
}
2828
type projectParameterOptions struct {
2929
AllowOverrideSource bool
3030
AllowOverrideDestination bool
3131
DefaultDestinationScheme database.ParameterDestinationScheme
32-
ProjectHistoryID uuid.UUID
32+
ProjectVersionID uuid.UUID
3333
}
3434
generateProjectParameter := func(t *testing.T, db database.Store, opts projectParameterOptions) database.ProjectParameter {
3535
if opts.DefaultDestinationScheme == "" {
@@ -44,7 +44,7 @@ func TestCompute(t *testing.T) {
4444
param, err := db.InsertProjectParameter(context.Background(), database.InsertProjectParameterParams{
4545
ID: uuid.New(),
4646
Name: name,
47-
ProjectHistoryID: opts.ProjectHistoryID,
47+
ProjectVersionID: opts.ProjectVersionID,
4848
DefaultSourceScheme: database.ParameterSourceSchemeData,
4949
DefaultSourceValue: sql.NullString{
5050
String: sourceValue,
@@ -68,7 +68,7 @@ func TestCompute(t *testing.T) {
6868
scope := generateScope()
6969
parameter, err := db.InsertProjectParameter(context.Background(), database.InsertProjectParameterParams{
7070
ID: uuid.New(),
71-
ProjectHistoryID: scope.ProjectHistoryID,
71+
ProjectVersionID: scope.ProjectVersionID,
7272
Name: "hey",
7373
})
7474
require.NoError(t, err)
@@ -85,7 +85,7 @@ func TestCompute(t *testing.T) {
8585
db := databasefake.New()
8686
scope := generateScope()
8787
parameter := generateProjectParameter(t, db, projectParameterOptions{
88-
ProjectHistoryID: scope.ProjectHistoryID,
88+
ProjectVersionID: scope.ProjectVersionID,
8989
DefaultDestinationScheme: database.ParameterDestinationSchemeProvisionerVariable,
9090
})
9191
values, err := projectparameter.Compute(context.Background(), db, scope)
@@ -105,7 +105,7 @@ func TestCompute(t *testing.T) {
105105
db := databasefake.New()
106106
scope := generateScope()
107107
parameter := generateProjectParameter(t, db, projectParameterOptions{
108-
ProjectHistoryID: scope.ProjectHistoryID,
108+
ProjectVersionID: scope.ProjectVersionID,
109109
})
110110
_, err := db.InsertParameterValue(context.Background(), database.InsertParameterValueParams{
111111
ID: uuid.New(),
@@ -131,7 +131,7 @@ func TestCompute(t *testing.T) {
131131
db := databasefake.New()
132132
scope := generateScope()
133133
parameter := generateProjectParameter(t, db, projectParameterOptions{
134-
ProjectHistoryID: scope.ProjectHistoryID,
134+
ProjectVersionID: scope.ProjectVersionID,
135135
})
136136
value, err := db.InsertParameterValue(context.Background(), database.InsertParameterValueParams{
137137
ID: uuid.New(),
@@ -157,7 +157,7 @@ func TestCompute(t *testing.T) {
157157
db := databasefake.New()
158158
scope := generateScope()
159159
parameter := generateProjectParameter(t, db, projectParameterOptions{
160-
ProjectHistoryID: scope.ProjectHistoryID,
160+
ProjectVersionID: scope.ProjectVersionID,
161161
})
162162
_, err := db.InsertParameterValue(context.Background(), database.InsertParameterValueParams{
163163
ID: uuid.New(),
@@ -183,7 +183,7 @@ func TestCompute(t *testing.T) {
183183
scope := generateScope()
184184
parameter := generateProjectParameter(t, db, projectParameterOptions{
185185
AllowOverrideSource: true,
186-
ProjectHistoryID: scope.ProjectHistoryID,
186+
ProjectVersionID: scope.ProjectVersionID,
187187
})
188188
_, err := db.InsertParameterValue(context.Background(), database.InsertParameterValueParams{
189189
ID: uuid.New(),

coderd/projects_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,17 @@ func TestProjects(t *testing.T) {
148148
},
149149
}}, nil)
150150
require.NoError(t, err)
151-
history, err := server.Client.CreateProjectHistory(context.Background(), user.Organization, project.Name, coderd.CreateProjectHistoryRequest{
151+
version, err := server.Client.CreateProjectVersion(context.Background(), user.Organization, project.Name, coderd.CreateProjectVersionRequest{
152152
StorageMethod: database.ProjectStorageMethodInlineArchive,
153153
StorageSource: data,
154154
})
155155
require.NoError(t, err)
156156
require.Eventually(t, func() bool {
157-
projectHistory, err := server.Client.ProjectHistory(context.Background(), user.Organization, project.Name, history.Name)
157+
projectVersion, err := server.Client.ProjectVersion(context.Background(), user.Organization, project.Name, version.Name)
158158
require.NoError(t, err)
159-
return projectHistory.Import.Status.Completed()
159+
return projectVersion.Import.Status.Completed()
160160
}, 15*time.Second, 10*time.Millisecond)
161-
params, err := server.Client.ProjectHistoryParameters(context.Background(), user.Organization, project.Name, history.Name)
161+
params, err := server.Client.ProjectVersionParameters(context.Background(), user.Organization, project.Name, version.Name)
162162
require.NoError(t, err)
163163
require.Len(t, params, 1)
164164
require.Equal(t, "example", params[0].Name)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy