diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..265afa5f --- /dev/null +++ b/Makefile @@ -0,0 +1,37 @@ + +CHART_VERSION ?= "" +CHART_URL ?= "./charts/trusted-artifact-signer" + +LDFLAGS=-X securesign/sigstore-ocp/tas-installer/cmd.helmChartVersion=$(CHART_VERSION) \ + -X securesign/sigstore-ocp/tas-installer/cmd.helmChartUrl=$(CHART_URL) + +PLATFORMS=darwin linux windows +ARCHITECTURES=amd64 arm64 + +.PHONY: build +build: build-tas-installer + +.PHONY: test +test: test-tas-installer + +.PHONY: cross +cross: cross-tas-installer + +.PHONY: build-tas-installer +build-tas-installer: + CGO_ENABLED=0 go build -C ./tas-installer -trimpath -ldflags "$(LDFLAGS)" -o ../tas-install + +.PHONY: test-tas-installer +test-tas-installer: + cd ./tas-installer && go test ./... + +.PHONY: cross-tas-installer +cross-tas-installer: + $(foreach GOOS, $(PLATFORMS),\ + $(foreach GOARCH, $(ARCHITECTURES), $(shell export GOOS=$(GOOS); export GOARCH=$(GOARCH); \ + go build -C ./tas-installer -trimpath -ldflags "$(LDFLAGS)" -o ../tas-install-$(GOOS)-$(GOARCH)))) + +.PHONY: clean +clean: + rm -f tas-install + rm -f tas-install-* diff --git a/tas-installer/cmd/install.go b/tas-installer/cmd/install.go index 050dc449..e3494a9b 100644 --- a/tas-installer/cmd/install.go +++ b/tas-installer/cmd/install.go @@ -21,6 +21,7 @@ var ( helmChartVersion string helmValuesFile string oidcConfig oidc.OIDCConfig + helmChartUrl = "./charts/trusted-artifact-signer" ) var installCmd = &cobra.Command{ @@ -70,7 +71,7 @@ func installTas(tasNamespace string) error { }, func() error { log.Print("installing helm chart") - if err := install.HandleHelmChartInstall(kc, oidcConfig, tasNamespace, tasReleaseName, helmValuesFile, helmChartVersion); err != nil { + if err := install.HandleHelmChartInstall(kc, oidcConfig, tasNamespace, tasReleaseName, helmValuesFile, helmChartUrl, helmChartVersion); err != nil { return err } return nil @@ -85,11 +86,12 @@ func installTas(tasNamespace string) error { } func init() { - installCmd.PersistentFlags().StringVar(&helmChartVersion, "chartVersion", "0.1.26", "Version of the Helm chart") + installCmd.PersistentFlags().StringVar(&helmChartVersion, "chartVersion", helmChartVersion, "Version of the Helm chart") installCmd.PersistentFlags().StringVar(&helmValuesFile, "valuesFile", "", "Custom values file for chart configuration") installCmd.PersistentFlags().StringVar(&oidcConfig.IssuerURL, "oidc-issuer-url", "", "Specify the OIDC issuer URL e.g for keycloak: https://[keycloak-domain]/auth/realms/[realm-name]") installCmd.PersistentFlags().StringVar(&oidcConfig.ClientID, "oidc-client-id", "", "Specify the OIDC client ID") installCmd.PersistentFlags().StringVar(&oidcConfig.Type, "oidc-type", "", "Specify the OIDC type") + installCmd.PersistentFlags().StringVar(&helmChartUrl, "chartUrl", helmChartUrl, "URL to Trusted Artifact Signer Helm chart") } func getFulcioSecretFiles() map[string]string { diff --git a/tas-installer/internal/install/install.go b/tas-installer/internal/install/install.go index 86f8065e..d3ec873c 100644 --- a/tas-installer/internal/install/install.go +++ b/tas-installer/internal/install/install.go @@ -13,8 +13,8 @@ import ( "time" ) -func HandleHelmChartInstall(kc *kubernetes.KubernetesClient, oidcConfig oidc.OIDCConfig, tasNamespace, tasReleaseName, helmValuesFile, helmChartVersion string) error { - if err := helm.InstallTrustedArtifactSigner(kc, oidcConfig, tasNamespace, tasReleaseName, helmValuesFile, helmChartVersion); err != nil { +func HandleHelmChartInstall(kc *kubernetes.KubernetesClient, oidcConfig oidc.OIDCConfig, tasNamespace, tasReleaseName, helmValuesFile, helmChartUrl, helmChartVersion string) error { + if err := helm.InstallTrustedArtifactSigner(kc, oidcConfig, tasNamespace, tasReleaseName, helmValuesFile, helmChartUrl, helmChartVersion); err != nil { return err } return nil diff --git a/tas-installer/pkg/helm/helm.go b/tas-installer/pkg/helm/helm.go index 12fbbde2..b1c13b94 100644 --- a/tas-installer/pkg/helm/helm.go +++ b/tas-installer/pkg/helm/helm.go @@ -37,8 +37,7 @@ func UninstallTrustedArtifactSigner(tasNamespace, tasReleaseName string) (*relea return action.NewUninstall(actionConfig).Run(tasReleaseName) } -func InstallTrustedArtifactSigner(kc *kubernetes.KubernetesClient, oidcConfig oidc.OIDCConfig, tasNamespace, tasReleaseName, pathToValuesFile, chartVersion string) error { - chartUrl := "charts/trusted-artifact-signer" +func InstallTrustedArtifactSigner(kc *kubernetes.KubernetesClient, oidcConfig oidc.OIDCConfig, tasNamespace, tasReleaseName, pathToValuesFile, chartUrl, chartVersion string) error { tv := templatedValues{ OpenShiftAppsSubdomain: kc.ClusterCommonName,