当前位置: 首页>>代码示例>>Golang>>正文


Golang Component.GetKey方法代码示例

本文整理汇总了Golang中github.com/opencontrol/compliance-masonry/models/components/versions/base.Component.GetKey方法的典型用法代码示例。如果您正苦于以下问题:Golang Component.GetKey方法的具体用法?Golang Component.GetKey怎么用?Golang Component.GetKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/opencontrol/compliance-masonry/models/components/versions/base.Component的用法示例。


在下文中一共展示了Component.GetKey方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: LoadComponent

// LoadComponent imports components into a Component struct and adds it to the
// Components map.
func (openControl *OpenControl) LoadComponent(componentDir string) error {
	// Get file system assistance.
	fs := fs.OSUtil{}
	// Read the component file.
	fileName := filepath.Join(componentDir, "component.yaml")
	componentData, err := fs.OpenAndReadFile(fileName)
	if err != nil {
		return errors.New(constants.ErrComponentFileDNE)
	}
	// Parse the component.
	var component base.Component
	component, err = versions.ParseComponent(componentData, fileName)
	if err != nil {
		return err
	}
	// Ensure we have a key for the component.
	if component.GetKey() == "" {
		component.SetKey(getKey(componentDir))
	}
	// If the component is new, make sure we load the justifications as well.
	if openControl.Components.CompareAndAdd(component) {
		openControl.Justifications.LoadMappings(component)
	}
	return nil
}
开发者ID:geramirez,项目名称:compliance-masonry,代码行数:27,代码来源:opencontrol.go

示例2: getCoveredByVerification

func (openControl *OpenControlGitBook) getCoveredByVerification(text string, component base.Component, coveredBy common.CoveredBy) string {
	if component != nil {
		verification := component.GetVerifications().Get(coveredBy.VerificationKey)
		text += exportLink(
			fmt.Sprintf("%s - %s", component.GetName(), verification.Name),
			filepath.Join("..", "components", component.GetKey()+".md"),
		)
	}
	return text
}
开发者ID:geramirez,项目名称:compliance-masonry,代码行数:10,代码来源:gitbookCertification.go

示例3: testSet

func testSet(example base.Component, actual base.Component, t *testing.T) {
	// Check that the key was loaded
	if example.GetKey() != actual.GetKey() {
		t.Errorf("Expected %s, Actual: %s", example.GetKey(), actual.GetKey())
	}
	// Check that the name was loaded
	if example.GetName() != actual.GetName() {
		t.Errorf("Expected %s, Actual: %s", example.GetName(), actual.GetName())
	}
	// Check that the schema version was loaded
	if example.GetVersion().NE(actual.GetVersion()) {
		t.Errorf("Expected %f, Actual: %f", example.GetVersion(), actual.GetVersion())
	}
	// Check that the references were loaded
	if example.GetReferences().Len() != actual.GetReferences().Len() {
		t.Errorf("Expected %d, Actual: %d", example.GetReferences().Len(), actual.GetReferences().Len())
	}
	// Check that the satisfies data was loaded
	if len(example.GetAllSatisfies()) != len(actual.GetAllSatisfies()) {
		t.Errorf("Expected %d, Actual: %d", len(example.GetAllSatisfies()), len(actual.GetAllSatisfies()))
	}
	// Check Narratives and Parameters.
	for idx, _ := range actual.GetAllSatisfies() {
		assert.Equal(t, (example.GetAllSatisfies())[idx].GetNarratives(), (actual.GetAllSatisfies())[idx].GetNarratives())
		assert.Equal(t, (example.GetAllSatisfies())[idx].GetParameters(), (actual.GetAllSatisfies())[idx].GetParameters())
	}
	// Check the responsible role.
	assert.Equal(t, example.GetResponsibleRole(), actual.GetResponsibleRole())
	// Check that the verifications were loaded
	if example.GetVerifications().Len() != actual.GetVerifications().Len() {
		t.Errorf("Expected %d, Actual: %d", example.GetVerifications().Len(), actual.GetVerifications())
	}
}
开发者ID:geramirez,项目名称:compliance-masonry,代码行数:33,代码来源:parse_test.go

示例4: loadValidAndTestComponent

func loadValidAndTestComponent(path string, t *testing.T, example base.Component) {
	openControl := models.OpenControl{
		Justifications: models.NewJustifications(),
		Components:     components.NewComponents(),
	}
	err := openControl.LoadComponent(path)
	if !assert.Nil(t, err) {
		t.Fatalf("Expected reading component found in %s to be successful", path)
	}

	// Check the test set with the GetAndApply function
	openControl.Components.GetAndApply(example.GetKey(), func(actual base.Component) {
		testSet(example, actual, t)
	})
	// Check the test set with the simple Get function
	actualComponent := openControl.Components.Get(example.GetKey())
	testSet(example, actualComponent, t)

}
开发者ID:geramirez,项目名称:compliance-masonry,代码行数:19,代码来源:parse_test.go

示例5: CompareAndAdd

// CompareAndAdd compares to see if the component exists in the map. If not, it adds the component.
// This function is thread-safe.
func (components *Components) CompareAndAdd(component base.Component) bool {
	components.Lock()
	defer components.Unlock()
	added := false
	if _, exists := components.mapping[component.GetKey()]; !exists {
		components.mapping[component.GetKey()] = component
		added = true
	} else {
		log.Fatalf("Component: %s exisits!\n", component.GetKey())
	}
	return added
}
开发者ID:geramirez,项目名称:compliance-masonry,代码行数:14,代码来源:components.go

示例6: Add

// Add adds a new component to the component map
func (components *Components) Add(component base.Component) {
	components.Lock()
	components.mapping[component.GetKey()] = component
	components.Unlock()
}
开发者ID:geramirez,项目名称:compliance-masonry,代码行数:6,代码来源:components.go

示例7: LoadMappings

// LoadMappings loads a set of mappings from a component
func (justifications *Justifications) LoadMappings(component base.Component) {
	for _, satisfies := range component.GetAllSatisfies() {
		justifications.Add(satisfies.GetStandardKey(), satisfies.GetControlKey(), component.GetKey(), satisfies)
	}
}
开发者ID:geramirez,项目名称:compliance-masonry,代码行数:6,代码来源:justifications.go


注:本文中的github.com/opencontrol/compliance-masonry/models/components/versions/base.Component.GetKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。