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

Add Insecure item for ImageRepository #313

Closed
qiuming520 opened this issue Sep 20, 2022 · 2 comments
Closed

Add Insecure item for ImageRepository #313

qiuming520 opened this issue Sep 20, 2022 · 2 comments

Comments

@qiuming520
Copy link

Add Insecure ( +optional ) item for ImageRepository
In some cases, the secret of docker registry is kubernetes.io/dockerconfigjson, we need set insecure is true for HTTP.
I want to add feature for ImageRepository of Insecure ( +optional ) item

before

type ImageRepositorySpec struct {

func parseImageReference(url string) (name.Reference, error) {
if s := strings.Split(url, "://"); len(s) > 1 {
return nil, fmt.Errorf(".spec.image value should not start with URL scheme; remove '%s://'", s[0])
}
ref, err := name.ParseReference(url)
if err != nil {
return nil, err
}
imageName := strings.TrimPrefix(url, ref.Context().RegistryStr())
if s := strings.Split(imageName, ":"); len(s) > 1 {
return nil, fmt.Errorf(".spec.image value should not contain a tag; remove ':%s'", s[1])
}
return ref, nil
}

after

type ImageRepositorySpec struct {
	// +optional
	Insecure bool `json:"insecure,omitempty"`
       
        ...
}
func parseImageReference(url string, insecure bool) (name.Reference, error) {
	if s := strings.Split(url, "://"); len(s) > 1 {
		return nil, fmt.Errorf(".spec.image value should not start with URL scheme; remove '%s://'", s[0])
	}

	var ref name.Reference
	var err error
	if insecure {
		ref, err = name.ParseReference(url, name.Insecure)
	} else {
		ref, err = name.ParseReference(url)
	}
	
	if err != nil {
		return nil, err
	}

	imageName := strings.TrimPrefix(url, ref.Context().RegistryStr())
	if s := strings.Split(imageName, ":"); len(s) > 1 {
		return nil, fmt.Errorf(".spec.image value should not contain a tag; remove ':%s'", s[1])
	}

	return ref, nil
}

@aryan9600
Copy link
Member

hi @qiuming520, thanks for opening this. this is planned and right now blocked behind a RFC: fluxcd/flux2#3081. once the RFC gets merged, we can start work on this.

@qiuming520
Copy link
Author

Get !Hope to have a conclusion soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants