[go: up one dir, main page]

Draft: Refactor manifest functions to become context-aware

What does this MR do?

Refactors manifests package to make them context-aware. ObjectFactory, ObjectProcessor and ManifestFactory can accept framework.RuntimeContext.

Here is an example of its usage with SecretGenerator for ApplicationConfig inventory:

var railsSecretsGenerator = &inventory.SecretGenerator{
	Name:       "{{ .Resource.Name }}-rails-secrets",
	Namespace:  "{{ .Resource.Namespace }}",
	SecretType: corev1.SecretTypeOpaque,
	Generators: []secret.Generator{
		&secret.PrivateKeyGenerator{
			Algorithm: secret.RSA,
			Size:      2048,
			Names: []string{
				"openid_connect_signing_key",
			},
		},
		&secret.SequenceGenerator{
			Length:        128,
			CharacterSets: []secret.CharacterSet{secret.Hexadecimal},
			Names: []string{
				"secret_key_base",
				"otp_key_base",
				"db_key_base",
				"encrypted_settings_key_base",
			},
		},
	},
	GenerateIfNeeded: true,
}

var railsSecretsInventory = &manifests.ManifestFactory{
	manifests.Decorate(railsSecretsGenerator.Generate,
		processors.WithLabelsFrom(
			&framework.SummonByName[client.Object]{Name: "Resource"},
		),
	),
}

Author's Checklist

For anything in this list which will not be completed, please provide a reason in the MR discussion.

Required

  • Ensure a release milestone is set.
  • MR title and description are up to date, accurate, and descriptive.
  • MR targeting the appropriate branch.
  • MR has a green pipeline on GitLab.com.
  • When ready for review, MR is labeled workflowready for review per the MR workflow.

Expected

  • Test plan indicating conditions for success has been posted and passes.
  • Documentation is created or updated.
  • Tests are added.

Related issues

Merge request reports

Loading