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

about raw data api #715

Open
allenhaozi opened this issue Aug 22, 2023 · 4 comments
Open

about raw data api #715

allenhaozi opened this issue Aug 22, 2023 · 4 comments

Comments

@allenhaozi
Copy link

For our scenario, we'll add a static/deploy.j2 to helm chart to render the helm charts information

So we need to get this file through the api,

However, the current api does not support it, as follows:

chartManipulationRoutes := []*cm_router.Route{
		{Method: "GET", Path: "/api/:repo/charts", Handler: s.getAllChartsRequestHandler, Action: cm_auth.PullAction},
		{Method: "HEAD", Path: "/api/:repo/charts/:name", Handler: s.headChartRequestHandler, Action: cm_auth.PullAction},
		{Method: "GET", Path: "/api/:repo/charts/:name", Handler: s.getChartRequestHandler, Action: cm_auth.PullAction},
		{Method: "HEAD", Path: "/api/:repo/charts/:name/:version", Handler: s.headChartVersionRequestHandler, Action: cm_auth.PullAction},
		{Method: "GET", Path: "/api/:repo/charts/:name/:version", Handler: s.getChartVersionRequestHandler, Action: cm_auth.PullAction},
		{Method: "GET", Path: "/api/:repo/charts/:name/:version/templates", Handler: s.getStorageObjectTemplateRequestHandler, Action: cm_auth.PullAction},
		{Method: "GET", Path: "/api/:repo/charts/:name/:version/values", Handler: s.getStorageObjectValuesRequestHandler, Action: cm_auth.PullAction},
		{Method: "POST", Path: "/api/:repo/charts", Handler: s.postRequestHandler, Action: cm_auth.PushAction},
		{Method: "POST", Path: "/api/:repo/prov", Handler: s.postProvenanceFileRequestHandler, Action: cm_auth.PushAction},
	}

In the helm charts definition, the raw field can be as follows:

type Chart struct {
	// Raw contains the raw contents of the files originally contained in the chart archive.
	//
	// This should not be used except in special cases like `helm show values`,
	// where we want to display the raw values, comments and all.
	Raw []*File `json:"-"`
	// Metadata is the contents of the Chartfile.
	Metadata *Metadata `json:"metadata"`
	// Lock is the contents of Chart.lock.
	Lock *Lock `json:"lock"`
	// Templates for this chart.
	Templates []*File `json:"templates"`
	// Values are default config for this chart.
	Values map[string]interface{} `json:"values"`
	// Schema is an optional JSON schema for imposing structure on Values
	Schema []byte `json:"schema"`
	// Files are miscellaneous files in a chart archive,
	// e.g. README, LICENSE, etc.
	Files []*File `json:"files"`

	parent       *Chart
	dependencies []*Chart
}

Can we provide the relevant api?
for example:

{Method: "GET", Path: "/api/:repo/charts/:name/:version/raw", Handler: s.getStorageObjectRawRequestHandler, Action: cm_auth.PullAction},

I can contribute this pr

@cbuto
Copy link
Contributor

cbuto commented Aug 22, 2023

@allenhaozi does the templates route return what you need? 🤔 or is the file you need outside of the templates dir?

/api/:repo/charts/:name/:version/templates

@allenhaozi
Copy link
Author

@allenhaozi does the templates route return what you need? 🤔 or is the file you need outside of the templates dir?

/api/:repo/charts/:name/:version/templates

@cbuto , I need the file outside of the templates dir
the templates route response
https://github.com/helm/chartmuseum/blob/main/pkg/chartmuseum/server/multitenant/handlers.go#L184

c.JSON(200, map[string]interface{}{
		"templates": chrt.Templates,
		"values":    chrt.Values,
	})

it did not return the raw except templates and values

@cbuto
Copy link
Contributor

cbuto commented Aug 23, 2023

@allenhaozi got it. in that case, I'd be good with a PR that exposes a new endpoint to return the raw contents from the chart.

@scbizu @jdolitsky do you guys have any concerns about this?

@scbizu
Copy link
Contributor

scbizu commented Aug 24, 2023

I am OK with the PR , but the in-memory unarchive will raise the latency , IDK if it will cause the abuse .

allenhaozi added a commit to allenhaozi/chartmuseum that referenced this issue Sep 8, 2023
allenhaozi added a commit to allenhaozi/chartmuseum that referenced this issue Sep 8, 2023
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

3 participants