Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .bingo/Variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ $(GO_BINDATA): $(BINGO_DIR)/go-bindata.mod
@echo "(re)installing $(GOBIN)/go-bindata-v3.1.2+incompatible"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=go-bindata.mod -o=$(GOBIN)/go-bindata-v3.1.2+incompatible "github.com/go-bindata/go-bindata/go-bindata"

GOLANGCI_LINT := $(GOBIN)/golangci-lint-v2.6.1
GOLANGCI_LINT := $(GOBIN)/golangci-lint-v2.11.4
$(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/golangci-lint-v2.6.1"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v2.6.1 "github.com/golangci/golangci-lint/v2/cmd/golangci-lint"
@echo "(re)installing $(GOBIN)/golangci-lint-v2.11.4"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v2.11.4 "github.com/golangci/golangci-lint/v2/cmd/golangci-lint"

GORELEASER := $(GOBIN)/goreleaser-v1.25.1
GORELEASER := $(GOBIN)/goreleaser-v2.15.1
$(GORELEASER): $(BINGO_DIR)/goreleaser.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/goreleaser-v1.25.1"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=goreleaser.mod -o=$(GOBIN)/goreleaser-v1.25.1 "github.com/goreleaser/goreleaser"
@echo "(re)installing $(GOBIN)/goreleaser-v2.15.1"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=goreleaser.mod -o=$(GOBIN)/goreleaser-v2.15.1 "github.com/goreleaser/goreleaser/v2"

MOCKGEN := $(GOBIN)/mockgen-v0.4.0
$(MOCKGEN): $(BINGO_DIR)/mockgen.mod
Expand Down
2 changes: 1 addition & 1 deletion .bingo/bingo.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.21.3
go 1.25.8

require github.com/bwplotka/bingo v0.9.0
2 changes: 1 addition & 1 deletion .bingo/gci.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.21.3
go 1.25.8

require github.com/daixiang0/gci v0.13.4
2 changes: 1 addition & 1 deletion .bingo/go-bindata.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.21.3
go 1.25.8

require github.com/go-bindata/go-bindata v3.1.2+incompatible // go-bindata
4 changes: 2 additions & 2 deletions .bingo/golangci-lint.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.24.6
go 1.25.8

require github.com/golangci/golangci-lint/v2 v2.6.1 // cmd/golangci-lint
require github.com/golangci/golangci-lint/v2 v2.11.4 // cmd/golangci-lint
85 changes: 85 additions & 0 deletions .bingo/golangci-lint.sum

Large diffs are not rendered by default.

380 changes: 378 additions & 2 deletions .bingo/goreleaser.mod

Large diffs are not rendered by default.

813 changes: 813 additions & 0 deletions .bingo/goreleaser.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .bingo/mockgen.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.21.3
go 1.25.8

require go.uber.org/mock v0.4.0 // mockgen
4 changes: 2 additions & 2 deletions .bingo/variables.env
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ GCI="${GOBIN}/gci-v0.13.4"

GO_BINDATA="${GOBIN}/go-bindata-v3.1.2+incompatible"

GOLANGCI_LINT="${GOBIN}/golangci-lint-v2.6.1"
GOLANGCI_LINT="${GOBIN}/golangci-lint-v2.11.4"

GORELEASER="${GOBIN}/goreleaser-v1.25.1"
GORELEASER="${GOBIN}/goreleaser-v2.15.1"

MOCKGEN="${GOBIN}/mockgen-v0.4.0"

1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#
version: "2"
run:
go: "1.24"
issues-exit-code: 1
modules-download-mode: readonly
allow-parallel-runners: true
Expand Down
8 changes: 5 additions & 3 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 1
version: 2

before:
hooks:
Expand All @@ -14,7 +14,8 @@ builds:
- darwin

archives:
- format: tar.gz
- formats:
- tar.gz
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
Expand All @@ -24,7 +25,8 @@ archives:
{{- if .Arm }}v{{ .Arm }}{{ end }}
format_overrides:
- goos: windows
format: zip
formats:
- zip

release:
prerelease: auto
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Example: `OCM-6141 | feat: Allow longer cluster names up to 54 chars`
5. Use similar architecture to the create machinepool command, with the user options files and separate logic in `pkg/`. Do not always make a new service, `machine pool service` is a special case

### Dependencies and Modules
- Go 1.24.0 minimum version
- Minimum Go version: see the `go` directive in `go.mod`
- Major dependencies: AWS SDK v2, Cobra, Ginkgo v2, OCM SDK
- Use `go mod tidy` and `go mod vendor` as part of verification
- Mock generation using `go.uber.org/mock/gomock`.
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM registry.access.redhat.com/ubi9/go-toolset:latest AS builder
COPY . .
FROM registry.access.redhat.com/ubi9/go-toolset:1.25.8 AS builder
COPY --chown=1001:0 . .

ENV GOFLAGS=-buildvcs=false
RUN git config --global --add safe.directory /opt/app-root/src && \
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ RUN_CHECKS_SCRIPT := ./hack/run-checks.sh
# Ensure go modules are enabled:
export GO111MODULE=on
export GOPROXY=https://proxy.golang.org
# Use Go's documented toolchain switching, since some repackaged toolchains default to local-only.
export GOTOOLCHAIN=auto
# Let the selected Go binary provide its own GOROOT to avoid mixed-toolchain builds.
unexport GOROOT
# Use the selected toolchain binary for Bingo-managed tool builds.
GO := $(shell go env GOROOT)/bin/go

# Disable CGO so that we always generate static binaries:
export CGO_ENABLED=0
Expand Down
34 changes: 18 additions & 16 deletions cmd/create/idp/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ package idp
import (
"errors"
"fmt"
"net/url"
neturl "net/url"
"os"
"strings"

cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
"github.com/spf13/cobra"

urlHelper "github.com/openshift/rosa/pkg/helper/url"
"github.com/openshift/rosa/pkg/interactive"
"github.com/openshift/rosa/pkg/ocm"
)
Expand Down Expand Up @@ -70,22 +71,23 @@ func buildGithubIdp(cmd *cobra.Command,
Required: true,
})
if err != nil {
return idpBuilder, fmt.Errorf("Expected a valid option: %s", err)
return idpBuilder, fmt.Errorf("expected a valid option: %s", err)
}
}

