Skip to content

Refactor dependency resolution out of deployment handler #636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions ggdeploymentd/src/deployment_configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
#include <ggl/log.h>
#include <ggl/object.h>
#include <ggl/vector.h>
#include <linux/limits.h>
#include <string.h>
#include <stdint.h>

DeploymentConfiguration config;

GglError get_data_endpoint(GglByteVec *endpoint) {
static uint8_t resp_mem[128] = { 0 };
uint8_t resp_mem[128] = { 0 };
GglBuffer resp = GGL_BUF(resp_mem);

GglError ret = ggl_gg_config_read_str(
Expand All @@ -36,7 +38,7 @@ GglError get_data_endpoint(GglByteVec *endpoint) {
}

GglError get_data_port(GglByteVec *port) {
static uint8_t resp_mem[128] = { 0 };
uint8_t resp_mem[16] = { 0 };
GglBuffer resp = GGL_BUF(resp_mem);

GglError ret = ggl_gg_config_read_str(
Expand All @@ -58,7 +60,7 @@ GglError get_data_port(GglByteVec *port) {
}

GglError get_region(GglByteVec *region) {
static uint8_t resp_mem[128] = { 0 };
uint8_t resp_mem[30] = { 0 };
GglBuffer resp = GGL_BUF(resp_mem);

GglError ret = ggl_gg_config_read_str(
Expand All @@ -75,12 +77,12 @@ GglError get_region(GglByteVec *region) {
return ret;
}

ggl_byte_vec_chain_append(&ret, region, resp);
ggl_byte_vec_append(region, resp);
return ret;
}

GglError get_thing_name(char **thing_name) {
static uint8_t resp_mem[128] = { 0 };
GglError get_thing_name(GglBuffer *thing_name) {
uint8_t resp_mem[128] = { 0 };
GglBuffer resp = GGL_BUF(resp_mem);

GglError ret = ggl_gg_config_read_str(
Expand All @@ -91,12 +93,13 @@ GglError get_thing_name(char **thing_name) {
return ret;
}

*thing_name = (char *) resp.data;
memcpy(thing_name->data, resp.data, resp.len);
thing_name->len = resp.len;
return GGL_ERR_OK;
}

GglError get_root_ca_path(char **root_ca_path) {
static uint8_t resp_mem[128] = { 0 };
GglError get_root_ca_path(GglBuffer *root_ca_path) {
uint8_t resp_mem[PATH_MAX] = { 0 };
GglBuffer resp = GGL_BUF(resp_mem);

GglError ret = ggl_gg_config_read_str(
Expand All @@ -107,12 +110,13 @@ GglError get_root_ca_path(char **root_ca_path) {
return ret;
}

*root_ca_path = (char *) resp.data;
memcpy(root_ca_path->data, resp.data, resp.len);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to verify that the buffer is at least as long as resp.data before copying over the data. Similarly in other places

root_ca_path->len = resp.len;
return GGL_ERR_OK;
}

GglError get_tes_cred_url(char **tes_cred_url) {
static uint8_t resp_mem[128] = { 0 };
GglError get_tes_cred_url(GglBuffer *tes_cred_url) {
uint8_t resp_mem[128] = { 0 };
GglBuffer resp = GGL_BUF(resp_mem);

GglError ret = ggl_gg_config_read_str(
Expand All @@ -129,12 +133,13 @@ GglError get_tes_cred_url(char **tes_cred_url) {
return ret;
}

*tes_cred_url = (char *) resp.data;
memcpy(tes_cred_url->data, resp.data, resp.len);
tes_cred_url->len = resp.len;
return GGL_ERR_OK;
}

GglError get_posix_user(char **posix_user) {
static uint8_t resp_mem[128] = { 0 };
GglError get_posix_user(GglBuffer *posix_user) {
uint8_t resp_mem[128] = { 0 };
GglBuffer resp = GGL_BUF(resp_mem);

GglError ret = ggl_gg_config_read_str(
Expand All @@ -152,12 +157,13 @@ GglError get_posix_user(char **posix_user) {
return ret;
}

*posix_user = (char *) resp.data;
memcpy(posix_user->data, resp.data, resp.len);
posix_user->len = resp.len;
return GGL_ERR_OK;
}

GglError get_private_key_path(GglByteVec *pkey_path) {
uint8_t resp_mem[128] = { 0 };
uint8_t resp_mem[PATH_MAX] = { 0 };
GglBuffer resp = GGL_BUF(resp_mem);

GglError ret = ggl_gg_config_read_str(
Expand All @@ -169,12 +175,12 @@ GglError get_private_key_path(GglByteVec *pkey_path) {
return ret;
}

ggl_byte_vec_chain_append(&ret, pkey_path, resp);
ggl_byte_vec_append(pkey_path, resp);
return ret;
}

GglError get_cert_path(GglByteVec *cert_path) {
static uint8_t resp_mem[128] = { 0 };
uint8_t resp_mem[PATH_MAX] = { 0 };
GglBuffer resp = GGL_BUF(resp_mem);

GglError ret = ggl_gg_config_read_str(
Expand All @@ -186,12 +192,12 @@ GglError get_cert_path(GglByteVec *cert_path) {
return ret;
}

ggl_byte_vec_chain_append(&ret, cert_path, resp);
ggl_byte_vec_append(cert_path, resp);
return ret;
}

GglError get_rootca_path(GglByteVec *rootca_path) {
static uint8_t resp_mem[128] = { 0 };
uint8_t resp_mem[PATH_MAX] = { 0 };
GglBuffer resp = GGL_BUF(resp_mem);

GglError ret = ggl_gg_config_read_str(
Expand All @@ -203,6 +209,6 @@ GglError get_rootca_path(GglByteVec *rootca_path) {
return ret;
}

ggl_byte_vec_chain_append(&ret, rootca_path, resp);
ggl_byte_vec_append(rootca_path, resp);
return ret;
}
9 changes: 5 additions & 4 deletions ggdeploymentd/src/deployment_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef GGDEPLOYMENTD_DEPLOYMENT_CONFIGURATION_H
#define GGDEPLOYMENTD_DEPLOYMENT_CONFIGURATION_H

#include <ggl/buffer.h>
#include <ggl/error.h>
#include <ggl/vector.h>

Expand All @@ -22,10 +23,10 @@ extern DeploymentConfiguration config;
GglError get_data_endpoint(GglByteVec *endpoint);
GglError get_data_port(GglByteVec *port);
GglError get_region(GglByteVec *region);
GglError get_thing_name(char **thing_name);
GglError get_root_ca_path(char **root_ca_path);
GglError get_tes_cred_url(char **tes_cred_url);
GglError get_posix_user(char **posix_user);
GglError get_thing_name(GglBuffer *thing_name);
GglError get_root_ca_path(GglBuffer *root_ca_path);
GglError get_tes_cred_url(GglBuffer *tes_cred_url);
GglError get_posix_user(GglBuffer *posix_user);
GglError get_private_key_path(GglByteVec *pkey_path);
GglError get_cert_path(GglByteVec *cert_path);
GglError get_rootca_path(GglByteVec *rootca_path);
Expand Down
Loading