Skip to content

Commit

Permalink
Point CLI to production by default (#1460)
Browse files Browse the repository at this point in the history
We can still point to staging for testing, but that needs to be done through
a `staging` golang build tag.
  • Loading branch information
JAORMX authored Nov 4, 2023
1 parent aad8be2 commit 467c8d5
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 4 deletions.
3 changes: 2 additions & 1 deletion cmd/cli/app/auth/auth_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/stacklok/minder/internal/constants"
mcrypto "github.com/stacklok/minder/internal/crypto"
"github.com/stacklok/minder/internal/util"
"github.com/stacklok/minder/internal/util/cli"
Expand Down Expand Up @@ -76,7 +77,7 @@ will be saved to $XDG_CONFIG_HOME/minder/credentials.json`,
ctx := context.Background()

issuerUrlStr := util.GetConfigValue(viper.GetViper(), "identity.cli.issuer_url", "identity-url", cmd,
"https://auth.staging.stacklok.dev").(string)
constants.IdentitySeverURL).(string)
realm := util.GetConfigValue(viper.GetViper(), "identity.cli.realm", "identity-realm", cmd, "stacklok").(string)
clientID := util.GetConfigValue(viper.GetViper(), "identity.cli.client_id", "identity-client", cmd, "minder-cli").(string)

Expand Down
3 changes: 2 additions & 1 deletion cmd/cli/app/auth/auth_logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/stacklok/minder/internal/constants"
"github.com/stacklok/minder/internal/util"
"github.com/stacklok/minder/internal/util/cli"
)
Expand All @@ -48,7 +49,7 @@ var auth_logoutCmd = &cobra.Command{
util.ExitNicelyOnError(err, "Error removing credentials")

issuerUrlStr := util.GetConfigValue(viper.GetViper(), "identity.cli.issuer_url", "identity-url", cmd,
"https://auth.staging.stacklok.dev").(string)
constants.IdentitySeverURL).(string)
realm := util.GetConfigValue(viper.GetViper(), "identity.cli.realm", "identity-realm", cmd, "stacklok").(string)

parsedURL, err := url.Parse(issuerUrlStr)
Expand Down
17 changes: 17 additions & 0 deletions internal/constants/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// Copyright 2023 Stacklok, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package constants contains constants used throughout the application.
package constants
25 changes: 25 additions & 0 deletions internal/constants/prod.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//go:build !staging

//
// Copyright 2023 Stacklok, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package constants

const (
// IdentitySeverURL is the URL of the identity server
IdentitySeverURL = "https://auth.stacklok.com"
// MinderGRPCHost is the host of the minder gRPC server
MinderGRPCHost = "api.stacklok.com"
)
25 changes: 25 additions & 0 deletions internal/constants/staging.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//go:build staging

//
// Copyright 2023 Stacklok, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package constants

const (
// IdentitySeverURL is the URL of the identity server
IdentitySeverURL = "https://auth.staging.stacklok.dev"
// MinderGRPCHost is the host of the minder gRPC server
MinderGRPCHost = "staging.stacklok.dev"
)
5 changes: 3 additions & 2 deletions internal/util/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import (
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/stacklok/minder/internal/constants"
"github.com/stacklok/minder/internal/db"
"github.com/stacklok/minder/internal/util/jsonyaml"
minderv1 "github.com/stacklok/minder/pkg/api/protobuf/go/minder/v1"
Expand Down Expand Up @@ -142,12 +143,12 @@ func (JWTTokenCredentials) RequireTransportSecurity() bool {

// GrpcForCommand is a helper for getting a testing connection from cobra flags
func GrpcForCommand(cmd *cobra.Command, v *viper.Viper) (*grpc.ClientConn, error) {
grpc_host := GetConfigValue(v, "grpc_server.host", "grpc-host", cmd, "staging.stacklok.dev").(string)
grpc_host := GetConfigValue(v, "grpc_server.host", "grpc-host", cmd, constants.MinderGRPCHost).(string)
grpc_port := GetConfigValue(v, "grpc_server.port", "grpc-port", cmd, 443).(int)
insecureDefault := grpc_host == "localhost" || grpc_host == "127.0.0.1" || grpc_host == "::1"
allowInsecure := GetConfigValue(v, "grpc_server.insecure", "grpc-insecure", cmd, insecureDefault).(bool)

issuerUrl := GetConfigValue(v, "identity.cli.issuer_url", "identity-url", cmd, "https://auth.staging.stacklok.dev").(string)
issuerUrl := GetConfigValue(v, "identity.cli.issuer_url", "identity-url", cmd, constants.IdentitySeverURL).(string)
realm := GetConfigValue(v, "identity.cli.realm", "identity-realm", cmd, "stacklok").(string)
clientId := GetConfigValue(v, "identity.cli.client_id", "identity-client", cmd, "minder-cli").(string)

Expand Down

0 comments on commit 467c8d5

Please sign in to comment.