if interactive.Enabled() {
if restrictType == "organizations" {
switch restrictType {
case "organizations":
organizations, err = interactive.GetString(interactive.Input{
Question: "GitHub organizations",
Help: fmt.Sprintf("%s\n%s", cmd.Flags().Lookup("organizations").Usage, orgHelp),
Default: organizations,
Required: true,
})
if err != nil {
return idpBuilder, fmt.Errorf("Expected a valid GitHub organization: %s", err)
return idpBuilder, fmt.Errorf("expected a valid GitHub organization: %s", err)
}
} else if restrictType == "teams" {
case "teams":
teams, err = interactive.GetString(interactive.Input{
Question: "GitHub teams",
Help: fmt.Sprintf("%s%s", cmd.Flags().Lookup("teams").Usage, orgHelp),
Expand All @@ -95,14 +97,14 @@ func buildGithubIdp(cmd *cobra.Command,
func(val interface{}) error {
parts := strings.Split(fmt.Sprintf("%v", val), "/")
if len(parts) != 2 {
return fmt.Errorf("Expected a GitHub team to follow the form '<org>/<team>'")
return fmt.Errorf("expected a GitHub team to follow the form '<org>/<team>'")
}
return nil
},
},
})
if err != nil {
return idpBuilder, fmt.Errorf("Expected a valid GitHub organization: %s", err)
return idpBuilder, fmt.Errorf("expected a valid GitHub organization: %s", err)
}
}
}
Expand All @@ -123,21 +125,21 @@ func buildGithubIdp(cmd *cobra.Command,
registerURLBase = fmt.Sprintf("https://github.com/organizations/%s/settings/applications/new", teamOrg)
}

registerURL, err := url.Parse(registerURLBase)
registerURL, err := urlHelper.Parse(registerURLBase)
if err != nil {
return idpBuilder, fmt.Errorf("Error parsing URL: %v", err)
return idpBuilder, fmt.Errorf("error parsing URL: %v", err)
}

// Populate fields in the GitHub registration form
oauthURL, err := ocm.BuildOAuthURL(cluster, idpType)
if err != nil {
return idpBuilder, fmt.Errorf("Error building OAuth URL: %v", err)
return idpBuilder, fmt.Errorf("error building OAuth URL: %v", err)
}
oauthApplicationURL := oauthURL
if ocm.IsConsoleAvailable(cluster) {
oauthApplicationURL = cluster.Console().URL()
}
urlParams := url.Values{}
urlParams := neturl.Values{}
urlParams.Add("oauth_application[name]", cluster.Name())
urlParams.Add("oauth_application[url]", oauthApplicationURL)
urlParams.Add("oauth_application[callback_url]", oauthURL+"/oauth2callback/"+idpName)
Expand All @@ -163,7 +165,7 @@ func buildGithubIdp(cmd *cobra.Command,
Required: true,
})
if err != nil {
return idpBuilder, errors.New("Expected a GitHub application Client ID")
return idpBuilder, errors.New("expected a GitHub application client ID")
}

