Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

Commit

Permalink
Add spaces before comments and Fix spell checks
Browse files Browse the repository at this point in the history
  • Loading branch information
minhaj10p committed Jan 23, 2019
1 parent 90388ec commit aa73643
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
14 changes: 7 additions & 7 deletions generator/manipulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/docker/oscalkit/types/oscal/profile"
)

//ProcessAddition processess additions of a profile
// ProcessAddition processes additions of a profile
func ProcessAddition(alt profile.Alter, controls []catalog.Control) []catalog.Control {
for j, ctrl := range controls {
if ctrl.Id == alt.ControlId {
Expand All @@ -23,7 +23,7 @@ func ProcessAddition(alt profile.Alter, controls []catalog.Control) []catalog.Co
for _, catalogPart := range ctrl.Parts {
if p.Class == catalogPart.Class {
appended = true
//append with all the parts with matching classes
// append with all the parts with matching classes
parts := ModifyParts(p, ctrl.Parts)
ctrl.Parts = parts
}
Expand All @@ -43,7 +43,7 @@ func ProcessAddition(alt profile.Alter, controls []catalog.Control) []catalog.Co
for _, catalogPart := range subctrl.Parts {
if p.Class == catalogPart.Class {
appended = true
//append with all the parts
// append with all the parts
parts := ModifyParts(p, subctrl.Parts)
subctrl.Parts = parts
}
Expand All @@ -61,7 +61,7 @@ func ProcessAddition(alt profile.Alter, controls []catalog.Control) []catalog.Co
return controls
}

//ProcessAlteration processess alteration section of a profile
// ProcessAlteration processes alteration section of a profile
func ProcessAlteration(alterations []profile.Alter, c *catalog.Catalog) *catalog.Catalog {
for _, alt := range alterations {
for i, g := range c.Groups {
Expand All @@ -71,10 +71,10 @@ func ProcessAlteration(alterations []profile.Alter, c *catalog.Catalog) *catalog
return c
}

//ModifyParts modifies parts
// ModifyParts modifies parts
func ModifyParts(p catalog.Part, controlParts []catalog.Part) []catalog.Part {

//append with all the parts
// append with all the parts
var parts []catalog.Part
for i, part := range controlParts {
if p.Class != part.Class {
Expand All @@ -90,7 +90,7 @@ func ModifyParts(p catalog.Part, controlParts []catalog.Part) []catalog.Part {
return parts
}

//FindAlter finds alter manipulation attribute in the profile import chain
// FindAlter finds alter manipulation attribute in the profile import chain
func FindAlter(call profile.Call, p *profile.Profile) (*profile.Alter, error) {

ec := make(chan error)
Expand Down
9 changes: 5 additions & 4 deletions generator/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/docker/oscalkit/types/oscal/profile"
)

//CreateCatalogsFromProfile maps profile controls to multiple catalogs
// CreateCatalogsFromProfile maps profile controls to multiple catalogs
func CreateCatalogsFromProfile(profileArg *profile.Profile) ([]*catalog.Catalog, error) {

done := 0
Expand All @@ -22,19 +22,19 @@ func CreateCatalogsFromProfile(profileArg *profile.Profile) ([]*catalog.Catalog,
if err != nil {
return nil, err
}
//Get first import of the profile (which is a catalog)
// Get first import of the profile (which is a catalog)
for _, profileImport := range profileArg.Imports {
go func(profileImport profile.Import) {
c := make(chan *catalog.Catalog)
e := make(chan error)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

//ForEach Import's Href, Fetch the Catalog JSON file
// ForEach Import's Href, Fetch the Catalog JSON file
getCatalogForImport(ctx, profileImport, c, e)
select {
case importedCatalog := <-c:
//Prepare a new catalog object to merge into the final List of OutputCatalogs
// Prepare a new catalog object to merge into the final List of OutputCatalogs
if profileArg.Modify != nil {
importedCatalog = ProcessAlteration(profileArg.Modify.Alterations, importedCatalog)
}
Expand Down Expand Up @@ -69,6 +69,7 @@ func CreateCatalogsFromProfile(profileArg *profile.Profile) ([]*catalog.Catalog,
}
}

// GetMappedCatalogControlsFromImport gets mapped controls in catalog per profile import
func GetMappedCatalogControlsFromImport(importedCatalog *catalog.Catalog, profileImport profile.Import) (catalog.Catalog, error) {
newCatalog := catalog.Catalog{
Title: importedCatalog.Title,
Expand Down
2 changes: 1 addition & 1 deletion generator/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/docker/oscalkit/types/oscal/profile"
)

//AppendAlterations appends alter attributes from import chain
// AppendAlterations appends alter attributes from import chain
func AppendAlterations(p *profile.Profile) (*profile.Profile, error) {
if p.Modify == nil {
p.Modify = &profile.Modify{
Expand Down
8 changes: 4 additions & 4 deletions generator/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/docker/oscalkit/types/oscal/profile"
)

//ReadCatalog ReadCatalog
// ReadCatalog ReadCatalog
func ReadCatalog(r io.Reader) (*catalog.Catalog, error) {

o, err := oscal.New(r)
Expand All @@ -32,7 +32,7 @@ func ReadCatalog(r io.Reader) (*catalog.Catalog, error) {

}

//ReadProfile reads profile from byte array
// ReadProfile reads profile from byte array
func ReadProfile(r io.Reader) (*profile.Profile, error) {

o, err := oscal.New(r)
Expand All @@ -45,7 +45,7 @@ func ReadProfile(r io.Reader) (*profile.Profile, error) {
return o.Profile, nil
}

//GetFilePath GetFilePath
// GetFilePath GetFilePath
func GetFilePath(URL string) (string, error) {
uri, err := url.Parse(URL)
if err != nil {
Expand Down Expand Up @@ -74,7 +74,7 @@ func GetFilePath(URL string) (string, error) {

}

//GetAbsolutePath gets absolute file path
// GetAbsolutePath gets absolute file path
func GetAbsolutePath(path string) (string, error) {
if filepath.IsAbs(path) {
return path, nil
Expand Down

0 comments on commit aa73643

Please sign in to comment.