chore: Rename Projects to Templates (#880)

Customer feedback indicated projects was a confusing name.
After querying the team internally, it seemed unanimous
that it is indeed a confusing name.

Here's for a lil less confusion @ashmeer7 🥂
This commit is contained in:
Kyle Carberry
2022-04-06 12:42:40 -05:00
committed by GitHub
parent 584c8b4fc3
commit 02ad3f14f5
109 changed files with 2548 additions and 2547 deletions

View File

@ -21,10 +21,10 @@ type Organization struct {
UpdatedAt time.Time `json:"updated_at" validate:"required"`
}
// CreateProjectVersionRequest enables callers to create a new Project Version.
type CreateProjectVersionRequest struct {
// ProjectID optionally associates a version with a project.
ProjectID uuid.UUID `json:"project_id"`
// CreateTemplateVersionRequest enables callers to create a new Template Version.
type CreateTemplateVersionRequest struct {
// TemplateID optionally associates a version with a template.
TemplateID uuid.UUID `json:"template_id"`
StorageMethod database.ProvisionerStorageMethod `json:"storage_method" validate:"oneof=file,required"`
StorageSource string `json:"storage_source" validate:"required"`
@ -34,17 +34,17 @@ type CreateProjectVersionRequest struct {
ParameterValues []CreateParameterRequest `json:"parameter_values"`
}
// CreateProjectRequest provides options when creating a project.
type CreateProjectRequest struct {
// CreateTemplateRequest provides options when creating a template.
type CreateTemplateRequest struct {
Name string `json:"name" validate:"username,required"`
// VersionID is an in-progress or completed job to use as
// an initial version of the project.
// an initial version of the template.
//
// This is required on creation to enable a user-flow of validating a
// project works. There is no reason the data-model cannot support
// empty projects, but it doesn't make sense for users.
VersionID uuid.UUID `json:"project_version_id" validate:"required"`
// template works. There is no reason the data-model cannot support
// empty templates, but it doesn't make sense for users.
VersionID uuid.UUID `json:"template_version_id" validate:"required"`
ParameterValues []CreateParameterRequest `json:"parameter_values"`
}
@ -82,49 +82,49 @@ func (c *Client) ProvisionerDaemonsByOrganization(ctx context.Context, organizat
return daemons, json.NewDecoder(res.Body).Decode(&daemons)
}
// CreateProjectVersion processes source-code and optionally associates the version with a project.
// Executing without a project is useful for validating source-code.
func (c *Client) CreateProjectVersion(ctx context.Context, organizationID uuid.UUID, req CreateProjectVersionRequest) (ProjectVersion, error) {
// CreateTemplateVersion processes source-code and optionally associates the version with a template.
// Executing without a template is useful for validating source-code.
func (c *Client) CreateTemplateVersion(ctx context.Context, organizationID uuid.UUID, req CreateTemplateVersionRequest) (TemplateVersion, error) {
res, err := c.request(ctx, http.MethodPost,
fmt.Sprintf("/api/v2/organizations/%s/projectversions", organizationID.String()),
fmt.Sprintf("/api/v2/organizations/%s/templateversions", organizationID.String()),
req,
)
if err != nil {
return ProjectVersion{}, xerrors.Errorf("execute request: %w", err)
return TemplateVersion{}, xerrors.Errorf("execute request: %w", err)
}
defer res.Body.Close()
if res.StatusCode != http.StatusCreated {
return ProjectVersion{}, readBodyAsError(res)
return TemplateVersion{}, readBodyAsError(res)
}
var projectVersion ProjectVersion
return projectVersion, json.NewDecoder(res.Body).Decode(&projectVersion)
var templateVersion TemplateVersion
return templateVersion, json.NewDecoder(res.Body).Decode(&templateVersion)
}
// CreateProject creates a new project inside an organization.
func (c *Client) CreateProject(ctx context.Context, organizationID uuid.UUID, request CreateProjectRequest) (Project, error) {
// CreateTemplate creates a new template inside an organization.
func (c *Client) CreateTemplate(ctx context.Context, organizationID uuid.UUID, request CreateTemplateRequest) (Template, error) {
res, err := c.request(ctx, http.MethodPost,
fmt.Sprintf("/api/v2/organizations/%s/projects", organizationID.String()),
fmt.Sprintf("/api/v2/organizations/%s/templates", organizationID.String()),
request,
)
if err != nil {
return Project{}, xerrors.Errorf("execute request: %w", err)
return Template{}, xerrors.Errorf("execute request: %w", err)
}
defer res.Body.Close()
if res.StatusCode != http.StatusCreated {
return Project{}, readBodyAsError(res)
return Template{}, readBodyAsError(res)
}
var project Project
return project, json.NewDecoder(res.Body).Decode(&project)
var template Template
return template, json.NewDecoder(res.Body).Decode(&template)
}
// ProjectsByOrganization lists all projects inside of an organization.
func (c *Client) ProjectsByOrganization(ctx context.Context, organizationID uuid.UUID) ([]Project, error) {
// TemplatesByOrganization lists all templates inside of an organization.
func (c *Client) TemplatesByOrganization(ctx context.Context, organizationID uuid.UUID) ([]Template, error) {
res, err := c.request(ctx, http.MethodGet,
fmt.Sprintf("/api/v2/organizations/%s/projects", organizationID.String()),
fmt.Sprintf("/api/v2/organizations/%s/templates", organizationID.String()),
nil,
)
if err != nil {
@ -136,25 +136,25 @@ func (c *Client) ProjectsByOrganization(ctx context.Context, organizationID uuid
return nil, readBodyAsError(res)
}
var projects []Project
return projects, json.NewDecoder(res.Body).Decode(&projects)
var templates []Template
return templates, json.NewDecoder(res.Body).Decode(&templates)
}
// ProjectByName finds a project inside the organization provided with a case-insensitive name.
func (c *Client) ProjectByName(ctx context.Context, organizationID uuid.UUID, name string) (Project, error) {
// TemplateByName finds a template inside the organization provided with a case-insensitive name.
func (c *Client) TemplateByName(ctx context.Context, organizationID uuid.UUID, name string) (Template, error) {
res, err := c.request(ctx, http.MethodGet,
fmt.Sprintf("/api/v2/organizations/%s/projects/%s", organizationID.String(), name),
fmt.Sprintf("/api/v2/organizations/%s/templates/%s", organizationID.String(), name),
nil,
)
if err != nil {
return Project{}, xerrors.Errorf("execute request: %w", err)
return Template{}, xerrors.Errorf("execute request: %w", err)
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
return Project{}, readBodyAsError(res)
return Template{}, readBodyAsError(res)
}
var project Project
return project, json.NewDecoder(res.Body).Decode(&project)
var template Template
return template, json.NewDecoder(res.Body).Decode(&template)
}