Skip to content

Commit

Permalink
Merge branch 'main' into change-log-verb
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam0Brien authored Sep 27, 2024
2 parents db239cf + 28c7c16 commit e3860d7
Show file tree
Hide file tree
Showing 49 changed files with 1,081 additions and 547 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ bin/
.vscode/
.idea/
*.swp
.docker

inventory.db
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.10-1052.1724178568 AS builder
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.10-1086 AS builder

ARG TARGETARCH
USER root
Expand All @@ -24,7 +24,7 @@ COPY main.go Makefile ./
ARG VERSION
RUN VERSION=${VERSION} make build

FROM registry.access.redhat.com/ubi8/ubi-minimal:8.10-1052.1724178568
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.10-1086

COPY --from=builder /workspace/bin/inventory-api /usr/local/bin/

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile-e2e
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.10-1052.1724178568 AS builder
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.10-1086 AS builder

ARG TARGETARCH
USER root
Expand All @@ -22,7 +22,7 @@ COPY test/e2e .
RUN go mod tidy
RUN go test -c -o e2e-inventory-tests

FROM registry.access.redhat.com/ubi8/ubi-minimal:8.10-1052.1724178568
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.10-1086

COPY --from=builder /workspace/e2e-inventory-tests /usr/local/bin/

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ Depending on the config file you're using, the curl command will require additio
To add a k8s-policy_ispropagatedto-k8s-cluster relationship you can use the following `curl` command:

```bash
curl -H "Content-Type: application/json" --data "@data/k8spolicy_ispropagatedto_k8scluster.json" http://localhost:8081/api/inventory/v1beta1/resource-relationships/k8s-policy.is-propagated.to-k8s-cluster
curl -H "Content-Type: application/json" --data "@data/k8spolicy_ispropagatedto_k8scluster.json" http://localhost:8081/api/inventory/v1beta1/resource-relationships/k8s-policy_is-propagated-to_k8s-cluster
```

To update it, use the `PUT` verb as follows:

```bash
curl -X PUT -H "Content-Type: application/json" --data "@data/k8spolicy_ispropagatedto_k8scluster.json" http://localhost:8081/api/inventory/v1beta1/resource-relationships/k8s-policy.is-propagated.to-k8s-cluster
curl -X PUT -H "Content-Type: application/json" --data "@data/k8spolicy_ispropagatedto_k8scluster.json" http://localhost:8081/api/inventory/v1beta1/resource-relationships/k8s-policy_is-propagated-to_k8s-cluster
```

And finally, to delete it, use the `DELETE` verb, notice that the data file is different this time. We only need the reporter data to delete a relationship.

```bash
curl -X DELETE -H "Content-Type: application/json" --data "@data/relationship_reporter_data.json" http://localhost:8081/api/inventory/v1beta1/resource-relationships/k8s-policy.is-propagated.to-k8s-cluster
curl -X DELETE -H "Content-Type: application/json" --data "@data/relationship_reporter_data.json" http://localhost:8081/api/inventory/v1beta1/resource-relationships/k8s-policy_is-propagated-to_k8s-cluster
```

### Running with `make run`
Expand Down
1 change: 1 addition & 0 deletions api/buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ plugins:
- fq_schema_naming=true
- default_response=true
- naming=json
- enum_type=string

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

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import "buf/validate/validate.proto";
option go_package = "github.com/project-kessel/inventory-api/api/kessel/inventory/v1beta1/relationships";
option java_multiple_files = true;
option java_package = "org.project_kessel.api.inventory.v1beta1.relationships";
option java_outer_classname = "K8SPolicyIsPropagatedToK8SClusterProto";

