Skip to content

Instantly share code, notes, and snippets.

@indrasaputra
Last active October 17, 2018 16:00
Show Gist options
  • Save indrasaputra/97390b9801c8d011ae29e7e93e9c684d to your computer and use it in GitHub Desktop.
Save indrasaputra/97390b9801c8d011ae29e7e93e9c684d to your computer and use it in GitHub Desktop.
type Kubernetes struct {
// omitted
}
type Service struct {
Name string
HasMetric bool
HasLog bool
HasDocument bool
HasCICD bool
HasResourceLimit bool
}
type Checker struct {
// omitted
}
func (k *Kubernetes) AllServices(ctx context.Context) ([]*Service, error) {
// HTTP request to Kubernetes API
}
func (c *Checker) ServiceHasMetric(ctx context.Context, svc *Service) (bool, error) {
// HTTP request to Prometheus API
// It will check whether the microservice has
// the standardized metric
}
func (c *Checker) ServiceHasLog(ctx context.Context, svc *Service) (bool, error) {
// HTTP request to Elasticsearch API
// It will check whether the microservice has
// the standardized log
}
func (c *Checker) ServiceHasDocument(ctx context.Context, svc *Service) (bool, error) {
// HTTP request to Github API
// It will check whether the microservice has
// the standardized README.md
}
func (c *Checker) ServiceHasCICD(ctx context.Context, svc *Service) (bool, error) {
// HTTP request to Github
// It will check whether the microservice has
// the standardized .gitlab-ci.yml
}
func (c *Checker) ServiceHasResourceLimit(ctx context.Context, svc *Service) (bool, error) {
// HTTP request to Kubernetes
// It will check whether the microservice has
// the standardized resource limit
}
func (c *Checker) CheckStandards(ctx context.Context, svc *Service) (*Service, []error) {
// the code below should describe what we need to do
var err error
var errorList []error
// check metric
svc.HasMetric, err = c.ServiceHasMetric(ctx, svc)
if err != nil {
errorList = append(errorList, err)
}
// check log
svc.HasLog, err = c.ServiceHasLog(ctx, svc)
if err != nil {
errorList = append(errorList, err)
}
// check document
svc.HasDocument, err = c.ServiceHasDocument(ctx, svc)
if err != nil {
errorList = append(errorList, err)
}
// check CI/CD
svc.HasCICD, err = c.ServiceHasCICD(ctx, svc)
if err != nil {
errorList = append(errorList, err)
}
// check resource limit
svc.HasResourceLimit, err = c.ServiceHasResourceLimit(ctx, svc)
if err != nil {
errorList = append(errorList, err)
}
return svc, errorList
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment