Skip to content
This repository was archived by the owner on Apr 6, 2026. It is now read-only.

Certs - Implementation of SDK and CLI#9

Merged
dborovcanin merged 12 commits into
absmach:mainfrom
nyagamunene:certs-7
Sep 4, 2024
Merged

Certs - Implementation of SDK and CLI#9
dborovcanin merged 12 commits into
absmach:mainfrom
nyagamunene:certs-7

Conversation

@nyagamunene

Copy link
Copy Markdown
Contributor

What type of PR is this?

This is a feature because it adds the following functionality: It add a SDK for software development.

What does this do?

It adds SDK for the API endpoints.

Which issue(s) does this PR fix/relate to?

Have you included tests for your changes?

Yes

Did you document any new/modified features?

No.

Notes

Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
@nyagamunene nyagamunene self-assigned this Aug 30, 2024
@dborovcanin dborovcanin marked this pull request as ready for review September 2, 2024 11:59
Comment thread sdk/sdk.go Outdated
Comment on lines +98 to +100
RetrieveCertDownloadToken(serialNumber string) (string, errors.SDKError)

OCSP(serialNumber string) (Cert, int, errors.SDKError)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add godoc comments with an explanation of what these methods do.

Comment thread sdk/sdk.go Outdated
Comment on lines +193 to +226
type mgSDK struct {
certsURL string
HostURL string

msgContentType ContentType
client *http.Client
curlFlag bool
}

type Config struct {
CertsURL string
HostURL string

MsgContentType ContentType
TLSVerification bool
CurlFlag bool
}

func NewSDK(conf Config) SDK {
return &mgSDK{
certsURL: conf.CertsURL,
HostURL: conf.HostURL,

msgContentType: conf.MsgContentType,
client: &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: !conf.TLSVerification,
},
},
},
curlFlag: conf.CurlFlag,
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Move this to the top. Swap the order of Config and mgSDK (i.e. declare exported struct first).

Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
@nyagamunene nyagamunene changed the title Certs - Implementation of SDK Certs - Implementation of SDK and CLI Sep 3, 2024
Comment thread Makefile Outdated
AM_DOCKER_IMAGE_NAME_PREFIX ?= absmach
BUILD_DIR = build
SERVICES = certs
SERVICES = certs cli

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove this argument, we have only certs service here.

Comment thread api/http/transport.go Outdated
}
req := issueCertReq{
entityID: chi.URLParam(r, "entityID"),
entityID: chi.URLParam(r, "entityID"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Extract string literal to constant.

Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>

@dborovcanin dborovcanin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

make dockers fails.
It should also be singular - make docker. There is no need for modularity here, simplify Makefile and Dockerfile and completely remove $SVC argument.

Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Comment thread Makefile Outdated
SERVICES = certs
DOCKERS = $(addprefix docker_,$(SERVICES))
DOCKERS_DEV = $(addprefix docker_dev_,$(SERVICES))
SERVICE = certs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@nyagamunene There was a misunderstanding, please revert the changes you made to Makefile and Dockerfile. I did not want to remove options to configure Go build flags (while some such as CGO_ENABLED could stay fixed) or build time and version. Let's remove the SERVICE param from Makefile since we have only one service.

Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>

@dborovcanin dborovcanin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let' keep SDK flat since we have only one SDK implementation for the time being: move pkg/sdk/go to pkg/sdk.

Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Comment thread Makefile Outdated
# SPDX-License-Identifier: Apache-2.0

AM_DOCKER_IMAGE_NAME_PREFIX ?= absmach
AM_DOCKER_IMAGE_NAME_PREFIX ?= ghcr.io/absmach/certs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The prefix is only ghcr.io/absmach.

Comment thread Makefile Outdated
ifdef pv
# Remove unused volumes
docker volume ls -f name=$(MF_DOCKER_IMAGE_NAME_PREFIX) -f dangling=true -q | xargs -r docker volume rm
docker volume ls -f name=$(AM_DOCKER_IMAGE_NAME_PREFIX) -f dangling=true -q | xargs -r docker volume rm

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks like we do not use pv. Remove everything unused.

Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
@dborovcanin dborovcanin merged commit 663b881 into absmach:main Sep 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Feature: Add sdk

2 participants