message K8SPolicyIsPropagatedToK8SCluster {

Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "buf/validate/validate.proto";
option go_package = "github.com/project-kessel/inventory-api/api/kessel/inventory/v1beta1/relationships";
option java_multiple_files = true;
option java_package = "org.project_kessel.api.inventory.v1beta1.relationships";
option java_outer_classname = "K8SPolicyIsPropagatedToK8SClusterDetailProto";

message K8SPolicyIsPropagatedToK8SClusterDetail {

Expand Down
5 changes: 3 additions & 2 deletions api/kessel/inventory/v1beta1/resources/k8s_policy.pb.go

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

1 change: 1 addition & 0 deletions api/kessel/inventory/v1beta1/resources/k8s_policy.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import "kessel/inventory/v1beta1/resources/reporter_data.proto";
option go_package = "github.com/project-kessel/inventory-api/api/kessel/inventory/v1beta1/resources";
option java_multiple_files = true;
option java_package = "org.project_kessel.api.inventory.v1beta1.resources";
option java_outer_classname = "K8sPolicyProto";

message K8sPolicy {
// Metadata about this resource
Expand Down
17 changes: 9 additions & 8 deletions api/kessel/inventory/v1beta1/resources/k8s_policy_detail.pb.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "buf/validate/validate.proto";
option go_package = "github.com/project-kessel/inventory-api/api/kessel/inventory/v1beta1/resources";
option java_multiple_files = true;
option java_package = "org.project_kessel.api.inventory.v1beta1.resources";
option java_outer_classname = "K8sPolicyDetailProto";

message K8sPolicyDetail {

Expand Down
11 changes: 11 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"os"
"path/filepath"
"strings"
"strconv"


"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand All @@ -20,6 +22,7 @@ import (
"github.com/project-kessel/inventory-api/internal/eventing"
"github.com/project-kessel/inventory-api/internal/server"
"github.com/project-kessel/inventory-api/internal/storage"
clowder "github.com/redhatinsights/app-common-go/pkg/api/v1"
)

// go build -ldflags "-X cmd.Version=x.y.z"
Expand Down Expand Up @@ -83,6 +86,14 @@ func init() {
panic(err)
}

if clowder.IsClowderEnabled() {
options.Storage.Postgres.Host = clowder.LoadedConfig.Database.Hostname
options.Storage.Postgres.Port = strconv.Itoa(clowder.LoadedConfig.Database.Port)
options.Storage.Postgres.User = clowder.LoadedConfig.Database.Username
options.Storage.Postgres.Password = clowder.LoadedConfig.Database.Password
options.Storage.Postgres.DbName = clowder.LoadedConfig.Database.Name
}

initConfig()
logLevel := getLogLevel()
logger, baseLogger = initLogger(logLevel)
Expand Down
24 changes: 12 additions & 12 deletions cmd/serve/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,20 @@ import (
"context"
"fmt"
relationshipsctl "github.com/project-kessel/inventory-api/internal/biz/relationships/k8spolicy"
hostsctl "github.com/project-kessel/inventory-api/internal/biz/resources/hosts"
k8sclustersctl "github.com/project-kessel/inventory-api/internal/biz/resources/k8sclusters"
k8spoliciesctl "github.com/project-kessel/inventory-api/internal/biz/resources/k8spolicies"
notifsctl "github.com/project-kessel/inventory-api/internal/biz/resources/notificationsintegrations"
relationshipsrepo "github.com/project-kessel/inventory-api/internal/data/relationships/k8spolicy"
hostsrepo "github.com/project-kessel/inventory-api/internal/data/resources/hosts"
k8sclustersrepo "github.com/project-kessel/inventory-api/internal/data/resources/k8sclusters"
k8spoliciesrepo "github.com/project-kessel/inventory-api/internal/data/resources/k8spolicies"
notifsrepo "github.com/project-kessel/inventory-api/internal/data/resources/notificationsintegrations"
relationshipssvc "github.com/project-kessel/inventory-api/internal/service/relationships/k8spolicy"
hostssvc "github.com/project-kessel/inventory-api/internal/service/resources/hosts"
k8sclusterssvc "github.com/project-kessel/inventory-api/internal/service/resources/k8sclusters"
k8spoliciessvc "github.com/project-kessel/inventory-api/internal/service/resources/k8spolicies"
notifssvc "github.com/project-kessel/inventory-api/internal/service/resources/notificationsintegrations"
"os"
"os/signal"
"syscall"
Expand All @@ -29,20 +41,8 @@ import (
pb "github.com/project-kessel/inventory-api/api/kessel/inventory/v1beta1/resources"

healthctl "github.com/project-kessel/inventory-api/internal/biz/health"
hostsctl "github.com/project-kessel/inventory-api/internal/biz/hosts"
k8sclustersctl "github.com/project-kessel/inventory-api/internal/biz/k8sclusters"
k8spoliciesctl "github.com/project-kessel/inventory-api/internal/biz/k8spolicies"
notifsctl "github.com/project-kessel/inventory-api/internal/biz/notificationsintegrations"
healthrepo "github.com/project-kessel/inventory-api/internal/data/health"
hostsrepo "github.com/project-kessel/inventory-api/internal/data/hosts"
k8sclustersrepo "github.com/project-kessel/inventory-api/internal/data/k8sclusters"
k8spoliciesrepo "github.com/project-kessel/inventory-api/internal/data/k8spolicies"
notifsrepo "github.com/project-kessel/inventory-api/internal/data/notificationsintegrations"
healthssvc "github.com/project-kessel/inventory-api/internal/service/health"
hostssvc "github.com/project-kessel/inventory-api/internal/service/hosts"
k8sclusterssvc "github.com/project-kessel/inventory-api/internal/service/k8sclusters"
k8spoliciessvc "github.com/project-kessel/inventory-api/internal/service/k8spolicies"
notifssvc "github.com/project-kessel/inventory-api/internal/service/notificationsintegrations"
)

func NewCommand(
Expand Down
Loading

0 comments on commit e3860d7

Please sign in to comment.