if clientSecret == "" {
Expand All @@ -173,7 +175,7 @@ func buildGithubIdp(cmd *cobra.Command,
Required: true,
})
if err != nil {
return idpBuilder, errors.New("Expected a GitHub application Client Secret")
return idpBuilder, errors.New("expected a GitHub application client secret")
}
}
}
Expand All @@ -194,7 +196,7 @@ func buildGithubIdp(cmd *cobra.Command,
},
})
if err != nil {
return idpBuilder, fmt.Errorf("Expected a valid Hostname: %s", err)
return idpBuilder, fmt.Errorf("expected a valid hostname: %s", err)
}
}
if githubHostname == "" && args.caPath != "" {
Expand All @@ -216,15 +218,15 @@ func buildGithubIdp(cmd *cobra.Command,
Default: caPath,
})
if err != nil {
return idpBuilder, fmt.Errorf("Expected a valid certificate bundle: %s", err)
return idpBuilder, fmt.Errorf("expected a valid certificate bundle: %s", err)
}
}
// Get certificate contents
ca := ""
if caPath != "" {
cert, err := os.ReadFile(caPath)
if err != nil {
return idpBuilder, fmt.Errorf("Expected a valid certificate bundle: %s", err)
return idpBuilder, fmt.Errorf("expected a valid certificate bundle: %s", err)
}
ca = string(cert)
}
Expand Down
20 changes: 10 additions & 10 deletions cmd/create/idp/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ package idp
import (
"errors"
"fmt"
"net/url"
"os"

cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
"github.com/spf13/cobra"

"github.com/openshift/rosa/pkg/helper"
urlHelper "github.com/openshift/rosa/pkg/helper/url"
"github.com/openshift/rosa/pkg/interactive"
"github.com/openshift/rosa/pkg/ocm"
)
Expand Down Expand Up @@ -54,7 +54,7 @@ func buildGitlabIdp(cmd *cobra.Command,
},
})
if err != nil {
return idpBuilder, fmt.Errorf("Expected a valid GitLab provider URL: %s", err)
return idpBuilder, fmt.Errorf("expected a valid GitLab provider URL: %s", err)
}
}
err = validateGitlabHostURL(gitlabURL)
Expand All @@ -66,7 +66,7 @@ func buildGitlabIdp(cmd *cobra.Command,
instructionsURL := fmt.Sprintf("%s/profile/applications", gitlabURL)
oauthURL, err := ocm.BuildOAuthURL(cluster, idpType)
if err != nil {
return idpBuilder, fmt.Errorf("Error building OAuth URL: %v", err)
return idpBuilder, fmt.Errorf("error building OAuth URL: %v", err)
}
err = interactive.PrintHelp(interactive.Help{
Message: "To use GitLab as an identity provider, register the application by opening:",
Expand Down Expand Up @@ -94,7 +94,7 @@ func buildGitlabIdp(cmd *cobra.Command,
Required: true,
})
if err != nil {
return idpBuilder, errors.New("Expected a GitLab application Application ID")
return idpBuilder, errors.New("expected a GitLab application ID")
}

if clientSecret == "" {
Expand All @@ -104,7 +104,7 @@ func buildGitlabIdp(cmd *cobra.Command,
Required: true,
})
if err != nil {
return idpBuilder, errors.New("Expected a GitLab application Secret")
return idpBuilder, errors.New("expected a GitLab application secret")
}
}
}
Expand All @@ -117,15 +117,15 @@ func buildGitlabIdp(cmd *cobra.Command,
Default: caPath,
})
if err != nil {
return idpBuilder, fmt.Errorf("Expected a valid certificate bundle: %s", err)
return idpBuilder, fmt.Errorf("expected a valid certificate bundle: %s", err)
}
}
// Get certificate contents
ca := ""
if caPath != "" {
cert, err := os.ReadFile(caPath)
if err != nil {
return idpBuilder, fmt.Errorf("Expected a valid certificate bundle: %s", err)
return idpBuilder, fmt.Errorf("expected a valid certificate bundle: %s", err)
}
ca = string(cert)
}
Expand Down Expand Up @@ -158,12 +158,12 @@ func buildGitlabIdp(cmd *cobra.Command,

func validateGitlabHostURL(val interface{}) error {
gitlabURL := fmt.Sprintf("%v", val)
parsedIssuerURL, err := url.ParseRequestURI(gitlabURL)
parsedIssuerURL, err := urlHelper.ParseRequestURI(gitlabURL)
if err != nil {
return fmt.Errorf("Expected a valid GitLab provider URL: %s", err)
return fmt.Errorf("expected a valid GitLab provider URL: %s", err)
}
if parsedIssuerURL.Scheme != helper.ProtocolHttps {
return errors.New("Expected GitLab provider URL to use an https:// scheme")
return errors.New("expected GitLab provider URL to use an https:// scheme")
}
if parsedIssuerURL.RawQuery != "" {
return errors.New("GitLab provider URL must not have query parameters")
Expand Down
Loading