From 14050c4f770151b219fd2d592e809207cf68df42 Mon Sep 17 00:00:00 2001 From: Venkatreddy KP Date: Tue, 22 Aug 2023 21:37:11 +0530 Subject: [PATCH] added service roles to register service actions with IAM --- dockerfiles/server/Dockerfile | 2 +- server/data/service-config/roles.yaml | 0 server/{ => data}/store-apps/app_list.yaml | 0 server/{ => data}/store-apps/conf/falco.yaml | 0 server/{ => data}/store-apps/conf/loki.yaml | 0 server/{ => data}/store-apps/conf/signoz.yaml | 0 server/pkg/iam-client/client.go | 2 +- server/pkg/iam-client/register_service.go | 8 +++++--- server/pkg/store-apps/sync_store_apps.go | 4 ++-- 9 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 server/data/service-config/roles.yaml rename server/{ => data}/store-apps/app_list.yaml (100%) rename server/{ => data}/store-apps/conf/falco.yaml (100%) rename server/{ => data}/store-apps/conf/loki.yaml (100%) rename server/{ => data}/store-apps/conf/signoz.yaml (100%) diff --git a/dockerfiles/server/Dockerfile b/dockerfiles/server/Dockerfile index c4534fde6..a0678a34c 100644 --- a/dockerfiles/server/Dockerfile +++ b/dockerfiles/server/Dockerfile @@ -8,7 +8,7 @@ RUN CGO_ENABLED=0 go build -o ./build/server cmd/server/main.go FROM alpine:3.16 RUN apk add --no-cache libc6-compat -COPY --from=builder ./store-apps /store-apps +COPY --from=builder ./data /data COPY --from=builder ./build/server server USER 65532:65532 diff --git a/server/data/service-config/roles.yaml b/server/data/service-config/roles.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/server/store-apps/app_list.yaml b/server/data/store-apps/app_list.yaml similarity index 100% rename from server/store-apps/app_list.yaml rename to server/data/store-apps/app_list.yaml diff --git a/server/store-apps/conf/falco.yaml b/server/data/store-apps/conf/falco.yaml similarity index 100% rename from server/store-apps/conf/falco.yaml rename to server/data/store-apps/conf/falco.yaml diff --git a/server/store-apps/conf/loki.yaml b/server/data/store-apps/conf/loki.yaml similarity index 100% rename from server/store-apps/conf/loki.yaml rename to server/data/store-apps/conf/loki.yaml diff --git a/server/store-apps/conf/signoz.yaml b/server/data/store-apps/conf/signoz.yaml similarity index 100% rename from server/store-apps/conf/signoz.yaml rename to server/data/store-apps/conf/signoz.yaml diff --git a/server/pkg/iam-client/client.go b/server/pkg/iam-client/client.go index 16321658f..e78c7b8e4 100644 --- a/server/pkg/iam-client/client.go +++ b/server/pkg/iam-client/client.go @@ -63,7 +63,7 @@ func (c *Client) RegisterRolesActions() error { iamConn := cm.NewIamConn( cm.WithGrpcDialOption(grpcOpts...), cm.WithIamAddress(c.cfg.IAMURL), - cm.WithIamYamlPath("provide the yaml location here"), + cm.WithIamYamlPath(c.cfg.ServiceRolesConfigFilePath), ) ctx := context.Background() diff --git a/server/pkg/iam-client/register_service.go b/server/pkg/iam-client/register_service.go index d54796aad..3cf101326 100644 --- a/server/pkg/iam-client/register_service.go +++ b/server/pkg/iam-client/register_service.go @@ -8,9 +8,10 @@ import ( ) type Config struct { - IAMURL string `envconfig:"IAM_URL" required:"true"` - ServiceRegister bool `envconfig:"SERVICE_REGISTER" default:"false"` - ServiceName string `envconfig:"SERVICE_NAME" default:"capten-server"` + IAMURL string `envconfig:"IAM_URL" required:"true"` + ServiceRegister bool `envconfig:"SERVICE_REGISTER" default:"false"` + ServiceName string `envconfig:"SERVICE_NAME" default:"capten-server"` + ServiceRolesConfigFilePath string `envconfig:"SERVICE_ROLES_CONFIG_FILE_PATH" default:"/data/service-config/roles.yaml"` } func NewConfig() (Config, error) { @@ -47,5 +48,6 @@ func RegisterService(log logging.Logger) error { if err != nil { return errors.WithMessage(err, "Registering Roles and Actions in IAM failed") } + log.Infof("service registration successful") return nil } diff --git a/server/pkg/store-apps/sync_store_apps.go b/server/pkg/store-apps/sync_store_apps.go index 4658a4451..5db3e16a4 100644 --- a/server/pkg/store-apps/sync_store_apps.go +++ b/server/pkg/store-apps/sync_store_apps.go @@ -14,9 +14,9 @@ import ( ) type Config struct { - AppStoreAppConfigPath string `envconfig:"APP_STORE_APP_CONFIG_PATH" default:"/store-apps/conf"` + AppStoreAppConfigPath string `envconfig:"APP_STORE_APP_CONFIG_PATH" default:"/data/store-apps/conf"` SyncAppStore bool `envconfig:"SYNC_APP_STORE" default:"false"` - AppStoreConfigFile string `envconfig:"APP_STORE_CONFIG_FILE" default:"/store-apps/app_list.yaml"` + AppStoreConfigFile string `envconfig:"APP_STORE_CONFIG_FILE" default:"/data/store-apps/app_list.yaml"` } type AppStoreConfig struct {