Skip to content

Commit

Permalink
Add license information to repositories (#2515)
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Antonio Osorio <[email protected]>
  • Loading branch information
JAORMX authored Mar 7, 2024
1 parent e28f335 commit 5a78abc
Show file tree
Hide file tree
Showing 12 changed files with 1,294 additions and 1,230 deletions.
15 changes: 15 additions & 0 deletions database/migrations/000024_repo_license_add.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- Copyright 2024 Stacklok, Inc
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

ALTER TABLE repositories DROP COLUMN license;
15 changes: 15 additions & 0 deletions database/migrations/000024_repo_license_add.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- Copyright 2024 Stacklok, Inc
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

ALTER TABLE repositories ADD COLUMN license VARCHAR(255) DEFAULT 'unknown';
4 changes: 3 additions & 1 deletion database/query/repositories.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ INSERT INTO repositories (
webhook_url,
deploy_url,
clone_url,
default_branch) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, sqlc.arg(default_branch)) RETURNING *;
default_branch,
license
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, sqlc.arg(default_branch), sqlc.arg(license)) RETURNING *;

-- name: GetRepositoryByID :one
SELECT * FROM repositories WHERE id = $1;
Expand Down
1 change: 1 addition & 0 deletions docs/docs/ref/proto.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/controlplane/handlers_githubwebhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ func (s *Server) registerWebhookForRepository(
IsPrivate: repoGet.GetPrivate(),
IsFork: repoGet.GetFork(),
DefaultBranch: repoGet.GetDefaultBranch(),
License: repoGet.GetLicense().GetSPDXID(),
}

return regResult, nil
Expand Down
4 changes: 4 additions & 0 deletions internal/controlplane/handlers_repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ func (s *Server) RegisterRepository(ctx context.Context,
String: r.DefaultBranch,
Valid: true,
},
License: sql.NullString{
String: r.License,
Valid: true,
},
})
// even if we set the webhook, if we couldn't create it in the database, we'll return an error
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions internal/db/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 18 additions & 7 deletions internal/db/repositories.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/util/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ func PBRepositoryFromDB(dbrepo db.Repository) *minderv1.Repository {
DeployUrl: dbrepo.DeployUrl,
CloneUrl: dbrepo.CloneUrl,
DefaultBranch: dbrepo.DefaultBranch.String,
License: dbrepo.License.String,
CreatedAt: timestamppb.New(dbrepo.CreatedAt),
UpdatedAt: timestamppb.New(dbrepo.UpdatedAt),
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/api/openapi/minder/v1/minder.swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5a78abc

Please sign in to comment.