Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins that want to use a credential config file do not get credential propagation passed (cli flags work fine) #1171

Open
jakobmoellerdev opened this issue Dec 2, 2024 · 0 comments
Labels
area/ipcei Important Project of Common European Interest kind/bugfix Bug

Comments

@jakobmoellerdev
Copy link
Contributor

What happened:

Assuming a plugin implementing the uploader ppi, we expect that we can pass credentials to it like so:

- type: credentials.config.ocm.software
  consumers:
  - identity:
      type: JFrog
      #path: ""
      hostname: int.repositories.cloud.sap
  credentials:
  - type: Credentials/v1
    properties:
      username: "123"
      password: "123"

This is the equivalent of the CLI Call

ocm --cred :type=JFrog --cred :hostname=int.repositories.cloud.sap --cred username="123" --cred password="123"

Interestingly, only the CLI call does a consumer type matching correctly in consumerProviderRegistry. The credentials do not even get loaded correctly into the Credential Source, so I am assuming a problem in config parsing.

What you expected to happen:

Config File Direct Credentials get passed correctly.

How to reproduce it (as minimally and precisely as possible):

Write a config file as described above. Make sure that the credentials get used.

Anything else we need to know:

Uploader specification code on the PPI:

func (a *Uploader) ValidateSpecification(p ppi.Plugin, spec ppi.UploadTargetSpec) (*ppi.UploadTargetSpecInfo, error) {
	var info ppi.UploadTargetSpecInfo
	my, ok := spec.(*HelmTargetSpec)
	if !ok {
		return nil, fmt.Errorf("invalid spec type %T", spec)
	}

	purl, err := ParseURL(my.URL)
	if err != nil {
		return nil, fmt.Errorf("failed to parse URL: %w", err)
	}

	info.ConsumerId = credentials.ConsumerIdentity{
		cpi.ID_TYPE:   NAME,
		ID_HOSTNAME:   purl.Hostname(),
		ID_REPOSITORY: my.Repository,
	}
	if purl.Port() != "" {
		info.ConsumerId.SetNonEmptyValue(ID_PORT, purl.Port())
	}

	return &info, nil
}

Environment:

@github-actions github-actions bot added the area/ipcei Important Project of Common European Interest label Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ipcei Important Project of Common European Interest kind/bugfix Bug
Projects
Status: 🆕 ToDo
Development

No branches or pull requests

1 participant